longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
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
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
<template>
    <flex-layout direction="row" class="page-history" :no-bg="true" :loading="loading">
        <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>
            <div slot="box-tools" class="box-tools" style="right: 36px;">
                <el-tooltip class="item" effect="dark" content="数据对比" placement="bottom">
                    <i class="iconfont el-icon-jiankong" @click="toShowComparison"></i>
                </el-tooltip>
            </div>
            <div slot="box-tools" class="box-tools" style="right: 65px;">
                <el-tooltip class="item" effect="dark" content="数据导出" placement="bottom">
                    <i class="iconfont el-icon-daochu" @click="showDataDifferDialog" style="font-size: 24px"></i>
                </el-tooltip>
            </div>
            <div slot="box-tools" class="box-tools" style="right: 96px;">
                <el-tooltip class="item" effect="dark" content="标准曲线" placement="bottom">
                    <i class="iconfont el-icon-biaozhunquxian" @click="confirmAddStandardLine"
                        style="font-size: 20px"></i>
                </el-tooltip>
            </div>
            <div slot="box-tools" class="box-tools" style="right: 125px;display: flex;align-items: center;width:160px">
                <label style="font-size:12px;margin-right:8px">显示粒度:</label>
                <el-select v-model="show_num" size="small" style="width:90px" @change="testRecordChange">
                    <el-option :value="1" label="×1"></el-option>
                    <el-option :value="2" label="×2"></el-option>
                    <el-option :value="3" label="×3"></el-option>
                    <el-option :value="4" label="×4"></el-option>
                    <el-option :value="5" label="×5"></el-option>
                    <el-option :value="6" label="×6"></el-option>
                    <el-option :value="7" label="×7"></el-option>
                    <el-option :value="8" label="×8"></el-option>
                    <el-option :value="9" label="×9"></el-option>
                    <el-option :value="10" label="×10"></el-option>
                </el-select>
            </div>
            <flex-layout :no-bg="true">
                <div class="content-header" slot="header">
                    <div class="table-layout">
                        <div class="table-row">
                            <div class="table-cell text-right w80">电池状态:</div>
                            <div class="table-cell">
                                <el-input v-model="formateBattState" placeholder="" size="small" :disabled="true">
                                </el-input>
                            </div>
                            <div class="table-cell text-right w80">端电压:</div>
                            <div class="table-cell">
                                <el-input v-model="top.group" placeholder="" size="small" :disabled="true"
                                    style="min-width:12rem"></el-input>
                            </div>
                            <div class="table-cell text-right w80">电池电流:</div>
                            <div class="table-cell">
                                <el-input v-model="top.curr" placeholder="" size="small" :disabled="true"></el-input>
                            </div>
                            <div class="table-cell text-right w80">测试时长:</div>
                            <div class="table-cell">
                                <el-input v-model="top.test_long" placeholder="" 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-cascader v-if="isAio" v-model="test_record1.value" :options="test_record1.list" size="small"
                                            placeholder="请选择测试日期" style="width: 100%; min-width:16rem"
                                            @change="testRecordChange">
                                <template slot-scope="{ node, data }">
                                  <span>{{ data.label }}</span>
                                  <span v-if="!node.isLeaf"> ({{data.children.length }})</span>
                                </template>
                              </el-cascader>
                                <el-cascader v-else  v-model="test_record.value" :options="test_record.list" size="small"
                                    placeholder="请选择测试日期" style="width: 100%; min-width:16rem"
                                    @change="testRecordChange">
                                    <template slot-scope="{ node, data }">
                                        <span>{{ data.label }}</span>
                                        <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
                                    </template>
                                </el-cascader>
                            </div>
                            <div class="table-cell text-right w80">测试容量:</div>
                            <div class="table-cell">
                                <el-input v-model="top.test_cap" placeholder="" size="small" :disabled="true">
                                </el-input>
                            </div>
                            <div class="table-cell text-right w80">剩余容量:</div>
                            <div class="table-cell">
                                <el-input v-model="top.re_cap" placeholder="" size="small" :disabled="true"></el-input>
                            </div>
 
                            <div class="table-cell text-right w80">续航时长:</div>
                            <div class="table-cell">
                                <el-tooltip class="item" effect="dark" content="机房停电时电池对实际负载供电时长" placement="top">
                                    <el-input v-model="top.xuhang" placeholder="" size="small" :disabled="true">
                                    </el-input>
                                </el-tooltip>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="page-content">
                    <div class="flex-box-list">
                        <div class="flex-box" style="margin-bottom: 8px;">
                            <chart-wrapper :title="groupVolTitle">
                                <line-chart ref="groupVol" id="groupVol" unit="V"></line-chart>
                            </chart-wrapper>
                        </div>
                        <div class="flex-box" style="margin-bottom: 8px;">
                            <chart-wrapper :title="monBarTitle">
                                <div class="chart-tools-wrapper">
                                    <el-select v-model="chartType" size="mini" @change="changeChartType">
                                        <el-option v-for="item in chartTypes" :key="item.value" :label="item.label"
                                            :value="item.value"></el-option>
                                    </el-select>
                                </div>
                                <bar-chart ref="monBar" id="monBar" :show-label="false"></bar-chart>
                            </chart-wrapper>
                        </div>
                    </div>
                    <div class="flex-box-list">
                        <div class="flex-box" style="margin-top: 8px;">
                            <chart-wrapper title="电池电流折线图(A)">
                                <line-chart ref="groupCurr" id="groupCurr" unit="A" start-zero></line-chart>
                            </chart-wrapper>
                        </div>
                        <div class="flex-box" style="margin-top: 8px;">
                            <chart-wrapper :title="monInfo.title">
                                <line-chart ref="monInfo" id="monInfo" :unit="monInfo.unit"></line-chart>
                            </chart-wrapper>
                        </div>
                    </div>
                </div>
                <div class="content-footer" slot="footer">
                    <div class="slider-container">
                        <el-slider v-model="slider" size="small" :format-tooltip="formatTooltip" @input="sliderInput">
                        </el-slider>
                    </div>
                </div>
            </flex-layout>
        </content-box>
        <el-dialog title="历史数据对比" width="1200px" :visible.sync="showComparison" v-if="showComparison"
            :close-on-click-modal="false" top="0" class="dialog-center" :modal-append-to-body="false">
            <comparison :test_record="test_record"></comparison>
        </el-dialog>
      <!-- 电压/温度差 -->
      <el-dialog
          title="电压/温度差分析"
          width="auto"
          :visible.sync="dataDiffter"
          :close-on-click-modal="false"
          top="0"
          class="dialog-center">
        <data-diffter
            v-if="dataDiffter" :visible.sync="dataDiffter"
            :vol="volDiffer" :temp="tempDiffer" @success="ensureExportExcel"></data-diffter>
      </el-dialog>
        <div id="allGraph">
            <div class="chart-contain">
                <div class="chart" ref="allGraph"></div>
            </div>
        </div>
        <form :action="exportInfo.action" method="post" ref="all_picture" enctype="multipart/form-data">
            <input type="hidden" id="exPageName" name="pageName" value="exportTbal" />
            <input type="hidden" name="ltop_echart" ref="ltop_echart" value="" />
            <input type="hidden" name="rtop_echart" ref="rtop_echart" value="" />
            <input type="hidden" name="lbottom_echart" ref="lbottom_echart" value="" />
            <input type="hidden" name="rbottom_echart" ref="rbottom_echart" value="" />
            <input type="hidden" name="actucap_echart" ref="actucap_echart" value="" />
            <input type="hidden" name="restcap_echart" ref="restcap_echart" value="" />
            <input type="hidden" name="capperc_echart" ref="capperc_echart" value="" />
            <input type="hidden" name="tmp_echart" ref="tmp_echart" value=""> <!-- 单体温度折线图 -->
            <input type="hidden" name="mon_res" ref="mon_res" value=""> <!-- 单体内阻 -->
            <input type="hidden" name="JH_curr" ref="JH_curr" value=""> <!-- 单体均衡电流 -->
            <input type="hidden" name="last_vol" ref="last_vol" value=""> <!-- 终止电压柱状图 -->
            <input type="hidden" name="last_tmp" ref="last_tmp" value=""> <!-- 终止温度柱状图 -->
            <input type="hidden" name="restcap_line_echart" ref="restcap_line_echart" value=""> <!-- 剩余容量 -->
            <input type="hidden" name="group_vol_qth" ref="group_vol_qth">
            <!--驼峰锅底-->
 
            <input type="hidden" name="obj-bmd" ref="obj_bmd" value="" />
            <input type="hidden" name="obj-title" ref="obj_title" value="" /> <!-- 落后单体阀值信息 -->
            <input type="hidden" name="arr-data" ref="arr_data" value="" />
            <!--存放单体的起始信息二维数组-->
            <input type="hidden" name="mon-vol-list" ref="mon_vol_list" value="" /> <!-- 所有单体电压测试信息 -->
            <input type="hidden" name="mon-tmp-list" ref="mon_tmp_list" value="" /> <!-- 所有单体温度测试信息 -->
            <input type="hidden" name="mon-group-list" ref="mon_group_list" value="" /> <!-- 在线电压 -->
 
            <!-- 电压/温度对比数据 -->
            <input type="hidden" name="splitTime" ref="splitTime" value="" />
            <input type="hidden" name="mon_vol_compare_pic" ref="mon_vol_compare_pic" value="" />
            <input type="hidden" name="mon_temp_compare_pic" ref="mon_temp_compare_pic" value="" />
            <input type="hidden" name="time-compare-list" ref="time_compare_list" value="" />
            <input type="hidden" name="mon-vol-compare-list" ref="mon_vol_compare_list" value="" />
            <input type="hidden" name="mon-tmp-compare-list" ref="mon_tmp_compare_list" value="" />
        </form>
    </flex-layout>
