<template>
  <div id="">
    <a-collapse v-model="activeNames" accordion>
      <a-collapse-panel v-for="(item, index) in options" :key="item.name" :header="item.title">
        <component :is="item.name" :rowData="rowData" :openType="openType" @addDiFangSuccess="addDiFangSuccess"></component>
      </a-collapse-panel>
    </a-collapse>
  </div>
</template>

<script>
import { optionsForJiangxiDiFangGongChen } from './forDifferentProvince';
import n_weiXiuYangHu from './n_weiXiuYangHu';
import n_weiYangJingFei from './n_weiYangJingFei';
import n_xianGongXianDuan from './n_xianGongXianDuan';
import n_xunShiJianCha from './n_xunShiJianCha';
import w_biaoShiBiaoPai from './w_biaoShiBiaoPai';
import w_diRongYangMao from './w_diRongYangMao';
import w_xianGongXianDuanAnQuanGuanLi from './w_xianGongXianDuanAnQuanGuanLi';
export default {
  props: {
    arrChildType: {
      type: String,
      default: '',
    },
    rowData: {
      type: Object,
      default: {},
    },
    openType: {
      type: Boolean,
      default: true,
    },
  },
  components: {
    w_diRongYangMao,
    w_biaoShiBiaoPai, // 外业-标识标牌
    w_xianGongXianDuanAnQuanGuanLi, // 外业-标识标牌
    n_xunShiJianCha, // 内业-巡视检查
    n_weiXiuYangHu, // 内业-维修养护
    n_xianGongXianDuan, // 内业-险工险段
    n_weiYangJingFei, // 内业-维养经费
  },
  data() {
    return {
      activeNames: [],
      options: [],
    };
  },
  computed: {
    // 监听属性 类似于data概念
    currentRlcode() {
      return localStorage.getItem('currentRlcode')
        ? localStorage.getItem('currentRlcode')
        : '';
    },
  },
  watch: {
    // 监控data中的数据变化
    arrChildType(newValue, oldValue) {
      if (newValue == 'out') {
        this.options = optionsForJiangxiDiFangGongChen[1].childrens;
        this.activeNames = ['w_diRongYangMao'];
      } else {
        this.options = optionsForJiangxiDiFangGongChen[2].childrens;
        this.activeNames = ['n_xunShiJianCha'];
      }
    },
  },
  created() {},
  methods: {
    handleChange(val) {
      console.log(val);
    },
    addDiFangSuccess() {
      this.$emit('addDiFangSuccess');
    },
  },
};
</script>

<style lang='less' scoped>

</style>
