zmc
2023-12-22 c7e4dd9bd50cf6e6426598753c796ec1a27f333f
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
<template>
  <el-row ref="h1">
    <el-col>
      <!-- 菜单读标题 -->
      <div ref="h1" class="header-container">
        <span class="describe-info">店铺名选择:</span>
        <!-- 店铺名  级联 -->
        <ShopNameAndID @submit-id="(n) => (deviceId[1] = n)"></ShopNameAndID>
 
        <!-- 异常类型选择 -->
        <ExceptionType @submitExceptionType="(val) => (exceptionValue = val)">
        </ExceptionType>
 
        <TimeSelect @submit-time="giveTime"></TimeSelect>
      </div>
      <div
        ref="h2"
        style="display: flex; margin-top: 2px; justify-content: right"
      >
        <el-button
          type="primary"
          plain
          style="margin-left: 20px"
          :loading="button.queryButton"
          @click="showTable"
          >查询</el-button
        >
 
        <el-tooltip
          class="box-item"
          effect="dark"
          content="点击可导出Excel文件"
          placement="top-start"
        >
          <!-- 做成函数js文件 -->
          <el-icon
            class="iconExcel clickable"
            title="导出Excel文件"
            @click="exportDom"
          >
            <i-ep-Download />
            <!-- 导出为Excel -->
          </el-icon>
        </el-tooltip>
      </div>
      <div style="display: flex; justify-content: right; margin-right: 40px">
        <span class="collapse-header-text">
          静安区 {{ beginTime }} —— {{ endTime }} 油烟监测异常信息汇总</span
        >
      </div>
      <br />
 
      <el-collapse ref="h3" v-model="activeNames">
        <el-collapse-item name="1">
          <template #title>
            <el-tooltip
              class="box-item"
              effect="dark"
              content="点击可折叠"
              placement="right-start"
            >
              <h4 class="collapse-header">异常分析</h4>
              <el-icon class="header-icon">
                <i-ep-info-filled />
              </el-icon>
            </el-tooltip>
 
            <el-tooltip
              class="box-item"
              effect="dark"
              content="点击可折叠"
              placement="right-start"
            >
            </el-tooltip>
          </template>
          <el-card class="box-card">
            <el-row :gutter="25">
              <el-col :span="8">
                <div style="display: flex">
                  <img
                    src="@/assets/exceed.jpg"
                    style="width: 25px; height: 25px; margin-top: 5px"
                  />
                  <span
                    style="
                      font-size: 16px;
                      font-weight: bold;
                      margin-top: 4px;
                      margin-left: 4px;
                    "
                    >油烟浓度超标</span
                  >
                </div>
 
                <div class="box-card-label">
                  <el-scrollbar>
                    <span class="box-card-label">异常店铺占比:</span>
                    <span style="font-size: 20px"
                      >{{ exception0.length }} /{{ shopsTotal }}
                      </span
                    >
                    <span style="font-size: 17px">
                      ({{
                        ((exception0.length/shopsTotal)*100).toFixed(1)
                      }}%)</span
                    >
                    {{  shopsTotal}}
                    <span class="right-text">
                      异常数占比:{{  ((exception0Num/exceptionAllNum) * 100).toFixed(1) }}%
                    </span>
                  </el-scrollbar>
                </div>
 
                <hr />
                <div class="box-card-butcontainer">
                  <el-card class="sub-box-card">
                    <el-scrollbar max-height="70px">
                      <ExceptionText
                        v-for="(item, index) in exception0"
                        :key="item"
                        :devId="item.devId"
                        exception-value="0"
                        :begin-time="beginTime"
                        :end-time="endTime"
                        @submit-exception-data="getAbnormalDataByClick"
                      >
                        {{ item.diName }}
                        <span
                          v-if="index < exception0.length - 1"
                          class="text-blank"
                          >,</span
                        >
                      </ExceptionText>
                    </el-scrollbar>
                  </el-card>
                </div>
              </el-col>
 
              <el-col :span="8">
                <div style="display: flex">
                  <img
                    src="@/assets/exception.jpg"
                    style="width: 25px; height: 25px; margin-top: 5px"
                  />
                  <span
                    style="
                      font-size: 16px;
                      font-weight: bold;
                      margin-top: 5px;
                      margin-left: 4px;
                    "
                    >供电异常</span
                  >
                </div>
                <div class="box-card-label">
                  <el-scrollbar>
                    <span class="box-card-label">异常店铺占比:</span>
                    <span style="font-size: 20px"
                      >{{ exception1.length }} /{{ shopsTotal }}</span
                    >
                    <span style="font-size: 17px">
                      ({{
                        ((exception1.length/shopsTotal)*100).toFixed(1)
                      }}%)</span
                    >
                    <span class="right-text">
                      异常数占比:{{  ((exception1Num/exceptionAllNum) * 100).toFixed(1) }}%
                    </span>
                  </el-scrollbar>
                </div>
 
                <hr />
 
                <div>
                  <el-card class="sub-box-card">
                    <el-scrollbar max-height="70px">
                      <ExceptionText
                        v-for="(item, index) in exception1"
                        :key="item"
                        :devId="item.devId"
                        exception-value="1"
                        :begin-time="beginTime"
                        :end-time="endTime"
                        @submit-exception-data="getAbnormalDataByClick"
                      >
                        {{ item.diName }}
                        <span
                          v-if="index < exception1.length - 1"
                          class="text-blank"
                          >,</span
                        >
                      </ExceptionText>
                    </el-scrollbar>
                  </el-card>
                </div>
              </el-col>
 
              <el-col :span="8">
                <div style="display: flex">
                  <img
                    src="@/assets/offline.jpg"
                    style="width: 25px; height: 25px; margin-top: 5px"
                  />
                  <span
                    style="
                      font-size: 16px;
                      font-weight: bold;
                      margin-top: 5px;
                      margin-left: 4px;
                    "
                    >设备或网络异常</span
                  >
                </div>
                <div class="box-card-label">
                  <el-scrollbar>
                    <span class="box-card-label">异常店铺占比:</span>
                    <span style="font-size: 20px"
                      >{{ exception2.length }} /{{ shopsTotal }}</span
                    >
                    <span style="font-size: 17px">
                      ({{
                        (((exception2.length)/shopsTotal)*100).toFixed(1)
                      }}%)</span
                    >
                    <span class="right-text">
                      异常数占比:{{ connectException  }}%
                    </span>
                  </el-scrollbar>
                </div>
                <hr />
                <div>
                  <el-card class="sub-box-card">
                    <el-scrollbar max-height="70px">
                      <ExceptionText
                        v-for="(item, index) in exception2"
                        :key="item"
                        :devId="item.devId"
                        exception-value="2"
                        :begin-time="beginTime"
                        :end-time="endTime"
                        @submit-exception-data="getAbnormalDataByClick"
                      >
                        {{ item.diName }}
                        <span
                          v-if="index < exception2.length - 1"
                          class="text-blank"
                          >,</span
                        >
                      </ExceptionText>
                    </el-scrollbar>
                  </el-card>
                </div>
              </el-col>
            </el-row>
          </el-card>
        </el-collapse-item>
      </el-collapse>
 
      <h4 class="table-text">异常数据</h4>
 
    </el-col>
  </el-row>
  <el-card class="table-page" v-show="!isNoData">
    <el-table
      ref="tableH"
      size="small"
      v-loading="loading"
      :data="displayData"
      style="width: 100%"
      border
      :height="tableHeight"
      :cell-class-name="tableCellClassName"
 
    >
      <el-table-column prop="diName" label="店铺名称" align="center">
        <template #default="{ row }">
          <el-tooltip effect="dark" :content="row.diName">
            <div class="cell ellipsis">{{ row.diName }}</div>
          </el-tooltip>
        </template>
      </el-table-column>
 
      <el-table-column prop="devId" label="设备编号" align="center">
        <template #default="{ row }">
          <el-tooltip effect="dark" :content="row.devId">
            <div class="cell ellipsis">{{ row.devId }}</div>
          </el-tooltip>
        </template>
      </el-table-column>
 
      <el-table-column prop="diSupplier" label="供应商" align="center">
        <template #default="{ row }">
          <el-tooltip effect="dark" :content="row.diSupplier">
            <div class="cell ellipsis">{{ row.diSupplier }}</div>
          </el-tooltip>
        </template>
      </el-table-column>
 
 
      <el-table-column prop="exception" label="异常分类" align="center">
        <template #default="{ row }">
          <el-tooltip effect="dark" :content="row.exception">
            <div class="cell ellipsis">{{ row.exception }}</div>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="异常类型" align="center">
        <template #default="{ row }">
          <span v-if="row.exceptionType == '0'">油烟数据超标</span>
          <span v-else-if="row.exceptionType == '1'">疑似供电异常</span>
          <span v-else-if="row.exceptionType == '2'">掉线</span>
        </template>
      </el-table-column>
      <el-table-column prop="region" label="地区" align="center">
        <template #default="{ row }">
          <el-tooltip effect="dark" :content="row.region">
            <div class="cell ellipsis">{{ row.region }}</div>
          </el-tooltip>
        </template>
      </el-table-column>
 
      <el-table-column prop="beginTime" label="开始时间" align="center">
        <template #default="{ row }">
          <el-tooltip effect="dark" :content="row.beginTime">
            <div class="cell ellipsis">{{ row.beginTime }}</div>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column prop="endTime" label="结束时间" align="center">
        <template #default="{ row }">
          <el-tooltip effect="dark" :content="row.endTime">
            <div class="cell ellipsis">{{ row.endTime }}</div>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template #default="{ row }">
          <el-button
            type="primary"
            class="table-button"
            @click="showDrawer(row)"
            >查看详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>
 
    <el-pagination
      ref="h4"
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :total="total"
      :page-size="pageSize"
      layout="total,prev, pager, next, jumper"
    />
  </el-card>
  <el-empty v-show="isNoData" :image-size="200" />
  <!-- 对话框 -->
  <div>
    <el-dialog v-model="centerDialogVisible" draggable align-center>
      <template #header>
        <div style="font-size: 17px">
          店铺名:{{ rowShopName }}
          <span style="margin-left: 40px">异常类型:</span>
          <span v-if="rowExceptionType == '0'">油烟数据超标</span>
          <span v-else-if="rowExceptionType == '1'">供电异常</span>
          <span v-else-if="rowExceptionType == '2'">掉线</span>
          <div style="margin-top: 10px">
            异常时间段:{{ rowBeginTime }} ~
            {{ rowEndTime }}
          </div>
        </div>
        
        <div class="dialog-button-position">
          <el-button
            type="danger"
            :loading="button.preButton"
            :disabled="isPreCantouch || banTouch"
            @click="getPreviousRowData"
            >上条异常</el-button
          >
          <el-button
            type="danger"
            :loading="button.afterButton"
            :disabled="isNextCantouch || banTouch"
            @click="getNextRowData"
            >下条异常</el-button
          >
        </div>
      </template>
 
      <!-- 超标数据时 -->
      <!-- 折线图 -->
 
      <!-- 掉线 -->
      <!-- <div
          ref="ref"
          v-show="isOfflineShow"
          style="
            width: 100%;
            height: 300px;
            /* min-width: 100px; */
            margin-bottom: 20px;
            margin-left: 10px;
            min-width: 350px;
          "
        ></div> -->
 
      <ExceptionTypeLineChart
        :option="option"
        :is-open-dialog="centerDialogVisible"
        v-loading="chartLoading"
      ></ExceptionTypeLineChart>
 
      <!--  -->
      <div style="margin-top: 40px; margin-bottom: 5px; border: 1px">
        <el-table
          :data="exceedingData"
          height="360"
          border
          style="margin-top: 25px"
        >
         <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
          fixed
          :index="indexMethod"
          
        ></el-table-column>
          <el-table-column fixed prop="diName" label="店铺名称"  show-overflow-tooltip/>
          <el-table-column prop="mvStatCode" label="设备编号" align="center" show-overflow-tooltip/>
          <el-table-column prop="diSupplier" label="供应商" align="center" show-overflow-tooltip/>
          <el-table-column prop="mvDataTime" label="采集时间" align="center" show-overflow-tooltip/>
         
          <el-table-column
            prop="mvFumeConcentration2"
            label="油烟浓度(mg/m³)"
            align="center"
            show-overflow-tooltip
          />
        </el-table>
      </div>
 
      <el-tag type="success" class="mx-1" effect="dark" round
        ><span class="table-line-lable" v-show="rowExceptionType == '0'"
          >异常记录:
        </span>
        <span v-show="rowExceptionType == '1' || rowExceptionType == '2'"
          >缺失数据:</span
        >
        <span class="table-line-num">{{ exceptionTotal }}条</span>
        <span v-show="rowExceptionType === '1' || rowExceptionType === '2'">
          (逻辑计算)</span
        >
      </el-tag>
    </el-dialog>
  </div>
