<template>
  <!-- 任务审核记录 -->
  <div class="auditRecords">
    <el-dialog title="查看审核记录" :visible.sync="dialogVisible" width="1000px" :before-close="handleClose"
      :close-on-click-modal="false">
      <el-table :data="tableData" style="width: 100%;" border header-row-class-name="custom-table-header"
        @sort-change="sortChange">
        <el-table-column label="#" align="center" width="60px">
          <template slot-scope="scope">
            <div>
              {{ (queryParams.current - 1) * queryParams.size + scope.$index + 1 }}
            </div>
          </template>
        </el-table-column>
        <el-table-column v-for="item in columnList" :key="item.value" :prop="item.value"
          :render-header="$commonJS.renderHeaderMethods" :label="item.name" sortable="custom" align="center">
          <template slot-scope="scope">
            <div v-if="['name'].includes(item.value)">
              <el-link @click="handleItem(scope.row, item.value)">
                <span v-html="$commonJS.getColumnData(scope.row, item)"></span>
              </el-link>
            </div>
            <div v-else-if="['taskType'].includes(item.value)"
              v-html="$commonJS.getColumnData(scope.row, item, null, { data: taskType })"></div>
            <div v-else v-html="$commonJS.getColumnData(scope.row, item)"></div>
          </template>
        </el-table-column>
      </el-table>
      <div style="text-align: center;padding-top: 20px;">
        <el-pagination background layout="total, prev, pager, next, jumper" :current-page.sync="queryParams.current"
          :page-size.sync="queryParams.size" @current-change="handleCurrentChange" :total="queryParams.total">
        </el-pagination>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleClose">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { column } from '../mixins/index2'
export default {
  mixins: [column],
  data() {
    return {
      // 审核记录数据
      tableData: [],
      dialogVisible: false,
      // 审核记录分页信息
      queryParams: {
        current: 1,
        size: 10,
        total: 0,
      },
      // 排序
      sort:[{ "orderBy": "createTime", "orderType": 1 }],
    }
  },
  mounted() {

  },
  methods: {
    //排序
    sortChange({ column, prop, order }) {
      //如需要多个字段排序，则不需要清空
      var params = {
        sort: this.sort,
        column,
        prop,
        order,
      }
      this.sort = this.$commonJS.getSortData(params)
      this.queryParams.current = 1
      this.getList()
    },
    getList(id) {
      let params = {
        ...this.queryParams,//分页信息
        // searchQuery: this.$commonJS.objectToString(this.searchOption),//检索条件
        orderDTOList: this.sort,//排序信息
        id: id,
      }
      this.$api.query(params).then(response => {
        if (response.code == 200) {
          this.tableData = response.data.data
          this.queryParams.current = response.data.current
          this.queryParams.size = response.data.size
          this.queryParams.total = response.data.total
        }
      })
    },
    // 打开弹窗
    open(id) {
      // this.getList(id)
      this.dialogVisible = true
    },
    handleClose() {
      this.dialogVisible = false
    },
    // 分页查询
    handleCurrentChange(val) {
      this.queryParams.current = val
      this.getList()
    },

  },
}
</script>

<style lang="scss" scoped></style>