<template>
  <div :class="$style.personalStatistics">
    <a-card :class="$style.conditions">
      <a-tabs v-model="activeKey" type="line" @change="toggleTabs">
        <a-tab-pane key="1" tab="审计项目完成情况-内审">
          <a-form-model
            ref="projectSearchForm"
            class="ant-advanced-search-form"
            :model="form"
            :rules="rules"
            v-bind="formItemLayout"
          >
            <a-row :gutter="24" :class="$style.antformitem">
              <a-col :span="8">
                <a-form-model-item label="年度" prop="timeRange">
                  <AuditRangePicker :time-range.sync="form.timeRange" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="审计机构" prop="unitNames">
                  <AuditGroupPicker
                    ref="unitNames"
                    v-model="form.unitNames"
                    :single="false"
                    :read-only="false"
                    :root-node="rootNode"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <div :class="$style.buttonContent">
                  <a-button @click="handleReset">重置</a-button>
                  <a-button type="primary" @click="handleAction('serach')">查询</a-button>
                  <a-button :loading="exportLoading" type="primary" @click="handleAction('export')"
                    >导出</a-button
                  >

                  <a-button :loading="exportLoading" type="primary" @click="exportGroup"
                    >导出单位及内部审计机构基本情况</a-button
                  >
                </div>
              </a-col>
            </a-row>
          </a-form-model>

          <p :class="$style.tableTitle"> 审计项目完成情况-内审 </p>
          <a-card class="reporttablecardxm">
            <sd-data-table
              ref="dataTable"
              :key="dataKey"
              :columns="columns1"
              :actions="actions"
              :process-req="processReq1"
              :defultpagination-pagesize="10"
              data-url="api/xcoa-mobile/v1/spicAuditReportList/projectCompletionStatusList"
              @dataLoaded="dataLoaded"
              @rowClick="rowClick"
            >
            </sd-data-table>
          </a-card>
        </a-tab-pane>

        <a-tab-pane key="2" tab="审计项目整改完成情况及成果统计">
          <a-form-model
            ref="StatisticsSearchForm"
            class="ant-advanced-search-form"
            :model="rectForm"
            :rules="rectRules"
            v-bind="formItemLayout"
          >
            <a-row :gutter="24" :class="$style.antformitem">
              <a-col :span="8">
                <a-form-model-item label="年度" prop="timeRange">
                  <AuditRangePicker :time-range.sync="rectForm.timeRange" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="审计机构" prop="unitNames">
                  <AuditGroupPicker
                    ref="unitNames"
                    v-model="rectForm.unitNames"
                    :single="false"
                    :read-only="false"
                    :root-node="rootNode"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="审计类型" prop="auditType">
                  <sd-select
                    v-model="rectForm.auditType"
                    :allow-clear="true"
                    :options="auditTypeOptions"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <div :class="$style.buttonContent">
                  <a-button @click="handleReset">重置</a-button>
                  <a-button type="primary" @click="handleRectStatistics('serach')">查询</a-button>
                  <a-button
                    :loading="exportLoading"
                    type="primary"
                    @click="handleRectStatistics('export')"
                    >导出</a-button
                  >
                </div>
              </a-col>
            </a-row>
          </a-form-model>

          <p :class="$style.tableTitle"> 审计项目整改完成情况及成果统计 </p>
          <a-card class="reporttablecardxm">
            <sd-data-table
              ref="dataTable"
              :key="dataKey"
              :columns="columns2"
              :process-req="processReq2"
              :defultpagination-pagesize="10"
              data-url="api/xcoa-mobile/v1/spicAuditReportList/projectRectStatisticsList"
              @dataLoaded="dataLoaded"
              @rowClick="rowClick"
            >
            </sd-data-table>
          </a-card>
        </a-tab-pane>

        <a-tab-pane key="3" tab="审计问题整改明细台账-内审">
          <a-form-model
            ref="problemSearchForm"
            class="ant-advanced-search-form"
            :model="problemForm"
            :rules="problemRules"
            v-bind="formItemLayout"
          >
            <a-row :gutter="24" :class="$style.antformitem">
              <a-col :span="8">
                <a-form-model-item label="年度" prop="timeRange">
                  <AuditRangePicker :time-range.sync="problemForm.timeRange" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="审计机构" prop="unitNames">
                  <AuditGroupPicker
                    ref="unitNames"
                    v-model="problemForm.unitNames"
                    :single="false"
                    :read-only="false"
                    :root-node="rootNode"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="项目分类" prop="auditType">
                  <sd-select
                    v-model="problemForm.auditType"
                    :allow-clear="true"
                    :options="auditTypeOptions"
                    @change="onChange"
                  />
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row :gutter="24" :class="$style.antformitem">
              <a-col :span="8">
                <a-form-model-item label="被审计单位" prop="auditUnitedName">
                  <AuditGroupPicker
                    ref="auditUnitedName"
                    v-model="problemForm.auditUnitedName"
                    :single="false"
                    :read-only="false"
                    :root-node="rootNode"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="问题名称" prop="findTitle">
                  <a-input v-model="problemForm.findTitle" @change="onChange" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <div :class="$style.buttonContent">
                  <a-button @click="handleReset">重置</a-button>
                  <a-button type="primary" @click="problemHandleAction('serach')">查询</a-button>
                  <a-button
                    :loading="exportLoading"
                    type="primary"
                    @click="problemHandleAction('export')"
                    >导出</a-button
                  >
                </div>
              </a-col>
            </a-row>
          </a-form-model>

          <p :class="$style.tableTitle"> 审计问题整改明细台账-内审 </p>
          <a-card class="reporttablecardxm">
            <sd-data-table
              ref="dataTable"
              :key="dataKey"
              :columns="columns3"
              :process-req="processReq3"
              :defultpagination-pagesize="10"
              data-url="api/xcoa-mobile/v1/spicAuditReportList/problemRectItemList"
              @dataLoaded="dataLoaded"
              @rowClick="rowClick"
            >
            </sd-data-table>
          </a-card>
        </a-tab-pane>
      </a-tabs>
    </a-card>
  </div>