</template>
 
<script>
import ExceptionType from '../sfc/ExceptionType.vue';
import TimeSelect from '../sfc/TimeSelect.vue';
import ExceptionText from '../sfc/ExceptionText.vue';
 
import * as XLSX from 'xlsx/xlsx.mjs';
import dayjs from 'dayjs';
import axiosInstanceInstance from '../utils/request.js';
 
const ShopNameAndID = defineAsyncComponent(() =>
  import('../sfc/../sfc/ShopNameAndID.vue')
);
 
//  异常图形异步组件
const ExceptionTypeLineChart = defineAsyncComponent(() =>
  import('../sfc/ExceptionTypeLineChart.vue')
);
export default {
  name: 'TablePage',
  components: {
    ExceptionType,
    TimeSelect,
    ShopNameAndID,
    ExceptionText,
    ExceptionTypeLineChart
  },
  data() {
    return {
      exception0Num:0,
      exception1Num:0,
      exception2Num:0,
      // 折线图加载中
      chartLoading:false,
      button:{
        // 查询按钮
        queryButton:false,
        // 上一条按钮
        preButton:false,
        // 下一条按钮
        afterButton:false,
        // 
        banTouch:0
      },
      // 异常折线图的配置
      option: {},
      // 折线图展示
      isChartShow: false,
      // table元素
      tableRef: null,
      // 异常表格数据
      tableHeight: 300,
      // 空数据状态
      isNoData: false,
      // 弹出框中表格条数
      exceptionTotal: 0,
      // 无数据时的时间数组,元素相差10分钟
      // abnormalTimeTenMinute: [],
      // 店铺总数
      shopsTotal: 0,
 
      // ’上一条‘按钮是否可以被点击状态
      isPreCantouch: false,
      // ’下一条‘按钮是否可以被点击状态
      isNextCantouch: false,
 
      // 对话框是否展示
      centerDialogVisible: false,
 
      // 抽屉头部信息
      // 折线图对应的当前表格行数据
      // 店铺名
      rowShopName: '',
      // 异常类型
      rowExceptionType: '',
      // 异常开始时间
      rowBeginTime: '',
      // 异常结束时间
      rowEndTime: '',
      // 异常的设备编号
      rowMvStatCode: '',
      // 供应商
      rowDiSupplier:'',
      // 表格的一行数据
      rowTable: [],
      //拼接的所有数据
      allExceptionTimeData: [],
      // 无数据时增加的前30分钟数据
      beforeData: [],
      // 无数据时增加的后40分钟数据
      afterData: [],
 
      // -1表示未选择表格的行
      selectedRowIndex: -1,
 
      // 默认选择的折叠面板编号
      activeNames: ['1'],
      // 异常时的表格
      abnormalTb: [],
      // 异常的起止时间
      abnormalBt: '',
      abnormalEt: '',
      // 是否展示时间轴  否
      isAbnormal: false,
      // 保存着异常类型0对应的店铺名称和设备编号
      exception0: [],
      // 保存着异常类型1对应的店铺名称和设备编号
      exception1: [],
      // 保存着异常类型2对应的店铺名称和设备编号
      exception2: [],
      // 加载动画
      loading: false,
      // 抽屉加载动画
      loadingDrawer: true,
      // 分页展示数据
 
      // 异常表的数据
      displayData: [],
      // 存放后端返回的json数据
      jsonData: [],
      // 分页的起始索引
      startIndex: 0,
      // 当前页
      currentPage: 1,
      // 每页条数
      pageSize: 10,
      total: 0,
      // 选择店铺名
      deviceId: [],
      deviceInfo: [],
      // 时间选择器开始时间
      beginTime: '',
      // 时间选择器结束时间
      endTime: '',
      // 异常表数据
      abnormalData: [],
      // 弹出的对话框中的异常表格数据
      exceedingData: [],
      drawerVisible: false,
      // 表格的一行数据
      drawerData: {},
      // 抽屉方向,从右向左打开
      drawerDirection: 'rtl',
      optionsTime: [
        // 时间颗粒度
        {
          value: '10',
          label: '10分钟数据',
          disabled: true
        }
      ],
      // 店铺名 级联选择器
      optionsShop: [],
      // 异常类型选择器
      exceptionValue: []
    };
  },
  // 监听  判断按钮是否可点击
  watch: {
    selectedRowIndex(newVaue) {
      // 处于表格的最后一条数据 设置‘上一条’按钮不可点
      if (newVaue === this.displayData.length - 1) {
        this.isPreCantouch = true;
        //用户先点了第一条,pre为true,然后点击最后一条,next为true。此时两个按钮都被封锁
        if (this.isNextCantouch == true) {
          this.isNextCantouch = false;
        }
      }
      // 处于表格第一条数据 设置‘下一条’按钮不可点
      else if (newVaue === 0) {
        this.isNextCantouch = true;
        //用户先点了表格最后一条,next为true,然后点击第一条,pre为true。此时两个按钮都被封锁
        if (this.isPreCantouch == true) {
          this.isPreCantouch = false;
        }
      }
      // 处于表格的中间行 将按钮设置为可点击状态
      else {
        this.isPreCantouch = false;
        this.isNextCantouch = false;
      }
    },
 
    // 当选择的时间发生变化时,异常分析部分的异常店铺数量同步变化
    beginTime() {
      this.getShopNames();
    },
    endTime() {
      this.getShopNames();
    },
    centerDialogVisible() {
      window.addEventListener('resize', this.updateChart);
    }
  },
  computed:{
    exceptionAllNum(){
      let sum = this.exception0Num+this.exception1Num+this.exception2Num
      return sum == 0?1:sum
    },
    connectException(){
      let sum = this.exception0Num+this.exception1Num+this.exception2Num
      if(sum == 0){
        return 0
      }
      else{
        return (100 - ((exception0Num/sum) * 100) - ((exception1Num/sum) * 100)).toFixed(1)
      }
    }
  },
  mounted() {
    // 从接口获取店铺名称 给级联下拉框
    this.getDeviceInfo();
    // 展示最近7天数据
    this.getRecentSevenDays();
    // 根据异常类型返回店铺名称和设备编号 渲染异常分析部分对应的店铺名
    this.getShopNames();
    this.calcTableHeight();
    window.addEventListener('resize', this.updateChart);
  },
  methods: {
    // 功能:对话框表格序号递增
    // 时间:2023-8-17
    indexMethod(index) {
      return index + 1 ;
    },
 
    // 功能:改变表格某个单元格的颜色
    tableCellClassName({ row, column, rowIndex, columnIndex }) {
     if(columnIndex == 4){
        if (row.exceptionType == '0') {
          return 'exceeding-row';
        } else if (row.exceptionType == '1') {
          return 'abnormal-power-supply';
        } else if (row.exceptionType == '2') {
          return 'disconnect';
        }
     }
      
    },
 
    //功能: 动态计算表格高度
    calcTableHeight() {
      const h1 = this.$refs.h1.$el.offsetHeight;
      const h2 = this.$refs.h4.$el.offsetHeight;
      this.tableHeight = `calc(100vh - ${h1}px - ${h2}px - 45px - var(--el-main-padding) * 2 - var(--el-card-padding))`;
    },
 
    //功能: 时间是否超过10分钟
    isTimeDifferenceGreaterThan10Minutes(dateString1, dateString2) {
      const date1 = new Date(dateString1);
      const date2 = new Date(dateString2);
 
      // 计算两个日期的时间差(毫秒)
      const timeDifferenceMs = Math.abs(date1 - date2);
 
      // 转换为分钟
      const timeDifferenceMinutes = Math.floor(timeDifferenceMs / (1000 * 60));
 
      // 判断时间差是否大于10分钟
      return timeDifferenceMinutes > 10;
    },
 
    // 以10分钟为间隔返回时间字符串数组
    generateTimePoints(timePoints, yAxisData) {
      let updatedTimePoints = [];
      let yAxisDataAdressed = [];
      for (let i = 0; i < timePoints.length; i++) {
        updatedTimePoints.push(timePoints[i]);
        yAxisDataAdressed.push(yAxisData[i]);
        if (i < timePoints.length - 1) {
          let current = timePoints[i];
          let next = timePoints[i + 1];
          while (this.isTimeDifferenceGreaterThan10Minutes(current, next)) {
            current = dayjs(current)
              .add(10, 'minute')
              .format('YYYY-MM-DD HH:mm:ss');
            updatedTimePoints.push(current);
            yAxisDataAdressed.push(null);
          }
        }
      }
      let obj = {};
      obj['time'] = updatedTimePoints;
      obj['data'] = yAxisDataAdressed;
      return obj;
    },
 
    isExceedOneMonth(dateStr1, dateStr2) {
      // 超过一个月,返回True,否则返回False
      // 将日期字符串转为日期对象
      const date1 = new Date(dateStr1);
      const date2 = new Date(dateStr2);
 
      // 获取两个日期的年、月、日
      const year1 = date1.getFullYear();
      const month1 = date1.getMonth();
      const day1 = date1.getDate();
 
      const year2 = date2.getFullYear();
      const month2 = date2.getMonth();
      const day2 = date2.getDate();
 
      // 判断两个日期是否相差一个月
      if (year1 === year2) {
        // 年份相等,比较月份差值
        if (Math.abs(month1 - month2) === 1) {
          // 月份差值为1,还需要判断具体日期
          if (
            (month1 < month2 && day1 < day2) ||
            (month1 > month2 && day1 > day2)
          ) {
            return true;
          }
        }
      } else if (Math.abs(year1 - year2) === 1) {
        // 年份差值为1,比较月份和日期
        if (
          (year1 < year2 && month1 === 11 && month2 === 0 && day1 < day2) ||
          (year1 > year2 && month1 === 0 && month2 === 11 && day1 > day2)
        ) {
          return true;
        }
      }
 
      // 默认返回false,表示两个日期字符串不相差一个月
      return false;
    },
 
    // 刚打开卡片时第一个图形不会自动伸缩 当点击上/下一条时会自动伸缩
    // 图形响应式变化
    // updateChart() {
    //   this.$nextTick(() => {
    //     if (this.chart1) {
    //       this.chart1.resize();
    //     }
    //     if (this.chart2) {
    //       this.chart2.resize();
    //     }
    //   });
    // },
 
    // 从时间选择器组件拿到开始和结束时间
    giveTime(val) {
      //将中国标准时间转为指定格式(该组件返回的标准时间的格式,所以必须的加这个函数)
      this.beginTime = dayjs(val[0]).format('YYYY-MM-DD HH:mm:ss');
      this.endTime = dayjs(val[1]).format('YYYY-MM-DD HH:mm:ss');
    },
 
    // 参数:异常的开始和结束时间。返回时间数组,从开始时间的后10分钟到结束时间为止。
    // 比如12:00:00-13:00:00 所以返回的数组元素是 12:10:00 ,12:20:00,12:30:00....13:00:00
    descTenTime(begin, end) {
      let time = [];
      if (begin == end) {
        time.push(begin);
        return time;
      }
      // 保留结果 00 10 20 30
      let temp = dayjs(begin).add(10, 'minute').format('YYYY-MM-DD HH:mm:ss');
      while (temp != end) {
        time.push(temp);
        temp = dayjs(temp).add(10, 'minute').format('YYYY-MM-DD HH:mm:ss');
      }
      // 加上异常的结束时间
      time.push(temp);
      return time;
    },
 
    // 保存当前选择的行所有信息
    setinfo(index) {
      this.rowShopName = this.displayData[index].diName;
      this.rowExceptionType = this.displayData[index].exceptionType;
      this.rowBeginTime = this.displayData[index].beginTime;
      this.rowEndTime = this.displayData[index].endTime;
      this.rowMvStatCode = this.displayData[index].devId;
      this.rowDiSupplier = this.displayData[index].diSupplier
    },
 
    //功能: 供电异常和掉线时的表格数据
    setExceptionData() {
      // 无数据时的时间数组 时间相差10分钟
      const abnormalTimeTenMinute = this.descTenTime(
        this.rowBeginTime,
        this.rowEndTime
      );
      // 去除供电异常和掉线区间的第一个有元素的值
      this.exceedingData = [];
 
      for (let i = 0; i < abnormalTimeTenMinute.length; i++) {
        this.exceedingData.push({
          mvStatCode: this.rowMvStatCode,
          diName: this.rowShopName,
          diSupplier:this.rowDiSupplier,
          mvDataTime: abnormalTimeTenMinute[i],
          mvFumeConcentration2: ''
        });
      }
 
      // 保存无数据时表格条数
      this.exceptionTotal = abnormalTimeTenMinute.length;
    },
    // 点击表格的行时
    selectTableRow(row) {
      // 获取当前行的索引
      this.selectedRowIndex = this.displayData.indexOf(row);
      // 进入抽屉页面更新头部数据
      this.setinfo(this.selectedRowIndex);
    },
 
    // 获取获取表格下一行数据
    getNextRowData() {
      // 不是表格的第一行
      if (this.selectedRowIndex !== 0) {
        // 点击过程中 锁住上下条按钮  在设置完图形配置项后解锁
        this.banTouch = 1
 
        //得到上一行数据索引
        this.selectedRowIndex = this.selectedRowIndex - 1;
        //请求数据 改变exceedingData
        this.setinfo(this.selectedRowIndex);
        let params = {};
        if (this.drawerData.devId) {
          params['devId'] = this.displayData[this.selectedRowIndex].devId;
        }
        if (this.drawerData.beginTime) {
          params['beginTime'] =
            this.displayData[this.selectedRowIndex].beginTime;
        }
        if (this.drawerData.endTime) {
          params['endTime'] = this.displayData[this.selectedRowIndex].endTime;
        }
        this.button.afterButton = true
        axiosInstanceInstance
          .get('/fume/exceed', { params: params })
          .then((response) => {
            // 保存返回的超标数据
            this.exceedingData = response.data.data;
            this.drawChartTest();
            this.exceptionTotal = this.exceedingData.length;
            this.button.afterButton = false
          });
      }
 
    },
 
    // 获取获取表格下一行数据
    getPreviousRowData() {
      // 不是表格的第一行
      if (this.selectedRowIndex < this.displayData.length - 1) {
        // 点击过程中 锁住上下条按钮  在设置完图形配置项后解锁
        this.banTouch = 1
 
        //得到上一行数据索引
        this.selectedRowIndex = this.selectedRowIndex + 1;
 
        //请求数据 改变exceedingData
        this.setinfo(this.selectedRowIndex);
        let params = {};
        if (this.drawerData.devId) {
          params['devId'] = this.displayData[this.selectedRowIndex].devId;
        }
        if (this.drawerData.beginTime) {
          params['beginTime'] =
            this.displayData[this.selectedRowIndex].beginTime;
        }
        if (this.drawerData.endTime) {
          params['endTime'] = this.displayData[this.selectedRowIndex].endTime;
        }
        this.button.preButton = true
        axiosInstanceInstance
          .get('/fume/exceed', { params: params })
          .then((response) => {
            // 保存返回的超标数据
            this.exceedingData = response.data.data;
            this.drawChartTest();
            this.exceptionTotal = this.exceedingData.length;
            this.button.preButton = false
          });
      }
    },
 
    // ‘查看详情’ 弹出框部分
    showDrawer(row) {
      // 计算当前行的索引
      this.selectTableRow(row);
 
      this.rowTable = row;
 
      // 表格的行数据以对象形式给drawerData
      this.drawerData = row;
 
      this.centerDialogVisible = true;
 
      // 根据行数据请求详细超标数据渲染折线图
      let params = {};
      if (this.drawerData.devId) {
        params['devId'] = this.drawerData.devId;
      }
      if (this.drawerData.beginTime) {
        params['beginTime'] = this.drawerData.beginTime;
      }
      if (this.drawerData.endTime) {
        params['endTime'] = this.drawerData.endTime;
      }
 
      axiosInstanceInstance
        .get('/fume/exceed', { params: params })
        .then((response) => {
          // 保存返回的超标数据
          this.exceedingData = response.data.data;
          this.drawChartTest();
          this.exceptionTotal = this.exceedingData.length;
        });
    },
 
    // 用户根据输入的条件查询
    showTable() {
      if (this.isExceedOneMonth(this.beginTime, this.endTime)) {
        alert('时间跨度不能超过一个月');
        return;
      }
      let params = {};
 
      if (this.deviceId[1]) {
        params['devId'] = this.deviceId[1];
      }
      if (this.exceptionValue.length != 0) {
        params['exceptionValue'] = this.exceptionValue.join();
      }
 
      if (this.beginTime) {
        params['beginTime'] = this.beginTime;
      }
      if (this.endTime) {
        params['endTime'] = this.endTime;
      }
      this.loading = true;
      this.button.queryButton = true
      
      axiosInstanceInstance
        .get('/fume/abnormalthree', { params: params })
        .then((response) => {
          this.abnormalData = response.data.data;
          this.total = this.abnormalData.length;
          this.loading = false;
          this.button.queryButton = false
          if (response.data.data.length == 0) {
            ElMessage('该时段无数据');
            this.isNoData = true;
            return;
          }
          // 移除空数据状态
          this.isNoData = false;
          this.handleCurrentChange(1);
 
        });
    },
    handleSizeChange(val) {
      this.pageSize = val;
      // 改变每页显示数目时跳到第一页
      this.handleCurrentChange(1);
    },
    handleCurrentChange(val) {
      const startIndex = (val - 1) * this.pageSize;
      const endIndex = startIndex + this.pageSize;
 
      this.displayData = this.abnormalData.slice(startIndex, endIndex);
    },
 
    //相差多少个十分钟  计算中并不包括开始时间,但包括结束时间。
    diffTenMinutesNum(beginNormal, endNormal) {
      // 将开始时间和结束时间转换为dayjs对象
      const start = dayjs(beginNormal);
      const end = dayjs(endNormal);
 
      // 计算结束时间减去开始时间中间相差多少个十分钟
      const diffInMinutes = end.diff(start, 'minute');
      const diffInTenMinutes = Math.floor(diffInMinutes / 10);
      return diffInTenMinutes;
    },
 
    // 参数:异常的开始时间,异常的结束时间。
    // 功能:返回开始时间的前30分钟的时间点,结束时间后40分钟的时间点
    before30AndAfter40(begin, end) {
      let time = [];
      const before30MinBegin = dayjs(begin)
        .subtract(30, 'minute')
        .format('YYYY-MM-DD HH:mm:ss');
      // 后一段的开始时间
      const after10MinBegin = dayjs(end)
        .add(10, 'minute')
        .format('YYYY-MM-DD HH:mm:ss');
      // 往后40分钟
      const after40MinEnd = dayjs(end)
        .add(40, 'minute')
        .format('YYYY-MM-DD HH:mm:ss');
      time.push(before30MinBegin);
      time.push(after10MinBegin);
      time.push(after40MinEnd);
      return time;
    },
 
    // 参数:设备编号, 开始时间, 结束时间
    // 功能:返回某设备在该时段历史数据的get请求参数。
    requestGetParms(devnum, begin, end) {
      return {
        devId: devnum,
        beginTime: begin,
        endTime: end
      };
    },
    // 参数:对象数组(该对象中的属性不能是引用类型,否则拷贝的值还是会相互影响)
    // 功能:拷贝该对象数组。
    shallowCopyList(itemIsObjOfList) {
      let tempList = [];
      itemIsObjOfList.forEach((item) => {
        tempList.push({ ...item });
      });
      return tempList;
    },
 
    // 参数:添加首尾时间数据的异常数据数组(元素为对象)
    // 功能:对中间异常区间时间和值进行补充,返回处理后的结果
    // 详细描述:遍历数组,当发现数组元素为空时,设置该元素的时间为上一个元素时间的后10分钟,并把浓度值设置为null(上个元素的时间一定不为空,无需再去判断上个元素为空的情况)。
    addTenMinutes(exceptionDataArr) {
      // x轴 日期时间
      let dateList = [];
      // y轴 超标油烟浓度
      let fumeExceeding = [];
      let obj = {};
      for (let i = 0; i < exceptionDataArr.length; i++) {
        if (exceptionDataArr[i] == null) {
          //x轴日期。元素为null时, 设置该元素的时间为前一元素的时间后10分钟
          dateList.push(
            dayjs(dateList[dateList.length - 1])
              .add(10, 'minute')
              .format('YYYY-MM-DD HH:mm:ss')
          );
          // 超标油烟浓度
          fumeExceeding.push(null);
        } else {
          //x轴日期
          dateList.push(exceptionDataArr[i].mvDataTime);
          // 超标油烟浓度
          fumeExceeding.push(exceptionDataArr[i].mvFumeConcentration2);
        }
      }
      obj['dateList'] = dateList;
      obj['fumeExceeding'] = fumeExceeding;
      return obj;
    },
 
    // 参数:加上前后区间的异常数据,时间字符串
    // 功能:判断data中是否有该日期时间,存在返回该时间对应的浓度值,否则返回-1
    findTimeInExceptionData(data, time) {
      for (let i = 0; i < data.length; i++) {
        if (data[i] == null) {
          continue;
        }
        if (data[i]['mvDataTime'] == time) {
          return data[i]['mvFumeConcentration2'];
        }
      }
      return -1;
    },
    // 参数:前区间的开始时间, 后区间的结束时间, 加上前后区间的总时间段的异常数据的对象数组
    // 功能:根据开始和结束时间,返回以10分钟为间隔的时间和对应的值
    keepContinuousByEachTenMinutes(
      intervalStarTime,
      intervalEndTime,
      headAndTailExceptionData
    ) {
      let xAxis = [];
      let yAxis = [];
      let obj = {};
      let current = intervalStarTime;
      let tail = dayjs(intervalEndTime)
        .add(10, 'minute')
        .format('YYYY-MM-DD HH:mm:ss');
      while (current != tail) {
        let value = this.findTimeInExceptionData(
          headAndTailExceptionData,
          current
        );
        if (value != -1) {
          xAxis.push(current);
          yAxis.push(value);
        } else {
          xAxis.push(current);
          yAxis.push(null);
        }
        current = dayjs(current)
          .add(10, 'minute')
          .format('YYYY-MM-DD HH:mm:ss');
      }
      obj['xAxis'] = xAxis;
      obj['yAxis'] = yAxis;
      return obj;
    },
 
    // 参数:超标数据前面区间的数据
    // 功能:返回除去最后一个元素的数组
    removeLastItemOfBeforeData(beforeDataOfExceeding) {
      let tempList = [];
      if (beforeDataOfExceeding.length == 1) {
        return tempList;
      } else {
        for (let i = 0; i < beforeDataOfExceeding.length - 1; i++) {
          tempList.push({ ...beforeDataOfExceeding[i] });
        }
        return tempList;
      }
    },
 
    // 设置option
    // 参数:x轴时间, y轴油烟浓度, 异常类别(0代表超标,1代表供电异常和掉线), 异常开始时间,异常结束时间,异常开始时间在整个区间的索引下标,异常结束时间在整个区间的索引下标
    setOption(
      xData,
      yData,
      exceptionCategory,
      exceptionBeginTime,
      exceptionEndTime,
      beginIndex,
      endIndex
    ) {
      this.option = {};
      // 超标
      if (exceptionCategory == 0) {
        this.option = {
          tooltip: {},
          toolbox: {
            // 工具栏
            feature: {
              //     dataZoom: {
              //   yAxisIndex: 'none'
              // },
              // 保存为图片
              saveAsImage: {}
            }
          },
          xAxis: {
            type: 'category',
            data: xData,
            name: '时间',
            axisLabel: {
              formatter: function (value) {
                return value.slice(11, -3);
              }
            }
          },
          yAxis: {
            type: 'value',
            name: 'mg/m³'
          },
          series: [
            {
              name: '油烟浓度',
              type: 'line',
              data: yData.map((item) => {
                if (item >= 1) {
                  return {
                    value: item,
                    itemStyle: {
                      color: 'red'
                    }
                  };
                }
                return item;
              }),
              // 变换指定时间区间的背景颜色
              markArea: {
                itemStyle: {
                  color: 'rgba(255, 173, 177, 0.4)'
                },
                data: [
                  [
                    {
                      name: '超标时间段',
                      xAxis: exceptionBeginTime
                    },
                    {
                      xAxis: exceptionEndTime
                    }
                  ]
                ]
              },
              markLine: {
                symbol: 'none',
                itemStyle: {
                  // 基线公共样式
                  normal: {
                    lineStyle: {
                      type: 'dashed'
                    },
                    label: {
                      show: true,
                      position: 'end',
                      formatter: '{b}'
                    }
                  }
                },
                data: [
                  {
                    name: '超标',
                    type: 'average',
                    yAxis: 1,
                    lineStyle: {
                      // color: '#ff0000'
                      color: 'red'
                    }
                  }
                ]
              }
            }
          ],
          // 指定时间区间的线段变颜色
          visualMap: {
            show: false,
            dimension: 0,
            pieces: [
              {
                lte: beginIndex,
                color: 'green'
              },
              {
                gt: beginIndex,
                lte: endIndex,
                color: 'red'
              },
              {
                gt: endIndex,
                lte: xData.length - 1,
                color: 'green'
              }
            ]
          }
        };
      }
      // 供电异常和掉线
      else if (exceptionCategory == 1) {
        this.option = {
          tooltip: {},
          toolbox: {
            // 工具栏
            feature: {
              // dataZoom: {
              //   // 区域缩放
              //   yAxisIndex: 'none'
              // },
              // 保存为图片
              saveAsImage: {}
            }
          },
          xAxis: {
            type: 'category',
            data: xData,
            name: '时间',
            axisLabel: {
              formatter: function (value) {
                return value.slice(11, -3);
              }
            }
          },
          yAxis: {
            type: 'value',
            name: 'mg/m³'
          },
          series: [
            {
              name: '油烟数据',
              type: 'line',
              data: yData,
              markLine: {
                silent: true,
                data: [
                  // 标注无数据时间段的效果,将这个时间段的数轴部分变为红色
                  {
                    name: '无数据',
                    xAxis: exceptionBeginTime
                  },
                  {
                    xAxis: exceptionEndTime
                  }
                ],
                lineStyle: {
                  color: 'red'
                }
              }
            }
          ]
        };
      }
      this.banTouch = 0
    },
 
    // 功能:点击 ‘查看详情’, ‘下一条’按钮时会 先逻辑计算。最后展示图形
    drawChartTest() {
      this.beforeData = [];
      this.afterData = [];
      this.allExceptionTimeData = [];
      //异常的开始时间 结束时间
      let exceptionBeginTime = this.rowBeginTime;
      let exceptionEndTime = this.rowEndTime;
 
      // beforeAndAfterTime[0]:前30分钟的时间点
      // beforeAndAfterTime[1]:后10分钟的时间点
      // beforeAndAfterTime[2]:后40分钟的时间点
      let beforeAndAfterTime = this.before30AndAfter40(
        exceptionBeginTime,
        exceptionEndTime
      );
 
      // 构造异常时间前的区间数据请求参数
      let paramsBefore = this.requestGetParms(
        this.displayData[this.selectedRowIndex].devId,
        beforeAndAfterTime[0],
        this.displayData[this.selectedRowIndex].beginTime
      );
 
      // 构造异常时间后的区间数据请求参数
      let paramsAfter = this.requestGetParms(
        this.displayData[this.selectedRowIndex].devId,
        beforeAndAfterTime[1],
        beforeAndAfterTime[2]
      );
 
      // 折线图加载中效果
      this.chartLoading = true
      // 请求前半段
      axiosInstanceInstance
        .get('/fume/history', { params: paramsBefore })
        .then((result1) => {
          this.beforeData = result1.data.data;
          // 请求后半段
          axiosInstanceInstance
            .get('/fume/history', { params: paramsAfter })
            .then((result2) => {
              this.afterData = result2.data.data;
              //保存异常区间的值
              let tempArr = [];
              // 保存异常区间前后的值
              let before = [];
              let after = [];
 
              // 判断是否是供电异常或掉线
              if (
                this.rowExceptionType === '1' ||
                this.rowExceptionType === '2'
              ) {
                // 重构表格 缺失异常数据自动填充
                this.setExceptionData();
 
                //相差几个10分钟
                const TenMinuteNum = this.diffTenMinutesNum(
                  exceptionBeginTime,
                  exceptionEndTime
                );
                //用null填充中异常无数据的时间
                for (let i = 0; i < TenMinuteNum; i++) {
                  tempArr.push(null);
                }
                before = this.shallowCopyList(this.beforeData);
 
                after = this.shallowCopyList(this.afterData);
                // after = this.afterData
              }
              // 超标
              else {
                let beforeTemp = this.removeLastItemOfBeforeData(
                  this.beforeData
                );
                // 前后区间只显示距离超标区间时间最近的浓度小于1的时间点
                for (let i = beforeTemp.length - 1; i >= 0; i--) {
                  if (beforeTemp[i].mvFumeConcentration2 >= 1) {
                    break;
                  }
                  if (beforeTemp[i].mvFumeConcentration2 < 1) {
                    before.unshift(this.beforeData[i]);
                  }
                }
 
                for (let i = 0; i < this.afterData.length; i++) {
                  if (this.afterData[i].mvFumeConcentration2 >= 1) {
                    break;
                  }
                  if (this.afterData[i].mvFumeConcentration2 < 1) {
                    after.unshift(this.afterData[i]);
                  }
                }
                tempArr = this.shallowCopyList(this.exceedingData);
              }
 
              // 将前后区间数据 与 异常区间数据 合并
              this.allExceptionTimeData = [...before, ...tempArr, ...after];
              // x轴日期时间
              let dateList = [];
              // y轴 超标油烟浓度
              let fumeExceeding = [];
              let timeAndValue = {};
 
              // 从添加了首位区间的开始和结束时间进行遍历 保证时间以10分钟为间隔
              timeAndValue = this.keepContinuousByEachTenMinutes(
                beforeAndAfterTime[0],
                beforeAndAfterTime[2],
                this.allExceptionTimeData
              );
 
              dateList = timeAndValue['xAxis'];
              fumeExceeding = timeAndValue['yAxis'];
 
              // 提取异常起始时间点在整个区间内的数据索引
              let startIndex = dateList.findIndex(
                (item) => item === exceptionBeginTime
              );
              let endIndex = dateList.findIndex(
                (item) => item === exceptionEndTime
              );
 
              // 供电异常和掉线情况 超标情况
              if (
                this.rowExceptionType === '1' ||
                this.rowExceptionType === '2'
              ) {
                this.setOption(
                  dateList,
                  fumeExceeding,
                  1,
                  exceptionBeginTime,
                  exceptionEndTime,
                  startIndex,
                  endIndex
                );
              } else {
                // 超标情况
                this.setOption(
                  dateList,
                  fumeExceeding,
                  0,
                  exceptionBeginTime,
                  exceptionEndTime,
                  startIndex,
                  endIndex
                );
              }
              this.chartLoading = false
            });
        });
    },
 
    getDeviceInfo() {
      // 级联下拉框数据 从接口中动态获取
      axiosInstanceInstance.get('/fume/device').then((result) => {
        this.deviceInfo = result.data.data;
        // 获取到总的店铺数量
        this.shopsTotal = result.data.data.length;
        this.deviceInfo.forEach((item) => {
          this.optionsShop[this.optionsShop.length] = {
            value: item.diName,
            label: item.diName,
            children: [
              {
                value: item.diCode,
                label: item.diCode
              }
            ]
          };
        });
      });
    },
    exportDom() {
      // 导出为Excel文件
      const fields = [
        'devId',
        'exceptionType',
        'region',
        'beginTime',
        'endTime'
      ];
      const itemsFormatted = this.abnormalData.map((item) => {
        const newItem = {};
        fields.forEach((field) => {
          newItem[field] = item[field];
        });
        return newItem;
      });
      // 创建xlsx对象
      const xls = XLSX.utils.json_to_sheet(itemsFormatted);
      // 编辑表头行       修改表头
      xls['A1'].v = '设备编号';
      xls['B1'].v = '异常类型';
      xls['C1'].v = '地区';
      xls['D1'].v = '开始时间';
      xls['E1'].v = '结束时间';
      // 创建workbook,并把sheet添加进去
      const wb = XLSX.utils.book_new();
      XLSX.utils.book_append_sheet(wb, xls, 'Sheet1');
      // 将workbook转为二进制xlsx文件并下载
      XLSX.writeFile(wb, '分析数据.xlsx');
    },
 
    getAbnormalDataByClick(val) {
      this.abnormalData = val;
      this.total = this.abnormalData.length;
      // 默认显示第一页
      this.handleCurrentChange(1);
    },
 
    // 根据异常类型返回店铺名称和设备编号
    // 比如油烟超标对应的所有店铺名称和设备编号(已去除重复的店铺名)
    getShopNames() {
      axiosInstanceInstance
        .get('/fume/shopname', {
          params: {
            exceptionType: '0',
            beginTime: this.beginTime,
            endTime: this.endTime
          }
        })
        .then((result) => {
          this.exception0 = result.data.data;
        });
      axiosInstanceInstance
        .get('/fume/shopname', {
          params: {
            exceptionType: '1',
            beginTime: this.beginTime,
            endTime: this.endTime
          }
        })
        .then((result) => {
          this.exception1 = result.data.data;
        });
      axiosInstanceInstance
        .get('/fume/shopname', {
          params: {
            exceptionType: '2',
            beginTime: this.beginTime,
            endTime: this.endTime
          }
        })
        .then((result) => {
          this.exception2 = result.data.data;
        });
 
        /* 异常数量 */
        axiosInstanceInstance
        .get('/fume/exceptionnum', {
          params: {
            exceptionType: '0',
            beginTime: this.beginTime,
            endTime: this.endTime
          }
        })
        .then((result) => {
          this.exception0Num = result.data.data;
        });
        axiosInstanceInstance
        .get('/fume/exceptionnum', {
          params: {
            exceptionType: '1',
            beginTime: this.beginTime,
            endTime: this.endTime
          }
        })
        .then((result) => {
          this.exception1Num = result.data.data;
        });
        axiosInstanceInstance
        .get('/fume/exceptionnum', {
          params: {
            exceptionType: '2',
            beginTime: this.beginTime,
            endTime: this.endTime
          }
        })
        .then((result) => {
          this.exception2Num = result.data.data;
        });
    },
 
    // 页面加载时默认展示7天异常表数据
    getRecentSevenDays() {
      // 给级联选择器设置默认的选择项
      this.devId = ['付小姐在成都', 'qinshi_31010320210010'];
      let params = {};
      params['beginTime'] = this.beginTime;
      params['endTime'] = this.endTime;
      axiosInstanceInstance
        .get('/fume/abnormalthree', { params: params })
        .then((response) => {
          if (response.data.data.length == 0) {
            ElMessage('该时段无数据');
            return;
          }
          // 保存返回的
          this.abnormalData = response.data.data;
          // 分页
          this.total = this.abnormalData.length;
          // 默认显示第一页
          this.handleCurrentChange(1);
          this.loading = false;
        });
    }
  }
};
</script>
 
