lishifeng
2020-09-15 ce10677f47a14879424e7f562f78442cc03cfda1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
<template>
  <flex-layout direction="row" class="page-real-time">
    <home-list slot="header" 
    @toggleChange="toggleChange" 
    @leaf-click="leafClick"></home-list>
    <content-box style="margin-left: 4px; margin-right: 4px;" :title="battFullName">
      <div slot="box-tools" class="box-tools">
        <el-tooltip class="item" effect="dark" content="历史数据" placement="bottom">
          <i class="iconfont el-icon-jinru" @click="syncPage"></i>
        </el-tooltip>
      </div>
      <flex-layout>
        <div class="content-header" slot="header" :model="inputs">
          <div class="table-layout">
            <div class="table-row">
              <div class="table-cell text-right w80">电池状态:</div>
              <div class="table-cell">
                <el-input :value="backInputs.batt_state" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">端电压:</div>
              <div class="table-cell">
                <el-input :value="backInputs.group_online_vol" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">电池电流:</div>
              <div class="table-cell">
                <el-input :value="backInputs.group_curr" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">更新日期:</div>
              <div class="table-cell">
                <el-input :value="backInputs.rec_datetime" size="small" :disabled="true"></el-input>
              </div>
            </div>
            <div class="table-row">
              <div class="table-cell text-right w80">测试时长:</div>
              <div class="table-cell">
                <el-input :value="backInputs.batt_test_tlong" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">测试容量:</div>
              <div class="table-cell">
                <el-input :value="backInputs.batt_test_cap" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">剩余容量:</div>
              <div class="table-cell">
                <el-input :value="backInputs.batt_syrl_cap" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">续航时长:</div>
              <div class="table-cell">
                <el-input :value="backInputs.sysc" size="small" :disabled="true"></el-input>
              </div>
            </div>
          </div>
        </div>
        <div class="page-content">
          <div class="page-content-tools">
            <el-popover
            placement="bottom"
            trigger="hover"
            v-show="showControl">
              <div class="hdw-menu-list">
                <ul>
                  <li class="hdw-menu-item"><a @click="dischargeDialog.show = true" href="javascript:void(0);">启动核容测试</a></li>
                  <li class="hdw-menu-item"><a @click="stopTest" href="javascript:void(0);">停止测试</a></li>
                  <!-- <li class="hdw-menu-item"><a @click="systemDialog.show = true" href="javascript:void(0);">系统参数设置</a></li>
                  <li class="hdw-menu-item"><a href="javascript:void(0);">清除告警</a></li>
                  <li class="hdw-menu-item"><a href="javascript:void(0);">启动养护/除硫</a></li>
                  <li class="hdw-menu-item"><a href="javascript:void(0);">停止养护/除硫</a></li>
                  <li class="hdw-menu-item"><a href="javascript:void(0);">启动离线养护</a></li>
                  <li class="hdw-menu-item"><a href="javascript:void(0);">停止离线养护</a></li>
                  <li class="hdw-menu-item"><a href="javascript:void(0);">定期重启设备</a></li>
                  <li class="hdw-menu-item"><a href="javascript:void(0);">重启设备</a></li> -->
                </ul>
              </div>
              <button class="hdw-btn" slot="reference">
                <span>功能列表</span>
                <i class="hdw-icon el-icon-caret-bottom"></i>
              </button>
            </el-popover>
          </div>
          <el-tabs v-model="acTabs" type="border-card" class="flex-layout" @tab-click="tabClick">
            <el-tab-pane label="电路拓扑图" name="eleLine">
                <science-box :top="8" :left="8" no-header v-show="stateListShow">
                  <div class="hdw-state-list table-layout">
                    <div v-for="state in showStateList" :key="state.text"
                    class="table-row" :class="state.type">
                      <div class="table-cell text-right">
                        <i v-if="state.icon" class="iconfont" :class="state.icon"></i>{{state.text}}
                      </div>
                      <div class="table-cell">
                        {{state.value}}{{state.unit}}
                      </div>
                    </div>
                  </div>
                </science-box>
                <circuit-diagram
                :online-vol="inputs.online_vol"
                :group-vol="inputs.group_vol"
                :batt-curr="inputs.group_curr"
                :dev-temp="diagram.temp"
                :type="diagram.type"></circuit-diagram>
            </el-tab-pane>
            <el-tab-pane label="电压" name="vol">
              <bar-chart ref="vol" id="vol" unit="V"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="内阻" name="res">
              <bar-chart ref="res" id="res" unit="mΩ" max-color="red" min-color="green"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="温度" name="temp">
              <bar-chart ref="temp" id="temp" unit="℃" max-color="red" min-color="green"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="电导" name="conduct">
              <bar-chart ref="conduct" id="conduct"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="均衡电流" name="curr">
              <bar-chart ref="curr" id="curr" unit="A"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="数据表格" name="tblData">
              <el-table border size="small" :data="table.datas" height="100%">
                <el-table-column
                  v-for="header in table.headers"
                  :key="header.prop"
                  :prop="header.prop"
                  :label="header.label"
                  :width="header.width"
                  align="center"></el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </div>
      </flex-layout>
    </content-box>
    <!-- 放电参数设置 -->
    <el-dialog
    :title="dischargeDialogTitle"
    width="700px"
    :visible.sync="dischargeDialog.show"
    :close-on-click-modal="false"
    top="0"
    class="dialog-center"
    :modal-append-to-body="false">
      <discharge-dialog-content
      v-if="dischargeDialog.show"
      :batt="batt"></discharge-dialog-content>
    </el-dialog>
    <!-- 系统参数设置 -->
    <el-dialog
    title="系统参数设置"
    width="700px"
    :visible.sync="systemDialog.show"
    :close-on-click-modal="false"
    top="0"
    class="dialog-center"
    :modal-append-to-body="false">
      <system-params
      v-if="systemDialog.show"
      :batt="batt"></system-params>
    </el-dialog>
  </flex-layout>
