whyczyk
2022-06-25 db20378d45836a9763db3a213808ee3d3b0ff3ad
高频开关电源柜遥测量BUG修改
2个文件已修改
7919 ■■■■ 已修改文件
src/pages/alarmMager/hfSwitch.vue 6169 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/dataTest/movingRingSystem/powerBox.vue 1750 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/alarmMager/hfSwitch.vue
Diff too large
src/pages/dataTest/movingRingSystem/powerBox.vue
@@ -1,114 +1,184 @@
<template>
    <flex-layout direction="row" class="page-real-time" :no-bg="true">
        <content-box style="margin-left: 4px; margin-right: 4px;" :title="battFullName">
            <div class="flex-page-content">
                <div class="page-content-tools">
                    <div>
                        <el-row :gutter="8">
                            <el-col :span="16" class="status-text">
                                通讯状态:
                            </el-col>
                            <el-col :span="8">
                                <hdw-light :type="allSignal"></hdw-light>
                            </el-col>
                        </el-row>
                    </div>
                </div>
                <el-tabs type="border-card" class="flex-layout noborder top-border" v-model="acTabs" @tab-click="tabsChange">
                    <el-tab-pane label="交流配电柜遥测量" name="acData">
                        <div class="full-height">
                            <ggdmeasure v-if="acTabs=='acData'" :powerDeviceId="powerData.info.powerDeviceId"></ggdmeasure>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="交流配电柜" name="acSignalData">
                        <power-box-component title="交流配电柜遥测量" :data="acData" :length="1"></power-box-component>
                        <power-box-component title="交流配电柜遥信量" :data="acSignalData" :length="4">
                            <div slot="tools">
                                <i class="box-tools el-icon-s-tools" @click="acDialog=true"></i>
                            </div>
                        </power-box-component>
                    </el-tab-pane>
                    <el-tab-pane label="高频开关电源柜遥测量" name="acDcData">
                        <div class="full-height">
                            <hf-switch v-if="acTabs=='acDcData'" :powerDeviceId="powerData.info.powerDeviceId"></hf-switch>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="高频开关电源柜" name="acDcSignalData">
                        <power-box-component title="高频开关电源柜遥测量" :data="acDcData" :length="1"></power-box-component>
                        <power-box-component title="高频开关电源柜遥信量" :data="acDcSignalData" :length="4">
                            <div slot="tools">
                                <i class="box-tools el-icon-s-tools" @click="acDcDialog=true"></i>
                            </div>
                        </power-box-component>
                    </el-tab-pane>
                    <el-tab-pane label="直流配电柜遥测量" name="dcData">
                        <div class="full-height">
                            <dcmeasure v-if="acTabs=='dcData'" :powerDeviceId="powerData.info.powerDeviceId"></dcmeasure>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="直流配电柜" name="dcSignalData">
                        <power-box-component title="直流配电柜遥测量" :data="dcData" :length="1"></power-box-component>
                        <power-box-component title="直流配电柜遥信量" :data="dcSignalData" :length="4">
                            <div slot="tools">
                                <i class="box-tools el-icon-s-tools" @click="dcDialog=true"></i>
                            </div>
                        </power-box-component>
                    </el-tab-pane>
                </el-tabs>
  <flex-layout direction="row" class="page-real-time" :no-bg="true">
    <content-box
      style="margin-left: 4px; margin-right: 4px"
      :title="battFullName"
    >
      <div class="flex-page-content">
        <div class="page-content-tools">
          <div>
            <el-row :gutter="8">
              <el-col :span="16" class="status-text"> 通讯状态: </el-col>
              <el-col :span="8">
                <hdw-light :type="allSignal"></hdw-light>
              </el-col>
            </el-row>
          </div>
        </div>
        <el-tabs
          type="border-card"
          class="flex-layout noborder top-border"
          v-model="acTabs"
          @tab-click="tabsChange"
        >
          <el-tab-pane label="交流配电柜遥测量" name="acData">
            <div class="full-height">
              <ggdmeasure
                v-if="acTabs == 'acData'"
                :powerDeviceId="powerData.info.powerDeviceId"
              ></ggdmeasure>
            </div>
        </content-box>
        <el-dialog
            title="交流配电柜遥信量配置"
            width="500px"
            :visible.sync="acDialog"
            :close-on-click-modal="false"
            top="0"
            class="dialog-center"
            :modal-append-to-body="false"
            :destroy-on-close="true">
            <ac-config :visible.sync="acDialog" :batt="batt" :info="configs.ac" @success="getPowerACConfigById"></ac-config>
        </el-dialog>
        <el-dialog
            title="高频开关电源柜遥信量配置"
            width="500px"
            :visible.sync="acDcDialog"
            :close-on-click-modal="false"
            top="0"
            class="dialog-center"
            :modal-append-to-body="false"
            :destroy-on-close="true">
            <ac-dc-config :visible.sync="acDcDialog" :batt="batt" :info="configs.acDc" @success="getPowerACDCConfigById"></ac-dc-config>
        </el-dialog>
        <el-dialog
            title="直流配电柜遥信量配置"
            width="500px"
            :visible.sync="dcDialog"
            :close-on-click-modal="false"
            top="0"
            class="dialog-center"
            :modal-append-to-body="false"
            :destroy-on-close="true">
            <dc-config :visible.sync="dcDialog" :batt="batt" :info="configs.dc" @success="getPowerDCConfigById"></dc-config>
        </el-dialog>
        <el-dialog
            title="图表配置"
            width="500px"
            :visible.sync="chartDialog"
            :close-on-click-modal="false"
            top="0"
            class="dialog-center"
            :modal-append-to-body="false"
            :destroy-on-close="true">
            <chart-type-config :visible.sync="chartDialog" v-if="chartDialog" :info="chartTypeConfig" @success="changeChartTypeSuccess"></chart-type-config>
        </el-dialog>
    </flex-layout>
          </el-tab-pane>
          <el-tab-pane label="交流配电柜" name="acSignalData">
            <power-box-component
              title="交流配电柜遥测量"
              :data="acData"
              :length="1"
            ></power-box-component>
            <power-box-component
              title="交流配电柜遥信量"
              :data="acSignalData"
              :length="4"
            >
              <div slot="tools">
                <i
                  class="box-tools el-icon-s-tools"
                  @click="acDialog = true"
                ></i>
              </div>
            </power-box-component>
          </el-tab-pane>
          <el-tab-pane label="高频开关电源柜遥测量" name="acDcData">
            <div class="full-height">
              <hf-switch
                v-if="acTabs == 'acDcData'"
                :powerDeviceId="powerData.info.powerDeviceId"
              ></hf-switch>
            </div>
          </el-tab-pane>
          <el-tab-pane label="高频开关电源柜" name="acDcSignalData">
            <power-box-component
              title="高频开关电源柜遥测量"
              :data="acDcData"
              :length="1"
            ></power-box-component>
            <power-box-component
              title="高频开关电源柜遥信量"
              :data="acDcSignalData"
              :length="4"
            >
              <div slot="tools">
                <i
                  class="box-tools el-icon-s-tools"
                  @click="acDcDialog = true"
                ></i>
              </div>
            </power-box-component>
          </el-tab-pane>
          <el-tab-pane label="直流配电柜遥测量" name="dcData">
            <div class="full-height">
              <dcmeasure
                v-if="acTabs == 'dcData'"
                :powerDeviceId="powerData.info.powerDeviceId"
              ></dcmeasure>
            </div>
          </el-tab-pane>
          <el-tab-pane label="直流配电柜" name="dcSignalData">
            <power-box-component
              title="直流配电柜遥测量"
              :data="dcData"
              :length="1"
            ></power-box-component>
            <power-box-component
              title="直流配电柜遥信量"
              :data="dcSignalData"
              :length="4"
            >
              <div slot="tools">
                <i
                  class="box-tools el-icon-s-tools"
                  @click="dcDialog = true"
                ></i>
              </div>
            </power-box-component>
          </el-tab-pane>
        </el-tabs>
      </div>
    </content-box>
    <el-dialog
      title="交流配电柜遥信量配置"
      width="500px"
      :visible.sync="acDialog"
      :close-on-click-modal="false"
      top="0"
      class="dialog-center"
      :modal-append-to-body="false"
      :destroy-on-close="true"
    >
      <ac-config
        :visible.sync="acDialog"
        :batt="batt"
        :info="configs.ac"
        @success="getPowerACConfigById"
      ></ac-config>
    </el-dialog>
    <el-dialog
      title="高频开关电源柜遥信量配置"
      width="500px"
      :visible.sync="acDcDialog"
      :close-on-click-modal="false"
      top="0"
      class="dialog-center"
      :modal-append-to-body="false"
      :destroy-on-close="true"
    >
      <ac-dc-config
        :visible.sync="acDcDialog"
        :batt="batt"
        :info="configs.acDc"
        @success="getPowerACDCConfigById"
      ></ac-dc-config>
    </el-dialog>
    <el-dialog
      title="直流配电柜遥信量配置"
      width="500px"
      :visible.sync="dcDialog"
      :close-on-click-modal="false"
      top="0"
      class="dialog-center"
      :modal-append-to-body="false"
      :destroy-on-close="true"
    >
      <dc-config
        :visible.sync="dcDialog"
        :batt="batt"
        :info="configs.dc"
        @success="getPowerDCConfigById"
      ></dc-config>
    </el-dialog>
    <el-dialog
      title="图表配置"
      width="500px"
      :visible.sync="chartDialog"
      :close-on-click-modal="false"
      top="0"
      class="dialog-center"
      :modal-append-to-body="false"
      :destroy-on-close="true"
    >
      <chart-type-config
        :visible.sync="chartDialog"
        v-if="chartDialog"
        :info="chartTypeConfig"
        @success="changeChartTypeSuccess"
      ></chart-type-config>
    </el-dialog>
  </flex-layout>
