<template>
  <div style="padding: 20px;padding-top: 0px;" 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 download from '@/common/services/download'
import { Message } from 'ant-design-vue'
import TableActionTypes from '@/common/services/table-action-types'
import StatisticsService from './statistics-service'
import components from './_import-components/audit-statistics-find-list-import'
const columns = [
  {
    title: '序号',
    customRender: (text, record, index) => `${index + 1}`,
    width: '80px',
  },
  {
    title: '审计机构',
    dataIndex: 'UNIT_NAME',
    width: '200px',
  },
  {
    title: '项目名称',
    dataIndex: 'PROJECT_TITLE',
    width: '200px',
  },
  {
    title: '审计类型',
    dataIndex: 'AUDIT_TYPE',
    width: '200px',
  },
  {
    title: '问题名称（定性描述）',
    dataIndex: 'FIND_TITLE',
    width: '200px',
  },
  {
    title: '审计问题描述',
    dataIndex: 'FIND_DESC',
    width: '180px',
  },
  {
    title: '整改责任主体',
    dataIndex: 'RESP_UNIT_NAME',
    width: '180px',
  },
  {
    title: '问题分类',
    dataIndex: 'PROBLEM_CATEGORY_FUNCTION',
    width: '150px',
  },
  {
    title: '问题类型',
    dataIndex: 'RECT_TYPE',
    width: '150px',
  },
  {
    title: '措施执行情况',
    dataIndex: 'DRAFT_RECT_MEASURE',
    width: '150px',
  },
  {
    title: '计划完成日期',
    dataIndex: 'DRAFT_FINISH_DATE',
    width: '150px',
  },
  {
    title: '整改状态',
    dataIndex: 'RECT_STATE',
    width: '150px',
  },
  {
    title: '是否完成当年整改阶段目标',
    dataIndex: 'WHETHER_FINISH_TARGET',
    width: '180px',
  },
  {
    title: '整改完成日期',
    dataIndex: 'FINISH_DATE',
    width: '150px',
  },
  {
    title: '销号状态',
    dataIndex: 'CANCELL_STATUS',
    width: '150px',
  },
]
export default {
  name: 'AuditStatisticsFindList',
  metaInfo: {
    title: '整改发现统计透视图',
  },
  components,
  data() {
    return {
      columns,
      data: [],
      actions: [
        {
          label: '导出',
          id: 'export',
          permission: null,
          type: TableActionTypes.primary,
          callback: () => {
            const params = JSON.parse(this.$route.query.params)
            // 整改发现列表导出
            StatisticsService.exportAuditfindData(params)
              .then((data) => {
                const url = URL.createObjectURL(data)
                download(url, '问题整改列表导出.xls')
              })
              .catch(() => {
                Message.error('导出失败')
              })
          },
        },
      ],
    }
  },
  computed: {
    dataUrl() {
      const params = JSON.parse(this.$route.query.params)
      return (
        'api/xcoa-mobile/v1/iam-statistics/getFindRectifyList?rectUnitFlag=' + params.rectUnitFlag
      )
    },
  },
  methods: {
    processReq(req) {
      const parasm = JSON.parse(this.$route.query.params)
      req.data = {
        ...req.data,
        ...parasm,
      }
      if (req.data.pageIndex === undefined) {
        req.data.pageIndex = req.data.startPosition
      }

      if (req.data.pageSize === undefined) {
        req.data.pageSize = 10
      }

      return req
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.titlepoint {
  background: #1890ff;
  height: 27px;
  width: 8px;
  position: fixed;
  top: 12px;
  left: 20px;
  border-radius: 8px;
}
.toptitle {
  color: #404040;
  font-weight: bold;
  font-size: 22px;
  position: fixed;
  left: 40px;
  top: 9px;
}
:global(.reporttablecardxm) {
  :global(.ant-table-body) {
    height: calc(100vh - 140px);
    overflow: auto;
  }
}
</style>
