<template>
  <div class="screen-common-wrap">
    <el-card class="content-z" v-if="selectList">
      <a-tabs v-model="activeKey">
        <a-tab-pane
          v-for="item in tabs"
          :key="item.name"
          :tab="item.title"
        >
          <component
            :is="item.name"
            v-if="activeKey === item.name"
            :selectedGQ="selectedGQ"
            :gqPath="params.path"
            :gqStPath="params.stPath"
          />
        </a-tab-pane>
      </a-tabs>
    </el-card>
  </div>

</template>
<script>

import Dl from "@/views/dashboard-screen/screen/screen_Bd_Dl_Ycxx/dl.vue";
import Bd from "@/views/dashboard-screen/screen/screen_Bd_Dl_Ycxx/bd.vue";
import ZzBd from "@/views/dashboard-screen/screen/screen_Bd_Dl_Ycxx/zzBd.vue";
import ZzDl from "@/views/dashboard-screen/screen/screen_Bd_Dl_Ycxx/zzdl.vue";
import GqImg from "@/views/dashboard-screen/screen/screen_Bd_Dl_Ycxx/gqImg.vue";
import GqSTImg from "@/views/dashboard-screen/screen/screen_Bd_Dl_Ycxx/gqStImg.vue";
import request from "@/utils/request";

export default {
  name: 'ScreenBdDlYcxx',
  components: {
    Bd,
    Dl,
    ZzBd,
    ZzDl,
    GqImg,
    GqSTImg
  },
  props: {
    params: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      activeKey: 'Bd',
      selectList: null,
      selectedGQ: null,
      tabs: [{
        title: '(推送)变电异常信息',
        name: 'Bd'
      }, {
        title: '(推送)电力异常信息',
        name: 'Dl'
      },
        {
          title: '(自主发现)变电异常信息',
          name: 'ZzBd'
        },
        {
          title: '(自主发现)电力异常信息',
          name: 'ZzDl'
        }]
    }
  },
  async created() {
    window['dlBD'] = this;
    await this.getSelectGQ()
  },
  computed: {},
  methods: {
    async getSelectGQ() {
      const res = await request('/system/dict/data/type/dlyc_sygq')
      const selectList = res.data || []
      this.selectedGQ = selectList.find(item => item.dictLabel.includes(this.params?.name))
      if (this.selectedGQ && this.params?.path) {

        const stCadName = this.params.name + '(所亭CAD)'
        this.tabs.unshift(
          {
            title: stCadName,
            name: 'GqSTImg'
          }
        )
        const cadName = this.params.name + '(CAD)'
        this.tabs.unshift(
          {
            title: cadName,
            name: 'GqImg'
          }
        )
        this.activeKey = 'GqImg'
      }
      this.selectList = selectList
    }
  }
}
</script>
<style scoped>
@import '~@/assets/less/common.less'
</style>