</template>
 
<script>
    import echarts from "echarts"
    import ContentBox from "../../components/ContentBox";
    import HomeList from "./HomeList";
    import BarChart from "../../components/chart/BarChart";
    import LineChart from "../../components/chart/LineChart";
    import ChartWrapper from "@/components/ChartWrapper";
    import chartImage from '@/assets/images/eleOn.gif'
    import comparison from '../../components/comparisonData/comparison.vue'
    import getSpecialPointIndex from "@/assets/js/tools/getSpecialPointIndex";
    import getQgth from "@/assets/js/tools/getQgth";
    import {
        searchAll_lowAction,
        searchBattresdata,
        searchBattTestData,
        searchBattTestDataStop,
        searchHistory
    } from "../../assets/js/history";
 
    import {
        formatSeconds,
        GetMonomerCap,
        GetHourRate,
        getBarNum,
        Title,
        getLow,
        regEquipType,
        sethoubeiTime,
    } from "../../assets/js/tools";
 
    let Titleobj = new Title();
    import ECharts from "echarts/lib/echarts";
    //引入折线图
    import "echarts/lib/chart/bar";
    import "echarts/lib/chart/line"
    //引入提示框
    import "echarts/lib/component/tooltip";
    //引入标题
    import "echarts/lib/component/title";
    //引入图例标志
    import "echarts/lib/component/legend";
    //区域缩放
    import "echarts/lib/component/dataZoom";
 
    //markeline
    import "echarts/lib/component/markLine"
 
    // 引入自定义主题
    import "@/components/chart/theme/transparent"
    import DataDiffter from "@/pages/dataTest/dialogs/DataDiffter";
    import getMinInfo from "@/assets/js/tools/getMinInfo";
    import getMaxInfo from "@/assets/js/tools/getMaxInfo";
    // 端信息
    let allData = {
        groupVol: [],
        onlineVol: [],
        testCurr: [],
        testTimeLong: [],
        monNumList: [],
        recordTime: [],
        testCap: [],
        dataList: [],
        endData: {}
    };
    // 单体折线信息
    let monLineData = {
        vol: [], // 单体电压
        temp: [], // 单体温度
        realCap: [], // 单体实际容量
        resCap: [], // 单体剩余容量
        preCap: [] // 单体容量百分比
    };
    // 单体柱状信息
    let monBarData = {
        vol: [], // 单体电压
        temp: [], // 单体温度
        realCap: [], // 单体实际容量
        resCap: [], // 单体剩余容量
        preCap: [], // 单体容量百分比
        jh_curr: [], // 单体均衡电流
        res: [], // 单体内阻
    };
    // 4个图表
    let groupVolLineChart, currLineChart, monLineChart, monBarChart;
    let allGraph;
    export default {
        components: {
          DataDiffter,
            ContentBox,
            HomeList,
            BarChart,
            LineChart,
            ChartWrapper,
            comparison
        },
        data() {
            let baseURL = this.$axios.defaults.baseURL;
            baseURL = baseURL ? baseURL : "";
            return {
                HistoryData: [],
                show_num: 5,
                humpPotBottom: true,   // 驼峰锅底
                loading: false,
                isNew: true,
                showComparison: false,
                dataDiffter: false,
                volDiffer: [],
                tempDiffer: [],
                data: [],
                batt: {},
                groupVolTitle: '端电压折线图(V)',
                groupVolQth: {
                    code: 0,
                    low: 0,
                    lowTime: '00:00:00',
                    high: 0,
                    highTime: '00:00:00',
                    qt: 0,
                    qg: 0,
                    qh: 0,
                    title: '正常'
                },
                top: {
                    state: "", // 电池状态
                    group: "", // 端电压
                    curr: "", // 电池电流
                    test_long: "", // 测试时长
                    test_cap: "", // 测试容量
                    re_cap: "", // 剩余容量
                    xuhang: "" // 续航时长
                },
                test_record: {
                    value: [],
                    list: [{
                            value: "herongDischarge",
                            label: "核容放电",
                            children: []
                        },
                        {
                            value: "jianceDischarge",
                            label: "监测放电",
                            children: []
                        },
                        {
                            value: "herongCharge",
                            label: "核容充电",
                            children: []
                        },
                        {
                            value: "jianceCharge",
                            label: "监测充电",
                            children: []
                        }
                    ]
                },
                test_record1: {
                  value: [],
                  list: [
                    {
                      value: 0,
                      label: "电池组1",
                      children: [
                        {
                          value: "herongDischarge",
                          label: "核容放电",
                          children: []
                        },
                        {
                          value: "jianceDischarge",
                          label: "监测放电",
                          children: []
                        },
                        {
                          value: "herongCharge",
                          label: "核容充电",
                          children: []
                        },
                        {
                          value: "jianceCharge",
                          label: "监测充电",
                          children: []
                        }
                      ]
                    },
                    {
                      value: 1,
                      label: "电池组2",
                      children: [
                        {
                          value: "herongDischarge",
                          label: "核容放电",
                          children: []
                        },
                        {
                          value: "jianceDischarge",
                          label: "监测放电",
                          children: []
                        },
                        {
                          value: "herongCharge",
                          label: "核容充电",
                          children: []
                        },
                        {
                          value: "jianceCharge",
                          label: "监测充电",
                          children: []
                        }
                      ]
                    },
                  ]
                },
                slider: 100,
                testTimeLong: [],
                battState: {
                    test_type: -100,
                    stop_reason: ''
                },
                monBarTitle: "最大值=0V;最小值=0V;平均值=0V",
                chartType: 'vol',
                chartTypes: [{
                        label: '单体电压',
                        value: 'vol',
                        unit: 'V',
                        fixed: 3,
                    },
                    {
                        label: '单体温度',
                        value: 'temp',
                        unit: '℃',
                        fixed: 1,
                    },
                    {
                        label: '单体实际容量',
                        value: 'realCap',
                        unit: 'AH',
                        fixed: 0,
                    },
                    {
                        label: '单体剩余容量',
                        value: 'resCap',
                        unit: 'AH',
                        fixed: 0,
                    },
                    {
                        label: '单体容量百分比',
                        value: 'preCap',
                        unit: '%',
                        fixed: 0
                    }
                ],
                exportInfo: {
                    action: baseURL + "EchartPictureDowload.servlet",
                    ltop_echart: "", // 组端电压折线图
                    rtop_echart: "", // 单体电压柱状图
                    lbottom_echart: "", // 测试电流
                    rbottom_echart: "", // 单体电压折线图
                    actucap_echart: "", // 实际容量
                    restcap_echart: "", // 剩余容量
                    capperc_echart: "", // 容量百分比
                    tmp_echart: "", // 单体温度折线图
                    mon_res: "", // 单体内阻
                    JH_curr: "", // 单体均衡电流
                    last_vol: "", // 终止电压柱状图
                    last_tmp: "", // 终止温度柱状图
                    restcap_line_echart: "", // 剩余容量
                    obj_bmd: "", //
                    obj_title: "", // 落后单体阀值信息
                    arr_data: [], // 存放单体的起始信息二维数组
                    mon_vol_list: [], // 所有单体电压测试信息
                    mon_tmp_list: [], // 所有单体温度测试信息
                    mon_group_list: [] // 所有单体温度测试信息
                },
                low_list: [],
                monInfo: {
                    title: "单体电压(V)",
                    unit: "V",
                }
            }
 
        },
        methods: {
            changeShow() {
                // 端信息
                allData = {
                    groupVol: [],
                    onlineVol: [],
                    testCurr: [],
                    testTimeLong: [],
                    monNumList: [],
                    recordTime: [],
                    testCap: [],
                    dataList: [],
                    endData: {}
                };
                // 单体折线信息
                monLineData = {
                    vol: [], // 单体电压
                    temp: [], // 单体温度
                    realCap: [], // 单体实际容量
                    resCap: [], // 单体剩余容量
                    preCap: [] // 单体容量百分比
                };
                // 单体柱状信息
                monBarData = {
                    vol: [], // 单体电压
                    temp: [], // 单体温度
                    realCap: [], // 单体实际容量
                    resCap: [], // 单体剩余容量
                    preCap: [], // 单体容量百分比
                    jh_curr: [], // 单体均衡电流
                    res: [], // 单体内阻
                };
                this.formateHisData(this.HistoryData);
            },
            toggleChange() {
                this.resize();
            },
            resize() {
                this.$G.chartManage.resize("groupVol");
                this.$G.chartManage.resize("monBar");
                this.$G.chartManage.resize("groupCurr");
                this.$G.chartManage.resize("monInfo");
            },
            leafClick(data) {
                this.batt = data;
                // 如果是LD9就跳转到LD9的历史页面
                if (regEquipType(data.FBSDeviceId, 'LD9')) {
                  let search =
                    "?province=" +
                    data.StationName1 +
                    "&city=" +
                    data.StationName2 +
                    "&county=" +
                    data.StationName5 +
                    "&home=" +
                    data.StationName3 +
                    "&batt=" +
                    data.BattGroupId;
                  window.parent.postMessage(
                    {
                      cmd: "syncPage",
                      params: {
                        pageInfo: {
                          label: "历史数据",
                          name: "history",
                          src: '#/history-ld9' + search,
                          closable: true,
                        },
                      },
                    },
                    "*"
                  );
                  return;
                }
                // 重置页面内容
                this.init();
                // 获取充放电记录
                this.searchBattTestData();
                this.isNew = false;
            },
            // 初始化页面数据
            init() {
                // 初始化充放电记录
                this.test_record.value = [];
                this.test_record.list[0].children = [];
                this.test_record.list[1].children = [];
                this.test_record.list[2].children = [];
                this.test_record.list[3].children = [];
 
                // 初始化A059充放电记录
                if(this.isAio) {
                  this.test_record1.value = [];
                  this.test_record1.list.map(item=>{
                    item.children.map(item1=>{
                      item1.children = [];
                    });
                  });
                }
 
                // 初始化顶部文本框内容
                this.top = {
                    state: "", // 电池状态
                    group: "", // 端电压
                    curr: "", // 电池电流
                    test_long: "", // 测试时长
                    test_cap: "", // 测试容量
                    re_cap: "", // 剩余容量
                    xuhang: "---" // 续航时长
                };
 
                // 初始化电池状态
                this.battState.test_type = -100;
 
                // 初始化图表
                this.initChart();
            },
            // 初始化图表和图表数据
            initChart() {
                let batt = this.batt;
                // 拖动条默认值100
                this.slider = 100;
                this.testTimeLong = [];
 
                // 端信息
                allData = {
                    groupVol: [],
                    onlineVol: [],
                    testCurr: [],
                    testTimeLong: [],
                    recordTime: [],
                    testCap: [],
                    monNumList: [],
                    dataList: [],
                };
                let monCount = batt.MonCount;
                console.log(batt);
                // 锂电池包
                if(regEquipType(batt.FBSDeviceId, "lithiumPack")) {
                  monCount = monCount*batt.packCount;
                }
                console.log(monCount);
                for (let i = 1; i <= monCount; i++) {
                    allData.monNumList[i - 1] = ("#" + i);
                }
                // 单体折线信息
                monLineData = {
                    vol: [], // 单体电压
                    temp: [], // 单体温度
                    realCap: [], // 单体实际容量
                    resCap: [], // 单体剩余容量
                    preCap: [] // 单体容量百分比
                };
                // 单体柱状信息
                monBarData = {
                    vol: [], // 单体电压
                    temp: [], // 单体温度
                    realCap: [], // 单体实际容量
                    resCap: [], // 单体剩余容量
                    preCap: [], // 单体容量百分比
                    jh_curr: [], // 单体均衡电流
                    res: [], // 单体内阻
                };
 
                // 初始化图表的配置项
                this.initChartOptions();
 
                // 设置折线图
                this.setLineChart();
 
                // 设置柱状图
                this.setBarChart();
            },
            initChartOptions() {
                // 端电压折线图
                groupVolLineChart = {
                    color: ["#0081ff", "#df9d02"],
                    title: {
                        show: false,
                        text: "端电压折线图(V)",
                        x: "left",
                        textStyle: {
                            fontSize: "14"
                        }
                    },
                    legend: {
                        show: false,
                        data: ["在线电压", "组端电压"],
                        right: 0,
                        orient: "vertical"
                    },
                    series: [{
                        name: "在线电压",
                        data: []
                    },
                        {
                            name: "组端电压",
                            data: []
                        }
                    ]
                };
 
                // 电池电流折线图
                currLineChart = {
                    title: {
                        show: false,
                        text: "电池电流折线图(A)",
                        x: "center",
                        textStyle: {
                            fontSize: "14"
                        }
                    },
                    series: [{
                        name: "电池电流",
                        areaStyle: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#00feff'
                            }, {
                                offset: 1,
                                color: 'transparent'
                            }])
                        },
                        data: []
                    }]
                };
 
                // 单体信息折线图
                monLineChart = {
                    title: {
                        show: false,
                        text: "单体电压(V)",
                        x: "center",
                        textStyle: {
                            fontSize: "14"
                        }
                    },
                    series: []
                };
 
 
                // 图表类型
                let chartInfo = this.getChartInfo();
                let unit = chartInfo.unit;
                let label = chartInfo.label;
                // 单体信息柱状图
                this.monBarTitle = "最大值=0" + unit + ";最小值=0" + unit + ";平均值=0" + unit;
                monBarChart = {
                    title: {
                        show: false,
                        text: "最大值=0" + unit + ";最小值=0" + unit + ";平均值=0" + unit,
                        x: "center",
                        textStyle: {
                            fontSize: "14"
                        }
                    },
                    series: [{
                        name: "初始值",
                        hColor: '#0B388B',
                        data: []
                    },
                        {
                            name: label,
                            barGap: "-100%",
                            data: []
                        },
                    ]
                };
            },
            // 设置折线图
            setLineChart() {
                // 设置端电压折线图
                this.setGroupVolLineChart();
                // 设置电池电流折线图
                this.setCurrLineChart();
                // 设置单体折线图
                this.setMonLineChart();
                // 建立联动
                this.$G.chartManage.connect(["groupVol", "groupCurr", "monInfo"]);
            },
            // 设置端电压折线图
            setGroupVolLineChart() {
                // 根据allData.groupVol数据设置groupVolLineChart的值
                groupVolLineChart.series[0].data = allData.onlineVol;
                groupVolLineChart.series[1].data = allData.groupVol;
                let specialPoint = getSpecialPointIndex(allData.groupVol.map(item => {
                    return item[1];
                }));
                let markLine = {};
                this.groupVolQth.code = specialPoint.code;
                if (specialPoint.code && this.test_record.value[0] == "herongDischarge" && this.humpPotBottom) {
                    let batt = this.batt;
                    let qgth = getQgth(specialPoint, batt.MonVolStd * batt.MonCount);
                    this.groupVolTitle = qgth.title;
 
                    // 设置groupVolQth
                    this.groupVolQth.code = 1;
                    this.groupVolQth.low = specialPoint.minVal;
                    this.groupVolQth.lowTime = allData.groupVol[specialPoint.min][0];
                    this.groupVolQth.high = specialPoint.maxVal;
                    this.groupVolQth.highTime = allData.groupVol[specialPoint.max][0];
                    this.groupVolQth.qg = qgth.qg;
                    this.groupVolQth.qt = qgth.qt;
                    this.groupVolQth.qh = qgth.qh;
                    this.groupVolQth.title = qgth.label;
 
                    markLine = {
                        data: [{
                                label: {
                                    show: true,
                                    position: 'end',
                                    formatter: [
                                        '{a|Tg:' + allData.groupVol[specialPoint.min][0] + '}' + '{c|}',
                                        '{b|锅底电压Vg:' + allData.groupVol[specialPoint.min][1] + 'V}' + '{c|}'
                                    ].join('\n'),
                                    rich: {
                                        a: {
 
                                        },
                                        b: {
 
                                        },
                                        c: {
                                            width: 60
                                        }
                                    },
                                },
                                xAxis: allData.groupVol[specialPoint.min][0],
                            },
                            {
                                label: {
                                    show: true,
                                    position: 'end',
                                    formatter: [
                                        '{c|}' + '{a|Tt:' + allData.groupVol[specialPoint.max][0] + '}',
                                        '{c|}' + '{b|驼峰电压Vt:' + allData.groupVol[specialPoint.max][1] + 'V}'
                                    ].join('\n'),
                                    rich: {
                                        a: {
 
                                        },
                                        b: {
 
                                        },
                                        c: {
                                            width: 80,
                                        }
                                    },
                                },
                                xAxis: allData.groupVol[specialPoint.max][0],
                            }
                        ]
                    };
                } else {
                    this.groupVolTitle = "端电压折线图(V)";
                }
                groupVolLineChart.series[1].markLine = markLine;
                // 更新图表
                this.$refs.groupVol.setOption(groupVolLineChart);
            },
            // 设置电池电流折线图
            setCurrLineChart() {
                // 根据allData.testCurr数据设置currLineChart的值
                currLineChart.series[0].data = allData.testCurr;
                // 更新图表
                this.$refs.groupCurr.setOption(currLineChart);
            },
            // 设置单体折线图
            setMonLineChart() {
                let chartInfo = this.getChartInfo();
                // 根据monLineData的值设置monLineChart
                let dataList = monLineData.vol;
                let title = chartInfo.label + "(" + chartInfo.unit + ")";
                let unit = chartInfo.unit;
                let isUpdate = true;
                switch (chartInfo.value) {
                    case "vol":
                        dataList = monLineData.vol;
                        break;
                    case "temp":
                        dataList = monLineData.temp;
                        break;
                    case "resCap":
                        dataList = monLineData.resCap;
                        break;
                    default:
                        isUpdate = false;
                        break;
                }
                // 检测是否更新
                if (!isUpdate) {
                    return;
                }
                this.monInfo.title = title;
                this.monInfo.unit = unit;
                monLineChart.title.show = false;
                monLineChart.series = dataList.map((item, index) => {
                    let monNum = "#" + (index + 1);
                    return {
                        name: monNum,
                        data: item
                    };
                });
 
                this.$nextTick(() => {
                    // 更新图表
                    this.$refs.monInfo.setOption(monLineChart);
                });
            },
            // 设置柱状图
            setBarChart() {
                let chartInfo = this.getChartInfo();
                let unit = chartInfo.unit;
                let fixed = chartInfo.fixed;
                // 根据monBarData的值设置monBarChart
                let dataList = this.getBarDataList();
                let index = this.getDataIndex(dataList.length, this.slider);
                if (index != -1) {
                    let data = dataList[index];
                    let batNum = getBarNum(data);
                    monBarChart.title.show = false;
                    monBarChart.title.text = "最大值=" + batNum.max + unit + ";最小值=" + batNum.min + unit + ";平均值=" + batNum
                        .avg.toFixed(fixed) + unit
                    this.monBarTitle = monBarChart.title.text;
                    monBarChart.series[1].name = chartInfo.label;
                    monBarChart.series[1].data = data;
                    monBarChart.series[0].data = dataList[0];
                } else {
                    console.log("未获取到值")
                }
                // 设置柱状图
                this.$refs.monBar.setOption(monBarChart);
            },
            getBarDataList() {
                let chartInfo = this.getChartInfo();
                // 根据monBarData的值设置monBarChart
                let dataList = monBarData.vol;
                switch (chartInfo.value) {
                    case 'vol':
                        dataList = monBarData.vol;
                        break;
                    case 'temp':
                        dataList = monBarData.temp;
                        break;
                    case 'realCap':
                        dataList = monBarData.realCap;
                        break;
                    case 'resCap':
                        dataList = monBarData.resCap;
                        break;
                    case 'preCap':
                        dataList = monBarData.preCap;
                        break;
                    default:
                        dataList = monBarData.vol
                        break;
                }
 
                return dataList;
            },
            // 查询测试信息
            searchBattTestData() {
                let batt = this.batt;
                // 开启等待框
                let loading = this.$layer.loading(1);
                searchBattTestData({
                        num: batt.FBSDeviceId,
                        BattGroupId: batt.BattGroupId
                    })
                    .then(res => {
                        // 关闭等待框
                        this.$layer.close(loading);
                        // 解析数据
                        let rs = JSON.parse(res.data.result);
                        let herongDischarge = []; // 核容放电
                        let herongCharge = []; // 核容充电
                        let jianceDischarge = []; // 监测放电
                        let jianceCharge = []; // 监测充电
                        if (rs.code == 1) {
                            rs.data.forEach(item => {
                                item.value = item.test_starttime;
                                item.label = item.test_starttime;
                                if (item.test_type == 3) {
                                    // 测试类型为放电
                                    if (item.test_starttype == 3) {
                                        //  核容放电
                                        herongDischarge.push(item);
                                    } else {
                                        // 监测放电
                                        jianceDischarge.push(item);
                                    }
                                } else if (item.test_type == 2) {
                                    // 测试类型为充电
                                    if (item.test_starttype == 3) {
                                        //  核容充电
                                        herongCharge.push(item);
                                    } else {
                                        // 监测充电
                                        jianceCharge.push(item);
                                    }
                                }
                            });
                        } else {
                            this.$layer.msg("未获取到充放电记录");
                        }
                        // 充放电记录
                        if(this.isAio) {
                          this.setAioTestRecord(herongDischarge, 0);
                          this.setAioTestRecord(jianceDischarge, 1);
                          this.setAioTestRecord(herongCharge, 2);
                          this.setAioTestRecord(jianceCharge, 3);
                        }else {
                          this.setNormalTestRecord(herongDischarge, jianceDischarge, herongCharge, jianceCharge);
                        }
                    })
                    .catch(error => {
                        this.$layer.close(loading);
                        console.log(error);
                    });
            },
            /**
             * 设置普通类型充放电数据
             */
            setNormalTestRecord(herongDischarge, jianceDischarge, herongCharge, jianceCharge) {
              this.test_record.list[0].children = herongDischarge;
              this.test_record.list[1].children = jianceDischarge;
              this.test_record.list[2].children = herongCharge;
              this.test_record.list[3].children = jianceCharge;
            },
            /**
             * 设置A059充放电数据
             */
            setAioTestRecord(data, index) {
              data.map(item=>{
                // 电池组1充放电数据
                if(item.upload_client_type == 1) {
                  this.test_record1.list[0].children[index].children.push(item);
                }else {
                  this.test_record1.list[1].children[index].children.push(item);
                }
              });
            },
            // 切换测试信息
            testRecordChange() {
                let testRecord = this.getTestRecord();
                // 初始化图表
                this.initChart();
                // 已选择测试信息
                if(testRecord != -1) {
                  let num = testRecord.record_num/this.show_num;    // 根据粒度查询数据
                  // 查询历史数据
                  this.searchHistory(testRecord.BattGroupId, testRecord.test_record_count, num);
                }
 
                // 获取顶部电池组信息
                // this.searchBattTestDataStop(
                //     testRecord.BattGroupId,
                //     testRecord.test_record_count
                // );
            },
            // 查询顶部信息
            searchBattTestDataStop(BattGroupId, count) {
                searchBattTestDataStop(BattGroupId, count).then(res => {
                    let rs = JSON.parse(res.data.result);
                    if (rs.code == 1) {
                        let data = rs.data[0];
                        this.top.test_cap = data.test_cap.toFixed(1) + "AH";
                        this.top.test_long = formatSeconds(data.test_timelong);
                    }
                });
            },
            // 查询历史信息
            searchHistory(BattGroupId, count, num) {
                this.loading = true;
                this.$nextTick(() => {
                    searchHistory({
                        BattGroupId: BattGroupId,
                        test_record_count: count,
                        data_new: Math.floor(num)
                    }).then(res => {
                        this.loading = false;
                        let rs = JSON.parse(res.data.result);
                        let data = [];
                        // 数据
                        if (rs.code == 1) {
                            data = rs.data;
                        }
                        this.HistoryData = data
                        // 格式化数据
                        this.formateHisData(data);
                        this.searchBattresdata();
                    }).catch(error => {
                        this.loading = false;
                        console.log(error);
                    });
                });
 
            },
            // 格式化历史信息数据
            formateHisData(data) {
                // let filterData = data.filter((item, i) => {
                //     if (item.record_num % this.show_num == 0) {
                //         return item
                //     }
                // })
                let record_time = -1; // 记录时间
                let record_num = -100; // 记录笔数
                allData.endData = data[data.length - 1];
                data.forEach(item => {
                    let mon_num = item.mon_num;
                    let testTimeLong = formatSeconds(item.test_timelong);
                    // 获取组端电压,在线电压,组端电流的信息和开辟一个单体柱状图
                    if (record_num != item.record_num) {
                        record_time = item.record_time;
                        record_num = item.record_num;
                        allData.groupVol.push([testTimeLong, item.group_vol]);
                        allData.onlineVol.push([testTimeLong, item.online_vol]);
                        allData.testCurr.push([testTimeLong, item.test_curr]);
                        allData.recordTime.push(testTimeLong);
                        allData.testTimeLong.push(item.test_timelong);
                        allData.testCap.push(item.test_cap);
                        allData.dataList.push(item);
                        this.testTimeLong.push(item.test_timelong);
                        // 开辟空间
                        monBarData.vol.push([]);
                        monBarData.temp.push([]);
                        monBarData.realCap.push([]);
                        monBarData.resCap.push([]);
                        monBarData.preCap.push([]);
                    }
                    // 单体电压柱状图设置
                    let mon_num_text = "#" + mon_num;
                    let monBarVol = monBarData.vol[monBarData.vol.length - 1];
                    monBarVol.push([mon_num_text, item.mon_vol]);
 
                    // 单体温度柱状图
                    let monBarTemp = monBarData.temp[monBarData.temp.length - 1];
                    monBarTemp.push([mon_num_text, item.mon_tmp]);
 
                    // 设置单体折线图信息
                    if (typeof monLineData.vol[mon_num - 1] != "object") {
                        let index = mon_num - 1;
                        // 开辟空间
                        monLineData.vol[index] = [];
                        monLineData.temp[index] = [];
                        monLineData.resCap[index] = [];
                    }
                    // 获取到需要使用的空间
                    let monLineVol = monLineData.vol[mon_num - 1];
                    monLineVol.push([testTimeLong, item.mon_vol]);
 
                    let monLineTemp = monLineData.temp[mon_num - 1];
                    monLineTemp.push([testTimeLong, item.mon_tmp]);
                });
 
                // 初始化图表的配置项
                this.initChartOptions();
 
                // 设置容量
                this.setCapList();
                // 设置折线图表
                this.setLineChart();
                // 执行滑动事件
                this.sliderInput();
            },
            setCapList() {
                let batt = this.batt;
                let batt_test_data = monBarData.vol;
                let batt_test_evary_record = allData.dataList;
                for (let i = 0; i < batt_test_data.length; i++) {
                    let vol_list = batt_test_data[i].map(item => {
                        return item[1];
                    });
                    let max_vol = Math.max.apply(null, vol_list);
                    for (let j = 0; j < vol_list.length; j++) {
                        let avg_curr = batt_test_evary_record[i].test_timelong > 0 ? batt_test_evary_record[i]
                            .test_cap * 3600 / batt_test_evary_record[i].test_timelong : batt_test_evary_record[i]
                            .test_curr;
                        let actionvalue = GetMonomerCap(batt.MonCapStd, GetHourRate(batt.MonCapStd, avg_curr),
                            batt_test_evary_record[i].test_cap, max_vol, vol_list[j], batt.MonVolStd, 1);
                        let restvalue = GetMonomerCap(batt.MonCapStd, GetHourRate(batt.MonCapStd, avg_curr),
                            batt_test_evary_record[i].test_cap, max_vol, vol_list[j], batt.MonVolStd, 0);
                        let batt_num_text = "#" + (j + 1);
                        monBarData.realCap[i].push([batt_num_text, actionvalue.toFixed(0)]);
                        monBarData.resCap[i].push([batt_num_text, restvalue.toFixed(0)]);
                        monBarData.preCap[i].push([batt_num_text, (actionvalue * 100 / batt.MonCapStd).toFixed(0)]);
                    }
                }
                // 容量
                monLineData.vol.forEach((item, key) => {
                    item.forEach((volItem, volItemKey) => {
                        let resCapItem = monBarData.resCap[volItemKey];
                        if(resCapItem) {
                            monLineData.resCap[key].push([volItem[0], resCapItem[key][1]]);
                        }
                    });
                });
            },
            // 获取测试的信息
            getTestRecord() {
                let value = this.test_record.value;
                // A059设备
                if(this.isAio) {
                  value = this.test_record1.value;
                }
                // 没有选择充放电记录,返回-1
                if (value.length == 0) {
                    return -1;
                }
                let type = value[0];
                let time = value[1];
                let list = this.test_record.list;
                // A059设备
                if(this.isAio) {
                  value = this.test_record1.value;
                  let index = value[0];
                  type = value[1];
                  time = value[2];
                  list = this.test_record1.list[index].children;
                }
                let result = 0;
                // 遍历list
                for (let i in list) {
                    let item = list[i];
                    if (item.value == type) {
                        for (let j in item.children) {
                            let child = item.children[j];
                            if (child.value == time) {
                                result = child;
                                break;
                            }
                        }
                        break;
                    }
                }
                // 设置电池状态
                this.battState.test_type = result.test_type;
                this.battState.stop_reason = result.test_stoptype_reason;
                // 返回结果集
                return result;
            },
            // 格式化滑块显示的内容
            formatTooltip(value) {
                let testTimeLong = this.testTimeLong;
                let index = this.getDataIndex(testTimeLong.length, value);
                let test_long = formatSeconds(0);
                if (index != -1) {
                    test_long = formatSeconds(testTimeLong[index]);
                }
                this.top.test_long = test_long;
                return test_long;
            },
            // 拖动滑块时触发
            sliderInput() {
                // 设置头部信息
                this.setTopData();
 
                // 设置柱状图
                this.setBarChart();
            },
            // 设置顶部文本框的数据
            setTopData() {
                let batt = this.batt;
                // 组端电压和在线电压
                let groupVol = allData.groupVol;
                let onlineVol = allData.onlineVol;
                let testCurr = allData.testCurr;
                let testCap = allData.testCap;
                let monVols = monBarData.vol;
                let dataList = allData.dataList;
                let index = this.getDataIndex(groupVol.length, this.slider);
                if (index != -1) {
                    this.top.group =
                        "在线:" +
                        onlineVol[index][1].toFixed(2) +
                        "V;组端:" +
                        groupVol[index][1].toFixed(2) +
                        "V";
                    this.top.curr = testCurr[index][1].toFixed(1) + "A";
                    this.top.test_cap = testCap[index].toFixed(1) + "AH";
                    // 剩余容量
                    let monVol = monVols[index];
                    let list = dataList[index];
                    let avg_curr = list.test_timelong > 0 ? list.test_cap * 3600 / list.test_timelong : list.test_curr;
                    let batNum = getBarNum(monVol);
                    let over_cap = GetMonomerCap(batt.MonCapStd, GetHourRate(batt.MonCapStd, avg_curr),
                        list.test_cap, batNum.max, batNum.min, batt.MonVolStd, 0);
                    this.top.re_cap = over_cap.toFixed(1) + 'AH';
 
                }
                // 设置续航时长
                let lastIndex = this.getDataIndex(groupVol.length, 100);
                if (lastIndex != -1) {
                    // 实际容量
                    let monVol = monVols[lastIndex];
                    let list = dataList[lastIndex];
                    let avg_curr = list.test_timelong > 0 ? list.test_cap * 3600 / list.test_timelong : list.test_curr;
                    let batNum = getBarNum(monVol);
                    let real_cap = GetMonomerCap(batt.MonCapStd, GetHourRate(batt.MonCapStd, avg_curr),
                        list.test_cap, batNum.max, batNum.min, batt.MonVolStd, 1);
                    let xuhang = batt.Load_curr ? real_cap / batt.Load_curr : 0;
                    this.top.xuhang = xuhang ? sethoubeiTime(xuhang) : '---';
                }
            },
            // 根据百分比获取显示的数据的笔数
            getDataIndex(num, percent) {
                if (percent <= 0) {
                    return 0;
                }
                return Math.floor(num * percent / 100) - 1;
            },
            // 向父级发送同步页面的指令
            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: 'movingRingSysteRrealTime',
                            src: '#/moving-ring-system' + search,
                            closable: true,
                        }
                    },
                }, "*");
            },
            toShowComparison() {
                this.showComparison = true;
            },
            getChartInfo() {
                let chartType = this.chartType;
                let chartTypes = this.chartTypes;
                let chartTypeInfo = chartTypes[0];
                for (let i = 0; i < chartTypes.length; i++) {
                    if (chartType == chartTypes[i].value) {
                        chartTypeInfo = chartTypes[i];
                        break;
                    }
                }
                return chartTypeInfo;
            },
            changeChartType() {
                if (allData.groupVol.length == 0) {
                    this.initChart();
                } else {
                    let loading = this.$layer.loading();
                    setTimeout(() => {
                        this.setBarChart();
                        this.setMonLineChart();
                        this.$layer.close(loading);
                    }, 100);
                }
            },
            showDataDifferDialog() {
              if (allData.groupVol.length == 0) {
                this.$layer.msg('暂无数据导出,请先选择充放电数据!');
                return false;
              }
 
              this.volDiffer = monLineData.vol;
              this.tempDiffer = monLineData.temp;
              this.$nextTick(()=>{
                this.dataDiffter = true;
              });
            },
            ensureExportExcel(data) {
              // 关闭弹出框
              this.dataDiffter = false;
              // 定义导出
              this.loading = true;
 
              setTimeout(()=>{
                // 对数据进行处理
                this.$refs.splitTime.value = data.splitTime;
                this.$refs.mon_vol_compare_pic.value = data.mon_vol_compare_pic;
                this.$refs.mon_temp_compare_pic.value = data.mon_temp_compare_pic;
                this.$refs.time_compare_list.value = data.time_compare_list;
                this.$refs.mon_vol_compare_list.value = data.mon_vol_compare_list;
                this.$refs.mon_tmp_compare_list.value = data.mon_tmp_compare_list;
                this.$nextTick(()=>{
                  this.exportExcel();
                  this.loading = false;
                });
              }, 1000);
 
 
            },
            // 导出报表
            exportExcel() {
 
                if (allData.groupVol.length == 0) {
                    this.$layer.msg('暂无数据导出,请先选择充放电数据!');
                    return false;
                }
                let lastarray = new Array();
                lastarray.push(allData.monNumList);
 
                //组端电压折线图
                let groupVolLineChartOption = this.$refs.groupVol.getOption(groupVolLineChart);
                groupVolLineChartOption.title.show = true;
                groupVolLineChartOption.title.x = 'center';
                groupVolLineChartOption.legend.show = false;
                this.createGraphByOpt(groupVolLineChartOption);
                let oltop = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 电池电流折线图
                let currLineChartOption = this.$refs.groupVol.getOption(currLineChart);
                currLineChartOption.title.show = true;
                currLineChartOption.title.x = 'center';
                currLineChartOption.legend.show = false;
                this.createGraphByOpt(currLineChartOption);
                let ortop = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                //获取起始单体电压
                lastarray.push(monBarData.vol[0].map(item => {
                    return item[1];
                }));
 
 
                //单体电压柱状图
                let monBarVol = monBarData.vol;
                let monBarEndVol = monBarVol[this.getDataIndex(monBarVol.length, this.slider)];
                //获取单体截止电压
                let monBarVolArr = monBarEndVol.map(item => {
                    return item[1];
                });
                lastarray.push(monBarVolArr);
                monBarChart.title.show = true;
                monBarChart.title.text = this.getTitle(monBarVolArr, 'Voltage');
                let lowObj = Titleobj; //落后单体电压信息
                monBarChart.title.x = 'center';
                monBarChart.series[0].name = "单体电压";
                monBarChart.series[0].data = monBarEndVol;
                let monBarChartVolOption = this.$refs.monBar.getOption(monBarChart);
                this.createGraphByOpt(monBarChartVolOption);
                let orbottom1 = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                //单体实际容量柱状图
                let monBarRealCap = monBarData.realCap;
                let monBarRealCapEnd = monBarRealCap[this.getDataIndex(monBarRealCap.length, this.slider)];
                let monBarRealCapArr = monBarRealCapEnd.map(item => {
                    return item[1];
                });
                lastarray.push(monBarRealCapArr);
                let monRealCapNum = getBarNum(monBarRealCapEnd);
                monBarChart.title.show = true;
                monBarChart.title.text = this.getTitle(monBarRealCapArr, "Actual_capacity");
                monBarChart.title.x = 'center';
                monBarChart.series[0].name = "单体实际容量";
                monBarChart.series[0].data = monBarRealCapEnd;
                let monBarChartRealCapOption = this.$refs.monBar.getOption(monBarChart);
                this.createGraphByOpt(monBarChartRealCapOption);
                let orbottom2 = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                //单体剩余容量柱状图
                let monBarResCap = monBarData.resCap;
                let monBarResCapEnd = monBarResCap[this.getDataIndex(monBarResCap.length, this.slider)];
                let monBarResCapArr = monBarResCapEnd.map(item => {
                    return item[1];
                });
                lastarray.push(monBarResCapArr);
                monBarChart.title.show = true;
                monBarChart.title.text = this.getTitle(monBarResCapArr, "Residual_capacity");
                monBarChart.title.x = 'center';
                monBarChart.series[0].name = "单体剩余容量";
                monBarChart.series[0].data = monBarResCapEnd;
                let monBarChartResCapOption = this.$refs.monBar.getOption(monBarChart);
                this.createGraphByOpt(monBarChartResCapOption);
                let orbottom3 = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                //单体容量百分比柱状图
                let monBarPreCap = monBarData.preCap;
                let monBarPreCapEnd = monBarPreCap[this.getDataIndex(monBarPreCap.length, this.slider)];
                let monBarPreCapArr = monBarPreCapEnd.map(item => {
                    return item[1];
                });
                lastarray.push(monBarPreCapArr);
                monBarChart.title.show = true;
                monBarChart.title.text = this.getTitle(monBarPreCapArr, "Percent_total_capacity");
                monBarChart.title.x = 'center';
                monBarChart.series[0].name = "单体容量百分比";
                monBarChart.series[0].data = monBarPreCapEnd;
                let monBarChartPreCapOption = this.$refs.monBar.getOption(monBarChart);
                this.createGraphByOpt(monBarChartPreCapOption);
                let orbottom4 = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 单体电压折线图
                monLineChart.title.show = true;
                monLineChart.title.text = "单体电压(V)";
                monLineChart.title.x = 'center';
                monLineChart.series = monLineData.vol.map((item, index) => {
                    let monNum = "#" + (index + 1);
                    return {
                        name: monNum,
                        data: item
                    };
                });
                let monLineChartVolOption = this.$refs.groupVol.getOption(monLineChart);
                this.createGraphByOpt(monLineChartVolOption);
                let vol_line = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 单体温度折线图
                monLineChart.title.show = true;
                monLineChart.title.text = "单体温度(℃)";
                monLineChart.title.x = 'center';
                monLineChart.series = monLineData.temp.map((item, index) => {
                    let monNum = "#" + (index + 1);
                    return {
                        name: monNum,
                        data: item
                    };
                });
                let monLineChartTempOption = this.$refs.groupVol.getOption(monLineChart);
                this.createGraphByOpt(monLineChartTempOption);
                let tmp_line = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 单体剩余容量折线图
                monLineChart.title.show = true;
                monLineChart.title.text = "剩余容量(AH)";
                monLineChart.title.x = 'center';
                monLineChart.series = monLineData.resCap.map((item, index) => {
                    let monNum = "#" + (index + 1);
                    return {
                        name: monNum,
                        data: item
                    };
                });
                let monLineChartResCapOption = this.$refs.groupVol.getOption(monLineChart);
                this.createGraphByOpt(monLineChartResCapOption);
                let resCap_line = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 单体内阻
                let monBarRes = monBarData.res;
                let monBarResArr = monBarRes.map(item => {
                    return item[1];
                });
                monBarChart.title.show = true;
                monBarChart.title.text = this.getTitle(monBarResArr, "Resistance");
                monBarChart.title.x = 'center';
                monBarChart.series[0].name = "单体内阻";
                monBarChart.series[0].data = monBarRes;
                monBarChart.series[1].name = "";
                monBarChart.series[1].data = [];
                let monBarResOption = this.$refs.monBar.getOption(monBarChart);
                this.createGraphByOpt(monBarResOption);
                let mon_res = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 单体均衡电流
                let jhCurr = monBarData.jh_curr;
                let jhCurrArr = jhCurr.map(item => {
                    return item[1];
                });
                let jhCurrNum = getBarNum(jhCurr);
                monBarChart.title.show = true;
                monBarChart.title.text = "最大值=" + jhCurrNum.max + "A;最小值=" + jhCurrNum.min + 'A;平局值=' + jhCurrNum.avg
                    .toFixed(0) + "A";
                monBarChart.title.x = 'center';
                monBarChart.series[0].name = "单体均衡电流";
                monBarChart.series[0].data = jhCurr;
                monBarChart.series[1].name = "";
                monBarChart.series[1].data = [];
                let jhCurrOption = this.$refs.monBar.getOption(monBarChart);
                this.createGraphByOpt(jhCurrOption);
                let JH_curr = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 终止单体电压
                let endVolData = monBarData.vol[monBarData.vol.length - 1];
                let endVolDataNum = getBarNum(endVolData);
                monBarChart.title.show = true;
                monBarChart.title.text = "最大值=" + endVolDataNum.max + "V;最小值=" + endVolDataNum.min + 'V;平局值=' +
                    endVolDataNum.avg.toFixed(2) + "V";
                monBarChart.title.x = 'center';
                monBarChart.series[0].name = "终止单体电压";
                monBarChart.series[0].data = endVolData;
                let endVolDataOption = this.$refs.monBar.getOption(monBarChart);
                this.createGraphByOpt(endVolDataOption);
                let last_vol = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 终止温度电压
                let endTempData = monBarData.temp[monBarData.temp.length - 1];
                let endTempDataNum = getBarNum(endTempData);
                monBarChart.title.show = true;
                monBarChart.title.text = "最大值=" + endTempDataNum.max + "℃;最小值=" + endTempDataNum.min + '℃;平局值=' +
                    endTempDataNum.avg.toFixed(0) + "℃";
                monBarChart.title.x = 'center';
                monBarChart.series[0].name = "终止单体温度";
                monBarChart.series[0].data = endTempData;
                let endTempDataOption = this.$refs.monBar.getOption(monBarChart);
                this.createGraphByOpt(endTempDataOption);
                let last_tmp = allGraph.getDataURL({
                    pixelRatio: 1,
                    backgroundColor: '#fff'
                });
 
                // 恢复name值
                monBarChart.series[0].name = "初始值";
 
                lastarray.push(monBarData.res.map(item => {
                    return item[1];
                }));
 
                lastarray.push(monBarData.temp[0].map(item => {
                    return item[1];
                }));
 
                lastarray.push(monBarData.temp[monBarData.temp.length - 1].map(item => {
                    return item[1];
                }));
                let batt = this.batt;
                let testdata = allData.endData;
 
                this.$refs.ltop_echart.value = oltop; // 组端电压折线图
                this.$refs.rtop_echart.value = ortop; // 电池电流折线图
                this.$refs.lbottom_echart.value = vol_line; // 单体电压折线图
                this.$refs.rbottom_echart.value = orbottom1; //单体电压柱状图
                this.$refs.actucap_echart.value = orbottom2; //单体实际容量
                this.$refs.restcap_echart.value = orbottom3; //单体剩余容量
                this.$refs.capperc_echart.value = orbottom4; //单体容量百分比
                this.$refs.tmp_echart.value = tmp_line; // 单体温度
                this.$refs.restcap_line_echart.value = resCap_line; // 剩余容量
                this.$refs.mon_res.value = mon_res; // 单体内阻
                this.$refs.JH_curr.value = JH_curr; // 单体均衡电流
                this.$refs.last_vol.value = last_vol; // 终止单体电压柱状图
                this.$refs.last_tmp.value = last_tmp; // 终止单体温度柱状图
                let top_cause = this.battState.stop_reason;
                batt.StationIp = top_cause;
                this.$refs.obj_bmd.value = JSON.stringify({
                    binf: batt,
                    sdata: testdata
                });
                this.$refs.obj_title.value = JSON.stringify(lowObj);
                this.$refs.arr_data.value = JSON.stringify(lastarray);
                let batt_test_data = monBarData.vol.map(item => {
                    return item.map(item2 => {
                        return item2[1];
                    })
                });
                this.$refs.mon_vol_list.value = JSON.stringify(batt_test_data);
                let batt_test_tmpdata = monLineData.temp.map(item => {
                    return item.map(item2 => {
                        return item2[1];
                    })
                });
                this.$refs.mon_tmp_list.value = JSON.stringify(batt_test_tmpdata);
                this.$refs.mon_group_list.value = JSON.stringify(allData.dataList);
                this.$refs.group_vol_qth.value = JSON.stringify(this.groupVolQth);
 
                this.$refs.all_picture.submit();
 
            },
            createGraphByOpt(opt) {
                allGraph.clear();
                let lineStyle = {
                    color: "#000"
                };
 
                // 设置x轴的颜色
                if(opt.xAxis[0].axisLine) {
                    opt.xAxis[0].axisLine.lineStyle = lineStyle;
                }else {
                    opt.xAxis[0].axisLine = {
                        lineStyle,
                    };
                }
 
                // 设置x轴刻度的值
                if(opt.xAxis[0].axisLabel) {
                    opt.xAxis[0].axisLabel.color = "#000";
                }else {
                    opt.xAxis[0].axisLabel = {
                        color: "#000",
                    };
                }
 
                // 设置y轴的颜色
                if(opt.yAxis[0].axisLine) {
                    opt.yAxis[0].axisLine.lineStyle = lineStyle;
                }else {
                    opt.yAxis[0].axisLine = {
                        lineStyle,
                    };
                }
 
                // 设置y轴刻度的值
                if(opt.yAxis[0].axisLabel) {
                    opt.yAxis[0].axisLabel.color = "#000";
                }else {
                    opt.yAxis[0].axisLabel = {
                        color: "#000",
                    };
                }
                opt.animation = false;
                allGraph.setOption(opt);
            },
            // 设置内阻信息
            searchBattresdata() {
                let batt = this.batt;
                searchBattresdata(batt.BattGroupId).then(res => {
                    let rs = JSON.parse(res.data.result);
                    if (rs.code == 1) {
                        let data = rs.data;
                        for (let i = 0; i < data.length; i++) {
                            let item = data[i];
                            let battNumText = '#' + item.mon_num;
                            monBarData.jh_curr.push([battNumText, item.mon_JH_curr]);
                            monBarData.res.push([battNumText, item.mon_res]);
                        }
                    }
                }).catch(error => {
                    console.log(error);
                });
            },
            getTitle(array, units) {
                let getLow = this.getLow;
                var title = "";
                //a=new Title();
                //alert(Titleobj);
                Titleobj = new Title();
                var sum = 0;
                if (array != undefined && array.length > 0) {
                    Titleobj.setMax(Math.max.apply(null, array));
                    Titleobj.setMin(Math.min.apply(null, array));
                    for (var i = 0; i < array.length; i++) {
                        sum += parseFloat(array[i]);
                    }
                    var batt = this.batt;
                    //console.info(batt);
                    if ("Resistance" == units) {
                        Titleobj.setAvg((sum / array.length).toFixed(3));
                        var low = getLow(3, 2);
                        if (low.low_method == 0) {
                            //根据标称值计算
                            Titleobj.setAlow(((2 - low.low_value) * batt.MonResStd).toFixed(3));
                            low = getLow(3, 3);
                            Titleobj.setClow(((2 - low.low_value) * batt.MonResStd).toFixed(3));
                        } else {
                            //根据平均值计算
                            Titleobj.setAlow(((2 - low.low_value) * Titleobj.getAvg()).toFixed(3));
                            low = getLow(3, 3);
                            Titleobj.setClow(((2 - low.low_value) * Titleobj.getAvg()).toFixed(3));
                        }
                        var count = 0;
                        for (var i = 0; i < array.length; i++) {
                            if (parseFloat(Titleobj.getAlow()) < parseFloat(array[i])) {
                                //console.info(title.getAlow()+"<"+array[i]);
                                count++;
                            }
                        }
                        Titleobj.setLc(count);
                        Titleobj.setLp((count * 100 / array.length).toFixed(1));
                        //console.info(title);
                    } else {
                        if ("Voltage" == units) {
                            Titleobj.setAvg((sum / array.length).toFixed(3));
                            var low = getLow(1, 1);
                            if (low.low_method == 0) {
                                //根据标称值计算
                                Titleobj.setAlow((low.low_value * batt.MonVolStd).toFixed(3));
                                low = getLow(1, 0);
                                Titleobj.setClow((low.low_value * batt.MonVolStd).toFixed(3));
                            } else {
                                //根据平均值计算
                                Titleobj.setAlow((low.low_value * Titleobj.getAvg()).toFixed(3));
                                low = getLow(1, 0);
                                Titleobj.setClow((low.low_value * Titleobj.getAvg()).toFixed(3));
                            }
                        } else if ("Temperature" == units) {
                            Titleobj.setAvg((sum / array.length).toFixed(1));
                            var low = getLow(1, 1);
                            if (low.low_method == 0) {
                                //根据标称值计算
                                Titleobj.setAlow((low.low_value * batt.MonTmpStd).toFixed(1));
                                low = getLow(1, 0);
                                Titleobj.setClow((low.low_value * batt.MonTmpStd).toFixed(1));
                            } else {
                                //根据平均值计算
                                Titleobj.setAlow((low.low_value * Titleobj.getAvg()).toFixed(1));
                                low = getLow(1, 0);
                                Titleobj.setClow((low.low_value * Titleobj.getAvg()).toFixed(1));
                            }
                        } else if ("Conductance" == units) {
                            Titleobj.setAvg((sum / array.length).toFixed(0));
                            var low = getLow(3, 2);
                            if (low.low_method == 0) {
                                //根据标称值计算
                                Titleobj.setAlow((low.low_value * batt.MonSerStd).toFixed(0));
                                low = getLow(3, 3);
                                Titleobj.setClow((low.low_value * batt.MonSerStd).toFixed(0));
                            } else {
                                //根据平均值计算
                                Titleobj.setAlow((low.low_value * Titleobj.getAvg()).toFixed(0));
                                low = getLow(3, 3);
                                Titleobj.setClow((low.low_value * Titleobj.getAvg()).toFixed(0));
                            }
                        } else if ("Actual_capacity" == units) {
                            Titleobj.setAvg((sum / array.length).toFixed(0));
                            var low = getLow(2, 2);
                            if (low.low_method == 0) {
                                //根据标称值计算
                                Titleobj.setAlow((low.low_value * batt.MonCapStd).toFixed(0));
                                //console.info(batt);
                                low = getLow(2, 3);
                                Titleobj.setClow((low.low_value * batt.MonCapStd).toFixed(0));
                            } else {
                                //根据平均值计算
                                Titleobj.setAlow((low.low_value * Titleobj.getAvg()).toFixed(0));
                                low = getLow(2, 3);
                                Titleobj.setClow((low.low_value * Titleobj.getAvg()).toFixed(0));
                            }
                        } else if ("Residual_capacity" == units) {
                            Titleobj.setAvg((sum / array.length).toFixed(0));
                            var low = getLow(1, 1);
                            if (low.low_method == 0) {
                                //根据标称值计算
                                Titleobj.setAlow((low.low_value * Titleobj.getAvg()).toFixed(0));
                                //console.info(batt);
                                low = getLow(1, 0);
                                Titleobj.setClow((low.low_value * Titleobj.getAvg()).toFixed(0));
                            } else {
                                //根据平均值计算
                                Titleobj.setAlow((low.low_value * Titleobj.getAvg()).toFixed(0));
                                //console.info(batt);
                                low = getLow(1, 0);
                                Titleobj.setClow((low.low_value * Titleobj.getAvg()).toFixed(0));
                            }
 
                        } else if ("Percent_total_capacity" == units) {
                            Titleobj.setAvg((sum / array.length).toFixed(2));
                            var low = getLow(2, 2);
                            if (low.low_method == 0) {
                                //根据标称值计算
                                Titleobj.setAlow((low.low_value * batt.MonCapStd).toFixed(2));
                                //console.info(batt);
                                low = getLow(2, 3);
                                Titleobj.setClow((low.low_value * batt.MonCapStd).toFixed(2));
                            } else {
                                //根据平均值计算
                                Titleobj.setAlow((low.low_value * Titleobj.getAvg()).toFixed(2));
                                low = getLow(2, 3);
                                Titleobj.setClow((low.low_value * Titleobj.getAvg()).toFixed(2));
                            }
                        } else if ("MonJHCurr" == units) {
                            //单体均衡
                            Titleobj.setAvg((sum / array.length).toFixed(2));
                        }
                        var count = 0;
                        for (var i = 0; i < array.length; i++) {
                            if (parseFloat(Titleobj.getAlow()) > parseFloat(array[i])) {
                                count++;
                            }
                        }
                        Titleobj.setLc(count);
                        Titleobj.setLp((count * 100 / array.length).toFixed(1));
                    }
 
                    //console.info(Title);
                    title = Titleobj.getAllTile(units);
                }
                return title;
            },
            searchAll_lowAction() {
                searchAll_lowAction().then(res => {
                    let rs = JSON.parse(res.data.result);
                    if (rs.code == 1) {
                        this.low_list = rs.data;
                    }
                }).catch(error => {
                    console.log(error);
                });
            },
            getLow(lowtype, lownametype) {
                let low_list = this.low_list;
                if (lowtype != undefined && low_list != undefined && lownametype != undefined) {
                    for (var i = 0; i < low_list.length; i++) {
                        if (lowtype == low_list[i].low_type && lownametype == low_list[i].low_nametype) {
                            return low_list[i];
                        }
                    }
                }
            },
            // 添加标准曲线
            confirmAddStandardLine() {
                // 电池信息
                let batt = this.batt;
                // 记录信息
                let testRecord = this.getTestRecord();
                if (testRecord != -1) {
                    if (testRecord.test_type != 3) {
                        this.$layer.msg('请选择放电数据');
                        return;
                    }
                    //单体电压柱状图
                    let monBarVol = monBarData.vol;
                    let monBarEndVol = monBarVol[this.getDataIndex(monBarVol.length, 100)];
                    let minInfo = getMaxInfo(monBarEndVol.map(item=>{
                      return item[1];
                    }));
                    let note = Math.abs(testRecord.test_cap / (testRecord.test_timelong / 3600));
                    note = note?(batt.MonCapStd/note).toFixed(0):0;
                    if(note == 0) {
                      this.$layer.msg('数据异常,请添加其他数据!');
                      return;
                    }
                    let searchParams = {
                        BattgroupId: batt.BattGroupId,
                        test_record_count: testRecord.test_record_count,
                        monvolstd: batt.MonVolStd,
                        moncapstd: batt.MonCapStd,
                        note: Math.abs(note),
                        battproducer: batt.BattProducer,
                        battmodel: batt.BattModel,
                        mon_num: minInfo.key+1,
                    };
                    const h = this.$createElement;
                    this.$confirm(h('div', null, [
                        h('p', null, '标称容量:' + searchParams.moncapstd + "AH"),
                        h('p', null, '标称电压:' + searchParams.monvolstd + "V"),
                        h('p', null, '电池品牌:' + searchParams.battproducer),
                        h('p', null, '电池型号:' + searchParams.battmodel),
                        h('p', null, '小时率:' + searchParams.note),
                    ]), "添加标准曲线", {
                        type: 'null',
                    }).then(() => {
                        this.addStandardLine(searchParams);
                    }).catch(() => {});
                } else {
                    this.$layer.msg('暂无放电数据,请先选择充放电数据!');
                }
            },
            addStandardLine(params) {
                // 添加标准曲线
                this.$apis.dataTest.history.addStandardLine(params).then(res => {
                    let rs = JSON.parse(res.data.result);
                    if (rs.code == 1) {
                        this.$layer.msg("添加标准曲线成功");
                    } else {
                        this.$layer.msg("添加标准曲线失败");
                    }
                }).catch(error => {
                    console.log(error);
                });
            },
            searchHistorySetting() {
              this.$apis.pageSetting.realTime.searchParam({
                categoryId: 11
              }).then(res=>{
                let rs = JSON.parse(res.data.result);
                if(rs.code == 1 && rs.data.length != 0) {
                  let data = rs.data[0];
                  // 驼峰锅底
                  this.humpPotBottom = data.status?true:false;
                  // 显示粒度
                  let data1 = rs.data[1];
                  this.show_num = data1.status;
                }else {
                  this.humpPotBottom = false;
                  this.show_num = 5;
                }
              }).catch(error=>{
                this.humpPotBottom = false;
                this.show_num = 5;
                console.log(error);
              });
            }
        },
        computed: {
            battFullName() {
                let batt = this.batt;
                if (batt.StationName && batt.BattGroupName) {
                    return batt.StationName + "-" + batt.BattGroupName;
                }
                return "电池组全称";
            },
            formateBattState() {
                let battState = this.battState;
                if (battState.test_type == 3) {
                    return "放电(终止原因:" + battState.stop_reason + ")";
                } else if (battState.test_type == 2) {
                    return "充电"
                } else {
                    return "";
                }
            },
            isAio() {
              // A059设备
              let batt = this.batt;
              return regEquipType(batt.FBSDeviceId, ["aio"]);
            }
        },
        mounted() {
            // 初始化图表
            this.initChart();
            this.searchAll_lowAction();
            this.searchHistorySetting();
            // 基于准备好的dom,初始化echarts实例
            allGraph = ECharts.init(this.$refs.allGraph, 'transparent');
            // 屏幕缩放时触发
            window.addEventListener("resize", () => {
                this.resize();
            });
        }
    };
