<template>
  <manager-dialog
    title="操作日志"
    icon="el-icon-chat-line-square"
    :visible.sync="operlogDialogVisible"
    width="50%"
    @opened="open"
  >
    <el-row>
      <el-table :data="tableData" border stripe>
        <el-table-column label="操作用户" prop="userName" show-overflow-tooltip />
        <el-table-column label="创建时间" prop="createTime" show-overflow-tooltip />
        <el-table-column label="操作记录" prop="statusName" show-overflow-tooltip />
      </el-table>
      <el-pagination
        :current-page="pagination.current"
        :page-sizes="[10, 50, 100]"
        :page-size="pagination.size"
        layout="total,sizes, prev, pager, next,jumper"
        :total="pagination.total"
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
      />
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button style="border-radius: 3px" @click="operlogDialogVisible = false;logQuery.page.current = 1">关闭</el-button>
    </span>
  </manager-dialog>
</template>

<script>
import { getOperRecordList } from '../api/report-config-manage'
export default {
  name: '',
  props: ['reportId'],
  data() {
    return {
      operlogDialogVisible: false,
      // 查询操作日志传参
      logQuery: {
        logAuditReportConfLogMap: {
          repoerId: null
        },
        page: {
          current: 1,
          size: 10,
          total: 0
        }
      },
      tableData: [],
      pagination: {
        current: 1,
        size: 10,
        total: 0
      }
    }
  },
  methods: {
    open() {
      this.logQuery.logAuditReportConfLogMap.repoerId = this.reportId
      this.getLogData()
    },
    // 获取操作日志
    getLogData() {
      getOperRecordList(this.logQuery).then(resp => {
        if (resp.data.returnCode == '0') {
          this.tableData = resp.data.data.list
          this.pagination.current = resp.data.data.page.current
          this.pagination.size = resp.data.data.page.size
          this.pagination.total = resp.data.data.page.total
        }
      })
    },
    handleCurrentChange(current) {
      this.logQuery.page.current = current
      this.getLogData()
    },
    handleSizeChange(size) {
      this.logQuery.page.size = size
      this.getLogData()
    }
  }
}
</script>
