<template>
  <div class="grid-content bg-purple" style="height: 100%;">
    <a-card class="box-card" style="height: 100%">
      <a-tabs
        v-model:activeKey="activeContent"
        type="card"
        style="height:100%;width: 100%;"
      >
        <a-tab-pane key="first" tab="督查人员">
          <duChaRenYuanList
            v-if="showRightComponent"
            ref="renYuanList"
            :objType="duChaType"
            :dczId="currentSelectTreeNodeId"
            :dczName="currentSelectTreeNodeName"
            @showEditDialog="showEditDialog"
          ></duChaRenYuanList>
        </a-tab-pane>
        <a-tab-pane
          key="third"
          tab="督查区域"
          v-if="showRightComponent && !hideArea"
        >
          <duChaQuYuList
            ref="qyList"
            :objType="duChaType"
            :dczId="currentSelectTreeNodeId"
            :dczName="currentSelectTreeNodeName"
            @showEditDialog="showEditDialog_qy"
            @emitCurrentObjSelectName="emitCurrentObjSelectName"
          ></duChaQuYuList>
        </a-tab-pane>
        <a-tab-pane key="second" tab="督查对象">
          <duChaDuiXiangList
            v-if="showRightComponent"
            ref="duiXiangList"
            :objType="duChaType"
            :plnaId="plnaTreeCode"
            :dczId="currentSelectTreeNodeId"
            :dczName="currentSelectTreeNodeName"
            :activeContent="activeContent"
            @showEditDialog_dx="showEditDialog_dx"
            @emitCurrentObjSelectName="emitCurrentObjSelectName"
          ></duChaDuiXiangList>
        </a-tab-pane>
      </a-tabs>
    </a-card>
    <!-- 添加督查人员、督查对象、督查区域 -->
    <editDczInfo
      ref="editDczInfoRef"
      :dczId="currentSelectTreeNodeId"
      :psn="currentSelectTreeNodePsn"
      :jiGouId="orgId"
      @addSuccess="RenYuanaAddSuccessHandler"
    ></editDczInfo>
    <component
      :is="curEditDcdxInfo"
      ref="editDcdxInfoRef"
      :objType="duChaType"
      :plnaId="currentSelectTreeNodeId"
      :dczId="currentSelectTreeNodeId"
      @addSuccess="DuiXiangAddSuccessHandler"
    ></component>
    <editDcqyInfo
      ref="editDcqyInfoRef"
      :objType="duChaType"
      :plnaId="currentSelectTreeNodeId"
      :dczId="currentSelectTreeNodeId"
      @addSuccess="quYuAddSuccessHandler"
    ></editDcqyInfo>
  </div>
</template>

<script>
import duChaQuYuList from '../../duChaGuanLi/duChaQuYuList.vue';
import duChaRenYuanList from '../../duChaGuanLi/duChaRenYuanList.vue';
import editDcdxInfo from '../editDcdxInfo.vue';
import editDcdxInfoCommon from '../editDcdxInfo_common.vue';
import editDcdxInfoDfgc from '../editDcdxInfo_dfgc.vue';
import editDcdxInfoDfgcaqdx from '../editDcdxInfo_dfgcaqdx.vue';
import editDcdxInfoDike2022 from '../editDcdxInfo_dike2022.vue';
import editDcdxInfoFhgczgfc from '../editDcdxInfo_fhgcfczg.vue';
import editDcdxInfoHuws from '../editDcdxInfo_hhws.vue';
import editDcdxInfoNcgsgc from '../editDcdxInfo_ncgsgc.vue';
import editDcdxInfoNcysaq from '../editDcdxInfo_ncysaq.vue';
import editDcdxInfoNy from '../editDcdxInfo_ny.vue';
import editDcdxInfoQsgc from '../editDcdxInfo_qsgc.vue';
import editDcdxInfoSiLuan from '../editDcdxInfo_siLuan.vue';
import editDcdxInfoSjss from '../editDcdxInfo_sjss.vue';
import editDcdxInfoSjzhdcjh from '../editDcdxInfo_sjzhdcjh.vue';
import editDcdxInfoSkfhdd from '../editDcdxInfo_skfhdd.vue';
import editDcdxInfoSlaqscdpc from '../editDcdxInfo_slaqscdpc.vue';
import editDcdxInfosltsn from '../editDcdxInfo_sltsn.vue';
import editDcdxInfoSxzzf from '../editDcdxInfo_sxzzf.vue';
import editDcdxInfoSyd from '../editDcdxInfo_syd.vue';
import editDcdxInfosz from '../editDcdxInfo_sz.vue';
import editDcdxInfoSzygljs from '../editDcdxInfo_szygljs.vue';
import editDcdxInfoVillSaf from '../editDcdxInfo_villsaf.vue';
import editDcdxInfoxshd from '../editDcdxInfo_xshd.vue';
import editDcdxInfoXskbzh from '../editDcdxInfo_xskbzh.vue';
import editDcdxInfoYjbysy from '../editDcdxInfo_yjbysy.vue';
import editDcdxInfoZdshgc from '../editDcdxInfo_zdshgc.vue';
import editDcdxInfoZdsl from '../editDcdxInfo_zdsl.vue';
import editDcqyInfo from '../editDcqyInfo.vue';
import editDczInfo from '../editDczInfo.vue';
import duChaDuiXiangList from './duChaDuiXiangList.vue';