</template>

<script>
import components from './_import-components/xm-audit-project-info-list-import'
import AuditRangePicker from '@product/iam/components/picker/audit-range-picker.vue'
import AuditGroupPicker from '@product/iam/components/picker/audit-group-picker.vue'
import { message } from '@/common/one-ui'
import download from '@/common/services/download'
import axios from '@/common/services/axios-instance'
import { getUserInfo } from '@/common/store-mixin'
export default {
  name: 'XmAuditProjectInfoList',
  metaInfo: {
    title: '审计项目基本信息台账',
  },
  components: {
    ...components,
    AuditRangePicker,
    AuditGroupPicker,
  },

  data() {
    return {
      auditTypeOptions: [],
      activeKey: '1',
      exportLoading: false,
      dataKey: 0,
      reqData1: {
        dateStart: '',
        dateEnd: '',
        unitNames: '',
      },
      reqData2: {
        dateStart: '',
        dateEnd: '',
        unitNames: '',
        auditType: '',
      },
      reqData3: {
        dateStart: '',
        dateEnd: '',
        unitNames: '',
        auditType: '',
        auditUnitedName: '',
        findTitle: '',
      },
      data: [],
      columns1: [
        {
          title: '序号',
          dataIndex: 'id',
          width: '100px',
        },
        {
          title: '单位',
          dataIndex: 'unitName',
          width: '300px',
        },
        {
          title: '计划内项目数',
          dataIndex: 'inPlanNum',
          width: '150px',
        },
        {
          title: '计划外项目数',
          dataIndex: 'outPlanNum',
          width: '150px',
        },
        {
          title: '完成数',
          dataIndex: 'closeNum',
          width: '120px',
        },
        {
          title: '完成率（%）',
          dataIndex: 'finshedCate',
          width: '150px',
        },
        {
          title: '纳入审计全覆盖范围项目数',
          dataIndex: 'coverNum',
          width: '230px',
        },
        {
          title: '审计子企业户数（户）',
          dataIndex: 'childOrgNum',
          width: '200px',
        },
        {
          title: '其中：审计境外子企业户数(户)',
          dataIndex: 'overseasOrgNum',
          width: '280px',
        },
        {
          title: '审计资产总额(亿元)',
          dataIndex: 'auditAssets',
          width: '200px',
        },
        {
          title: '其中：审计境外资产总额(亿元)',
          dataIndex: 'overseasAuditAssets',
          width: '280px',
        },
        {
          title: '贯彻落实国家重大政策措施审计',
          dataIndex: 'auditType01',
          width: '280px',
        },
        {
          title: '经济责任审计-离任审计',
          dataIndex: 'auditType03',
          width: '220px',
        },
        {
          title: '经济责任审计-任中审计',
          dataIndex: 'auditType04',
          width: '220px',
        },
        {
          title: '资产负债损益审计',
          dataIndex: 'auditType05',
          width: '200px',
        },
        {
          title: '基本建设项目审计',
          dataIndex: 'auditType06',
          width: '200px',
        },
        {
          title: '境外审计',
          dataIndex: 'auditType07',
          width: '120px',
        },
        {
          title: '大数据审计',
          dataIndex: 'auditType08',
          width: '150px',
        },
        {
          title: '回头看审计',
          dataIndex: 'auditType09',
          width: '150px',
        },
        {
          title: '信息系统审计',
          dataIndex: 'auditType10',
          width: '150px',
        },
        {
          title: '风险管理审计',
          dataIndex: 'auditType11',
          width: '150px',
        },
        {
          title: '内部控制审计',
          dataIndex: 'auditType02',
          width: '150px',
        },
        {
          title: '绩效审计',
          dataIndex: 'auditType12',
          width: '120px',
        },
        {
          title: '金融业务审计',
          dataIndex: 'auditType13',
          width: '150px',
        },
        {
          title: '燃料专项审计',
          dataIndex: 'auditType14',
          width: '150px',
        },
        {
          title: '投资专项审计',
          dataIndex: 'auditType15',
          width: '150px',
        },
        {
          title: '科研经费审计',
          dataIndex: 'auditType16',
          width: '150px',
        },
        {
          title: '资金管理审计',
          dataIndex: 'auditType17',
          width: '150px',
        },
        {
          title: '其他',
          dataIndex: 'auditType18',
          width: '120px',
        },
      ],
      columns2: [
        {
          title: '序号',
          dataIndex: 'id',
          width: '100px',
        },
        {
          title: '项目名称',
          dataIndex: 'projectTitle',
          width: '300px',
        },
        {
          title: '项目实施年度',
          dataIndex: 'planYear',
          width: '200px',
        },
        {
          title: '纠正违规金额（万元）',
          dataIndex: 'accounts',
          width: '200px',
        },
        {
          title: '节约成本费用数额（万元）',
          dataIndex: 'svaingSum',
          width: '200px',
        },
        {
          title: '挽回损失（万元）',
          dataIndex: 'improperSum',
          width: '200px',
        },
        {
          title: '增加收入数额（万元）',
          dataIndex: 'recoverySum',
          width: '200px',
        },
        {
          title: '督促清理往来款项收回资金（万元）',
          dataIndex: 'wasteAmount',
          width: '300px',
        },
        {
          title: '工程结算及竣工决算项目数量（个）',
          dataIndex: 'completionNumber',
          width: '300px',
        },
        {
          title: '新建修订制度、流程、标准数量（项）',
          dataIndex: 'itemNum',
          width: '330px',
        },

        {
          title: '追责问责',
          children: [
            {
              title: '追责问责人次',
              dataIndex: 'personNum',
              width: '200px',
            },
            {
              title: '经济处罚金额（万元）',
              dataIndex: 'economicMoney',
              width: '200px',
            },
          ],
        },
        {
          title: '移送纪检监察线索（条）',
          dataIndex: 'clue',
          width: '250px',
        },

        {
          title: '整改完成情况',
          children: [
            {
              title: '审计发现主要问题汇总表问题数量',
              dataIndex: 'findNum',
              width: '300px',
            },
            {
              title: '审计发现主要问题汇总表累计整改完成率（%）',
              dataIndex: 'rectRates',
              width: '400px',
            },
            {
              title: '审计发现主要问题汇总表到期整改完成率（%）',
              dataIndex: 'rectRate',
              width: '400px',
            },
            {
              title: '审计意见书问题数量（个）',
              dataIndex: 'giveOptionsNum',
              width: '250px',
            },
            {
              title: '审计意见书累计整改完成率（%）',
              dataIndex: 'optionsRectRates',
              width: '400px',
            },
            {
              title: '审计意见书到期整改完成率（%）',
              dataIndex: 'optionsRectRate',
              width: '400px',
            },
            {
              title: '审计建议数量（条）',
              dataIndex: 'suggestion',
              width: '200px',
            },
            {
              title: '建议采纳率（%）',
              dataIndex: 'rectTypeRate',
              width: '200px',
            },
            {
              title: '揭示风险（条）',
              dataIndex: 'peoblemNatuer',
              width: '200px',
            },
            {
              title: '截止本月审计发现主要问题汇总表问题整改完成数',
              dataIndex: 'wanChengNum',
              width: '400px',
            },
            {
              title: '截止本月审计意见书问题整改完成数',
              dataIndex: 'wanChengOptionsNum',
              width: '300px',
            },
          ],
        },
      ],

      columns3: [
        {
          title: '序号',
          dataIndex: 'id',
          width: '100px',
        },
        {
          title: '项目单位',
          dataIndex: 'unitName',
          width: '300px',
        },
        {
          title: '被审单位',
          dataIndex: 'auditedUnitNames',
          width: '300px',
        },
        {
          title: '项目名称',
          dataIndex: 'projectTitle',
          width: '200px',
        },
        {
          title: '项目分类',
          dataIndex: 'auditType',
          width: '150px',
        },
        {
          title: '问题名称',
          dataIndex: 'findTitle',
          width: '250px',
        },

        {
          title: '问题分类',
          dataIndex: 'problemType',
          width: '150px',
        },
        {
          title: '问题类型',
          dataIndex: 'rectType',
          width: '150px',
        },
        {
          title: '问题整改状态',
          dataIndex: 'rectState',
          width: '200px',
        },
        {
          title: '销号状态',
          dataIndex: 'cancellStatus',
          width: '150px',
        },
        {
          title: '措施执行情况',
          dataIndex: 'draftRectMeasure',
          width: '200px',
        },
        {
          title: '计划完成时间',
          dataIndex: 'draftFinishDate',
          width: '200px',
        },
        {
          title: '审计发现问题整改（金额类）（万元）',
          children: [
            {
              title: '调整会计账目',
              dataIndex: 'adjustAccounts',
              width: '200px',
            },
            {
              title: '收回资金：增加收入数额',
              dataIndex: 'recoveryFunds',
              width: '250px',
            },
            {
              title: '收回资金：督促清理往来款项收回资金',
              dataIndex: 'avoidingWasteAmount',
              width: '350px',
            },
            {
              title: '收回资金：其他',
              dataIndex: 'reduceInvestmentAmount',
              width: '220px',
            },
            {
              title: '挽回损失：节约成本费用（开支）数额',
              dataIndex: 'costSavingAmount',
              width: '350px',
            },
            {
              title: '挽回损失：工程审减金额',
              dataIndex: 'engineeringReduction',
              width: '220px',
            },
            {
              title: '挽回损失：清退不当得利',
              dataIndex: 'improperClearanceAmount',
              width: '220px',
            },
            {
              title: '挽回损失：其他',
              dataIndex: 'recoveryLossAmount',
              width: '220px',
            },
            {
              title: '归还原资金渠道',
              dataIndex: 'repaymentChannels',
              width: '220px',
            },
            {
              title: '补缴税费',
              dataIndex: 'paymentTaxesFees',
              width: '220px',
            },
            {
              title: '其他',
              dataIndex: 'otherAmount',
              width: '220px',
            },
          ],
        },
        {
          title: '审计发现问题整改（非金额类）（个）',
          children: [
            {
              title: '新建制度、流程、标准（项）',
              dataIndex: 'newItems',
              width: '300px',
            },
            {
              title: '修订制度、流程、标准（项）',
              dataIndex: 'reviseItems',
              width: '300px',
            },
          ],
        },
        {
          title: '追责问责处理情况',
          children: [
            {
              title: '移送纪检监察部门案件线索（件）',
              dataIndex: 'transferMonitorClue',
              width: '300px',
            },
            {
              title: '追责问责人次',
              dataIndex: 'personNum',
              width: '220px',
            },
            {
              title: '党纪处分：警告',
              dataIndex: 'dealWay01',
              width: '220px',
            },
            {
              title: '党纪处分：严重警告',
              dataIndex: 'dealWay02',
              width: '220px',
            },
            {
              title: '党纪处分：撤销党内职务',
              dataIndex: 'dealWay03',
              width: '220px',
            },
            {
              title: '党纪处分：留党察看',
              dataIndex: 'dealWay04',
              width: '220px',
            },
            {
              title: '党纪处分：开除党籍',
              dataIndex: 'dealWay05',
              width: '220px',
            },
            {
              title: '政务处分：警告',
              dataIndex: 'dealWay06',
              width: '220px',
            },
            {
              title: '政务处分：记过',
              dataIndex: 'dealWay07',
              width: '220px',
            },
            {
              title: '政务处分：记大过',
              dataIndex: 'dealWay08',
              width: '220px',
            },
            {
              title: '政务处分：降级',
              dataIndex: 'dealWay09',
              width: '220px',
            },
            {
              title: '政务处分：撤职',
              dataIndex: 'dealWay10',
              width: '220px',
            },
            {
              title: '政务处分：开除',
              dataIndex: 'dealWay11',
              width: '220px',
            },
            {
              title: '内部纪律处分',
              dataIndex: 'dealWay12',
              width: '220px',
            },
            {
              title: '经济处罚金额（万元）',
              dataIndex: 'amountSum',
              width: '220px',
            },
          ],
        },
        {
          title: '根据审计建议给予党纪、政务和内部纪律处分',
          children: [
            {
              title: '合计',
              dataIndex: 'mentNum',
              width: '220px',
            },
            {
              title: '党纪处分：警告',
              dataIndex: 'dealManner01',
              width: '220px',
            },
            {
              title: '党纪处分：严重警告',
              dataIndex: 'dealManner02',
              width: '220px',
            },
            {
              title: '党纪处分：撤销党内职务',
              dataIndex: 'dealManner03',
              width: '220px',
            },
            {
              title: '党纪处分：留党察看',
              dataIndex: 'dealManner04',
              width: '220px',
            },
            {
              title: '党纪处分：开除党籍',
              dataIndex: 'dealManner05',
              width: '220px',
            },
            {
              title: '政务处分：警告',
              dataIndex: 'dealManner06',
              width: '220px',
            },
            {
              title: '政务处分：记过',
              dataIndex: 'dealManner07',
              width: '220px',
            },
            {
              title: '政务处分：记大过',
              dataIndex: 'dealManner08',
              width: '220px',
            },
            {
              title: '政务处分：降级',
              dataIndex: 'dealManner09',
              width: '220px',
            },
            {
              title: '政务处分：撤职',
              dataIndex: 'dealManner10',
              width: '220px',
            },
            {
              title: '政务处分：开除',
              dataIndex: 'dealManner11',
              width: '220px',
            },
            {
              title: '内部纪律处分',
              dataIndex: 'dealManner12',
              width: '220px',
            },
          ],
        },
        {
          title: '向司法机关移送或报告案件线索',
          dataIndex: 'accountability',
          width: '300px',
        },
        {
          title: '其中：涉案人员',
          dataIndex: 'otherItems',
          width: '300px',
        },
      ],

      rectForm: {
        unitNames: [],
        timeRange: [],
        auditType: '',
      },
      form: {
        unitNames: [],
        timeRange: [],
      },
      problemForm: {
        unitNames: [],
        timeRange: [],
        auditType: '',
        auditUnitedName: [],
        findTitle: '',
      },

      rules: {
        timeRange: [{ required: true, message: '请选择统计时间', trigger: 'change' }],
        unitNames: [{ required: true, message: '请选择审计机构', trigger: 'change' }],
      },
      rectRules: {
        timeRange: [{ required: true, message: '请选择统计时间', trigger: 'change' }],
        unitNames: [{ required: true, message: '请选择审计机构', trigger: 'change' }],
      },
      problemRules: {
        timeRange: [{ required: true, message: '请选择统计时间', trigger: 'change' }],
        unitNames: [{ required: true, message: '请选择审计机构', trigger: 'change' }],
      },
      formItemLayout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 14 },
      },
      rootNode: {},

      // actions: [
      //   {
      //     label: '导出',
      //     permission: null, // 纯前端操作，不需要权限控制
      //     callback: () => {
      //       this.$refs.dataTable.handleExport()
      //     },
      //   },
      // ],
    }
  },
  created() {
    let userInfo = getUserInfo()
    const params = {
      orgId: userInfo.deptId,
    }
    axios({
      url: 'api/xcoa-mobile/v1/iamorg/getCurrentUserGroup',
      method: 'get',
    }).then((res) => {
      userInfo = res.data
      params.orgId = res.data.id
      axios({
        url: 'api/xcoa-mobile/v1/iamorg/findIamOrgId',
        method: 'post',
        params,
      }).then((res) => {
        this.id = res.data
        const deptCode = userInfo.id.toString()
        const deptName = userInfo.name
        this.rootNode = { code: deptCode, name: deptName, id: this.id }
      })
    })
  },
  mounted() {
    this.tableResize()
    // 初始化审计类型数据字典信息
    this.initDictionaryInfo()
    //  if(this.form.timeRange.length === 0 || this.form.unitNames.length === 0
    //  || ){

    //  }
  },
  methods: {
    initDictionaryInfo() {
      axios({
        url: 'api/xcoa-mobile/v1/iam-law/dictionary?key=PRODUCT_IAM_AUDIT_TYPE',
        method: 'get',
      }).then((res) => {
        if (res.status === 200) {
          this.auditTypeOptions = res.data
        }
      })
    },
    toggleTabs(key) {
      this.activeKey = key
      if (this.activeKey === '1') {
        this.tableId = 'SJXMDataTable'
        this.SJXMTableExpressions = []
      }
      if (this.activeKey === '2') {
        this.tableId = 'JHBGDataTable'
        this.JHBGTableExpressions = []
        if (this.radioValue === 1) {
          this.JHBGTableExpressions.push({
            dataType: 'boolean',
            name: 'stateFlag',
            booleanValue: true,
          })
        } else if (this.radioValue === 2) {
          this.JHBGTableExpressions.push({
            dataType: 'boolean',
            name: 'stateFlag',
            booleanValue: false,
          })
        }
      }
      if (this.activeKey === '3') {
        this.tableId = 'SJJHDataTable'
        this.SJJHTableExpressions = []
        if (this.radioValue === 1) {
          this.SJJHTableExpressions.push({
            dataType: 'boolean',
            name: 'stateFlag',
            booleanValue: true,
          })
        } else if (this.radioValue === 2) {
          this.SJJHTableExpressions.push({
            dataType: 'boolean',
            name: 'stateFlag',
            booleanValue: false,
          })
        }
      }
      this.deleteButtonDisable = true
      if (this.$refs[`${this.tableId}`]) {
        this.$refs[`${this.tableId}`].clearSelection()
      }
    },
    tableResize() {
      document
        .getElementsByClassName('ant-table-empty')[0]
        .getElementsByClassName('ant-table-tbody')[0]
        .appendChild(document.getElementsByClassName('ant-table-placeholder')[0])
      var width = document.getElementsByClassName('ant-table-tbody')[0].offsetWidth
      document.getElementsByClassName('ant-table-placeholder')[0].style.width = `${width}%`
    },
    processReq1(req) {
      req.data = {
        maxResults: req.data.maxResults,
        startPosition: req.data.startPosition,
        dateStart: this.reqData1.dateStart,
        dateEnd: this.reqData1.dateEnd,
        unitIds: this.reqData1.unitNames,
      }
      return req
    },
    processReq2(req) {
      req.data = {
        maxResults: req.data.maxResults,
        startPosition: req.data.startPosition,
        dateStart: this.reqData2.dateStart,
        dateEnd: this.reqData2.dateEnd,
        unitIds: this.reqData2.unitNames,
        auditType: this.reqData2.auditType,
        auditUnitedId: this.reqData2.auditUnitedName,
        findTitle: this.reqData2.findTitle,
      }
      return req
    },
    processReq3(req) {
      req.data = {
        maxResults: req.data.maxResults,
        startPosition: req.data.startPosition,
        dateStart: this.reqData3.dateStart,
        dateEnd: this.reqData3.dateEnd,
        unitIds: this.reqData3.unitNames,
        auditType: this.reqData3.auditType,
        auditUnitedId: this.reqData3.auditUnitedName,
        findTitle: this.reqData3.findTitle,
      }
      return req
    },

    dataLoaded(res) {
      if (res.data.length) {
        res.data.forEach((item, index) => {
          item.id = index + 1
        })
      } else {
        this.tableResize()
      }
      return res
    },
    handleReset() {
      if (this.activeKey === '1') {
        this.$refs.projectSearchForm.resetFields()
      }
      if (this.activeKey === '2') {
        this.$refs.StatisticsSearchForm.resetFields()
      }
      if (this.activeKey === '3') {
        this.$refs.projectSearchForm.resetFields()
      }
    },
    handleAction(type) {
      debugger
      if (type === 'serach') {
        if (this.form.timeRange.length === 0 && this.form.unitNames.length === 0) {
          this.handleSearch1()
        } else {
          // 处理时间
          this.reqData1.dateStart = this.form.timeRange[0].year() + ''
          this.reqData1.dateEnd = this.form.timeRange[1].year() + ''
          // 处理部门
          const arr = []
          this.form.unitNames.forEach((item) => {
            arr.push(`'${item.id}'`)
          })
          this.reqData1.unitNames = arr.join(',')
          this.reqData1.unitIds = arr.join(',')
          this.handleSearch1()
        }
      } else {
        debugger
        if (this.form.timeRange.length === 0 && this.form.unitNames.length === 0) {
          this.handleExport()
        } else {
          // 处理时间
          this.reqData1.dateStart = this.form.timeRange[0].year() + ''
          this.reqData1.dateEnd = this.form.timeRange[1].year() + ''
          // 处理部门
          const arr = []
          this.form.unitNames.forEach((item) => {
            arr.push(`'${item.id}'`)
          })
          this.reqData1.unitNames = arr.join(',')
          this.reqData1.unitIds = arr.join(',')
          this.handleExport()
        }
      }
    },
    handleSearch1() {
      this.reqData1.startPosition = 0
      this.dataKey++
    },
    handleSearch2() {
      this.reqData2.startPosition = 0
      this.dataKey++
    },
    handleSearch3() {
      this.reqData3.startPosition = 0
      this.dataKey++
    },
    handleExport() {
      axios({
        method: 'post',
        url: 'api/xcoa-mobile/v1/spicAuditReportExport/exportProjectCompletionStatus',
        responseType: 'blob',
        data: {
          unitIds: this.reqData1.unitIds,
          dateStart: this.reqData1.dateStart,
          dateEnd: this.reqData1.dateEnd,
        },
      }).then((res) => {
        const url = URL.createObjectURL(res.data)
        download(url, '审计项目完成情况-内审.xlsx')
      })
    },
    handleRectStatistics(type) {
      if (type === 'serach') {
        if (
          this.rectForm.timeRange.length === 0 &&
          this.rectForm.unitNames.length === 0 &&
          this.problemForm.auditType.length === 0
        ) {
          this.handleSearch2()
        } else {
          // 处理时间
          this.reqData2.dateStart = this.rectForm.timeRange[0].year() + ''
          this.reqData2.dateEnd = this.rectForm.timeRange[1].year() + ''
          // 处理部门
          const arr = []
          this.rectForm.unitNames.forEach((item) => {
            arr.push(`'${item.id}'`)
          })
          this.reqData2.unitNames = arr.join(',')
          this.reqData2.unitIds = arr.join(',')
          if (this.rectForm.auditType.length !== 0) {
            this.reqData2.auditType = this.rectForm.auditType[0].id + ''
          } else {
            this.reqData2.auditType = ''
          }

          this.handleSearch2()
        }
      } else {
        debugger
        if (this.rectForm.timeRange.length === 0 && this.rectForm.unitNames.length === 0) {
          this.handleExport()
        } else {
          // 处理时间
          this.reqData2.dateStart = this.rectForm.timeRange[0].year() + ''
          this.reqData2.dateEnd = this.rectForm.timeRange[1].year() + ''
          // 处理部门
          const arr = []
          this.form.unitNames.forEach((item) => {
            arr.push(`'${item.id}'`)
          })
          this.reqData2.unitNames = arr.join(',')
          this.reqData2.unitIds = arr.join(',')
          this.handleExport()
        }
      }
    },

    // 审计问题整改明细台账
    problemHandleAction(type) {
      debugger
      if (type === 'serach') {
        if (
          this.problemForm.timeRange.length === 0 &&
          this.problemForm.unitNames.length === 0 &&
          this.problemForm.auditType.length === 0 &&
          this.problemForm.auditUnitedName.length === 0 &&
          this.problemForm.findTitle === ''
        ) {
          this.handleSearch3()
        } else {
          // 处理时间
          this.reqData3.dateStart = this.problemForm.timeRange[0].year() + ''
          this.reqData3.dateEnd = this.problemForm.timeRange[1].year() + ''
          // 处理部门
          const arr = []
          this.problemForm.unitNames.forEach((item) => {
            arr.push(`'${item.id}'`)
          })
          this.reqData3.unitNames = arr.join(',')
          this.reqData3.unitIds = arr.join(',')
          if (this.problemForm.auditUnitedName.length !== 0) {
            const arrs = []
            this.problemForm.auditUnitedName.forEach((item) => {
              arrs.push(`'${item.id}'`)
            })
            this.reqData3.auditUnitedName = arrs.join(',')
            this.reqData3.auditUnitedId = arrs.join(',')
          } else {
            this.reqData3.auditUnitedName = ''
            this.reqData3.auditUnitedId = ''
          }
          if (this.problemForm.auditType.length !== 0) {
            this.reqData3.auditType = this.problemForm.auditType[0].id + ''
          } else {
            this.reqData3.auditType = ''
          }
          if (this.problemForm.findTitle !== '') {
            this.reqData3.findTitle = this.problemForm.findTitle + ''
          } else {
            this.reqData3.findTitle = ''
          }

          this.handleSearch3()
        }
      } else {
        debugger
        if (
          this.problemForm.timeRange.length === 0 &&
          this.problemForm.unitNames.length === 0 &&
          this.problemForm.auditType.length === 0 &&
          this.problemForm.auditUnitedName.length === 0 &&
          this.problemForm.findTitle === ''
        ) {
          this.problemHandleExport()
        } else {
          // 处理时间
          this.reqData3.dateStart = this.problemForm.timeRange[0].year() + ''
          this.reqData3.dateEnd = this.problemForm.timeRange[1].year() + ''
          // 处理部门
          const arr = []
          this.problemForm.unitNames.forEach((item) => {
            arr.push(`'${item.id}'`)
          })
          this.reqData3.unitNames = arr.join(',')
          this.reqData3.unitIds = arr.join(',')
          if (this.problemForm.auditUnitedName.length !== 0) {
            const arrs = []
            this.problemForm.auditUnitedName.forEach((item) => {
              arrs.push(`'${item.id}'`)
            })
            this.reqData3.auditUnitedName = arrs.join(',')
            this.reqData3.auditUnitedId = arrs.join(',')
          } else {
            this.reqData3.auditUnitedName = ''
            this.reqData3.auditUnitedId = ''
          }
          if (this.problemForm.auditType.length !== 0) {
            this.reqData3.auditType = this.problemForm.auditType[0].id + ''
          } else {
            this.reqData3.auditType = ''
          }
          if (this.problemForm.findTitle !== '') {
            this.reqData3.findTitle = this.problemForm.findTitle + ''
          } else {
            this.reqData3.findTitle = ''
          }

          this.problemHandleExport()
        }
      }
    },

    problemHandleExport() {
      axios({
        method: 'post',
        url: 'api/xcoa-mobile/v1/spicAuditReportExport/exportProblemRectItem',
        responseType: 'blob',
        data: {
          unitIds: this.reqData3.unitIds,
          dateStart: this.reqData3.dateStart,
          dateEnd: this.reqData3.dateEnd,
          auditType: this.reqData3.auditType,
          auditUnitedId: this.reqData3.auditUnitedId,
          findTitle: this.reqData3.findTitle,
        },
      }).then((res) => {
        const url = URL.createObjectURL(res.data)
        download(url, '审计问题整改明细台账-内审.xlsx')
      })
    },

    // 导出单位及内部审计机构基本情况
    exportGroup() {
      axios({
        method: 'post',
        url: 'api/xcoa-mobile/v1/iam-audits-statistics/exportIamOrgExcel',
        responseType: 'blob',
        data: {
          unitIds: '',
          dateStart: '',
          dateEnd: '',
        },
      }).then((res) => {
        const url = URL.createObjectURL(res.data)
        download(url, '单位及内部审计机构基本情况表.xls')
      })
    },
    rowClick(record, { rowIndex, column }) {
      // const param = {
      //   dateStart: this.reqData.dateStart,
      //   dateEnd: this.reqData.dateEnd,
      //   unitIds: "'" + record.ORG_ID + "'",
      // }
      // let url = ''
      // if (column.dataIndex === 'REAL_NUM' || column.dataIndex === 'OUTSIDE_NUM') {
      //   if (column.dataIndex === 'REAL_NUM') {
      //     param.columnValue = 'SJXMS'
      //   } else {
      //     param.columnValue = 'JWXMS'
      //   }
      //   // 项目列表 实际 和境外
      //   url = '#/audit-annualplancompletion-project-list?params='
      // } else if (column.dataIndex === 'FIND_NUM') {
      //   // 发现列表
      //   url = '#/audit-problemamount-find-list?params='
      // } else {
      //   // 整改列表
      //   if (column.dataIndex === 'DONE_NUM') {
      //     param.rectStatus = '03'
      //   }
      //   param.rectUnitFlag = 'true'
      //   url = '#/audit-statistics-find-list?params='
      // }
      // url = url + encodeURIComponent(JSON.stringify(param)) + '&type=personnelstatistics'
      // window.open(url)
    },
  },
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.personalStatistics {
  :global(.ant-table-body) {
    overflow-x: scroll !important;
  }
  :global(.ant-form-item) {
    margin: 0;
  }

  :global(.ant-table-empty) {
    :global(.ant-table-body) {
      overflow-x: scroll !important;
    }
  }
  .conditions {
    margin-bottom: 20px;
  }
  .buttonContent {
    padding-top: 6px;
    text-align: right;
    button {
      margin: 0 4px;
    }
  }
  :global(.anticon-setting) {
    display: none;
  }
  .tableTitle {
    padding-top: 16px;
    margin: 0;
    font-size: 22px;
    font-weight: bold;
    color: #404040;
    text-align: center;
    background: white;
  }
  :global(.reporttablecardxm) {
    :global(.ant-table-body) {
      height: auto !important;
      min-height: auto !important;
      overflow: auto;
    }
  }
  :global(.ant-table-placeholder) {
    height: auto !important;
  }
}
</style>