</template>
 
<script>
import ContentBox from "../../components/ContentBox";
import HomeList from "./HomeList";
import BarChart from "../../components/chart/BarChart";
import CircuitDiagram from "./CircuitDiagram";
import ScienceBox from "../../components/ScienceBox";
import DischargeDialogContent from '../../components/params/DischargeDialogContent'
import SystemParams from '../../components//params/SystemParams'
 
import {
  realTimeSearch,
  realTimeGroup,
  realTimeAlarm,
  realTimePowerOff
} from "../../assets/js/realTime";
import {
  formatSeconds,
  sethoubeiTime,
  Timeout,
  regEquipType,
  getBarNum
} from "../../assets/js/tools";
 
import { const_61850 } from "../../assets/js/const";
/* import moment from "moment"; */
let vol, resChart, temp, conduct, currChart;
export default {
  components: {
    ContentBox,
    HomeList,
    BarChart,
    CircuitDiagram,
    ScienceBox,
    DischargeDialogContent,
    SystemParams
  },
  data() {
    return {
      username: sessionStorage.getItem('username'),
      /* 电池状态 模块 组端展示 */
      inputs: {
        group_vol: 0 /* 端电压-组端电压 */,
        online_vol: 0 /* 端电压-在线电压 */,
        group_curr: 0 /* 电池电流 */,
        batt_test_tlong: "0:00:00" /* 测试时长 */,
        rec_datetime: 0 /* 更新日期 */,
        batt_test_cap: 0 /* 测试容量 */,
        batt_rest_cap: 0, // 剩余容量
        batt_state: 0 /* 电池状态 */
      },
      acTabs: "eleLine",
      table: {
        headers: [
          {
            prop: "num1",
            label: "单体编号",
            width: ""
          },
          {
            prop: "vol1",
            label: "电压(V)",
            width: ""
          },
          {
            prop: "res1",
            label: "内阻(mΩ)",
            width: ""
          },
          {
            prop: "temp1",
            label: "温度(℃)",
            width: ""
          },
          {
            prop: "conduct1",
            label: "电导",
            width: ""
          },
          {
            prop: "curr1",
            label: "均衡电流(A)",
            width: ""
          }
        ],
        datas: [
          {
            num1: 0,
            vol1: 0,
            res1: 0,
            temp1: 0,
            conduct1: 0,
            curr1: 0
          }
        ]
      },
      batt: {},
      stateListShow: true,
      stateList: [
        {
          name: "workState",
          type: "",
          icon: "",
          text: "设备工作状态:",
          value: "在线浮充",
          show: true
        },
        {
          name: "connect",
          type: "",
          icon: "el-icon-tongxun",
          text: "设备通讯:",
          value: "正常",
          show: true
        },
        {
          name: "devTemp",
          type: "",
          icon: "el-icon-wendu",
          text: "设备温度:",
          value: "正常",
          show: true
        },
        {
          name: "contact",
          type: "",
          icon: "el-icon-fenxiang",
          text: "干接点:",
          value: "正常",
          show: false
        },
        {
          name: "stopReason",
          type: "",
          icon: "",
          text: "核容终止原因:",
          value: "未知",
          show: false
        },
        {
          name: "failReason",
          type: "",
          icon: "",
          text: "操作失败原因:",
          value: "未知",
          show: false
        },
        {
          name: "resDay",
          type: "",
          icon: "",
          text: "剩余天数:",
          value: "0",
          show: false
        },
        {
          name: "workMode",
          type: "",
          icon: "",
          text: "工作模式:",
          value: "停止",
          show: false
        },
        {
          name: "groupVol",
          type: "",
          icon: "",
          text: "组端电压:",
          value: "0",
          unit: "V",
          show: false
        },
        {
          name: "peakVol",
          type: "",
          icon: "",
          text: "峰值电压:",
          value: "0",
          unit: "V",
          show: false
        }
      ],
      timer: new Timeout(),
      diagram: {
        type: -1,
        desc: "",
        temp: 0 // 设备温度
      },
      dischargeDialog: {
        show: false
      },
      systemDialog: {
        show: false,
      },
    };
  },
  methods: {
    tabClick(tab) {
      this.$nextTick(() => {
        this.$G.chartManage.resize(tab.name);
      });
    },
    toggleChange() {
      this.resize();
    },
    resize() {
      this.$G.chartManage.resize(this.acTabs);
    },
    initChart() {
      // 电压
      vol = {
        title: {
          show: true,
          text: "最大值=0V;最小值=0V;平均值=0V",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "电压",
            type: "bar",
            data: []
          }
        ]
      };
 
      // 内阻
      resChart = {
        title: {
          show: true,
          text: "最大值=0mΩ;最小值=mΩ;平均值=0mΩ",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "内阻",
            type: "bar",
            data: []
          }
        ]
      };
 
      // 温度
      temp = {
        title: {
          show: true,
          text: "最大值=0℃;最小值=0℃;平均值=0℃",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "温度",
            type: "bar",
            data: []
          }
        ]
      };
 
      // 电导
      conduct = {
        title: {
          show: true,
          text: "最大值=0;最小值=0;平均值=0",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "电导",
            type: "bar",
            data: []
          }
        ]
      };
      // 均衡电流
      currChart = {
        title: {
          show: true,
          text: "最大值=0mA;最小值=0mA;平均值=0mA",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "均衡电流",
            type: "bar",
            data: []
          }
        ]
      };
      // 设置配置项
      this.setChart();
    },
    setChart() {
      this.$refs.vol.setOption(vol);
      this.$refs.res.setOption(resChart);
      this.$refs.temp.setOption(temp);
      this.$refs.conduct.setOption(conduct);
      this.$refs.curr.setOption(currChart);
    },
    startTimer() {
      this.timer.start(() => {
        this.$axios
          .all([
            this.realTimeSearch(),
            this.realTimeGroupss(),
            this.realTimePowerOffs()
          ])
          .then(() => {
            this.timer.open();
          })
          .catch(() => {
            this.timer.open();
          });
      }, 3000);
    },
    leafClick(data) {
      this.batt = data;
      this.realTimeAlarmss();
      // 开启循环请求
      this.startTimer();
    },
    /* 查询电池告警参数 */
    realTimeAlarmss() {
      var batt = this.batt;
      realTimeAlarm({
        dev_id: batt.FBSDeviceId
      }).then(res => {
        let rsccc = JSON.parse(res.data.result);
      });
    },
    /* 实时组端信息 */
    realTimeGroupss() {
      var batt = this.batt;
      realTimeGroup(batt.BattGroupId).then(res => {
        let rsa = JSON.parse(res.data.result);
        this.inputs = rsa.data[0];
      });
    },
    /* 查询电路图开关状态和信息 */
    realTimePowerOffs() {
      let batt = this.batt;
      // 设备为61850显示右侧的面板
      if (regEquipType(batt.FBSDeviceId, "equip61850")) {
        this.stateListShow = true;
      } else {
        this.stateListShow = false;
      }
 
      // 查询后台数据
      realTimePowerOff({
        dev_id: batt.FBSDeviceId
      }).then(res => {
        let rs = JSON.parse(res.data.result);
        let outTime = 2 * 60; //设备超时时间(2分钟)
        let isOutTime = true; //通讯中断        判断设备是否通讯中断    true:中断    false:正常
        if (rs.code == 1) {
          let data = rs.data[0];
          // 基础信息
          this.setEquipBase(data);
 
          // 判断是否超时
          var nowTime = new Date(data.note).getTime(); //当前时间
          var record = new Date(data.record_datetime).getTime();
          if (Math.abs(nowTime - record) / 1000 > outTime) {
            this.disconnect();
          } else {
            // 未超时执行逻辑
            // 设备为61850
            if (regEquipType(batt.FBSDeviceId, "equip61850")) {
              this.setEquip61850(data);
            }
          }
        } else {
          // 设备处于未连接
          this.disconnect();
        }
      });
    },
    disconnect() {
      // 设备未连接
      this.diagram.type = -1;
      this.setStateList("workState", "未连接");
      this.diagram.temp = 0;
      // 通讯状态
      this.setStateList("connect", "异常", "table-row-error");
      // 温度
      this.setStateList("devTemp", "未知", "table-row-warn");
      // 干接点
      this.setStateList("contact", "未知", "table-row-warn");
      // 核容终止原因
      this.setStateList("stopReason", "未知");
      // 操作失败原因
      this.setStateList("failReason", "未知");
    },
    // 基础信息
    setEquipBase(data) {
      // 设备的温度
      this.diagram.temp = data.dev_temp;
    },
    // 61850设备信息
    setEquip61850(data) {
      //  电路图类型
      let workstatus = parseInt(data.dev_workstate); //[0:'在线监测',1:'放电测试',2:'充电测试',3:'内阻测试',4:'未知'];
      this.diagram.desc = "";
      switch (workstatus) {
        case 0: //浮充状态拓扑图
          this.diagram.type = 0;
          this.diagram.desc = "(开关闭合)";
          break;
        case 4: //浮充状态(内阻测试)拓扑图
          this.diagram.type = 0;
          // 当前设备是否是内阻测试
          this.diagram.desc = "(开关闭合)";
          this.diagram.desc += "(内阻测试)";
          break;
        case 1: //充电状态拓扑图
          this.diagram.type = 2;
          this.diagram.desc = "(开关断开)";
          break;
        case 2: //放电状态拓扑图
          this.diagram.type = 1;
          this.diagram.desc = "(开关断开)";
          break;
        case 3: //放电状态拓扑图
          this.diagram.type = 7;
          break;
        case 5: //放电状态(KD测试)拓扑图
          this.diagram.type = 3;
          this.diagram.desc = "(开关断开)";
          this.diagram.desc += "(KD测试)";
          break;
        case 6: // 离线养护测试
          this.diagram.type = 4;
          this.diagram.desc = "离线养护测试";
          break;
        default:
          //未知
          this.diagram.type = -1;
          this.diagram.desc = "(未知)";
          break;
      }
 
      // 设备工作状态
      let workStates = const_61850.workstates;
      this.setStateList("workState", workStates[data.dev_workstate]);
      // 核容终止原因
      let stopReasons = const_61850.stopreasons;
      if (data.dev_workstate == 2) {
        this.setStateList("stopReason", "未知");
      } else {
        this.setStateList(
          "stopReason",
          stopReasons[data.dev_last_captest_stop_type]
        );
      }
 
      // 操作失败原因
      let failReasons = const_61850.failreasons;
      this.setStateList("failReason", failReasons[data.dev_alarmstate]);
 
      // 告警信息
      let alarms = data.dev_61850alarms.split(",");
      // alarms = ['false', 'false', 'true', 'false', 'true'];
      // 通讯状态
      if (alarms[1] == "true") {
        this.setStateList("connect", "异常", "table-row-error");
      } else {
        this.setStateList("connect", "正常", "");
      }
 
      // 温度
      if (alarms[2] == "true") {
        this.setStateList("devTemp", "异常", "table-row-error");
      } else {
        this.setStateList("devTemp", "正常", "");
      }
 
      // 干接点
      if (alarms[4] == "true") {
        this.setStateList("contact", "异常", "table-row-error");
      } else {
        this.setStateList("contact", "正常", "");
      }
    },
    // 设置stateList的值
    setStateList(name, value, type) {
      let stateList = this.stateList;
      for (let i = 0; i < stateList.length; i++) {
        let state = stateList[i];
        if (state.name == name) {
          state.value = value;
          state.type = type ? type : "";
        }
      }
    },
    /* echars图表 */
    realTimeSearch() {
      var batt = this.batt;
      realTimeSearch({
        BattGroupId: batt.BattGroupId
      }).then(res => {
        let rs = JSON.parse(res.data.result);
        if (rs.code == 1) {
          this.vovo = rs.data.map(item => {
            return {
              num1: "#" + item.mon_num,
              vol1: item.mon_vol,
              res1: item.mon_res,
              temp1: item.mon_tmp,
              conduct1: (1 / item.mon_res * 1000).toFixed(0),
              curr1: item.mon_JH_curr
            };
          });
        }
        this.table.datas = this.vovo;
 
        // 电压值
        let volTempVol = [];
        if (rs.code == 1) {
          volTempVol = rs.data.map(item => {
            return ["#" + item.mon_num, item.mon_vol];
          });
        }
        let volBarNum = getBarNum(volTempVol);
        vol.title.text = "最大值="+volBarNum.max.toFixed(2)+"V;最小值="+volBarNum.min.toFixed(2)+"V;平均值="+volBarNum.avg.toFixed(2)+"V";
        vol.series[0].data = volTempVol;
 
        // 内阻
        let volTempres = [];
        if (rs.code == 1) {
          volTempres = rs.data.map(item => {
            return ["#" + item.mon_num, item.mon_res];
          });
        }
        let resBarNum = getBarNum(volTempres);
        resChart.title.text = "最大值="+resBarNum.max.toFixed(2)+"mΩ;最小值="+resBarNum.min.toFixed(2)+"mΩ;平均值="+resBarNum.avg.toFixed(2)+"mΩ";
        resChart.series[0].data = volTempres;
 
        // 温度
        let volTempte = [];
        if (rs.code == 1) {
          volTempte = rs.data.map(item => {
            return ["#" + item.mon_num, item.mon_tmp];
          });
        }
        let tempBarNum = getBarNum(volTempte);
        temp.title.text = "最大值="+tempBarNum.max.toFixed(1)+"℃;最小值="+tempBarNum.min.toFixed(1)+"℃;平均值="+tempBarNum.avg.toFixed(1)+"℃";
        temp.series[0].data = volTempte;
 
        // 电导
        let conductTemp = [];
        if (rs.code == 1) {
          conductTemp = rs.data.map(item => {
            return ["#" + item.mon_num, (1 / item.mon_res * 1000).toFixed(0)];
          });
        }
        let conductBarNum = getBarNum(conductTemp);
        conduct.title.text = "最大值="+conductBarNum.max.toFixed(0)+";最小值="+conductBarNum.min.toFixed(0)+";平均值="+conductBarNum.avg.toFixed(0);
        conduct.series[0].data = conductTemp;
 
        // 均衡电流
        let currTemp = [];
        if (rs.code == 1) {
          currTemp = rs.data.map(item => {
            return ["#" + item.mon_num, item.mon_JH_curr];
          });
        }
        let currBarNum = getBarNum(currTemp);
        currChart.title.text = "最大值="+currBarNum.max.toFixed(1)+"mA;最小值="+currBarNum.min.toFixed(1)+"mA;平均值="+currBarNum.avg.toFixed(1)+"mA";
        currChart.series[0].data = currTemp;
 
        // 更新电压图表
        this.setChart();
      });
    },
    // 向父级发送同步页面的指令
    syncPage() {
      let batt = this.batt;
      let search =
        "?province=" +
        batt.StationName1 +
        "&city=" +
        batt.StationName2 +
        "&county=" +
        batt.StationName5 +
        "&home=" +
        batt.StationName3 +
        "&batt=" +
        batt.BattGroupId;
      window.parent.postMessage(
        {
          cmd: "syncPage",
          params: {
            pageInfo: {
              label: "历史数据",
              name: "history",
              src: "#/history" + search,
              closable: true
            }
          }
        },
        "*"
      );
    },
    // 停止测试
    stopTest() {
      this.$layer.confirm('停止测试',{icon: 3}, (index)=>{
        // 关闭询问层
        this.$layer.close(index);
        // 根据设备id进行停止
        if(regEquipType(this.batt.FBSDeviceId, 'equip61850')) {
          // 停止设备
          this.stop61850Test();
        }else {
          // 提示信息
          this.$layer.msg('未知设备类型,暂无法停止测试!');
        }
      });
    },
    // 停止61850测试
    stop61850Test() {
      // 开启等待框
      let loading = this.$layer.loading(1);
      // 请求后台
      this.$apis.dischargeTest.e61850.stop({
        num: const_61850.cmd.stop,
        dev_id: this.batt.FBSDeviceId
      }).then(res=>{
        let rs = JSON.parse(res.data.result);
        if(rs.code == 1) {
            // 提示信息
            this.$layer.msg('停止测试成功');
        }else {
            // 提示信息
            this.$layer.msg('停止测试失败!');
        }
        // 关闭等待框
        this.$layer.close(loading);
      }).catch(error=>{
        console.log(error);
        // 关闭等待框
        this.$layer.close(loading);
        // 提示信息
        this.$layer.msg('停止测试失败,停止测试请求异常!');
      });
    }
  },
  computed: {
    battFullName() {
      let batt = this.batt;
      if (batt.StationName && batt.BattGroupName) {
        return batt.StationName + "-" + batt.BattGroupName;
      }
      return "电池组全称";
    },
    backInputs() {
      const obj = {
          0: "未知",
          1: "浮充",
          2: "充电",
          3: "放电",
          4: "均充"
        },
        list = {
          batt_state: "未知",
          group_online_vol: "在线:0.00V;组端:0.00V",
          group_curr: "0.00A",
          rec_datetime: "1982-01-01 00:00:00",
          batt_test_tlong: formatSeconds(0),
          batt_test_cap: "0Ah",
          batt_syrl_cap: "---",
          sysc: "------"
        };
      if (this.diagram.type == -1) {
        return list;
      }
      list.batt_state = obj[this.inputs.batt_state];
      list.group_online_vol = `在线:${this.inputs.online_vol.toFixed(
        2
      )}V;组端:${this.inputs.group_vol.toFixed(2)}V`;
      list.group_curr = this.inputs.group_curr.toFixed(2) + "A";
      list.rec_datetime = this.inputs.rec_datetime;
      list.batt_test_tlong = formatSeconds(this.inputs.batt_test_tlong);
 
      list.batt_test_cap = this.inputs.batt_test_cap.toFixed(1) + "AH";
      if (this.inputs.batt_state === 2) {
        list.batt_syrl_cap = "---";
      } else {
        list.batt_syrl_cap = this.inputs.batt_rest_cap.toFixed(1) + "AH";
      }
      if (this.inputs.batt_state === 3) {
        list.sysc = sethoubeiTime(
          parseFloat(this.inputs.batt_rest_cap) /
            parseFloat(this.inputs.group_curr)
        );
      } else {
        list.sysc = "------";
      }
      return list;
    },
    showStateList() {
      return this.stateList.filter(item => {
        if (item.show) {
          return item;
        }
      });
    },
    dischargeDialogTitle() {
      let batt = this.batt;
      if (regEquipType(batt.FBSDeviceId, "equip61850")) {
        return "61850放电参数设置";
      } else {
        return "未知设备(待开发)"
      }
    },
    showControl() {
      if(this.username == 'superuser' || this.username == 'admin') {
        return true;
      }else {
        return false;
      }
    }
  },
  mounted() {
    // 初始化图表
    this.initChart();
 
    this.$nextTick(() => {
      this.$G.chartManage.resize(this.acTabs);
    });
 
    // 屏幕缩放时触发
    window.addEventListener("resize", () => {
      this.resize();
    });
  },
  destroyed() {
    this.timer.stop();
  }
};
</script>
 