export default {
  props: [
    'duChaType',
    'currentNodeinfo',
  ],
  data() {
    return {
      tabContentHeight: window.innerHeight - 260,
      showRightComponent: false,
      activeContent: 'first',
      plnaTreeCode: '',
      curEditDcdxInfo: 'editDcdxInfo', // 根据duChaType判断当前添加对象的弹窗类型
    };
  },
  computed: {
    orgId() {
      return localStorage.getItem('guid') ? localStorage.getItem('guid') : '';
    },
    hideArea() {
      return this.duChaType == '23';
    },
    currentSelectTreeNodeId() {
      const id = this.currentNodeinfo?.currentSelectTreeNodeId || '';
      return id;
    },
    currentSelectTreeNodeName() {
      return this.currentNodeinfo?.currentSelectTreeNodeName || '';
    },
    currentSelectTreeNodePsn() {
      return this.currentNodeinfo?.currentSelectTreeNodePsn || '';
    },
  },
  components: {
    duChaRenYuanList,
    duChaQuYuList,
    duChaDuiXiangList,
    editDczInfo,
    editDcqyInfo,
    editDcdxInfo,
    editDcdxInfosz,
    editDcdxInfoXskbzh,
    editDcdxInfoHuws,
    editDcdxInfoSjss,
    editDcdxInfosltsn,
    editDcdxInfoxshd,
    editDcdxInfoDfgc,
    editDcdxInfoSzygljs,
    editDcdxInfoQsgc,
    editDcdxInfoSyd,
    editDcdxInfoNy,
    editDcdxInfoSiLuan,
    editDcdxInfoZdsl,
    editDcdxInfoZdshgc,
    editDcdxInfoSxzzf,
    editDcdxInfoSkfhdd,
    editDcdxInfoYjbysy,
    editDcdxInfoNcysaq,
    editDcdxInfoDfgcaqdx,
    editDcdxInfoFhgczgfc,
    editDcdxInfoSlaqscdpc,
    editDcdxInfoNcgsgc,
    editDcdxInfoCommon,
    editDcdxInfoDike2022,
    editDcdxInfoVillSaf,
    editDcdxInfoSjzhdcjh,
  },
  mounted() {
    this.showRightComponent = true;
  },
  watch: {
    currentNodeinfo: {
      deep: true,
      handler(val) {
        console.log('[子] currentNodeinfo变化:', val?.currentSelectTreeNodeId);
        if (!val?.currentSelectTreeNodeId) return;
      },
    },
    duChaType(val) {
      // 1 小水库  2 人饮  3 水毁  4 水利工程建设  5 地下水  6 水闸  7 水利工程运行  36 大中型水库
      if (val == '1' || val == '2' || val == '3' || val == '36') {
        this.curEditDcdxInfo = 'editDcdxInfo';
      } else if (val == '6') {
        this.curEditDcdxInfo = 'editDcdxInfosz';
      } else if (val == '24') {
        this.curEditDcdxInfo = 'editDcdxInfoXskbzh'; // 江西小水库标准化
      } else if (val == '50') {
        this.curEditDcdxInfo = 'editDcdxInfoHuws'; // 江西河湖卫士
      } else if (val == '52') {
        this.curEditDcdxInfo = 'editDcdxInfoSjss'; // 疏浚沙石
      } else if (val == '51') {
        this.curEditDcdxInfo = 'editDcdxInfosltsn'; // 水里提速年
      } else if (val == '59') {
        this.curEditDcdxInfo = 'editDcdxInfoxshd'; // 059长江经济带小水电清理
      } else if (val == '58') {
        this.curEditDcdxInfo = 'editDcdxInfoDfgc'; // 堤防工程
      } else if (val == '60') {
        this.curEditDcdxInfo = 'editDcdxInfoSzygljs'; // 60 水资源管理节水
      } else if (val == '64') {
        this.curEditDcdxInfo = 'editDcdxInfoQsgc'; // 64 取水工程
      } else if (val == '61') {
        this.curEditDcdxInfo = 'editDcdxInfoSyd'; // 水源地
      } else if (val == '63') {
        this.curEditDcdxInfo = 'editDcdxInfoNy'; // 农业供水
      } else if (val == '18') {
        this.curEditDcdxInfo = 'editDcdxInfoSiLuan'; // 四乱迁移
      } else if (val == '65') {
        this.curEditDcdxInfo = 'editDcdxInfoZdsl'; // 65 重点水利
      } else if (val == '66') {
        this.curEditDcdxInfo = 'editDcdxInfoZdshgc'; // 66 重点水毁工程
      } else if (val == '85') {
        this.curEditDcdxInfo = 'editDcdxInfoSxzzf'; // 水行政执法
      } else if (val == '86') {
        this.curEditDcdxInfo = 'editDcdxInfoSkfhdd'; // 水库防洪调度
      } else if (val == '87') {
        this.curEditDcdxInfo = 'editDcdxInfoYjbysy'; // 应急备用水源
      } else if (val == '88') {
        this.curEditDcdxInfo = 'editDcdxInfoNcysaq'; // 农村供水工程运行管理
      } else if (val == '90') {
        this.curEditDcdxInfo = 'editDcdxInfoDfgcaqdx'; // 提防工程安全度汛
      } else if (val == '92') {
        this.curEditDcdxInfo = 'editDcdxInfoFhgczgfc'; // 水利监督发现问题整改情况复查
      } else if (val == '107') {
        this.curEditDcdxInfo = 'editDcdxInfoSlaqscdpc'; // 水利安全生产大排查
      } else if (val == '109') {
        this.curEditDcdxInfo = 'editDcdxInfoNcgsgc'; // 农村供水工程安全
      } else if (val == '111') {
        this.curEditDcdxInfo = 'editDcdxInfoCommon'; // 第二季度通用督查
      } else if (val == '114') {
        this.curEditDcdxInfo = 'editDcdxInfoDike2022'; // 堤防工程督查
      } else if (val == '117') {
        this.curEditDcdxInfo = 'editDcdxInfoVillSaf'; // 农村脱贫户饮水安全
      } else if (val == '1110') {
        this.curEditDcdxInfo = 'editDcdxInfoSjzhdcjh'; // 省级综合督查计划
      }
    },
  },
  methods: {
    showEditDialog(item) {
      this.$refs['editDczInfoRef'].showDialog();
    },
    showEditDialog_qy(item) {
      this.$refs['editDcqyInfoRef'].showDialog();
    },
    showEditDialog_dx(item) {
      this.$refs['editDcdxInfoRef'].showDialog(this.duChaType);
    },
    emitCurrentObjSelectName(item) {
      this.$refs['editDcdxInfoRef'].changeCurrentObjSelectName(item);
    },
    RenYuanaAddSuccessHandler: function () {
      this.$refs['renYuanList'].getDcryResult();
    },
    DuiXiangAddSuccessHandler: function () {
      this.$refs['duiXiangList'].getDcdxList1();
    },
    quYuAddSuccessHandler: function () {
      this.$refs['qyList'].getDcqyResult();
    },
  },
};
</script>

<style scoped></style>
