<template>
  <a-modal
    :open="dialogFormVisible"
    :title="currentObjectName + '督查填报'"
    :footer="null"
    width="100%"
    @cancel="closeDialog">
    <a-layout>
      <a-layout-content id="dxdcListMain">
        <a-tabs v-model="currentViewId" type="card" @tabClick="tabIndexChange">
          <a-tab-pane v-for="option in options" :key="option.label" :tab="option.label">
            <component
              :is="option.value"
              :currentObjectRgstrId="currentObjectRgstrId"
              :currentObjectName="currentObjectName"
              :currentResCode="currentResCode"
              :currentObjectId="currentObjectId"
              :activeLabel="activeLabel"
              :pType="pType"
              :openType="openType"
              :chkType="chkType"
              :ifView="ifView"
              :rowData="rowData"
              :currentRsvrNm="currentRsvrNm"
              :currentAdCode="currentAdCode"
              :labelList="signatureLabelList"
              @cancelHandler="cancelHandler"
              @addShuiKuSuccess="addShuiKuSuccess"> </component>
          </a-tab-pane>
        </a-tabs>
      </a-layout-content>
    </a-layout>
  </a-modal>
</template>

<script>
import request from '../../utils/gw_ajax_request';
import problemDialog from '../duChaWenTi/problemDialog.vue';
import zhongdianhuanjie from '../zonghexinxi/zhongdianluoshiNew.vue';
import signature from './components/signature.vue';
import effection from './rsvrFill/effection.vue';
import problemList from './rsvrProblemList.vue';
import anquanjianding from './shuiku/anquanjianding.vue';
import anquanyunxing from './shuiku/anquanyunxing.vue';
import gongchengshiti from './shuiku/gongchengshiti.vue';
import gongchengshitiFujian from './shuiku/gongchengshitiFujian.vue';
import jichuxinxi from './shuiku/jichuxinxi.vue';
import jichuxinxiFujian from './shuiku/jichuxinxiFujian.vue';
import RiChangXunCha from './shuiku/richangxunjian.vue';
import SecurityIdentity from './shuiku/SecurityIdentity.vue';
import shebeisheshi from './shuiku/shebeisheshi.vue';
import pblmRectifyReviewSituation from './shuiku/shuiku2021/pblmRectifyReviewSituation.vue';
import reservoirInspection from './shuiku/shuiku2021/reservoirInspectionFujian2021.vue';
import yunxingguanli from './shuiku/yunxingguanli.vue';
import yunxingguanliFujian from './shuiku/yunxingguanliFujian.vue';
import zoufangqingkuang from './shuiku/zeRenRen.1.vue';
import zerenrenFive from './shuiku/zeRenRenFive.vue';
import zerenren from './shuiku/zeRenRenNew.vue';
import zerenrenFujian from './shuiku/zeRenRenNewFujian.vue';
import ZongHeGuanli from './shuiku/zongheguanli.vue';
// import hdqzbhList from './hehuweishi/hedaoqingzhangbaohu.vue'

import { getrgstrIdObject } from '../../api/duChaTianBao';

import {
  optionsForFujian,
  optionsForFujianDsk,
  optionsForJiangxi,
  optionsForNation,
} from './shuiku/forDifferentProvince.js';
export default {
  components: {
    zerenren: zerenren,
    zerenrenFujian,
    gongchengshitiFujian,
    zerenrenFive: zerenrenFive,
    gongchengshiti: gongchengshiti,
    yunxingguanli: yunxingguanli,
    yunxingguanliFujian,
    jichuxinxi: jichuxinxi,
    jichuxinxiFujian,
    zhongdianhuanjie: zhongdianhuanjie,
    effection: effection,
    zoufangqingkuang: zoufangqingkuang,
    problemDialog: problemDialog,
    problemList: problemList,
    ZongHeGuanli: ZongHeGuanli,
    SecurityIdentity: SecurityIdentity,
    RiChangXunCha: RiChangXunCha,
    shebeisheshi: shebeisheshi,
    // hdqzbhList,
    signature,
    anquanyunxing,
    anquanjianding,
    reservoirInspection,
    pblmRectifyReviewSituation,
  },
  props: [
    'rowData',
    'currentObjectRgstrId',
    'currentResCode',
    'currentObjectId',
    'currentObjectName',
    'pType',
    'openType',
    'ifView',
    'currentRsvrNm',
    'currentAdCode',
    'chkType',
  ],
  data() {
    return {
      options: [
        {
          value: 'jichuxinxi',
          label: '基础信息纠错',
        },
        // {
        //     value: "reservoirInspection",
        //     label: '水库检查情况'
        // },
        // {
        //     value: "pblmRectifyReviewSituation",
        //     label: '问题整改复查情况'
        // },
        {
          value: 'problemList',
          label: '问题清单',
        },
        // {
        //     value: "signature",
        //     label: '责任人签字'
        // }
      ],
      value: '',
      dialogShow: false,
      currentViewId: '基础信息纠错',
      dialogFormVisible: true,
      activeLabel: '',
      signatureLabelList: ['行政责任人', '技术责任人', '巡查责任人'],
    };
  },
  computed: {
    persId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '1098101939614724096';
    },
    currentRlcode() {
      return localStorage.getItem('currentRlcode')
        ? localStorage.getItem('currentRlcode')
        : '';
    },
  },
  created() {},
  methods: {
    submitHandler() {
      getrgstrIdObject(this.rowData.code, this.rowData.objId).then((res) => {
        if (res.data.baseStat == '0') {
          this.$message.warning('请填写重点环节落实情况！');
          return;
        } else if (res.data.presStat == '0') {
          this.$message.warning('请填写责任人状态！');
          return;
        } else if (res.data.resRunStat == '0') {
          this.$message.warning('请填写水库工程实体和运行管理情况！');
          return;
        } else if (res.data.viewStat == '0') {
          this.$message.warning('走访用户状态！');
          return;
        }
        this.$confirm({
          title: '提示',
          content: '请确认所有信息填报完毕？',
          okType: 'warning',
          onOk: () => {
            const formObj = {
              rgstrId: this.currentObjectRgstrId,
              state: '2',
            };
            request.post('/dc/insp/rsvrRgstr/update', formObj).then((res) => {
              if (res.success) {
                this.$emit('addShuiKuSuccess');
                this.$message.success('提交成功');
              } else {
                this.$emit('cancelHandler');
              }
            });
          },
        });
      });
    },
    closeHandler() {
      this.dialogShow = false;
      this.$emit('addShuiKuSuccess');
    },
    appearDialog(type) {
      this.dialogShow = true;
      // this.problemSmallType = type
    },
    closePDialog() {
      this.dialogShow = false;
    },
    showDialog() {
      this.dialogFormVisible = true;
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    addShuiKuSuccess() {
      this.$emit('addShuiKuSuccess');
    },
    closeDialog() {
      this.$confirm({
        title: '提示',
        content: '确认退出吗？',
        okType: 'warning',
        onOk: () => {
          this.$emit('cancelHandler');
        },
      });
    },
    tabIndexChange(item) {
      if (item == '问题清单') {
        this.activeLabel = item;
      } else {
        this.activeLabel = '';
      }
    },
  },
};
</script>

<style lang='less' scoped>
:deep(.ant-modal) {
  top: 0;
}
</style>
