<template>
  <div>
    <div class="title">
      <el-select
        v-model="Singlevalue"
        collapse-tags
        placeholder="选择电站"
        popper-class="custom-header"
        :max-collapse-tags="1"
        style="width: 300px"
        size="large"
        @change="postemsDevice"
      >
        <el-option v-for="item in cities" :key="item.id" :label="item.stationName" :value="item.id" />
      </el-select>
      <div class="title_"></div>
      <el-select
        v-model="emsDeviceId"
        collapse-tags
        placeholder="选择编号"
        popper-class="custom-header"
        :max-collapse-tags="1"
        style="width: 240px"
        size="large"
        @change="getstationrealtime"
      >
        <el-option v-for="item in emsDevice" :key="item.id" :label="item.emsDeviceId" :value="item.id" />
      </el-select>
    </div>
    <!-- <div>
    
  </div> -->
    <div class="equipment">
      <el-card>
        <el-tabs v-model="activeName" class="demo-tabs" @tab-change="handletabs">
          <el-tab-pane v-for="(item, index) in deviceList" :key="index" :label="item.deviceClassName" :name="index">
            <div class="demo_div">
              <div v-for="(items, indexs) in item.devices" :key="indexs">
                <div :class="devicesClickindex == indexs ? 'demo_tabsccc' : 'demo_tabs'" @click="devicesClick(indexs, items.id)">
                  {{ items.deviceName }}
                </div>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>

        <div class="equipmentdiv" v-if="deviceType == 1">
          <div class="equipmenttime">末次数据时间：{{ pcslist.ts }}</div>
          <div style="height: 33px"></div>
          <div>设备状态</div>
          <div class="equipmentdevice">
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.sysStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">运行</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">停止</div>
                </div>
                <div class="equipment2">运行状态</div>
              </div>
            </el-card>
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.workStatus == 2">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">运行</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">工作状态</div>
              </div>
            </el-card> -->
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.gridStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">运行</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">并网状态</div>
              </div>
            </el-card> -->
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.faultStatus == 0">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment12">故障</div>
                </div>
                <div class="equipment2">故障状态</div>
              </div>
            </el-card>
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.controlMode == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">运行</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">控制模式</div>
              </div>
            </el-card> -->
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.emsCommStatus == 'GOOD'">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">失败</div>
                </div>
                <div class="equipment2">与EMS通信</div>
              </div>
            </el-card> -->
          </div>
          <div class="equipmentdata">设备数据</div>
          <!--  -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">当日充电量</div>
              <div>{{ pcslist.todayAcChargeKwh ?? "-" }} kWh</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">当日放电量</div>
              <div>{{ pcslist.todayAcDischargeKwh ?? "-" }} kWh</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">累计充电量</div>
              <div>{{ (pcslist.totalAcChargeKwh * 1).toFixed(2) ?? "-" }} kWh</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">累计放电量</div>
              <!-- <div>{{ pcslist.totalAcActivePower ?? "-" }} kW</div> -->
              <div>{{ pcslist.totalAcDischargeKwh ?? "-" }} kWh</div>
            </div>
          </div>
          <!-- 1 -->
          <div class="equipmentdata_equipment">
            <!-- <div class="equipmentdata_div">
              <div class="equipment_title">当日充电量</div>
              <div>{{ pcslist.todayAcChargeKwh ?? "-" }} kWh</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">当日放电量</div>
              <div>{{ pcslist.todayAcDischargeKwh ?? "-" }} kWh</div>
            </div> -->
            <div class="equipmentdata_div">
              <div class="equipment_title">交流频率</div>
              <div>{{ (pcslist.acFrequency * 1).toFixed(2) ?? "-" }} Hz</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">总交流有功功率</div>
              <div>{{ pcslist.totalAcActivePower ?? "-" }} kW</div>
              <!-- <div>{{ pcslist.totalAcPowerFactor ?? "-" }} kW</div> -->
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">总交流无功功率</div>
              <div>{{ pcslist.totalAcReactivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">总交流视在功率</div>
              <div>{{ pcslist.totalAcApparentPower ?? "-" }} kW</div>
            </div>
          </div>
          <!-- 2 -->
          <div class="equipmentdata_equipment">
            <!-- <div class="equipmentdata_div">
              <div class="equipment_title">总交流无功功率</div>
              <div>{{ pcslist.totalAcReactivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">总交流视在功率</div>
              <div>{{ pcslist.totalAcApparentPower ?? "-" }} kW</div>
            </div> -->
            <div class="equipmentdata_div">
              <!-- <div class="equipment_title">总交流功率因数</div> -->
              <div class="equipment_title">交流电流</div>
              <!-- <div>{{ pcslist.aphaseActivePower ?? "-" }}A</div> -->
              <div>{{ (pcslist.acAbCurrent * 1).toFixed(2) ?? "-" }}A</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">A相有功功率</div>
              <div>{{ pcslist.aphaseActivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">B相有功功率</div>
              <div>{{ pcslist.bphaseActivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">C相有功功率</div>
              <div>{{ pcslist.cphaseActivePower ?? "-" }} kW</div>
            </div>
          </div>
          <!-- 3  -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">A相无功功率</div>
              <div>{{ pcslist.aphaseReactivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">B相无功功率</div>
              <div>{{ pcslist.bphaseReactivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">C相无功功率</div>
              <div>{{ pcslist.cphaseReactivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">A相视在功率</div>
              <div>{{ pcslist.aphaseApparentPower ?? "-" }} kVA</div>
            </div>
          </div>
          <!-- 4  -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">B相视在功率</div>
              <div>{{ pcslist.bphaseApparentPower ?? "-" }} kVA</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">C相视在功率</div>
              <div>{{ pcslist.cphaseApparentPower ?? "-" }} kVA</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">AB电压</div>
              <div>{{ (pcslist.acAbVolt * 1).toFixed(2) ?? "-" }} V</div>
              <!-- <div class="equipment_title">AB离网电压</div> -->
              <!-- <div>{{ (pcslist.abOffGridVolt * 1).toFixed(2) ?? "-" }} V</div> -->
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">BC电压</div>
              <div>{{ (pcslist.acBcVolt * 1).toFixed(2) ?? "-" }} V</div>
            </div>
          </div>
          <!-- 5  -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">CA电压</div>
              <div>{{ (pcslist.acCaVolt * 1).toFixed(2) ?? "-" }} V</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">AB电流</div>
              <div>{{ (pcslist.acAbCurrent * 1).toFixed(2) ?? "-" }} A</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">BC电流</div>
              <div>{{ (pcslist.acBcCurrent * 1).toFixed(2) ?? "-" }} A</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">CA电流</div>
              <div>{{ (pcslist.acCaCurrent * 1).toFixed(2) ?? "-" }} A</div>
            </div>
          </div>
          <!-- 6 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">A相电压</div>
              <div>{{ (pcslist.acAphaseVolt * 1).toFixed(2) ?? "-" }} V</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">B相电压</div>
              <div>{{ (pcslist.acBphaseVolt * 1).toFixed(2) ?? "-" }} V</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">C相电压</div>
              <div>{{ (pcslist.acCphaseVolt * 1).toFixed(2) ?? "-" }} V</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">A相电流</div>
              <div>{{ (pcslist.acAphaseCurrent * 1).toFixed(2) ?? "-" }} A</div>
              <!-- <div>{{ (pcslist.acAbCurrent * 1).toFixed(2) ?? "-" }} A</div> -->
            </div>
          </div>
          <!-- 7 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">B相电流</div>
              <div>{{ (pcslist.acBphaseCurrent * 1).toFixed(2) ?? "-" }} A</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">C相电流</div>
              <div>{{ (pcslist.acCphaseCurrent * 1).toFixed(2) ?? "-" }} A</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">PCS模块温度</div>
              <div>{{ pcslist.moduleTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">PCS环境温度</div>
              <div>{{ pcslist.envTempr ?? "-" }} ℃</div>
            </div>
          </div>
          <!-- 8 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">PCS散热器温度</div>
              <div>{{ pcslist.radiatorTemp ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">A1模块温度</div>
              <div>{{ pcslist.aphaseIgbtMaxTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">B1模块温度</div>
              <div>{{ pcslist.bphaseIgbtMaxTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">C1模块温度</div>
              <div>{{ pcslist.cphaseIgbtMaxTempr ?? "-" }} ℃</div>
            </div>
          </div>
          <!-- 9 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">A2模块温度</div>
              <div>{{ pcslist.aphaseIgbtMinTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">B2模块温度</div>
              <div>{{ pcslist.bphaseIgbtMinTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">C2模块温度</div>
              <div>{{ pcslist.cphaseIgbtMaxTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">进风口温度</div>
              <div>{{ pcslist.airInletTemp ?? "-" }} ℃</div>
            </div>
          </div>
          <!-- 10 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">出风口温度</div>
              <div>{{ pcslist.airOutletTemp ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div1"></div>
          </div>
          <div class="equipmentdata">设备故障字</div>
          <!-- faultStatusWordList -->
          <div class="equipmentdata_data">
            <div class="equipmentdata_div2" v-for="(item, index) in pcslist.faultStatusWordList" :key="index">
              <div class="equipment_title">故障状态字</div>
              <div>{{ item }}</div>
            </div>
          </div>

          <div class="equipmentdata">支路数据</div>

          <el-table :data="pcslist.pcsBranches" style="width: 100%" border :scrollbar-always-on="true">
            <!-- <el-table-column type="index" label="支路" width="60" /> -->
            <el-table-column type="index" :index="indexMethod" label="支路" align="center" width="160" />
            <el-table-column prop="dcPower" label="直流功率(kW) " align="center" />
            <el-table-column prop="dcVolt" label="直流电压(V)" align="center" />
            <el-table-column prop="dcCurrent" label="直流电压(A)" align="center" />
          </el-table>
        </div>
        <div class="equipmentdiv" v-if="deviceType == 2">
          <div class="equipmenttime">末次数据时间：{{ datalist.ts }}</div>
          <div style="height: 33px"></div>
          <div>设备状态</div>
          <div class="equipmentdevice">
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="datalist.emsCommStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">运行</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">停止</div>
                </div>
                <div class="equipment2">运行状态</div>
              </div>
            </el-card> -->
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.emsCommStatus == 0">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">故障</div>
                </div>
                <div class="equipment2">工作状态</div>
              </div>
            </el-card> -->
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.emsCommStatus == 0">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">故障</div>
                </div>
                <div class="equipment2">故障状态</div>
              </div>
            </el-card>
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="pcslist.emsCommStatus == 'GOOD'">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">失败</div>
                </div>
                <div class="equipment2">与EMS通信</div>
              </div>
            </el-card> -->
          </div>
          <div class="equipmentdata">设备数据</div>
          <!--  -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">总有功功率</div>
              <div>{{ datalist.totalActivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">无功功率</div>
              <div>{{ datalist.totalReactivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">视在功率</div>
              <div>{{ datalist.aphaseApparentPower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">功率因数</div>
              <div>{{ datalist.totalAcPowerFactor ?? "-" }}</div>
            </div>
          </div>
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">A相有功功率</div>
              <div>{{ datalist.aphaseActivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">B相有功功率</div>
              <div>{{ datalist.bphaseActivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">C相有功功率</div>
              <div>{{ datalist.cphaseActivePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">电流互感器变比</div>
              <div>-</div>
            </div>
          </div>
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">电压互感器变比</div>
              <div>-</div>
            </div>
          </div>
          <div class="equipmentdata">电量数据</div>
          <div class="eltable">
            <el-table :data="Electricitymeterlist" style="width: 100%" border>
              <el-table-column prop="type" label="类别" width="180" />
              <el-table-column prop="total" label="总/kWh" width="180" />
              <el-table-column prop="tip" label="尖/kWh	" />
              <el-table-column prop="peak" label="峰/kWh" />
              <el-table-column prop="flat" label="平/kWh" />
              <el-table-column prop="valley" label="谷/kWh" />
            </el-table>
          </div>

          <!--  -->
        </div>
        <div class="equipmentdiv" v-if="deviceType == 3">
          <div class="equipmenttime">末次数据时间：{{ BMSlist.ts }}</div>
          <div style="height: 33px"></div>
          <div>设备状态</div>
          <div class="equipmentdevice">
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="BMSlist.workStatus == 0">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">空闲</div>
                </div>
                <div class="equipmentname" v-if="BMSlist.workStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">充电</div>
                </div>
                <div class="equipmentname" v-if="BMSlist.workStatus == 2">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">放电</div>
                </div>
                <div class="equipmentname" v-if="BMSlist.workStatus == 3">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">充满</div>
                </div>
                <div class="equipmentname" v-if="BMSlist.workStatus == 4">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">放空</div>
                </div>
                <div class="equipmentname" v-if="BMSlist.workStatus == 5">
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">故障</div>
                </div>
                <div class="equipment2">充放电状态</div>
              </div>
            </el-card>
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="BMSlist.batteryStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">堆状态</div>
              </div>
            </el-card> -->
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="BMSlist.pcsCommStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">与PCS通信</div>
              </div>
            </el-card> -->
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="BMSlist.emsCommStatus == 'GOOD'">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">失败</div>
                </div>
                <div class="equipment2">与EMS通信</div>
              </div>
            </el-card> -->
          </div>

          <div class="equipmentdata">设备数据</div>
          <!-- 1 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">总电压</div>
              <div>{{ BMSlist.tv ?? "-" }} V</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">总电流</div>
              <div>{{ BMSlist.tc ?? "-" }} A</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">SOC</div>
              <div>{{ BMSlist.soc ?? "-" }} %</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">SOH</div>
              <div>{{ BMSlist.soh ?? "-" }} %</div>
            </div>
          </div>
          <!-- 2 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">充电限制功率</div>
              <div>{{ BMSlist.rechargeablePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">放电限制功率</div>
              <div>{{ BMSlist.dischargeablePower ?? "-" }} kW</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">可充电量</div>
              <div>{{ BMSlist.rechargeableKwh ?? "-" }} kWh</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">可放电量</div>
              <div>{{ BMSlist.dischargeableKwh ?? "-" }} kWh</div>
            </div>
          </div>
          <!-- 3 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">平均单体温度</div>
              <div>{{ BMSlist.avgCellTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">平均单体电压</div>
              <div>{{ BMSlist.avgCellVoltage ?? "-" }} V</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">绝缘值</div>
              <div>{{ BMSlist.insulationResistance ?? "-" }} kΩ</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">正极绝缘值</div>
              <div>{{ BMSlist.posInsulationResistance ?? "-" }} kΩ</div>
            </div>
          </div>
          <!-- 4 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">负极绝缘值</div>
              <div>{{ BMSlist.negInsulationResistance ?? "-" }} kΩ</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">最高单体温度</div>
              <div>{{ BMSlist.maxCellTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">最低单体温度</div>
              <div>{{ BMSlist.minCellTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">最高单体电压</div>
              <div>{{ BMSlist.maxCellVoltage ?? "-" }} V</div>
            </div>
          </div>
          <!-- 4 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">最低单体电压</div>
              <div>{{ BMSlist.minCellVoltage ?? "-" }} V</div>
            </div>
          </div>
          <!--  -->
        </div>
        <div class="equipmentdiv" v-if="deviceType == 4">
          <div class="equipmenttime">末次数据时间：{{ Conditionerdata.ts }}</div>
          <div style="height: 33px"></div>
          <div>设备状态</div>
          <div class="equipmentdevice">
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.workStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">运行</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">停止</div>
                </div>
                <div class="equipment2">运行状态</div>
              </div>
            </el-card>
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.indoorFanStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">室内风机</div>
              </div>
            </el-card> -->
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.outdoorFanStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">运行</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">室外风机</div>
              </div>
            </el-card>
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.emergencyFanStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">应急风机</div>
              </div>
            </el-card>
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.compressorStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">运行</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">压缩机</div>
              </div>
            </el-card>
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.electricHeatingStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">停止</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">电加热</div>
              </div>
            </el-card>
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.dischargingHydrogenStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">排氢状态</div>
              </div>
            </el-card> -->
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.emsCommStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">与EMS通信</div>
              </div>
            </el-card> -->
            <!-- <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.sysStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1">-</div>
                </div>
                <div class="equipment2">工作模式</div>
              </div>
            </el-card> -->
            <el-card>
              <div class="equipmentdevice1">
                <div class="equipmentname" v-if="Conditionerdata.alarmStatus == 1">
                  <div class="equipmentborder"></div>
                  <div class="equipment1">正常</div>
                </div>
                <div class="equipmentname" v-else>
                  <div class="equipmentborderif"></div>
                  <div class="equipment1red">故障</div>
                </div>
                <div class="equipment2">故障状态</div>
              </div>
            </el-card>
          </div>

          <div class="equipmentdata">设备数据</div>
          <!-- class="" -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">电流</div>
              <div>{{ Conditionerdata.acVolt ?? "-" }} A</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">交流电压</div>
              <div>{{ Conditionerdata.acVolt ?? "-" }} V</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">直流电压</div>
              <div>{{ Conditionerdata.dcVolt ?? "-" }} V</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">盘管温度</div>
              <div>{{ Conditionerdata.coilTempr ?? "-" }} ℃</div>
            </div>
          </div>
          <!-- 2 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">柜外温度</div>
              <div>{{ Conditionerdata.outdoorTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">柜内温度</div>
              <div>{{ Conditionerdata.cabinetTempr ?? "-" }}℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">冷凝温度</div>
              <div>{{ Conditionerdata.condensingTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">融霜温度</div>
              <div>{{ Conditionerdata.defrostTempr ?? "-" }} ℃</div>
            </div>
          </div>
          <!-- 3 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">排气温度</div>
              <div>{{ Conditionerdata.exhaustTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">出风温度</div>
              <div>{{ Conditionerdata.airOutTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">回风温度</div>
              <div>{{ Conditionerdata.airInTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">柜内湿度</div>
              <div>{{ Conditionerdata.humidity ?? "-" }} %</div>
            </div>
          </div>
          <!-- 4 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">制热开启温度</div>
              <div>{{ Conditionerdata.heatingStartTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">制热关闭温度</div>
              <div>{{ Conditionerdata.heatingStopTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">制冷开启温度</div>
              <div>{{ Conditionerdata.refrigerationStartTempr ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">制冷关闭温度</div>
              <div>{{ Conditionerdata.refrigerationStopTempr ?? "-" }} ℃</div>
            </div>
          </div>
          <!-- 5-->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">高温告警温度</div>
              <div>{{ Conditionerdata.highTemprThreshold ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">低温告警温度</div>
              <div>{{ Conditionerdata.lowTemprThreshold ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">高湿告警点</div>
              <div>{{ Conditionerdata.humidity ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">除湿开启温度</div>
              <div>{{ Conditionerdata.dehumStartTemp ?? "-" }} ℃</div>
            </div>
          </div>
          <!-- 6 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">除湿关闭温度</div>
              <div>{{ Conditionerdata.dehumStartHum ?? "-" }} ℃</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">除湿开启湿度</div>
              <div>{{ Conditionerdata.dehumStopTemp ?? "-" }} %</div>
            </div>
            <div class="equipmentdata_div">
              <div class="equipment_title">除湿关闭湿度</div>
              <div>{{ Conditionerdata.dehumStopHum ?? "-" }} %</div>
            </div>
            <div class="equipmentdata_div4">
              <div class="equipment_title">内风机转速</div>
              <div>{{ Conditionerdata.innerFanSpeed ?? "-" }} rpm</div>
            </div>
          </div>
          <!-- 4 -->
          <div class="equipmentdata_equipment">
            <div class="equipmentdata_div">
              <div class="equipment_title">外风机转速</div>
              <div>{{ Conditionerdata.exhaustTempr ?? "-" }} rpm</div>
            </div>
          </div>
          <!--  -->
        </div>
      </el-card>
    </div>
  </div>
</template>
<script setup lang="ts">
import { onMounted, onUnmounted, Ref, ref } from "vue";
import {
  stationstationName,
  postemsSystemsingleStation,
  poststationdeviceList,
  postpcsInfo,
  electricMeterInfo,
  BMSfieldCode,
  BMSbatteryStackInfo,
  getairConditionerInfo
} from "@/api/home/Multisite";
import { Station } from "@/api/interface";
const currentDate = ref();
const Singlevalue = ref("");
const cities: Ref<Station.todo[]> = ref([]);
const emsDevice: Ref<any[]> = ref([]);
const emsDeviceId = ref("");
const intervalID = ref();
const poststationstationName = async () => {
  const { data } = await stationstationName({});
  Singlevalue.value = data[0].id;
  cities.value = data;
  postemsDevice(Singlevalue.value);
};
const postemsDevice = async (value: any) => {
  emsDevice.value = [];
  const { data } = await postemsSystemsingleStation({}, value);
  if (data.length == 0) {
    emsDeviceId.value = "";
    clearInterval(intervalID.value);

    return;
  } else {
    emsDeviceId.value = data[0].id;
  }
  for (let index = 0; index < data.length; index++) {
    if (data[index].emsDeviceId.length > 20) {
      data[index].emsDeviceId = data[index].emsDeviceId.substring(7);
    }
  }

  emsDevice.value = data;
  getstationrealtime();
};
const deviceList: Ref<Station.deviceList[]> = ref([]);
const deviceType = ref(1);

const getstationrealtime = async () => {
  const { data } = await poststationdeviceList({ emsId: emsDeviceId.value }, Singlevalue.value);
  if (data.length == 0) return;
  deviceList.value = data;
  deviceType.value = data[0].deviceType;
  handleClick();
  // 清除定时器的示例
  clearInterval(intervalID.value);
  intervalID.value = setInterval(function () {
    handleClick();
  }, 10000);
};
const activeName = ref(0);
const handletabs = (e: any) => {
  activeName.value = e;
  handleClick();
};
const handleClick = async () => {
  deviceType.value = deviceList.value[activeName.value].deviceType;
  // clearInterval(intervalID.value);
  if (deviceList.value[activeName.value].deviceType == 1) {
    getpcsdata();
  } else if (deviceList.value[activeName.value].deviceType == 2) {
    // devicesClickid.value
    devicesClickid.value = deviceList.value[activeName.value].devices[0].id;
    Electricitymeter();
  } else if (deviceList.value[activeName.value].deviceType == 3) {
    BMSfieldCodeid.value = deviceList.value[activeName.value].devices[0].id;

    getBMSfieldCode();
    getBMSbatteryStackInfo();
  } else if (deviceList.value[activeName.value].deviceType == 4) {
    airConditionerInfoid.value = deviceList.value[activeName.value].devices[0].id;
    getgetairConditionerInfo();
  }
};
//
const devicesClickindex = ref(0);
const devicesClickid = ref("1");
const devicesClick = async (val: number, id: string) => {
  devicesClickindex.value = val;
  devicesClickid.value = id;
  Electricitymeter();
};

const indexMethod = (index: number) => {
  return index + 1;
};
//PCS
const pcslist = ref();
const getpcsdata = async () => {
  const { data } = await postpcsInfo({ emsId: emsDeviceId.value }, Singlevalue.value, emsDeviceId.value);
  pcslist.value = data;
};
// 电表
const Electricitymeterlist = ref();
const datalist = ref();
const Electricitymeter = async () => {
  const { data } = await electricMeterInfo({ emsId: emsDeviceId.value }, Singlevalue.value, devicesClickid.value);
  datalist.value = data;
  // 电表
  let tableData = [
    {
      type: "日正向总电能",
      total: "-",
      tip: "-",
      peak: "-",
      flat: "-",
      valley: "-"
    },
    {
      type: "日反向总电能",
      total: "-",
      tip: "-",
      peak: "-",
      flat: "-",
      valley: "-"
    },
    {
      type: "累计正向总电能",
      total: datalist.value.totalImportEnergy ?? "-",
      tip: "-",
      peak: "-",
      flat: "-",
      valley: "-"
    },
    {
      type: "累计反向总电能",
      total: datalist.value.totalExportEnergy ?? "-",
      tip: "-",
      peak: "-",
      flat: "-",
      valley: "-"
    }
  ];
  Electricitymeterlist.value = tableData;
};
// BMS
const BMSfieldCodeid = ref("");

const BMSdata = ref();
const getBMSfieldCode = async () => {
  const { data } = await BMSfieldCode({ deviceType: 9, deviceId: BMSfieldCodeid.value }, Singlevalue.value);
  BMSdata.value = data;
};
const BMSlist = ref();

const getBMSbatteryStackInfo = async () => {
  const { data } = await BMSbatteryStackInfo({ emsId: emsDeviceId.value }, Singlevalue.value, BMSfieldCodeid.value);
  BMSlist.value = data;
};
// 空调
const airConditionerInfoid = ref("");
const Conditionerdata = ref();
const getgetairConditionerInfo = async () => {
  const { data } = await getairConditionerInfo({ emsId: emsDeviceId.value }, Singlevalue.value, airConditionerInfoid.value);
  Conditionerdata.value = data;
};
onUnmounted(() => {
  clearInterval(intervalID.value);
});
onMounted(() => {
  const current = localStorage.getItem("currentDate");
  if (current) {
    currentDate.value = current;
  }

  poststationstationName();
});
</script>
<style scoped lang="scss">
@import "./index.scss";
</style>
<!-- -->
