<template>
  <div class="diFangTianBaoDialog">
    <a-modal
      :open="dialogFormVisible"
      :title="`${rowData.nm ? rowData.nm : ''} - 督查填报`"
      :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
                ref="diFangTabs"
                :is="option.value"
                :rowData="rowData"
                :openType="openType"
                :arrChildType="arrChildType"
                @addDiFangSuccess="addDiFangSuccess"></component>
            </a-tab-pane>
          </a-tabs>
        </a-layout-content>
      </a-layout>
    </a-modal>
  </div>
</template>

<script>
import { optionsForJiangxiDiFangGongChen } from './diFangGongCheng/forDifferentProvince';
import jichuxinxi from './diFangGongCheng/jichuxinxi.vue';
import problemList from './diFangGongCheng/problemList.vue';
import waiYeJianCha from './diFangGongCheng/waiYeJianCha.vue';
export default {
  props: {
    rowData: {
      type: Object,
      default: {},
    },
    inspType: {
      type: String,
      default: '',
    },
    openType: {
      type: Boolean,
      default: true,
    },
  },
  components: {
    jichuxinxi,
    waiYeJianCha, // 外业检查
    problemList, // 问题清单
  },
  data() {
    return {
      dialogFormVisible: true,
      options: [],
      arrChildType: '',
      currentViewId: '基础信息纠错',
      activeLabel: '',
    };
  },
  computed: {
    // 监听属性 类似于data概念
    currentRlcode() {
      return localStorage.getItem('currentRlcode')
        ? localStorage.getItem('currentRlcode')
        : '';
    },
  },
  mounted() {
    if (this.currentRlcode.indexOf('36') == '0') {
      // 江西省
      // var arr = [optionsForJiangxiDiFangGongChen[0],optionsForJiangxiDiFangGongChen[parseInt(this.inspType)],optionsForJiangxiDiFangGongChen[4]];
      var arr = optionsForJiangxiDiFangGongChen;
      // this.arrChild = [optionsForJiangxiDiFangGongChen[1].childrens,optionsForJiangxiDiFangGongChen[2].childrens]
      this.options = arr;
    }
  },
  methods: {
    closeDialog() {
      this.$confirm({
        title: '提示',
        content: '确认退出吗？',
        okType: 'warning',
        onOk: () => {
          this.$emit('cancelHandler');
        },
      });
    },
    tabIndexChange(item) {
      this.arrChildType = '';
      if (item == '问题清单') {
        this.activeLabel = item;
        this.$refs.diFangTabs[3].getProblemList();
      } else {
        this.activeLabel = '';
      }
      if (item == '外业检查') {
        this.arrChildType = 'out';
      }
      if (item == '内业检查') {
        this.arrChildType = 'in';
      }
    },
    addDiFangSuccess() {
      this.$emit('addDiFangSuccess');
    },
  },
};
</script>

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