<style scoped>
.page-real-time {
  color: #ffffff;
}
.table-cell.text-right {
  font-size: 14px;
}
.table-cell.text-right .iconfont {
  margin-right: 4px;
}
.table-row.table-row-error {
  color: #ff0000;
}
.table-row.table-row-warn {
  color: #e6a23c;
}
.table-row .table-cell {
  padding-top: 12px;
}
.page-content {
  position: relative;
  padding-top: 8px;
  padding-bottom: 2px;
  box-sizing: border-box;
  height: 100%;
}
.box-tools {
  line-height: 32px;
}
.box-tools .iconfont {
  font-size: 20px;
}
.box-tools .iconfont:hover {
  cursor: pointer;
  color: #cfcfcf;
}
.box-tools .iconfont:active {
  color: #ff0000;
}
.page-content-tools {
  position: absolute;
  top: 14px;
  right: 8px;
  z-index: 99;
}
.hdw-btn {
  display: inline-block;
  color: #fff;
  background-color: #409eff;
  border-color: #409eff;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  text-align: center;
  box-sizing: border-box;
  outline: none;
  margin: 0;
  transition: 0.1s;
  font-weight: 500;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  padding: 6px 10px;
  font-size: 14px;
  border-radius: 4px;
}
.hdw-btn:hover {
  background-color: #3c91e6;
}
.hdw-menu-list {
  border: 1px solid #409eff;
}
.hdw-menu-list .hdw-menu-item {
  border-top: 1px solid #0e5194;
}
.hdw-menu-list .hdw-menu-item:first-child {
  border-top: none;
}
.hdw-menu-item a {
  display: block;
  text-align: center;
  padding: 8px;
  color: #ffffff;
  cursor: pointer;
  background-color: rgba(30, 125, 219, 0.767);
}
.hdw-menu-item a:hover {
  background-color: rgb(60, 135, 211);
}
.hdw-menu-item a:active {
  background-color: rgb(34, 100, 167);
}
.hdw-state-list {
  box-sizing: border-box;
  font-size: 14px;
  padding-bottom: 8px;
}
</style>