</script>
 
<style scoped>
    .page-history {
        color: #ffffff;
    }
 
    .table-cell.text-right {
        font-size: 14px;
    }
 
    .table-row .table-cell {
        padding-top: 12px;
    }
 
    .page-content {
        position: relative;
        padding-top: 8px;
        padding-bottom: 2px;
        box-sizing: border-box;
        height: 100%;
    }
 
    .history-list {
        position: absolute;
        top: 8px;
        left: 24px;
        z-index: 99;
    }
 
    .flex-box-list {
        display: flex;
        flex-direction: row;
        height: 50%;
        box-sizing: border-box;
    }
 
    .page-content .flex-box {
        flex: 1;
        overflow-x: hidden;
    }
 
    .slider-container {
        padding-left: 16px;
        padding-right: 16px;
        overflow: hidden;
    }
 
    .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;
    }
 
    .chart-wrapper {
        position: relative;
        box-sizing: border-box;
        margin: 0 16px;
        height: 100%;
        padding: 12px;
        background-image: radial-gradient(#151f4140, #3667ec40);
    }
 
    .chart-wrapper:before,
    .chart-wrapper:after,
    .chart-wrapper-corner {
        position: absolute;
        display: inline-block;
        content: " ";
        width: 18px;
        height: 18px;
    }
 
    .chart-wrapper:before {
        left: 0;
        top: 0;
        border-top: 2px solid #00FEFF;
        border-left: 2px solid #00FEFF;
    }
 
    .chart-wrapper:after {
        left: 0;
        bottom: 0;
        border-bottom: 2px solid #00FEFF;
        border-left: 2px solid #00FEFF;
    }
 
    .chart-wrapper-corner.top-right {
        top: 0;
        right: 0;
        border-top: 2px solid #00FEFF;
        border-right: 2px solid #00FEFF;
    }
 
    .chart-wrapper-corner.bottom-right {
        bottom: 0;
        right: 0;
        border-bottom: 2px solid #00FEFF;
        border-right: 2px solid #00FEFF;
    }
 
    .chart-tools-wrapper {
        position: absolute;
        top: 12px;
        right: 12px;
        z-index: 99;
    }
 
    #allGraph {
        position: absolute;
        top: -1000px;
        left: 0;
        width: 600px;
        height: 400px;
    }
 
    .chart-contain {
        width: 100%;
        height: 100%;
        background-color: #FFFFFF;
    }
 
    .chart {
        width: 100%;
        height: 100%;
    }
</style>