<template>
  <div style="padding: 20px; padding-top: 0" class="reporttablecardxm">
    <div
      style="position: absolute; padding-top: 10px; line-height: 32px"
      class="header_sd-header_common"
    >
      <div :class="$style.titlepoint"></div>
      <span :class="['toptitle', $style.toptitle]">发现整改列表</span>
    </div>
    <sd-data-table
      ref="dataTable"
      :projectlist="true"
      :columns="columns"
      :data-url="dataUrl"
      row-key="FIND_TITLE"
      :actions="actions"
      :process-req="processReq"
      :defultpagination-pagesize="50"
    />
  </div>
</template>

<script>
import { Message } from 'ant-design-vue'
import TableActionTypes from '@/common/services/table-action-types'
import download from '@/common/services/download'
import StatisticsService from './iam-audit-dsc-service'
import components from './_import-components/iam-audit-dsc-rectify-list-import'
const columns = [
  {
    title: '序号',
    customRender: (text, record, index) => `${index + 1}`,
    width: '80px',
  },
  {
    title: '项目名称',
    dataIndex: 'PROJECT_TITLE',
    width: '300px',
  },
  {
    title: '审计类型',
    dataIndex: 'AUDIT_TYPE',
    width: '200px',
  },
  {
    title: '审计发现标题',
    dataIndex: 'FIND_TITLE',
    width: '200px',
  },
  {
    title: '整改单位',
    dataIndex: 'RESP_UNIT_NAME',
    width: '200px',
  },
  {
    title: '审计发现类别',
    dataIndex: 'FIND_TYPE',
    width: '150px',
  },
  {
    title: '审计发现描述',
    dataIndex: 'FIND_DESC',
    width: '180px',
  },
  {
    title: '风险等级',
    dataIndex: 'RISK_LEVEL',
    width: '150px',
  },
  {
    title: '拟整改完成日期',
    dataIndex: 'FINISH_DATE',
    width: '150px',
  },
  {
    title: '整改措施',
    dataIndex: 'MEASURE',
    width: '150px',
  },
  {
    title: '整改状态',
    dataIndex: 'RECT_STATUS',
    width: '150px',
  },
  {
    title: '是否超期未整改',
    dataIndex: 'IS_TRUE',
    width: '100px',
  },
  {
    title: '整改完成日期',
    dataIndex: 'RECT_FINISH_DATE',
    width: '200px',
  },
  {
    title: '整改责任部门',
    dataIndex: 'RESPONSIBLE_DEPT_NAME',
    width: '100px',
  },
  {
    title: '确认状态',
    dataIndex: 'CONFIRM_STATUS',
    width: '150px',
  },
  {
    title: '确认日期',
    dataIndex: 'CONFIRM_TIME',
    width: '100px',
  },
]
export default {
  name: 'IamAuditDscRectifyList',
  metaInfo: {
    title: '整改发现统计透视图',
  },
  components,
  data() {
    return {
      params: null,
      columns,
      data: [],
      actions: [
        {
          label: '导出',
          id: 'export',
          permission: null,
          type: TableActionTypes.primary,
          callback: () => {
            // 整改发现列表导出
            this.params.maxResults = '-1'
            StatisticsService.exportRectifyList(this.params)
              .then((data) => {
                const url = URL.createObjectURL(data)
                download(url, '已整改问题列表导出.xls')
              })
              .catch(() => {
                Message.error('导出失败')
              })
          },
        },
      ],
    }
  },
  computed: {
    dataUrl() {
      return 'api/xcoa-mobile/v1/iam-statistics/getFindRectifyList'
    },
  },
  methods: {
    processReq(req) {
      const params = JSON.parse(this.$route.query.params)
      const newparams = {
        rectStatus: '03',
      }
      // 没有参数就不传
      if (params.unitNames !== "'null'") {
        newparams.unitNames = params.unitNames
      }
      if (params.planYear !== 'null') {
        newparams.dateStart = params.planYear
        newparams.dateEnd = params.planYear
      }
      if (
        newparams.dateStart === 'null' ||
        newparams.dateStart === null ||
        newparams.dateStart === '' ||
        newparams.dateStart === undefined
      ) {
        newparams.dateStart = params.dateStart
      }
      if (params.unitIds !== 'null') {
        newparams.unitIds = params.unitIds
      }
      req.data = {
        ...req.data,
        ...newparams,
      }
      if (req.data.pageIndex === undefined) {
        req.data.pageIndex = req.data.startPosition
      }

      if (req.data.pageSize === undefined) {
        req.data.pageSize = 10
      }
      this.params = req.data
      return req
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.titlepoint {
  position: absolute;
  top: 12px;
  left: 20px;
  width: 8px;
  height: 27px;
  background: #1890ff;
  border-radius: 8px;
}
.toptitle {
  position: absolute;
  top: 9px;
  left: 40px;
  width: 200px;
  font-size: 22px;
  font-weight: bold;
  color: #404040;
}
</style>
