﻿﻿﻿﻿﻿﻿<template>
  <a-form :model="queryParams" layout="inline" ref="searchForm" style="row-gap: 8px;">
    <a-form-item label="工程名称">
      <a-input v-model:value="queryParams.nm" placeholder="请输入工程名称" allow-clear />
    </a-form-item>
    <a-form-item label="问题来源时间">
      <a-select v-model:value="queryParams.pblmSourceTm" placeholder="选择问题来源时间" allow-clear>
        <a-select-option v-for="item in DuChaYears" :key="item.value" :value="item.value">{{ item.value }}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="问题归类">
      <a-select v-model:value="queryParams.ptypes" placeholder="请选择问题归类" mode="multiple" allow-clear show-search :max-tag-count="1" style="min-width: 180px;">
        <a-select-option v-for="item in duChaTypes" :key="item.NM" :value="item.NM">{{ item.NM }}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="问题来源">
      <a-input v-model:value="queryParams.pblmSource" placeholder="请输入问题来源" allow-clear />
    </a-form-item>
    <a-form-item label="整改文号">
      <a-input v-model:value="queryParams.zgWjName" placeholder="请输入整改文号" allow-clear />
    </a-form-item>
    <a-form-item label="问题印发文件名">
      <a-input v-model:value="queryParams.zgMemo" placeholder="请输入问题印发文件名" allow-clear />
    </a-form-item>
    <a-form-item label="问题编号">
      <a-input v-model:value="queryParams.fileNoNumber" placeholder="问题编号或范围值(如:1-100)" allow-clear />
    </a-form-item>
    <a-form-item label="责任处室（单位）">
      <a-select v-model:value="queryParams.dutyDept" placeholder="请选择责任处室（单位）" show-search allow-clear>
        <a-select-option v-for="(item, index) in ywcsList" :key="index" :value="item">{{ item }}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="整改状态" v-if="showRectifyStatus">
      <a-select
        v-model:value="workflowStats"
        placeholder="请选择整改状态"
        mode="tags"
        :max-tag-count="1"
        show-search
        allow-clear>
        <a-select-option v-for="item in rectifyProcStates" :key="item.code" :value="item.code">{{ item.name }}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="行政区划" v-if="showZgXianOrgId && showAd">
      <a-tree-select
        v-model:value="queryParams.zgXianOrgId"
        :tree-data="rectifyUnits"
        show-search
        placeholder="请选择行政区划"
        search-placeholder="请输入行政区划"
        :fieldNames="{children: 'children', label: 'label', key: 'id', value: 'id'}"
        treeNodeFilterProp="label"
        :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
        allow-clear />
    </a-form-item>
    <a-form-item label="严重程度" v-if="showInspPblmCate">
      <a-select v-model:value="queryParams.inspPblmCate" allow-clear>
        <a-select-option value="0">一般</a-select-option>
        <a-select-option value="1">较重</a-select-option>
        <a-select-option value="2">严重</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="稽察类问题" v-if="showRectifyStatus">
