<template>
  <el-dialog
    width="70%"
    @open="opened"
    @closed="closed"
    :fullscreen="true"
    :show-close="true"
    class="dialogs"
  >
    <template #title>
      <div class="showTitles currentShowTitles">
        <div class="titles">升压站</div>
      </div>
    </template>
    <div class="body">
      <div class="titleList">
        <div v-for="(item, index) in stationList" :key="index">
          <div
            v-if="item.id !== currentStation"
            :class="
              index === 0
                ? 'controlTypesLeft'
                : index === stationList.length - 1
                ? 'controlTypesRight'
                : 'controlTypes'
            "
            @click="handleTypeChange(item)"
          >
            {{ item.name }}
          </div>
          <div
            v-else
            :class="
              index === 0
                ? 'onControlTypesLeft'
                : index === stationList.length - 1
                ? 'onControlTypesRight'
                : 'onControlTypes'
            "
            @click="handleTypeChange(item)"
          >
            {{ item.name }}
          </div>
        </div>
      </div>
      <div style="height: 90vh">
        <Cl
        ref="svgRef"
        v-if="currentStation == 'CL_FDC' || currentStation == 'CL_SYZ'"
      />
      <KB
        ref="svgRef"
        v-if="currentStation == 'KB_FDC' || currentStation == 'KB_SYZ'"
      />
      <DX
        ref="svgRef"
        v-if="currentStation == 'DX_FDC' || currentStation == 'DX_SYZ'"
      />
      <SY
        ref="svgRef"
        v-if="currentStation == 'SY_FDC' || currentStation == 'SY_SYZ'"
      />
      </div>
    </div>
  </el-dialog>
</template>
<script>
import Cl from "./BoosterStation/cl.vue";
import KB from "./BoosterStation/kb.vue";
import DX from "./BoosterStation/dx.vue";
import SY from "./BoosterStation/sy.vue";
export default {
  components: {
    Cl,
    KB,
    DX,
    SY,
  },
  props: {
    currentStation: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      BasicInfo: {},
      line: "",
      currentStation: "",
      alarmTime: "",
      alarmContent: "",
      alarms: [],
      count: false,
      stationList: [],
      types: null,
    };
  },
  created() {},

  methods: {
    closed() {
      // todo 切换页面的时候应该让上一个页面停止刷新数据（调用end方法）
      this.$refs.svgRef.closed();
      // this.$refs.BasicInfo.end();
      // this.$refs.BasicInfo.labelChange();
      this.$emit("close");
      //clearInterval(this.refreshTimer);
    },
    opened() {
      this.currentStation = this.currentStation
        ? this.currentStation
        : this.$store.state.stationList[0].id;
      this.stationList = this.$store.state.stationList;
      this.$nextTick(() => {
        this.$refs.svgRef.opened();
      });
    },
    dbClicks(value) {
      this.$refs.BasicInfo.dbClicks(value, this.windturbine.windturbineId);
    },
    handleTypeChange(val) {
      this.currentStation = val.id;
      this.$nextTick(() => {
        this.$refs.svgRef.opened();
      });
    },
  },
};
</script>

<style lang="less" scoped>
.body {
  background-color: #000000;
  height: 89vh;
  width: 102%;
  margin-left: -1%;
  margin-top: -40px;
}
.title {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-left: 3vw;
  padding-top: 8px;
  position: absolute;
  width: 100%;
  background-color: #000000;
  padding-bottom: 10px;
}
.my-info-dialog {
  box-shadow: 0px 0px 10px #05bb4c;
}

.chunkdiv {
  display: flex;
  /* justify-content: center; */
  background-color: #363636;
  margin: 1px;
  padding: 4px 2px;
  font-size: 12px;
  color: #ffffff;
  overflow: hidden;
  white-space: nowrap;
  padding-left: 32px;
}

.title {
  font-size: 12px;
  color: #b3b3b3;
}

.titleList {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-top: -10px;
  color: #ffffff;
  margin-left: 50px;
}

table {
  margin-left: 2px;
  margin-right: 2px;
}

td {
  width: 20%;
}

el-tabs {
  background-color: black;
}

.svg {
  height: 67vh;
}

.controlTypes {
  width: 110px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(51, 51, 51, 1);
}
.controlTypesLeft {
  width: 110px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(51, 51, 51, 1);
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
}
.controlTypesRight {
  width: 110px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(51, 51, 51, 1);
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
}
.onControlTypes {
  width: 110px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(51, 51, 51, 1);
  background-color: rgba(37, 116, 219, 1);
}
.onControlTypesLeft {
  width: 110px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* border: 1px solid rgba(37, 116, 219, 1); */
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
  background-color: rgba(37, 116, 219, 1);
}
.onControlTypesRight {
  width: 110px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* border: 1px solid rgba(37, 116, 219, 1); */
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
  background-color: rgba(37, 116, 219, 1);
}
</style>