</template>
<script>
import ContentBox from "@/components/ContentBox";
import {getValByKey, Timeout} from "@/assets/js/tools";
import { getValByKey, Timeout } from "@/assets/js/tools";
import PowerBoxComponent from "@/components/PowerBoxComponent";
import getAcData from "@/pages/dataTest/movingRingSystem/const/getAcData";
import getAcDcData from "@/pages/dataTest/movingRingSystem/const/getAcDcData";
@@ -127,757 +197,803 @@
import getItemByKey from "@/assets/js/tools/getItemByKey";
import ChartTypeConfig from "@/pages/dataTest/movingRingSystem/dialog/chartTypeConfig";
import HdwLight from "@/pages/dataMager/components/HdwLight";
import ggdmeasure from '@/pages/alarmMager/GGDmeasure.vue';
import dcmeasure from '@/pages/alarmMager/DCmeasure.vue';
import hfSwitch from '@/pages/alarmMager/hfSwitch.vue';
import ggdmeasure from "@/pages/alarmMager/GGDmeasure.vue";
import dcmeasure from "@/pages/alarmMager/DCmeasure.vue";
import hfSwitch from "@/pages/alarmMager/hfSwitch.vue";
export default {
    name: "powerBox",
    components: {
        HdwLight,
        ChartTypeConfig,
        FlexBox,
        DcConfig,
        AcConfig,
        AcDcConfig,
        PowerBoxComponent,
        ContentBox,
        EChartWrapper,
        ggdmeasure,
        dcmeasure,
        hfSwitch
  name: "powerBox",
  components: {
    HdwLight,
    ChartTypeConfig,
    FlexBox,
    DcConfig,
    AcConfig,
    AcDcConfig,
    PowerBoxComponent,
    ContentBox,
    EChartWrapper,
    ggdmeasure,
    dcmeasure,
    hfSwitch,
  },
  chartOpts(option) {
    let opt = option ? option : {};
    let unit = opt.unit ? option.unit : "";
    let type = opt.type ? option.type : "bar";
    return {
      animation: false,
      tooltip: {
        trigger: "axis",
        axisPointer: {
          // 坐标轴指示器,坐标轴触发有效
          type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
        },
      },
      grid: {
        top: "32px",
        left: "1%",
        right: "1%",
        bottom: "18px",
        containLabel: true,
      },
      xAxis: [
        {
          type: "category",
          axisLabel: {
            interval: 0,
          },
        },
      ],
      yAxis: [
        {
          type: "value",
          name: unit ? "Y(" + unit + ")" : "Y",
          splitLine: {
            show: true,
          },
          min: getYMin,
          max: getYMax,
        },
      ],
      series: [
        {
          type: type,
          label: {
            show: true,
            position: "top",
            color: "#fff",
            formatter: function (params) {
              return params.value[1] + unit;
            },
          },
          data: [],
        },
      ],
    };
  },
  data() {
    let acData = getAcData();
    let acDcData = getAcDcData();
    let dcData = getDcData();
    let acSignalData = getAcSignalData();
    let acDcSignalData = getAcDcSignalData();
    let dcSignalData = getDcSignalData();
    return {
      layout: {
        gutter: 16,
        span: 8,
        span2: 6,
      },
      timer: new Timeout(),
      acTabs: "acData",
      allSignal: -1,
      batt: {},
      powerData: {
        info: {
          powerDeviceId: 0,
          stationId: 0,
          stationName: "",
          stationName1: "",
          stationName2: "",
          stationName3: "",
          stationName4: " ",
          stationName5: "",
        },
        realData: {},
      },
      acData,
      acDcData,
      dcData,
      acSignalData,
      acDcSignalData,
      dcSignalData,
      acDialog: false,
      acDcDialog: false,
      dcDialog: false,
      configs: {
        ac: getPowerConfigData("ac"),
        acDc: getPowerConfigData("acDc"),
        dc: getPowerConfigData("dc"),
      },
      chartDialog: false,
      chartTypeConfig: {
        id: null,
        name: "",
        type: 0,
      },
      chartTypes: [],
    };
  },
  watch: {
    "$route.params.powerDeviceId"(powerDeviceId) {
      this.$nextTick(() => {
        this.getPowerInfo(powerDeviceId);
      });
    },
    chartOpts(option) {
        let opt = option?option:{};
        let unit = opt.unit?option.unit:"";
        let type = opt.type?option.type:'bar';
        return {
            animation: false,
            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器,坐标轴触发有效
                    type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
                },
            },
            grid: {
                top: '32px',
                left: '1%',
                right: '1%',
                bottom: '18px',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    axisLabel: {
                        interval: 0,
                    },
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: unit?'Y('+unit+')':'Y',
                    splitLine: {
                        show: true,
                    },
                    min: getYMin,
                    max: getYMax,
                },
            ],
            series: [
                {
                    type: type,
                    label: {
                        show: true,
                        position: 'top',
                        color: '#fff',
                        formatter: function (params) {
                            return params.value[1] + unit;
                        }
                    },
                    data: []
                }
            ]
  },
  methods: {
    getPowerACDCConfigById() {
      let id = this.powerData.info.powerDeviceId;
      this.acDcSignalData = getAcDcSignalData();
      this.$apis.dataMager.powerMager
        .getPowerACDCConfigById(id)
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            let data = rs.data;
            this.configs.acDc = {
              powerDeviceId: id,
              moduleCap: data.moduleCap,
              moduleInUseCount: data.moduleInUseCount,
              moduleSlotCount: data.moduleSlotCount,
              usePurpose: data.usePurpose,
            };
          } else {
            this.configs.acDc = getPowerConfigData("acDc");
          }
          this.configs.acDc.powerDeviceId = id;
          this.changeAcDcData(this.configs.acDc);
        })
        .catch((error) => {
          this.configs.acDc = getPowerConfigData("acDc");
          this.configs.acDc.powerDeviceId = id;
          this.changeAcDcData(this.configs.acDc);
          console.log(error);
        });
    },
    changeAcDcData(config) {
      let inUseCount = config.moduleInUseCount;
      let list = {};
      for (let i = 1; i <= inUseCount; i++) {
        list["isAcdcMod" + i + "Off"] = 1;
        list["isAcdcMod" + i + "Err"] = 1;
      }
      this.acDcSignalData.map((item) => {
        if (item.inUse == 0) {
          item.inUse = getValByKey(item.key, list, 0);
        }
    },
    data() {
        let acData = getAcData();
        let acDcData = getAcDcData();
        let dcData = getDcData();
        let acSignalData = getAcSignalData();
        let acDcSignalData = getAcDcSignalData();
        let dcSignalData = getDcSignalData();
        return {
            layout: {
                gutter: 16,
                span: 8,
                span2: 6,
            },
            timer: new Timeout(),
            acTabs: "acData",
            allSignal: -1,
            batt: {},
            powerData: {
                info: {
                    powerDeviceId: 0,
                    stationId: 0,
                    stationName: "",
                    stationName1: "",
                    stationName2: "",
                    stationName3: "",
                    stationName4: " ",
                    stationName5: "",
                },
                realData: {}
            },
            acData,
            acDcData,
            dcData,
            acSignalData,
            acDcSignalData,
            dcSignalData,
            acDialog: false,
            acDcDialog: false,
            dcDialog: false,
            configs: {
                ac: getPowerConfigData('ac'),
                acDc: getPowerConfigData('acDc'),
                dc: getPowerConfigData('dc'),
            },
            chartDialog: false,
            chartTypeConfig: {
                id: null,
                name: '',
                type: 0,
            },
            chartTypes: [],
      });
      let slotCount = config.moduleSlotCount;
      let list2 = {};
      for (let i = 1; i <= slotCount; i++) {
        list2["isAcdcMod" + i + "Off"] = 1;
        list2["isAcdcMod" + i + "Err"] = 1;
      }
      // 更新插槽数
      this.acDcSignalData = this.acDcSignalData.filter((item) => {
        let pattern = /^isAcdcMod\d*(Off|Err)$/;
        if (pattern.test(item.key)) {
          return getValByKey(item.key, list2, 0) ? true : false;
        } else {
          return true;
        }
      });
    },
    watch: {
        "$route.params.powerDeviceId"(powerDeviceId) {
            this.$nextTick(() => {
                this.getPowerInfo(powerDeviceId);
            });
        },
    getPowerACConfigById() {
      let id = this.powerData.info.powerDeviceId;
      this.acSignalData = getAcSignalData();
      this.$apis.dataMager.powerMager
        .getPowerACConfigById(id)
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            let data = rs.data;
            this.configs.ac = {
              powerDeviceId: data.powerDeviceId,
              inputSWCount: data.inputSWCount,
              outputSWCount: data.outputSWCount,
              cap: data.cap,
              usePurpose: data.usePurpose,
            };
          } else {
            this.configs.ac = getPowerConfigData("ac");
          }
          this.configs.ac.powerDeviceId = id;
          this.changeAcData(this.configs.ac);
        })
        .catch((error) => {
          this.configs.ac = getPowerConfigData("ac");
          this.configs.ac.powerDeviceId = id;
          this.changeAcData(this.configs.ac);
          console.log(error);
        });
    },
    methods: {
        getPowerACDCConfigById() {
            let id = this.powerData.info.powerDeviceId;
            this.acDcSignalData = getAcDcSignalData();
            this.$apis.dataMager.powerMager.getPowerACDCConfigById(id).then(res=>{
                let rs = JSON.parse(res.data.result);
                if(rs.code == 1) {
                    let data = rs.data;
                    this.configs.acDc = {
                        powerDeviceId: id,
                        moduleCap: data.moduleCap,
                        moduleInUseCount: data.moduleInUseCount,
                        moduleSlotCount: data.moduleSlotCount,
                        usePurpose: data.usePurpose,
                    };
                }else {
                    this.configs.acDc = getPowerConfigData('acDc');
                }
                this.configs.acDc.powerDeviceId = id;
                this.changeAcDcData(this.configs.acDc);
            }).catch(error=>{
                this.configs.acDc = getPowerConfigData('acDc');
                this.configs.acDc.powerDeviceId = id;
                this.changeAcDcData(this.configs.acDc);
                console.log(error);
            });
        },
        changeAcDcData(config) {
            let inUseCount = config.moduleInUseCount;
            let list = {};
            for(let i=1; i<=inUseCount; i++) {
                list['isAcdcMod'+i+'Off'] = 1;
                list['isAcdcMod'+i+'Err'] = 1;
            }
            this.acDcSignalData.map(item=>{
                if(item.inUse == 0) {
                    item.inUse = getValByKey(item.key, list, 0);
                }
            });
            let slotCount = config.moduleSlotCount;
            let list2 = {};
            for(let i=1; i<=slotCount; i++) {
                list2['isAcdcMod'+i+'Off'] = 1;
                list2['isAcdcMod'+i+'Err'] = 1;
            }
            // 更新插槽数
            this.acDcSignalData = this.acDcSignalData.filter(item=>{
                let pattern = /^isAcdcMod\d*(Off|Err)$/;
                if(pattern.test(item.key)) {
                    return getValByKey(item.key, list2, 0)?true:false;
                }else {
                    return true;
                }
            });
        },
        getPowerACConfigById() {
            let id = this.powerData.info.powerDeviceId;
            this.acSignalData = getAcSignalData();
            this.$apis.dataMager.powerMager.getPowerACConfigById(id).then(res=>{
                let rs = JSON.parse(res.data.result);
                if(rs.code == 1) {
                    let data = rs.data;
                    this.configs.ac = {
                        powerDeviceId: data.powerDeviceId,
                        inputSWCount: data.inputSWCount,
                        outputSWCount: data.outputSWCount,
                        cap: data.cap,
                        usePurpose: data.usePurpose,
                    };
                }else {
                    this.configs.ac = getPowerConfigData('ac');
                }
                this.configs.ac.powerDeviceId = id;
                this.changeAcData(this.configs.ac);
            }).catch(error=>{
                this.configs.ac = getPowerConfigData('ac');
                this.configs.ac.powerDeviceId = id;
                this.changeAcData(this.configs.ac);
                console.log(error);
            });
        },
        changeAcData(config) {
            let outputSWCount = config.outputSWCount;
            let list = {};
            for(let i=1; i<=outputSWCount; i++) {
                list['isFsw1Sw'+i+'trip'] = 1;
                list['isFsw2Sw'+i+'trip'] = 1;
            }
            this.acSignalData = this.acSignalData.filter(item=>{
                let pattern = /^isFsw\d*Sw\d*trip$/;
                if(pattern.test(item.key)) {
                    return getValByKey(item.key, list, 0)?true:false;
                }else {
                    return true;
                }
            });
        },
        getPowerDCConfigById() {
            let id = this.powerData.info.powerDeviceId;
            this.dcSignalData = getDcSignalData();
            this.$apis.dataMager.powerMager.getPowerDCConfigById(id).then(res=>{
                let rs = JSON.parse(res.data.result);
                if(rs.code == 1) {
                    let data = rs.data;
                    this.configs.dc = {
                        powerDeviceId: data.powerDeviceId,
                        inputSWCount: data.inputSWCount,
                        outputSWCount: data.outputSWCount,
                        cap: data.cap,
                        usePurpose: data.usePurpose,
                    };
                }else {
                    this.configs.dc = getPowerConfigData('dc');
                }
                this.configs.dc.powerDeviceId = id;
                this.changeDcData(this.configs.dc);
            }).catch(error=>{
                this.configs.dc = getPowerConfigData('dc');
                this.configs.dc.powerDeviceId = id;
                this.changeDcData(this.configs.dc);
                console.log(error);
            });
        },
        changeDcData(config) {
            console.log(config);
            let outputSWCount = config.outputSWCount;
            let list = {};
            for(let i=1; i<=outputSWCount; i++) {
                list['isFsw1Sw'+i+'trip'] = 1;
                list['isFsw2Sw'+i+'trip'] = 1;
            }
            this.dcSignalData = this.dcSignalData.filter(item=>{
                let pattern = /^isFsw\d*Sw\d*trip$/;
                if(pattern.test(item.key)) {
                    return getValByKey(item.key, list, 0)?true:false;
                }else {
                    return true;
                }
            });
        },
        getPowerConfig() {
            this.$axios.all([
                this.getPowerACDCConfigById(),
                this.getPowerACConfigById(),
                this.getPowerDCConfigById(),
                this.getPowerDisplayConfigList(),
            ]).then(()=>{
                this.startSearch();
            }).catch(error=>{
                this.startSearch();
            });
        },
        startSearch() {
            this.timer.start(()=>{
                this.$axios.all([
                    this.getPowerBoxData(),
                ]).then(()=>{
                    // 启动循环
                    this.timer.open();
                }).catch(error=>{
                    // 启动循环
                    this.timer.open();
                });
            }, 2000);
        },
        getPowerInfo(powerDeviceId) {
            this.powerData.info.powerDeviceId = powerDeviceId;
            this.$apis.dataMager.powerMager.getInfoById({
                powerDeviceId: powerDeviceId
            }).then(res => {
                console.log(res);
                let rs = JSON.parse(res.data.result);
                if (rs.code == 1) {
                    this.powerData.info = rs.data;
                    this.batt.StationName = this.powerData.info.stationName;
                } else {
                    this.powerData.info = {
                        powerDeviceId: 0,
                        stationId: 0,
                        stationName: "",
                        stationName1: "",
                        stationName2: "",
                        stationName3: "",
                        stationName4: " ",
                        stationName5: "",
                    };
                }
                // 获取配置数据
                this.getPowerConfig();
            }).catch(error => {
                console.log(error);
            });
        },
        leafClick(data) {
            this.batt = data;
        },
        getPowerBoxData() {
            let id = this.powerData.info.powerDeviceId;
            this.$apis.dataMager.powerMager.getPowerBoxData(id).then(res=>{
                console.log(res);
                let rs = JSON.parse(res.data.result);
                if(rs.code == 1) {
                    this.allSignal = 0;
                    let data = rs.data;
                    // 交流
                    if(data.ac.commStatus) {
                        this.setAcInfo(data.ac);
                    }else {
                        this.setAcInfo({});
                    }
                    // 高频
                    if(data.acdc.commStatus) {
                        this.setAcDcInfo(data.acdc);
                    }else {
                        this.setAcDcInfo({});
                    }
                    // 直流
                    if(data.dc.commStatus) {
                        this.setDcInfo(data.dc);
                    }else {
                        this.setDcInfo({});
                    }
                }else {
                    this.setAcInfo({});
                    this.setAcDcInfo({});
                    this.setDcInfo({});
                    this.allSignal = 1;
                }
            }).catch(error=>{
                console.log(error);
            });
        },
        setAcInfo(data) {       // 设置交流配电柜的值
            let acTabs = this.acTabs;
            if(acTabs == "acData" || acTabs == "acSignalData") {
                this.acData.map(item=>{
                    item.value = getValByKey(item.key, data, "???", 2);
                });
                if(acTabs == "acData") {
                    this.setAcChart(this.acData);
                }
            }
            if(acTabs == "acSignalData") {
                this.acSignalData.map(item=>{
                    item.value = getValByKey(item.key, data, -1);
                });
            }
        },
        setAcDcInfo(data) {     // 设置高频开关电源柜的值
            let acTabs = this.acTabs;
            if(acTabs == "acDcData" || acTabs == "acDcSignalData") {
                this.acDcData.map(item=>{
                    item.value = getValByKey(item.key, data, "???", 2);
                });
                if(acTabs == "acDcData") {
                    this.setAcDcChart(this.acDcData);
                }
            }
            if(acTabs == "acDcSignalData") {
                this.acDcSignalData.map(item=>{
                    item.value = item.inUse==0?-1:getValByKey(item.key, data, -1);
                });
            }
        },
        setDcInfo(data) {       // 设置直流配电柜的值
            let acTabs = this.acTabs;
            if(acTabs == "dcData" || acTabs == "dcSignalData") {
                this.dcData.map(item=>{
                    item.value = getValByKey(item.key, data, "???", 2);
                });
                if(acTabs == "dcData") {
                    this.setDcChart(this.dcData);
                }
            }
            if(acTabs == "dcSignalData") {
                this.dcSignalData.map(item=>{
                    item.value = getValByKey(item.key, data, -1);
                });
            }
        },
        tabsChange() {
            this.resize();
        },
        setOption() {
            // 交流配电柜图表
            this.$refs.acOneInputVol.setOption(this.$options.chartOpts());
            this.$refs.acOneInputCurr.setOption(this.$options.chartOpts());
            this.$refs.acTwoInputVol.setOption(this.$options.chartOpts());
            this.$refs.acTwoInputCurr.setOption(this.$options.chartOpts());
            this.$refs.acVolAlarmLimit.setOption(this.$options.chartOpts());
            this.$refs.acTemp.setOption(this.$options.chartOpts());
            // 高频交流电源柜图表
            this.$refs.acDcInputVol.setOption(this.$options.chartOpts());
            this.$refs.acDcOutputVol.setOption(this.$options.chartOpts());
            this.$refs.acDcOutputCurr.setOption(this.$options.chartOpts());
            this.$refs.acDcCurr.setOption(this.$options.chartOpts());
            this.$refs.acDcVol.setOption(this.$options.chartOpts());
            this.$refs.acDcModuleOutputCurr.setOption(this.$options.chartOpts());
            this.$refs.acDcVolAlarmLimit.setOption(this.$options.chartOpts());
            this.$refs.acDcTemp.setOption(this.$options.chartOpts());
            // 直流配电柜
            this.$refs.dcInputVol.setOption(this.$options.chartOpts());
            this.$refs.dcOutputVol.setOption(this.$options.chartOpts());
            this.$refs.dcOutputCurr.setOption(this.$options.chartOpts());
            this.$refs.dcVolLimit.setOption(this.$options.chartOpts());
            this.$refs.dcTemp.setOption(this.$options.chartOpts());
            // 重置大小
            this.resize();
        },
        setAcChart(data) {
            this.setChartOption(data, {
                keys: ['acIn1VolA', 'acIn1VolB', 'acIn1VolC'],
                refs: this.$refs.acOneInputVol,
                name: 'acOneInputVol',
                unit: "V",
            });
            this.setChartOption(data, {
                keys: ['acIn1CurrA', 'acIn1CurrB', 'acIn1CurrC'],
                refs: this.$refs.acOneInputCurr,
                name: 'acOneInputCurr',
                unit: "A",
            });
            this.setChartOption(data, {
                keys: ['acIn2VolA', 'acIn2VolB', 'acIn2VolC'],
                refs: this.$refs.acTwoInputVol,
                name: 'acTwoInputVol',
                unit: "V"
            });
            this.setChartOption(data, {
                keys: ['acIn2CurrA', 'acIn2CurrB', 'acIn2CurrC'],
                refs: this.$refs.acTwoInputCurr,
                name: 'acTwoInputCurr',
                unit: "A"
            });
            this.setChartOption(data, {
                keys: ['acVolHLimit', 'acVolLLimit'],
                refs: this.$refs.acVolAlarmLimit,
                name: 'acVolAlarmLimit',
                unit: "V"
            });
            this.setChartOption(data, {
                keys: ['temperature'],
                refs: this.$refs.acTemp,
                name: 'acTemp',
                unit: "℃"
            });
        },
        setAcDcChart(data) {
            this.setChartOption(data, {
                keys: ['acIn1VolA', 'acIn1VolB', 'acIn1VolC','acIn2VolA', 'acIn2VolB', 'acIn2VolC'],
                refs: this.$refs.acDcInputVol,
                name: 'acDcInputVol',
                unit: "V",
            });
            this.setChartOption(data, {
                keys: ['acOutVolA', 'acOutVolB', 'acOutVolC'],
                refs: this.$refs.acDcOutputVol,
                name: 'acDcOutputVol',
                unit: "V",
            });
            this.setChartOption(data, {
                keys: ['acOutCurrA', 'acOutCurrB', 'acOutCurrC'],
                refs: this.$refs.acDcOutputCurr,
                name: 'acDcOutputCurr',
                unit: "A",
            });
            this.setChartOption(data, {
                keys: ['loaderCurr', 'chargLimitCurr', 'battgroup1Curr', 'battgroup2Curr'],
                refs: this.$refs.acDcCurr,
                name: 'acDcCurr',
                unit: "A",
            });
            this.setChartOption(data, {
                keys: ['dcOutVol', 'junChargeVol', 'floatChargeVol', 'battgroup1Vol', 'battgroup2Vol'],
                refs: this.$refs.acDcVol,
                name: 'acDcVol',
                unit: "V",
            });
            let modulesKeys = [];
            for(let i=1; i<=16; i++) {
                modulesKeys.push('m'+i+'OutCurr');
            }
            this.setChartOption(data, {
                keys: modulesKeys,
                refs: this.$refs.acDcModuleOutputCurr,
                name: 'acDcModuleOutputCurr',
                unit: "A",
            });
            this.setChartOption(data, {
                keys: ['acVolHLimit', 'acVolLLimit', 'dcOutVolHLimit', 'dcOutVolLLimit'],
                refs: this.$refs.acDcVolAlarmLimit,
                name: 'acDcVolAlarmLimit',
                unit: "V",
            });
            this.setChartOption(data, {
                keys: ['acdcmTemp'],
                refs: this.$refs.acDcTemp,
                name: 'acDcTemp',
                unit: "℃",
            });
        },
        setDcChart(data) {
            this.setChartOption(data, {
                keys: ['dcIn1Vol', 'dcIn2Vol'],
                refs: this.$refs.dcInputVol,
                name: 'dcInputVol',
                unit: "V",
            });
            this.setChartOption(data, {
                keys: ['dcOut1Vol', 'dcOut2Vol'],
                refs: this.$refs.dcOutputVol,
                name: 'dcOutputVol',
                unit: "V",
            });
            this.setChartOption(data, {
                keys: ['dcOut1Curr', 'dcOut2Curr'],
                refs: this.$refs.dcOutputCurr,
                name: 'dcOutputCurr',
                unit: "A",
            });
            this.setChartOption(data, {
                keys: ['acVolHLimit', 'acVolLLimit'],
                refs: this.$refs.dcVolLimit,
                name: 'dcVolLimit',
                unit: "V",
            });
            this.setChartOption(data, {
                keys: ['temperature'],
                refs: this.$refs.dcTemp,
                name: 'dcTemp',
                unit: "℃",
            });
        },
        setChartOption(data, option) {
            let opt = this.$options.chartOpts({
                unit: option.unit
            });
            let chartType = this.getItemByName(option.name, this.chartTypes);
            opt.tooltip.axisPointer.type = chartType==0?'shadow':chartType.type==0?'shadow':'line';
            opt.series[0].type = chartType==0?'bar':chartType.type==0?'bar':'line';
            opt.series[0].data = option.keys.map(item=>{
                let res = getItemByKey(item, data);
                return res==0?["未知", 0]:[res.label1, res.value];
            });
            option.refs.setOption(opt);
        },
        resize() {
            this.$nextTick(()=>{
                // let acTabs = this.acTabs;
                // 交流配电柜遥测量
                // if(acTabs == "acData") {
                //     this.$refs.acOneInputVol.resize();
                //     this.$refs.acOneInputCurr.resize();
                //     this.$refs.acTwoInputVol.resize();
                //     this.$refs.acTwoInputCurr.resize();
                //     this.$refs.acVolAlarmLimit.resize();
                //     this.$refs.acTemp.resize();
                // }
                // // 高频交流电源柜
                // if(acTabs == 'acDcData') {
                //     this.$refs.acDcInputVol.resize();
                //     this.$refs.acDcOutputVol.resize();
                //     this.$refs.acDcOutputCurr.resize();
                //     this.$refs.acDcCurr.resize();
                //     this.$refs.acDcVol.resize();
                //     this.$refs.acDcModuleOutputCurr.resize();
                //     this.$refs.acDcVolAlarmLimit.resize();
                //     this.$refs.acDcTemp.resize();
                // }
                // // 直流配电柜
                // if(acTabs == 'dcData')  {
                //     this.$refs.dcInputVol.resize();
                //     this.$refs.dcOutputVol.resize();
                //     this.$refs.dcOutputCurr.resize();
                //     this.$refs.dcVolLimit.resize();
                //     this.$refs.dcTemp.resize();
                // }
            });
        },
        getItemByName(name, list) {
            let result = 0;
            for(let i=0; i<list.length; i++) {
                let item = list[i];
                if(item.name == name) {
                    result = item;
                }
            }
            return result;
        },
        getPowerDisplayConfigList() {
            this.$apis.dataMager.powerMager.getPowerDisplayConfigList().then(res=>{
                let rs = JSON.parse(res.data.result);
                let data = [];
                if(rs.code == 1) {
                    data = rs.data;
                }
                this.chartTypes = data;
            }).catch(error=>{
                this.chartTypes = [];
                console.log(error);
            });
        },
        showChartConfigDialog(name) {
            let chartType = this.getItemByName(name, this.chartTypes);
            this.chartTypeConfig = chartType?chartType:{id:null, name: name, type: 0};
            this.$nextTick(()=>{
                this.chartDialog = true;
            });
        },
        changeChartTypeSuccess() {
            this.getPowerDisplayConfigList();
    changeAcData(config) {
      let outputSWCount = config.outputSWCount;
      let list = {};
      for (let i = 1; i <= outputSWCount; i++) {
        list["isFsw1Sw" + i + "trip"] = 1;
        list["isFsw2Sw" + i + "trip"] = 1;
      }
      this.acSignalData = this.acSignalData.filter((item) => {
        let pattern = /^isFsw\d*Sw\d*trip$/;
        if (pattern.test(item.key)) {
          return getValByKey(item.key, list, 0) ? true : false;
        } else {
          return true;
        }
      });
    },
    computed: {
        battFullName() {
            let batt = this.batt;
            if (batt.StationName && batt.BattGroupName) {
                return batt.StationName + "-" + "通信电源";
    getPowerDCConfigById() {
      let id = this.powerData.info.powerDeviceId;
      this.dcSignalData = getDcSignalData();
      this.$apis.dataMager.powerMager
        .getPowerDCConfigById(id)
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            let data = rs.data;
            this.configs.dc = {
              powerDeviceId: data.powerDeviceId,
              inputSWCount: data.inputSWCount,
              outputSWCount: data.outputSWCount,
              cap: data.cap,
              usePurpose: data.usePurpose,
            };
          } else {
            this.configs.dc = getPowerConfigData("dc");
          }
          this.configs.dc.powerDeviceId = id;
          this.changeDcData(this.configs.dc);
        })
        .catch((error) => {
          this.configs.dc = getPowerConfigData("dc");
          this.configs.dc.powerDeviceId = id;
          this.changeDcData(this.configs.dc);
          console.log(error);
        });
    },
    changeDcData(config) {
      console.log(config);
      let outputSWCount = config.outputSWCount;
      let list = {};
      for (let i = 1; i <= outputSWCount; i++) {
        list["isFsw1Sw" + i + "trip"] = 1;
        list["isFsw2Sw" + i + "trip"] = 1;
      }
      this.dcSignalData = this.dcSignalData.filter((item) => {
        let pattern = /^isFsw\d*Sw\d*trip$/;
        if (pattern.test(item.key)) {
          return getValByKey(item.key, list, 0) ? true : false;
        } else {
          return true;
        }
      });
    },
    getPowerConfig() {
      this.$axios
        .all([
          this.getPowerACDCConfigById(),
          this.getPowerACConfigById(),
          this.getPowerDCConfigById(),
          this.getPowerDisplayConfigList(),
        ])
        .then(() => {
          this.startSearch();
        })
        .catch((error) => {
          this.startSearch();
        });
    },
    startSearch() {
      this.timer.start(() => {
        this.$axios
          .all([this.getPowerBoxData()])
          .then(() => {
            // 启动循环
            this.timer.open();
          })
          .catch((error) => {
            // 启动循环
            this.timer.open();
          });
      }, 2000);
    },
    getPowerInfo(powerDeviceId) {
      this.powerData.info.powerDeviceId = powerDeviceId;
      this.$apis.dataMager.powerMager
        .getInfoById({
          powerDeviceId: powerDeviceId,
        })
        .then((res) => {
          console.log(res);
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            this.powerData.info = rs.data;
            this.batt.StationName = this.powerData.info.stationName;
          } else {
            this.powerData.info = {
              powerDeviceId: 0,
              stationId: 0,
              stationName: "",
              stationName1: "",
              stationName2: "",
              stationName3: "",
              stationName4: " ",
              stationName5: "",
            };
          }
          // 获取配置数据
          this.getPowerConfig();
        })
        .catch((error) => {
          console.log(error);
        });
    },
    leafClick(data) {
      this.batt = data;
    },
    getPowerBoxData() {
      let id = this.powerData.info.powerDeviceId;
      this.$apis.dataMager.powerMager
        .getPowerBoxData(id)
        .then((res) => {
          // console.log(res);
          let rs = JSON.parse(res.data.result);
          if (rs.code == 1) {
            this.allSignal = 0;
            let data = rs.data;
            // 交流
            if (data.ac.commStatus) {
              this.setAcInfo(data.ac);
            } else {
              this.setAcInfo({});
            }
            return "电池组全称";
        }
            // 高频
            if (data.acdc.commStatus) {
              this.setAcDcInfo(data.acdc);
            } else {
              this.setAcDcInfo({});
            }
            // 直流
            if (data.dc.commStatus) {
              this.setDcInfo(data.dc);
            } else {
              this.setDcInfo({});
            }
          } else {
            this.setAcInfo({});
            this.setAcDcInfo({});
            this.setDcInfo({});
            this.allSignal = 1;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    mounted() {
        // 获取电源信息
        let powerDeviceId = this.$route.params.powerDeviceId;
        if (powerDeviceId) {
            this.getPowerInfo(powerDeviceId);
        }
    setAcInfo(data) {
      // 设置交流配电柜的值
      let acTabs = this.acTabs;
      if (acTabs == "acData" || acTabs == "acSignalData") {
        this.acData.map((item) => {
          item.value = getValByKey(item.key, data, "???", 2);
        });
        // 设置配置项
        this.setOption();
        // 添加窗口自动缩放
        window.addEventListener('resize', this.resize);
        if (acTabs == "acData") {
          this.setAcChart(this.acData);
        }
      }
      if (acTabs == "acSignalData") {
        this.acSignalData.map((item) => {
          item.value = getValByKey(item.key, data, -1);
        });
      }
    },
    destroyed() {
        this.timer.stop();
        // 添加窗口自动缩放
        window.removeEventListener('resize', this.resize);
    setAcDcInfo(data) {
      // 设置高频开关电源柜的值
      let acTabs = this.acTabs;
      if (acTabs == "acDcData" || acTabs == "acDcSignalData") {
        this.acDcData.map((item) => {
          item.value = getValByKey(item.key, data, "???", 2);
        });
        if (acTabs == "acDcData") {
          this.setAcDcChart(this.acDcData);
        }
      }
      if (acTabs == "acDcSignalData") {
        this.acDcSignalData.map((item) => {
          item.value = item.inUse == 0 ? -1 : getValByKey(item.key, data, -1);
        });
      }
    },
    setDcInfo(data) {
      // 设置直流配电柜的值
      let acTabs = this.acTabs;
      if (acTabs == "dcData" || acTabs == "dcSignalData") {
        this.dcData.map((item) => {
          item.value = getValByKey(item.key, data, "???", 2);
        });
        if (acTabs == "dcData") {
          this.setDcChart(this.dcData);
        }
      }
      if (acTabs == "dcSignalData") {
        this.dcSignalData.map((item) => {
          item.value = getValByKey(item.key, data, -1);
        });
      }
    },
    tabsChange() {
      this.resize();
    },
    setOption() {
      // 交流配电柜图表
      this.$refs.acOneInputVol.setOption(this.$options.chartOpts());
      this.$refs.acOneInputCurr.setOption(this.$options.chartOpts());
      this.$refs.acTwoInputVol.setOption(this.$options.chartOpts());
      this.$refs.acTwoInputCurr.setOption(this.$options.chartOpts());
      this.$refs.acVolAlarmLimit.setOption(this.$options.chartOpts());
      this.$refs.acTemp.setOption(this.$options.chartOpts());
      // 高频交流电源柜图表
      this.$refs.acDcInputVol.setOption(this.$options.chartOpts());
      this.$refs.acDcOutputVol.setOption(this.$options.chartOpts());
      this.$refs.acDcOutputCurr.setOption(this.$options.chartOpts());
      this.$refs.acDcCurr.setOption(this.$options.chartOpts());
      this.$refs.acDcVol.setOption(this.$options.chartOpts());
      this.$refs.acDcModuleOutputCurr.setOption(this.$options.chartOpts());
      this.$refs.acDcVolAlarmLimit.setOption(this.$options.chartOpts());
      this.$refs.acDcTemp.setOption(this.$options.chartOpts());
      // 直流配电柜
      this.$refs.dcInputVol.setOption(this.$options.chartOpts());
      this.$refs.dcOutputVol.setOption(this.$options.chartOpts());
      this.$refs.dcOutputCurr.setOption(this.$options.chartOpts());
      this.$refs.dcVolLimit.setOption(this.$options.chartOpts());
      this.$refs.dcTemp.setOption(this.$options.chartOpts());
      // 重置大小
      this.resize();
    },
    setAcChart(data) {
      this.setChartOption(data, {
        keys: ["acIn1VolA", "acIn1VolB", "acIn1VolC"],
        refs: this.$refs.acOneInputVol,
        name: "acOneInputVol",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["acIn1CurrA", "acIn1CurrB", "acIn1CurrC"],
        refs: this.$refs.acOneInputCurr,
        name: "acOneInputCurr",
        unit: "A",
      });
      this.setChartOption(data, {
        keys: ["acIn2VolA", "acIn2VolB", "acIn2VolC"],
        refs: this.$refs.acTwoInputVol,
        name: "acTwoInputVol",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["acIn2CurrA", "acIn2CurrB", "acIn2CurrC"],
        refs: this.$refs.acTwoInputCurr,
        name: "acTwoInputCurr",
        unit: "A",
      });
      this.setChartOption(data, {
        keys: ["acVolHLimit", "acVolLLimit"],
        refs: this.$refs.acVolAlarmLimit,
        name: "acVolAlarmLimit",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["temperature"],
        refs: this.$refs.acTemp,
        name: "acTemp",
        unit: "℃",
      });
    },
    setAcDcChart(data) {
      this.setChartOption(data, {
        keys: [
          "acIn1VolA",
          "acIn1VolB",
          "acIn1VolC",
          "acIn2VolA",
          "acIn2VolB",
          "acIn2VolC",
        ],
        refs: this.$refs.acDcInputVol,
        name: "acDcInputVol",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["acOutVolA", "acOutVolB", "acOutVolC"],
        refs: this.$refs.acDcOutputVol,
        name: "acDcOutputVol",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["acOutCurrA", "acOutCurrB", "acOutCurrC"],
        refs: this.$refs.acDcOutputCurr,
        name: "acDcOutputCurr",
        unit: "A",
      });
      this.setChartOption(data, {
        keys: [
          "loaderCurr",
          "chargLimitCurr",
          "battgroup1Curr",
          "battgroup2Curr",
        ],
        refs: this.$refs.acDcCurr,
        name: "acDcCurr",
        unit: "A",
      });
      this.setChartOption(data, {
        keys: [
          "dcOutVol",
          "junChargeVol",
          "floatChargeVol",
          "battgroup1Vol",
          "battgroup2Vol",
        ],
        refs: this.$refs.acDcVol,
        name: "acDcVol",
        unit: "V",
      });
      let modulesKeys = [];
      for (let i = 1; i <= 16; i++) {
        modulesKeys.push("m" + i + "OutCurr");
      }
      this.setChartOption(data, {
        keys: modulesKeys,
        refs: this.$refs.acDcModuleOutputCurr,
        name: "acDcModuleOutputCurr",
        unit: "A",
      });
      this.setChartOption(data, {
        keys: [
          "acVolHLimit",
          "acVolLLimit",
          "dcOutVolHLimit",
          "dcOutVolLLimit",
        ],
        refs: this.$refs.acDcVolAlarmLimit,
        name: "acDcVolAlarmLimit",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["acdcmTemp"],
        refs: this.$refs.acDcTemp,
        name: "acDcTemp",
        unit: "℃",
      });
    },
    setDcChart(data) {
      this.setChartOption(data, {
        keys: ["dcIn1Vol", "dcIn2Vol"],
        refs: this.$refs.dcInputVol,
        name: "dcInputVol",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["dcOut1Vol", "dcOut2Vol"],
        refs: this.$refs.dcOutputVol,
        name: "dcOutputVol",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["dcOut1Curr", "dcOut2Curr"],
        refs: this.$refs.dcOutputCurr,
        name: "dcOutputCurr",
        unit: "A",
      });
      this.setChartOption(data, {
        keys: ["acVolHLimit", "acVolLLimit"],
        refs: this.$refs.dcVolLimit,
        name: "dcVolLimit",
        unit: "V",
      });
      this.setChartOption(data, {
        keys: ["temperature"],
        refs: this.$refs.dcTemp,
        name: "dcTemp",
        unit: "℃",
      });
    },
    setChartOption(data, option) {
      let opt = this.$options.chartOpts({
        unit: option.unit,
      });
      let chartType = this.getItemByName(option.name, this.chartTypes);
      opt.tooltip.axisPointer.type =
        chartType == 0 ? "shadow" : chartType.type == 0 ? "shadow" : "line";
      opt.series[0].type =
        chartType == 0 ? "bar" : chartType.type == 0 ? "bar" : "line";
      opt.series[0].data = option.keys.map((item) => {
        let res = getItemByKey(item, data);
        return res == 0 ? ["未知", 0] : [res.label1, res.value];
      });
      option.refs.setOption(opt);
    },
    resize() {
      this.$nextTick(() => {
        // let acTabs = this.acTabs;
        // 交流配电柜遥测量
        // if(acTabs == "acData") {
        //     this.$refs.acOneInputVol.resize();
        //     this.$refs.acOneInputCurr.resize();
        //     this.$refs.acTwoInputVol.resize();
        //     this.$refs.acTwoInputCurr.resize();
        //     this.$refs.acVolAlarmLimit.resize();
        //     this.$refs.acTemp.resize();
        // }
        // // 高频交流电源柜
        // if(acTabs == 'acDcData') {
        //     this.$refs.acDcInputVol.resize();
        //     this.$refs.acDcOutputVol.resize();
        //     this.$refs.acDcOutputCurr.resize();
        //     this.$refs.acDcCurr.resize();
        //     this.$refs.acDcVol.resize();
        //     this.$refs.acDcModuleOutputCurr.resize();
        //     this.$refs.acDcVolAlarmLimit.resize();
        //     this.$refs.acDcTemp.resize();
        // }
        // // 直流配电柜
        // if(acTabs == 'dcData')  {
        //     this.$refs.dcInputVol.resize();
        //     this.$refs.dcOutputVol.resize();
        //     this.$refs.dcOutputCurr.resize();
        //     this.$refs.dcVolLimit.resize();
        //     this.$refs.dcTemp.resize();
        // }
      });
    },
    getItemByName(name, list) {
      let result = 0;
      for (let i = 0; i < list.length; i++) {
        let item = list[i];
        if (item.name == name) {
          result = item;
        }
      }
      return result;
    },
    getPowerDisplayConfigList() {
      this.$apis.dataMager.powerMager
        .getPowerDisplayConfigList()
        .then((res) => {
          let rs = JSON.parse(res.data.result);
          let data = [];
          if (rs.code == 1) {
            data = rs.data;
          }
          this.chartTypes = data;
        })
        .catch((error) => {
          this.chartTypes = [];
          console.log(error);
        });
    },
    showChartConfigDialog(name) {
      let chartType = this.getItemByName(name, this.chartTypes);
      this.chartTypeConfig = chartType
        ? chartType
        : { id: null, name: name, type: 0 };
      this.$nextTick(() => {
        this.chartDialog = true;
      });
    },
    changeChartTypeSuccess() {
      this.getPowerDisplayConfigList();
    },
  },
  computed: {
    battFullName() {
      let batt = this.batt;
      if (batt.StationName && batt.BattGroupName) {
        return batt.StationName + "-" + "通信电源";
      }
      return "电池组全称";
    },
  },
  mounted() {
    // 获取电源信息
    let powerDeviceId = this.$route.params.powerDeviceId;
    if (powerDeviceId) {
      this.getPowerInfo(powerDeviceId);
    }
}
    // 设置配置项
    this.setOption();
    // 添加窗口自动缩放
    window.addEventListener("resize", this.resize);
  },
  destroyed() {
    this.timer.stop();
    // 添加窗口自动缩放
    window.removeEventListener("resize", this.resize);
  },
};
</script>
<style scoped>
.flex-page-content {
    padding: 4px;
    box-sizing: border-box;
    text-align: center;
  padding: 4px;
  box-sizing: border-box;
  text-align: center;
}
.flex-layout.el-tabs {
    display: flex;
    flex-direction: column;
    height: 100%;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.el-tab-pane-content {
    position: relative;
    width: 100%;
    height: 100%;
  position: relative;
  width: 100%;
  height: 100%;
}
.el-tab-pane-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}
.box-tools {
    font-size: 24px;
    margin-right: 8px;
    cursor: pointer;
  font-size: 24px;
  margin-right: 8px;
  cursor: pointer;
}
.top-box,
.bottom-box {
    box-sizing: border-box;
  box-sizing: border-box;
}
.top-box {
    padding-bottom: 8px;
  padding-bottom: 8px;
}
.bottom-box {
    padding-top: 8px;
    padding-bottom: 8px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.flex-box-tools-icon {
    font-size: 20px;
    cursor: pointer;
  font-size: 20px;
  cursor: pointer;
}
.flex-box-tools-icon:active {
    color: #FF0000;
  color: #ff0000;
}
.page-content-tools {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 99;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 99;
}
.status-text {
    line-height: 32px;
    white-space: nowrap;
    font-size: 14px;
  line-height: 32px;
  white-space: nowrap;
  font-size: 14px;
}
</style>
</style>