<!--      <a-range-picker v-model="currentRange" format="YYYY-MM-DD" separator="至" allow-clear />-->
      <a-select v-model:value="queryParams.isJcFlow" placeholder="请选择稽察类问题" allow-clear>
        <a-select-option value="1">是</a-select-option>
        <a-select-option value="0">否</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="是否按期销号" v-if="isView">
      <a-select v-model:value="queryParams.isPdSche" allow-clear>
        <a-select-option value="0">否</a-select-option>
        <a-select-option value="1">是</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="调度年份">
      <a-select
        v-model:value="queryParams.schdYear"
        :disabled="!isView && !isYears"
        placeholder="调度年份"
        allow-clear>
        <a-select-option v-for="y in yearOptions" :key="y" :value="String(y)">{{ y }}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="审核状态" v-if="isAppeal">
      <a-select v-model:value="queryParams.recordWorkflowStat">
        <a-select-option value="0">全部</a-select-option>
        <a-select-option value="1">待我审核</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="流程类型" v-if="isView">
      <a-select v-model:value="processType" allow-clear>
        <a-select-option value="0">重新明确时限问题</a-select-option>
        <a-select-option value="1">延期问题</a-select-option>
        <a-select-option value="2">整改问题</a-select-option>
      </a-select>
    </a-form-item>
    <a-button v-if="isShowImport && readOnlyRole=='display'" @click="downloadTemplate" type="primary" size="small" style="color:rgba(255,255,255,1);margin-left:10px;">问题台账模板下载</a-button>
    <span v-if="isShowImport && readOnlyRole=='display'" style="padding-left: 10px; display: inline-block;">
      <commonUploadAutoSimple
        ref="ImportMend"
        :limit="1"
        :url="`/modular-source/6ace62b8e2bb467d98286d260aebcef2/pdcApi/file/insert?bizType=ledger&bizId=999`"
        @uploadOver="uploadOver"
        :accept="'.xls,.xlsx'"
        style="margin:auto;"
        fileDesc="问题台账导入"></commonUploadAutoSimple>
        <!-- /modular-source/6ace62b8e2bb467d98286d260aebcef2 -->
        <!-- comment=".xls,.xlsx格式,不超过50MB(自动上传)" -->
    </span>
    <a-button
      ref="queryButton"
      v-if="isSjdw"
      @click="quicklyByParams"
      
      ghost
      :loading="loading"
      type="primary"
      style="float:right;margin-right:10px;">快速查询</a-button>
    <a-button
      ref="queryButton"
      @click="queryByParams"
      
      :loading="loading"
      type="primary"
      style="color:rgba(255,255,255,1);float:right;margin-right:10px;z-index: 1;">查询</a-button>
    <a-button
      v-if="showRectifyStatus"
      ref="queryButton"
      @click="dialogFormVisible = true"
      :loading="loading"
      type="primary"
      style="color:rgba(255,255,255,1);float:right;margin-right:10px;z-index: 1;">导出</a-button>
    <a-button
      v-if="isDataScreen && readOnlyRole=='display'"
      ref="queryButton"
      @click="getDataScreen"
      :loading="loading"
      type="primary"
      style="color:rgba(255,255,255,1);float:right;margin-right:10px;z-index: 1;">数据筛查</a-button>
    <a-modal title="自定义表头" :open="dialogFormVisible" @ok="exportExcel" @cancel="dialogFormVisible = false">
      <a-form-item label="导出表头">
        <a-select v-model:value="exelHeads" placeholder="请选择需要导出的表头" mode="tags" style="width:400px">
          <a-select-option v-for="item in headsList" :key="item.value" :value="item.value">{{ item.lable }}</a-select-option>
        </a-select>
      </a-form-item>
    </a-modal>
    <a-modal title="导入错误列表" :open="importVisible" @ok="importVisible = false" @cancel="importVisible = false">
      <div style="width: 100%;max-height: 500px;overflow: auto">
        <p v-for="(item,index) in errorList" :key="index">{{ item }}</p>
      </div>
    </a-modal>
    <a-modal title="数据筛查结果" :open="dataScreenVisible" @ok="dataScreenVisible = false" @cancel="dataScreenVisible = false" width="1300px">
      <div class="data-screen">
        <div v-for="item in dataScreenList" :key="item.id">
          <div style="font-weight: bold;">{{ item.titleRule + item.pageSort + item.contentRule }}</div>
          <div v-if="item.children && item.children.length > 0" style="display: flex; justify-content: start; flex-wrap: wrap;">
            <div v-for="item1 in item.children" :key="item1" style="border: 1px solid #ccc;border-radius: 5px; padding: 5px 10px; margin-right: 5px;">{{ item1 }}</div>
          </div>
          <div v-else>无</div>
        </div>
      </div>
      <template #footer>
        <a-button :loading="dataScreenLoading" type="primary" @click="exportExcel1">导出</a-button>
        <a-button @click="dataScreenVisible = false">关闭</a-button>
      </template>
    </a-modal>
  </a-form>
</template>

<script>
import moment from 'moment';
import request from '../../../utils/gw_ajax_request';
import { exportModel } from '../../../utils/gw_exportModel';
import commonUploadAutoSimple from '../../../widgets/common-upload-auto-simple.vue';
import {
  getDuChaResource,
  getDuChaType,
  getDuChaYears,
  getDutyDept,
  getOrgTreeJson,
  getRectifyProcStates,
  getRectifyProcStates1,
} from '../Common/rectify_api.js';