<style scoped>
 
.header-container {
  display: flex;
  margin-left: 20px;
  /* flex-wrap: wrap;
    align-items: center; */
}
.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
 
.iconExcel {
  font-size: 25px;
  margin-left: 20px;
  bottom: -6px;
}
 
/* 可鼠标箭头变为可点击状态 */
.clickable {
  cursor: pointer;
}
.card-header {
  margin: 0;
}
 
body {
  margin: 0;
}
.exception-divider-rowline {
  margin: 10px 0px;
}
/* 异常分析数据与按钮 */
.exception-container {
  display: flex;
}
.example-showcase .el-loading-mask {
  z-index: 9;
}
 
.scrollbar-demo-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  margin: 10px;
  text-align: center;
  border-radius: 4px;
  background: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
}
.collapse-header {
  margin-left: 5px;
  font-size: 18px;
}
.collapse-header-text {
  margin-top: 5px;
  font-size: 14px;
  color: gray;
}
 
.box-card-label {
  font-size: 14px;
  white-space: nowrap;
}
 
.right-text {
  /* float :right; */
  /* text-align: right; */
  margin-left:80px;
}
:deep().el-card {
  border-radius: 9px;
}
 
/* ‘查看详情’ 的弹出框高度调整 */
:deep().el-dialog {
  height: 98%;
  /* 不出现滚动条 */
  overflow-y: hidden;
  border-radius: 9px;
}
.table-page {
  margin-left: 20px;
}
 