export default {
  props: {
    showRectifyStatus: {
      type: Boolean,
      default: true,
    },
    showZgXianOrgId: {
      type: Boolean,
      default: true,
    },
    showInspPblmCate: {
      type: Boolean,
      default: false,
    },
    loading: {
      type: Boolean,
      default: false,
    },
    showAd: {
      type: Boolean,
      default: true,
    },
    isView: {
      type: Boolean,
      default: false,
    },
    isYears: {
      type: Boolean,
      default: false,
    },
    isSjdw: {
      type: Boolean,
      default: false,
    },
    isShowImport: {
      type: Boolean,
      default: false,
    },
    isAppeal: {
      type: Boolean,
      default: false,
    },
    isDataScreen: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      currentRange: [],
      pblmSourceArr: [],
      ywcsList: [
        // {name: '防御处', value: '防御处'},
        // {name: '规计处', value: '规计处'},
        // {name: '监督处', value: '监督处'},
        // {name: '建管处', value: '建管处'},
        // {name: '农水处', value: '农水处'},
        // {name: '省河湖局', value: '省河湖局'},
        // {name: '省农电局', value: '省农电局'},
        // {name: '省水政总队', value: '省水政总队'},
        // {name: '水资源处', value: '水资源处'},
      ],
      workflowStats: [],
      queryParams: {
        zgMemo: '',
        isJcFlow: '',
        dutyDept: undefined,
        hasVedio: '',
        adCode: '',
        pblmStat: '',
        inspPblmCate: undefined,
        ifCasePblm: '',
        nm: '',
        rsName: '',
        adFullName: '',
        startTime: '',
        endTime: '',
        objType: '', // 为空才能不区分督查类别
        inspPblmName: '',
        dataStat: '2',
        persId: localStorage.getItem('persId'),
        villType: '0',
        pageSize: 10,
        pageNum: 1,
        pblmTotal: 0,
        ptype: '', // 督查类别
        ptypes: [],
        pblmSourceTm: undefined, // 年度
        pblmSource: '',
        zgXianOrgId: null, // 接收单位
        zgWjName: '', // 整改文号
        workflowStat: [], // 整改状态
        isPdTm: '', // 当前要求完成时限
        isPdSche: undefined,
        schdYear: moment(new Date().getFullYear().toString()).format('YYYY'),
        recordWorkflowStat: '1',
      },
      rectifyProcStates: getRectifyProcStates1(), // 整改流程所有流程状态
      duChaTypes: [
        // { name: '全选', id: '' },
        // { name: '堤防', id: '堤防' },
        // { name: '防汛', id: '防汛' },
        // { name: '河道疏浚沙石综合利用类', id: '河道疏浚沙石综合利用类' },
        // { name: '河湖卫士监督执法', id: '河湖卫士监督执法' },
        // { name: '农村水电', id: '农村水电' },
        // { name: '农村饮水', id: '农村饮水' },
        // { name: '水库', id: '水库' },
        // { name: '水系联通', id: '水系联通' },
        // { name: '水闸', id: '水闸' },
        // { name: '水资源管理', id: '水资源管理' },
        // { name: '项目建设提速类', id: '项目建设提速类' },
        // { name: '中小河流治理', id: '中小河流治理' },
        // { name: '重点山洪沟治理', id: '重点山洪沟治理' }
      ],
      sourceList: [],
      DuChaYears: getDuChaYears(),
      rectifyUnits: [],
      exelHeads: [
        'fileNoNumber[编号]',
        'inspPblmDesc[问题]',
        'problemDetails[问题详情]',
        'pblmSource[问题来源]',
        'pblmSourceTm[问题来源时间]',
        'nm[工程名称]',
        'upAdName[设区市/直管县]',
        'adName[县（市、区）]',
        'zgWjName[问题印发文号]',
        'zgMemo[问题印发文件名]',
        'issuedTm[问题印发时间]',
        'dutyDept[责任处室]',
        'objType[问题归类]',
        'pblmSggtn[整改要求]',
        // 'firstZgTm[初始整改时限]',
        'isPblmDel[问题是否已销号]',
        'isPdTm[销号时间]',
        'isPdSche[是否按期销号]',
        'psDlyTm[最新申请延期月份]',
        'applyPdTm[申请销号日期]',
        'applyFfcTm[提交业务处室日期]',
        'zgDate[当前要求整改完成时限]',
        'nlZgDate[年度初始整改时限]',
        'zgDevelopment[整改工作开展情况（由各地填报，需具体描述）]',
        'deptagePdEln[业务处室、单位不同意销号原因]',
        'zgRedefineReq[重新明确整改要求（如有，由业务处室、单位填写）]',
        'zgZgxx[整改描述]',
        'note[备注]',
        'zgDelayEln[整改时限延期说明]',
        'workflowStat[整改状态]',
        'overdueCount[问题超期次数]',
        'overdueRecord[问题超期整改记录]',
        'auditTotal[申请销号次数]',
        // 'schdYear[调度年份]',
        // 'informedNum[问题被通报次数]',
        // 'fileNoNumber[编号]',
        // 'inspPblmDesc[问题详情]',
        // 'pblmSource[问题来源]',
        // 'pblmSourceTm[问题来源时间]',
        // 'nm[工程名称]',
        // 'adCode[行政划区编码]',
        // 'upAdName[设区市/直管县]',
        // 'adName[行政划区名称]',
        // 'zgWjName[问题印发文号]',
        // 'zgMemo[问题印发文件名]',
        // 'issuedTm[问题印发时间]',
        // 'dutyDept[责任处室]',
        // 'objType[问题归类]',
        //
        // 'expectedZgDate[预计整改完成时间]',
        // 'zgDate[当前要求整改完成时限]',
        // 'isPblmDel[问题是否已销号]',
        // 'isPdTm[销号时间]',
        // 'firstZgTm[初始整改时限]',
        // 'isPdSche[是否按期销号]'
      ],
      exelHeads1: [
        'fileNoNumber[编号]',
        'inspPblmDesc[问题]',
        'problemDetails[问题详情]',
        'pblmSource[问题来源]',
        'pblmSourceTm[问题来源时间]',
        'nm[工程名称]',
        'upAdName[设区市/直管县]',
        'adName[县（市、区）]',
        'zgWjName[问题印发文号]',
        'zgMemo[问题印发文件名]',
        'issuedTm[问题印发时间]',
        'dutyDept[责任处室]',
        'objType[问题归类]',
        'pblmSggtn[整改要求]',
        // 'firstZgTm[初始整改时限]',
        'isPblmDel[问题是否已销号]',
        'isPdTm[销号时间]',
        'isPdSche[是否按期销号]',
        'psDlyTm[最新申请延期月份]',
        'applyPdTm[申请销号日期]',
        'applyFfcTm[提交业务处室日期]',
        'zgDate[当前要求整改完成时限]',
        'nlZgDate[年度初始整改时限]',
        'zgDevelopment[整改工作开展情况（由各地填报，需具体描述）]',
        'deptagePdEln[业务处室、单位不同意销号原因]',
        'zgRedefineReq[重新明确整改要求（如有，由业务处室、单位填写）]',
        'zgZgxx[整改描述]',
        'note[备注]',
        'zgDelayEln[整改时限延期说明]',
        'workflowStat[整改状态]',
        'overdueCount[问题超期次数]',
        'overdueRecord[问题超期整改记录]',
        'auditTotal[申请销号次数]',
        // 'schdYear[调度年份]',
        // 'informedNum[问题被通报次数]',
        // 'fileNoNumber[编号]',
        // 'inspPblmDesc[问题详情]',
        // 'pblmSource[问题来源]',
        // 'pblmSourceTm[问题来源时间]',
        // 'nm[工程名称]',
        // 'adCode[行政划区编码]',
        // 'upAdName[设区市/直管县]',
        // 'adName[行政划区名称]',
        // 'zgWjName[问题印发文号]',
        // 'zgMemo[问题印发文件名]',
        // 'issuedTm[问题印发时间]',
        // 'dutyDept[责任处室]',
        // 'objType[问题归类]',
        //
        // 'expectedZgDate[预计整改完成时间]',
        // 'zgDate[当前要求整改完成时限]',
        // 'isPblmDel[问题是否已销号]',
        // 'isPdTm[销号时间]',
        // 'firstZgTm[初始整改时限]',
        // 'isPdSche[是否按期销号]'
      ],
      headsList: [
        { lable: '编号', value: 'fileNoNumber[编号]' },
        { lable: '问题', value: 'inspPblmDesc[问题]' },
        { lable: '问题详情', value: 'problemDetails[问题详情]' },
        { lable: '问题来源', value: 'pblmSource[问题来源]' },
        { lable: '问题来源时间', value: 'pblmSourceTm[问题来源时间]' },
        { lable: '工程名称', value: 'nm[工程名称]' },
        { lable: '设区市/直管县', value: 'upAdName[设区市/直管县]' },
        { lable: '县（市、区）', value: 'adName[县（市、区）]' },
        { lable: '问题印发文号', value: 'zgWjName[问题印发文号]' },
        { lable: '问题印发文件名', value: 'zgMemo[问题印发文件名]' },
        { lable: '问题印发时间', value: 'issuedTm[问题印发时间]' },
        { lable: '责任处室', value: 'dutyDept[责任处室]' },
        { lable: '问题归类', value: 'objType[问题归类]' },
        { lable: '整改要求', value: 'pblmSggtn[整改要求]' },
        // {lable:'初始整改时限',value:'firstZgTm[初始整改时限]'},
        { lable: '问题是否已销号', value: 'isPblmDel[问题是否已销号]' },
        { lable: '销号时间', value: 'isPdTm[销号时间]' },
        { lable: '是否按期销号', value: 'isPdSche[是否按期销号]' },
        { lable: '最新申请延期月份', value: 'psDlyTm[最新申请延期月份]' },
        { lable: '申请销号日期', value: 'applyPdTm[申请销号日期]' },
        { lable: '提交业务处室日期', value: 'applyFfcTm[提交业务处室日期]' },
        {
          lable: '当前要求整改完成时限',
          value: 'zgDate[当前要求整改完成时限]',
        },
        { lable: '年度初始整改时限', value: 'nlZgDate[年度初始整改时限]' },
        {
          lable: '整改工作开展情况（由各地填报，需具体描述）',
          value: 'zgDevelopment[整改工作开展情况（由各地填报，需具体描述）]',
        },
        {
          lable: '业务处室、单位不同意销号原因',
          value: 'deptagePdEln[业务处室、单位不同意销号原因]',
        },
        {
          lable: '重新明确整改要求（如有，由业务处室、单位填写）',
          value:
            'zgRedefineReq[重新明确整改要求（如有，由业务处室、单位填写）]',
        },
        { lable: '整改描述', value: 'zgZgxx[整改描述]' },
        { lable: '备注', value: 'note[备注]' },
        { lable: '整改时限延期说明', value: 'zgDelayEln[整改时限延期说明]' },
        { lable: '整改状态', value: 'workflowStat[整改状态]' },
        { lable: '问题超期次数', value: 'overdueCount[问题超期次数]' },
        { lable: '问题超期整改记录', value: 'overdueRecord[问题超期整改记录]' },
        { lable: '申请销号次数', value: 'auditTotal[申请销号次数]' },
        // {lable:'调度年份',value:'schdYear[调度年份]'},
        // {lable:'问题被通报次数',value:'informedNum[问题被通报次数]'},
        // {lable:'编号',value:'fileNoNumber[编号]'},
        // {lable:'问题详情',value:'inspPblmDesc[问题详情]'},
        // {lable:'问题来源',value:'pblmSource[问题来源]'},
        // {lable:'问题来源时间',value:'pblmSourceTm[问题来源时间]'},
        // {lable:'工程名称',value:'nm[工程名称]'},
        // {lable:'行政划区编码',value:'adCode[行政划区编码]'},
        // {lable:'设区市/直管县',value:'upAdName[设区市/直管县]'},
        // {lable:'行政划区名称',value:'adName[行政划区名称]'},
        // {lable:'问题印发文号',value:'zgWjName[问题印发文号]'},
        // {lable:'问题印发文件名',value:'zgMemo[问题印发文件名]'},
        // {lable:'问题印发时间',value:'issuedTm[问题印发时间]'},
        // {lable:'责任处室',value:'dutyDept[责任处室]'},
        // {lable:'问题归类',value:'objType[问题归类]'},
        // {lable:'整改要求',value:'pblmSggtn[整改要求]'},
        // {lable:'预计整改完成时间',value:'expectedZgDate[预计整改完成时间]'},
        // {lable:'当前要求整改完成时限',value:'zgDate[当前要求整改完成时限]'},
        // {lable:'问题是否已销号',value:'isPblmDel[问题是否已销号]'},
        // {lable:'销号时间',value:'isPdTm[销号时间]'},
        // {lable:'初始整改时限',value:'firstZgTm[初始整改时限]'},
        // {lable:'是否按期销号',value:'isPdSche[是否按期销号]'}
        // {lable:'编号',value:'fileNoNumber[编号]'},
        // {lable:'问题描述',value:'pblmDescBz[问题描述]'},
        // {lable:'问题来源',value:'pblmSource[问题来源]'},
        // {lable:'工程名称',value:'rsName[工程名称]'},
        // {lable:'市',value:'city[市]'},
        // {lable:'区/县',value:'country[区/县]'},
        // {lable:'印发文号',value:'zgWh[印发文号]'},
        // {lable:'印发文件名',value:'zgWjName[印发文件名]'},
        // {lable:'整改截止日期',value:'zgDate[整改截止日期]'},
        // {lable:'预计完成日期',value:'expectedZgDate[预计完成日期]'},
        // {lable:'整改状态',value:'workflowStat1[整改状态]'},
        // {lable:'实际完成整改日期',value:'finishDate[实际完成整改日期]'},
        // {lable:'是否销号',value:'workflowStat2[是否销号]'},
        // {lable:'责任处室',value:'yewsName[责任处室]'},
        // {lable:'问题归类',value:'pTypeName[问题归类]'},
      ],
      dialogFormVisible: false,
      importVisible: false,
      errorList: [],
      isOpen: false,
      isYear: null,
      moment,
      processType: '', // 流程类型
      yearOptions: Array.from(
        { length: 11 },
        (_, i) => new Date().getFullYear() - 5 + i,
      ),
      dataScreenVisible: false, // 控制数据筛查按钮弹窗
      dataScreenList: [],
      dataScreenLoading: false,
      readOnlyRole: localStorage.getItem('readOnlyRole'),
    };
  },
  components: {
    commonUploadAutoSimple,
  },
  created() {
    console.log(this.isDataScreen, 'isDataScreen');
    this.getDuChaTypes();
    this.getDutyDept();
    this.getDuChaResource();
    this.rectifyUnits = this.getOrgTreeJson();
  },
  methods: {
    onChange() {
      this.isOpen = false;
      this.isYear = null;
    },
    handYearChange(open) {
      if (open) {
        this.isOpen = true;
      } else {
        this.isOpen = false;
      }
      this.timer = setTimeout(() => {
        this.dateYearDisabledRule();
      }, 0);
    },
    dateYearDisabledRule(type, value) {
      const typeR = type ? type : 'lteNow';
      const valueR = value ? moment(value).format('YYYY') : '';
      //获取dom元素
      const tableDom = document.querySelectorAll(
        '.ant-calendar-year-panel-body',
      );
      const prevBtn = document.querySelector(
        '.ant-calendar-year-panel-prev-decade-btn',
      );
      const nextBtn = document.querySelector(
        '.ant-calendar-year-panel-next-decade-btn',
      );
      const tdDom = tableDom[0].querySelectorAll('td');
      // 当前面板的第一个和最后一个年份类似年份翻页按钮因此和年份翻页按钮做相同处理，否则会有错误
      const prevBtnTd = tdDom[0];
      const nextBtnTd = tdDom[tdDom.length - 1];
      //定义所需对比值
      const nowDate = moment().format('YYYY');
      if (tableDom.length > 0) {
        switch (typeR) {
          //<=当前年
          case 'lteNow':
            (() => {
              tdDom.forEach((item) => {
                if (item.innerText < '2021') {
                  item.setAttribute('class', 'datepicker-year-disabled');
                } else {
                  item.classList.remove('datepicker-year-disabled');
                }
              });
              // 年份翻页按钮
              const ev = this.dateYearDisabledRule.bind(this, 'lteNow');
              prevBtn.removeEventListener('click', ev);
              nextBtn.removeEventListener('click', ev);
              prevBtn.addEventListener('click', ev);
              nextBtn.addEventListener('click', ev);

              prevBtnTd.removeEventListener('click', ev);
              nextBtnTd.removeEventListener('click', ev);
              prevBtnTd.addEventListener('click', ev);
              nextBtnTd.addEventListener('click', ev);
            })();
            break;

          //<=当前年、<=结束日期
          case 'rangeNowStart':
            (() => {
              tdDom.forEach((item) => {
                if (
                  item.innerText > nowDate ||
                  (valueR && item.innerText > valueR)
                ) {
                  item.setAttribute('class', 'datepicker-year-disabled');
                } else {
                  item.classList.remove('datepicker-year-disabled');
                }
              });

              // 年份翻页按钮
              const ev = this.dateYearDisabledRule.bind(
                this,
                'rangeNowStart',
                value,
              );
              prevBtn.removeEventListener('click', ev);
              nextBtn.removeEventListener('click', ev);
              prevBtn.addEventListener('click', ev);
              nextBtn.addEventListener('click', ev);

              prevBtnTd.removeEventListener('click', ev);
              nextBtnTd.removeEventListener('click', ev);
              prevBtnTd.addEventListener('click', ev);
              nextBtnTd.addEventListener('click', ev);
            })();
            break;

          //<=当前年、>=开始日期
          case 'rangeNowEnd':
            (() => {
              tdDom.forEach((item) => {
                if (
                  item.innerText > nowDate ||
                  (valueR && item.innerText < valueR)
                ) {
                  item.setAttribute('class', 'datepicker-year-disabled');
                } else {
                  item.classList.remove('datepicker-year-disabled');
                }
              });
              // 年份翻页按钮
              const ev = this.dateYearDisabledRule.bind(
                this,
                'rangeNowEnd',
                value,
              );
              prevBtn.removeEventListener('click', ev);
              nextBtn.removeEventListener('click', ev);
              prevBtn.addEventListener('click', ev);
              nextBtn.addEventListener('click', ev);

              prevBtnTd.removeEventListener('click', ev);
              nextBtnTd.removeEventListener('click', ev);
              prevBtnTd.addEventListener('click', ev);
              nextBtnTd.addEventListener('click', ev);
            })();
            break;
        }
      }
    },
    panelYearChange(value) {
      this.queryParams.schdYear = moment(value).format('YYYY');
      this.isYear = moment(value).format('YYYY');
      this.isOpen = false;
      clearTimeout(this.timer);
    },
    async downloadTemplate() {
      const url =
        '/modular-source/6ace62b8e2bb467d98286d260aebcef2/pdcApi/dc/insp/pblm/downTemplateExcel';
      const downloadName = '问题台账模板.xls';
      const type = 'get';
      await exportModel(type, url, downloadName);
    },
    getDutyDept() {
      getDutyDept().then((res) => {
        this.ywcsList = res.data;
      });
    },
    uploadOver(data) {
      this.errorList = [];
      this.importVisible = false;
      if (data && data.data) {
        request
          .post('/dc/insp/pblm/importZgList', { id: data.data.id })
          .then((res) => {
            if (res.success) {
              this.$message.success('导入文件成功');
            } else {
              if (res.code == 111) {
                this.$message.success('系统错误');
              }
              if (res.code == 222) {
                this.errorList = JSON.parse(res.message);
                this.importVisible = true;
              }
            }
          });
      }
    },
    getDuChaTypes() {
      request.get('/dc/insp/pblm/getListType').then((res) => {
        if (res.success) {
          this.duChaTypes = res.data;
        }
      });
      // getDuChaType(this.queryParams.persId).then(res => {
      //   this.duChaTypes = res.data
      // })
    },
    getDuChaResource() {
      getDuChaResource().then((res) => {
        this.sourceList = res.data;
      });
    },
    getOrgTreeJson() {
      getOrgTreeJson().then((res) => {
        const jsonArray = [];
        const jsonStr = JSON.stringify(res.data);
        jsonArray.push(res.data);
        this.rectifyUnits = jsonArray;
      });
    },
    isNumber(val) {
      var regPos = /^[+]{0,1}(\d+)$/; // 非负浮点数
      if (regPos.test(val)) {
        return true;
      } else {
        return false;
      }
    },
    dateTimeToString(date) {
      var y = date.getFullYear();
      var M = date.getMonth() + 1;
      var d = date.getDate();
      var H = date.getHours();
      var m = date.getMinutes();
      var s = date.getSeconds();
      return y + '-' + (M < 10 ? '0' + M : M) + '-' + (d < 10 ? '0' + d : d);
    },
    quicklyByParams() {
      var now = new Date(); // 当前日期
      var nowMonth = now.getMonth(); // 当前月
      var nowYear = now.getFullYear(); // 当前年
      // // 本月的开始时间
      // var monthStartDate = this.dateTimeToString(new Date(nowYear, nowMonth, 1))
      // // 本月的结束时间
      // // var monthEndDate = this.dateTimeToString(new Date(nowYear, nowMonth + 1, 0))
      // var monthEndDate = this.dateTimeToString(new Date(new Date(nowYear, nowMonth + 1, 0).getTime() + 10 * 24 * 3600 * 1000))

      // 本月的开始时间
      var monthStartDate = moment(new Date(nowYear, nowMonth, 1));
      // 本月的结束时间
      // var monthEndDate = this.dateTimeToString(new Date(nowYear, nowMonth + 1, 0))
      var monthEndDate = moment(
        new Date(
          new Date(nowYear, nowMonth + 1, 0).getTime() + 10 * 24 * 3600 * 1000,
        ),
      );

      this.workflowStats = ['22', '22-1', '20', '24', '24-1'];
      this.currentRange = [monthStartDate, monthEndDate];
      this.queryParams = {
        workflowStat: '22,22-1,20,24,24-1',
        startTime: monthStartDate.format('YYYY-MM-DD') + ' 00:00:00',
        endTime: monthEndDate.format('YYYY-MM-DD') + ' 23:59:59',
      };
      // console.log(this.queryParams, 'queryParams')
      this.queryParams.schdYear = moment(
        new Date().getFullYear().toString(),
      ).format('YYYY');

      this.queryParams.recordWorkflowStat = this.isAppeal
        ? this.queryParams.recordWorkflowStat
        : '';
      this.$emit('queryByParams', {
        queryParams: this.queryParams,
      });
    },
    queryByParams() {
      if (!this.isView) {
        this.queryParams.isPdSche = undefined;
      }
      // if (this.isView || this.isYears) {
      //   // this.queryParams.schdYear = null
      // } else {
      //   this.queryParams.schdYear = null
      // }
      if (this.queryParams.fileNoNumber) {
        if (this.queryParams.fileNoNumber.indexOf('-') > -1) {
          var numList = this.queryParams.fileNoNumber.split('-');
          if (
            ((!numList[0] || !numList[1]) && numList.length != 2) ||
            !this.isNumber(numList[0]) ||
            !this.isNumber(numList[1])
          ) {
            this.$message.warning('请输入正确的编号范围！');
            return;
          }
        }
      }
      if (this.currentRange) {
        // console.log(this.currentRange, this.currentRange[0])
        this.queryParams.startTime = this.currentRange[0]
          ? this.currentRange[0].format('YYYY-MM-DD') + ' 00:00:00'
          : '';
        this.queryParams.endTime = this.currentRange[1]
          ? this.currentRange[1].format('YYYY-MM-DD') + ' 23:59:59'
          : '';
      } else {
        this.queryParams.startTime = '';
        this.queryParams.endTime = '';
      }
      this.queryParams.workflowStat =
        this.workflowStats.length > 0 ? this.workflowStats.join(',') : '';

      // isDlyFlow = 1 和 isDlyHeavy = 1  就是重新明确
      // isDlyFlow = 1 和 isDlyHeavy = 0  就是延期
      // isDlyFlow = 0 和 isDlyHeavy = 0 就是整改
      if (this.processType == '0') {
        this.queryParams.isDlyFlow = 1;
        this.queryParams.isDlyHeavy = 1;
      } else if (this.processType == '1') {
        this.queryParams.isDlyFlow = 1;
        this.queryParams.isDlyHeavy = 0;
      } else if (this.processType == '2') {
        this.queryParams.isDlyFlow = 0;
        this.queryParams.isDlyHeavy = 0;
      } else {
        this.queryParams.isDlyFlow = '';
        this.queryParams.isDlyHeavy = '';
      }
      // this.queryParams.pblmSource = (this.pblmSourceArr.length>0?this.pblmSourceArr.join(","):"");

      this.queryParams.recordWorkflowStat = this.isAppeal
        ? this.queryParams.recordWorkflowStat
        : '';
      this.$emit('queryByParams', {
        queryParams: this.queryParams,
      });
    },
    async exportExcel() {
      this.queryByParams();
      if (this.exelHeads.length > 0) {
        this.queryParams.list = this.exelHeads;
        const data = JSON.stringify(this.queryParams);
        const url =
          '/modular-source/6ace62b8e2bb467d98286d260aebcef2/pdcApi/dc/insp/pblm/page/rever/exportzhidong';
        const type = 'post';
        const exportName = '问题查看.xls';
        const result = await exportModel(type, url, exportName, data);
        this.dialogFormVisible = false;
        // this.exelHeads = [];
        /*     await request.post("/dc/insp/pblm/page/rever/exportzhidong",data).then(res => {
              let blob = new Blob([res], {type: "application/vnd.ms-excel"});
                   let objectUrl = URL.createObjectURL(blob);
                   this.dialogFormVisible = false;
                   this.exelHeads = [];
                  const link = document.createElement('a');
                     link.href = objectUrl;
                     link.download = '问题查看.xls'; // 文件名
                     link.click(); // 下载文件
                     URL.revokeObjectURL(objectUrl); // 释放内存
             }) */
      } else {
        this.$message.warning('请选择需要导出的表头！');
      }
    },
    async exportFile() {
      const datas = JSON.stringify(this.queryParams);
      const url = '/pdcApi/dc/insp/pblm/page/rever/export';
      const type = 'post';
      const exportName = '问题查看.xls';
      const result = await exportModel(type, url, exportName, datas);
      /*  request.post( '/pdcApi/dc/insp/pblm/page/rever/export', this.queryParams).then(res => {
              let blob = new Blob([res], {type: "application/vnd.ms-excel"});
              let objectUrl = URL.createObjectURL(blob);
                // window.location.href = objectUrl;
               const link = document.createElement('a');
                link.href = objectUrl;
                link.download = '问题查看.xls'; // 文件名
                link.click(); // 下载文件
                URL.revokeObjectURL(objectUrl); // 释放内存
        }); */
      // return request({
      //     url:
      //     method: 'POST',
      //     data: data,
      //     headers:{
      //         responseType: 'blob'
      //     }
      // })
    },
    getDataScreen() {
      this.dataScreenList = [];
      this.dataScreenVisible = true;
      this.dataScreenLoading = true;
      request.post('/bis/insp/BisInspDataScreen/getListAll', {}).then((res) => {
        if (res.success) {
          this.dataScreenList = res.data;
          request
            .post('/bis/insp/BisInspDataScreen/getListAllContent', {
              schdYear: this.queryParams.schdYear,
            })
            .then((res) => {
              this.dataScreenList.forEach((item) => {
                this.$set(item, 'children', res.data[item.id]);
              });
              this.dataScreenLoading = false;
            });
        } else {
          this.$message.error(res.message);
        }
      });
    },
    async exportExcel1() {
      const data = JSON.stringify({
        schdYear: this.queryParams.schdYear,
        list: this.exelHeads1,
      });
      const url =
        '/modular-source/6ace62b8e2bb467d98286d260aebcef2/pdcApi/dc/insp/pblm/page/rever/exportzhidong';
      const type = 'post';
      const exportName = '问题查看.xls';
      const result = await exportModel(type, url, exportName, data);
    },
  },
};
</script>

<style lang='less' scoped>
/deep/ .ant-row {
  width: 18%;
}
.data-screen {
  height: 500px;
  overflow: auto;
}
/deep/.datepicker-year-disabled {
    pointer-events: none;
    cursor: not-allowed;
    a {
        color: rgba(0, 0, 0, 0.25);
        background: #f5f5f5;
    }
}
</style>
<style lang='less'>
    .datepicker-year-disabled {
        pointer-events: none;
        cursor: not-allowed;
        a {
            color: rgba(0, 0, 0, 0.25);
            background: #f5f5f5;
        }
    }
</style>