.table-text {
  font-size: 18px;
  margin: 5px 0px 10px 20px;
}
.text-blank {
  margin-right: 10px;
  color: #000000;
}
/* 店铺名选择文本 */
.describe-info {
  margin-top: 5px;
  font-weight: bold;
  white-space: nowrap;
}
/* 时间选择文本 */
.describe-time-text {
  margin-left: 30px;
  margin-top: 5px;
  font-weight: bold;
}
 
/* 异常表格下标签中的数组 */
.table-line-num {
  font-weight: bold;
  color: black;
}
.button_info.el-button_inner {
  text-align: left;
}
.el-collapse {
  margin-left: 20px;
}
:deep().el-collapse .el-collapse-item__content {
  padding-bottom: 0px;
}
.box-card {
  height: 190px;
}
 
.sub-box-card {
  height: 100px;
  border: 0px;
}
 
.mx-1 {
  margin-bottom: 0px;
}
.dialog-button-position {
  display: flex;
  justify-content: right;
  margin-bottom: 10px;
}
 
:deep().el-table__row .exceeding-row{
  background-color:  #F53F3F;
}
:deep().el-table__row .abnormal-power-supply{
  background-color:  #FDF4BF;
}
:deep().el-table__row .disconnect{
  background-color:  #F7BA1E;
}
 
 
.el-table {
  color: #000000;
}
 
 
/* 表格中的按钮宽度铺满 */
.table-button {
  width: 100%;
}
 
</style>