gaoluyang
2025-04-12 5d2f451118fe4a2b4076972e3269ce93882e5cb9
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
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
<template>
  <el-dialog :close-on-press-escape="false" :visible.sync="isShow" custom-class="unPassCheck" title="不合格复测" width="90%"
    @close="$emit('closeUnPassCheckDialog')">
    <div v-loading="loading" class="inspection">
      <!--      <el-row class="title">-->
      <!--        <el-col :span="24" style="text-align: right;">-->
      <!--          <el-button size="small" type="primary" @click="addVerifyDia = true" v-if="state==1">提交</el-button>-->
      <!--        </el-col>-->
      <!--      </el-row>-->
      <div class="center">
        <div class="search" style="text-align: left;display: flex;align-items: center;justify-content: space-between;">
          <div style="display: flex;align-items: center;">
            <span v-if="tableList.length > 0">检验模板:</span>
            <el-radio-group v-model="currentTable" size="small">
              <el-radio-button v-for="(item, index) in tableLists" :key="index" :label="item.templateId" size="small">{{
                item.templateName }}</el-radio-button>
            </el-radio-group>
          </div>
          <div style="display: flex;align-items: center;">
            <span>&nbsp;&nbsp;复测次数:</span>
            <el-select v-model="retestTag" placeholder="请选择" size="small"
              @change="m => handleChangeCableTag(currentSample.id, 4, 'cableTag', m)">
              <el-option v-for="item in unPassNumList" :key="item.retestTag" :label="item.retestTag"
                :value="item.retestTag">
              </el-option>
            </el-select>
          </div>
        </div>
        <!-- 常规检验原始记录 -->
        <div id="tableBox" v-loading="tableLoading" class="center-box">
          <table v-for="(item, index) in tableList" :key="index + currentTable + currentSample.id" border="1"
            cellpadding="10" class="tables">
            <tbody>
              <tr v-for="(m, i) in item.arr" :key="i">
                <td v-for="(n, j) in m" v-if="n.v.mc == undefined || Object.keys(n.v.mc).length === 4"
                  :id='item.templateId + "-" + n.i + "-" + n.r + "-" + n.c' :key="j"
                  :colspan="n.v.mc && n.v.mc.cs ? n.v.mc.cs : 1" :rowspan="n.v.mc && n.v.mc.rs ? n.v.mc.rs : 1"
                  :style="`background:${n.v.bg ? n.v.bg : ''};color:${n.v.fc};font-size:${n.v.fs}px;width:${handleWidth(n)}px !important;height:${item.style.rowlen[n.r]}px;font-wight:${n.v.bl ? 'bold' : ''};`">
                  <div :class="`content-h-${n.v.ht} content-v-${n.v.vt}`"
                    :style="`width:${handleWidth(n)}px !important;min-height:${item.style.rowlen[n.r]}px;`"
                    class="content">
                    <template
                      v-if="n.v.ps != undefined && typeof n.v.ps.value === 'string' && n.v.ps.value.includes('检验值') && state == 1">
                      <el-input v-if="getInspectionValueType(n.i) == 1"
                        :key="'abc-' + '000' + index + '000' + i + '000' + j" v-model="n.v.v"
                        :disabled="(getInspectionItemType(n.i) == 1 && !dataAcquisitionEidtAble) || (n.u != userId && n.u != undefined && n.u != '')"
                        class="table_input"
                        @change="m => changeInput(m, `${item.templateId}-${n.r}-${n.c}-${n.i}`, n, 'getDataType')"
                        @input="handleInput(n)" @mousewheel.native.prevent
                        @keydown.enter="changeInput('', `${item.templateId}-${n.r}-${n.c}-${n.i}`, n, 'getDataType')">
                      </el-input>
                      <el-input v-else-if="getInspectionValueType(n.i) == 2" v-model="n.v.v"
                        :disabled="getInspectionItemType(n.i) == 1 || (n.u != userId && n.u != undefined && n.u != '')"
                        class="table_input" type="textarea"
                        @change="m => changeInput(m, `${item.templateId}-${n.r}-${n.c}-${n.i}`, n, 'getDataType')" />
                      <!--                    <el-select v-else-if="getInspectionValueType(n.i) == 5" v-model="n.v.v" :disabled="state>1||getInspectionItemType(n.i) == 1 || (n.u != userId && n.u != undefined && n.u != '')"-->
                      <!--                               class="table_input" @change="m=>changeInput(m,`${item.templateId}-${n.r}-${n.c}-${n.i}`,n,'getDataType')"-->
                      <!--                               @visible-change="e=>getDic(e,n.i)">-->
                      <!--                      <el-option v-for="(e, i) in enumList" :key="i" :label="e.label" :value="e.value"></el-option>-->
                      <!--                    </el-select>-->
                      <span v-else-if="getInspectionValueType(n.i) == 4"
                        :style="`font-family:${n.v.ff} !important;`">/</span>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '结论'">
                      <el-select
                        v-if="(getInspectionValueType(n.i) == 2 || getInspectionValueType(n.i) == 5) && state == 1 && PROJECT == '装备电缆'"
                        v-model="n.v.v" class="table_input"
                        @change="m => changeInput(m, `${item.templateId}-${n.r}-${n.c}-${n.i}`, n, 'getDataType')">
                        <el-option :value="1" label="合格"></el-option>
                        <el-option :value="0" label="不合格"></el-option>
                        <el-option :value="3" label="不判定"></el-option>
                        <el-option :value="2" label="待定"></el-option>
                      </el-select>
                      <template v-if="state > 1">
                        <span v-if="n.v.v === 1" :style="`font-family:${n.v.ff} !important;color: green;`">合格</span>
                        <span v-else-if="n.v.v === 0" :style="`font-family:${n.v.ff} !important;color: red;`">不合格</span>
                        <span v-else-if="n.v.v === 3"
                          :style="`font-family:${n.v.ff} !important;color: #3A7BFA;`">不判定</span>
                        <span v-else :style="`font-family:${n.v.ff} !important;`">待定</span>
                      </template>
                      <template v-if="getInspectionValueType(n.i) != 2 && state == 1">
                        <span v-if="n.v.v === 1" :style="`font-family:${n.v.ff} !important;color: green;`">合格</span>
                        <span v-else-if="n.v.v === 0" :style="`font-family:${n.v.ff} !important;color: red;`">不合格</span>
                        <span v-else-if="n.v.v === 3"
                          :style="`font-family:${n.v.ff} !important;color: #3A7BFA;`">不判定</span>
                        <span v-else :style="`font-family:${n.v.ff} !important;`">待定</span>
                      </template>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '设备编码' && state == 1">
                      <span>{{ n.v.v }}</span>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '设备名称'">
                      <el-select v-model="n.v.v" :disabled="state > 1" class="table_input" filterable multiple
                        placeholder="设备" remote @change="(val) => changeEquip(val, n)"
                        @visible-change="e => getEquipOptions(e, n.i)">
                        <el-option v-for="item in equipOptions" :key="item.value" :label="item.label"
                          :value="item.value">
                          {{ item.label + '--' + item.value }}
                        </el-option>
                      </el-select>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '要求值' && state == 1">
                      <span :style="`font-family:${n.v.ff} !important;`">{{ getTell(n.i) }}</span>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '计算值' && state == 1"><span
                        :style="`font-family:${n.v.ff} !important;`">{{ toFixed(n.v.v, n.v.ct) }}</span></template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '最终值' && state == 1">
                      <span :style="`font-family:${n.v.ff} !important;`">{{ toFixed(n.v.v, n.v.ct) }}</span>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '样品编号'">
                      <div :title="currentSample.sampleCode"
                        style="display: flex;flex-wrap: nowrap;align-items: center;width: 100%">
                        <i v-if="!currentFiberOpticTape && !currentFiberOptic" class="el-icon-caret-left table_caret"
                          style="width: 16px;" @click="caretSample(-1)"></i>
                        <div
                          :style="`font-family:${n.v.ff} !important;overflow: hidden;white-space: nowrap;width: calc(100% - 32px);`">
                          {{ currentSample.sampleCode }}</div>
                        <i v-if="!currentFiberOpticTape && !currentFiberOptic" class="el-icon-caret-right table_caret"
                          style="width: 16px;" @click="caretSample(1)"></i>
                      </div>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '样品型号'">
                      <div v-if="currentSample.model !== undefined && currentSample.model !== null"
                        :style="`font-family:${n.v.ff} !important;`">{{ currentSample.model }}</div>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '套管'">
                      <div style="display: flex;flex-wrap: nowrap;align-items: center;">
                        <div :style="`font-family:${n.v.ff} !important;`">{{ currentBushing ? currentBushing.color : ''
                          }}
                        </div>
                      </div>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '光纤带'">
                      <div style="display: flex;flex-wrap: nowrap;align-items: center;">
                        <i v-if="currentFiberOpticTape" class="el-icon-caret-left table_caret" @click="caretTape(-1)
                          "></i>
                        <div :style="`font-family:${n.v.ff} !important;`">
                          {{ currentFiberOpticTape ? currentFiberOpticTape.code : '' }}</div>
                        <i v-if="currentFiberOpticTape" class="el-icon-caret-right table_caret"
                          @click="caretTape(1)"></i>
                      </div>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '光纤'">
                      <div style="display: flex;flex-wrap: nowrap;align-items: center;">
                        <i v-if="currentFiberOptic" class="el-icon-caret-left table_caret" @click="caretOptic(-1)"></i>
                        <div :style="`font-family:${n.v.ff} !important;`">
                          {{ currentFiberOptic ? currentFiberOptic.color : '' }}
                        </div>
                        <i v-if="currentFiberOptic" class="el-icon-caret-right table_caret" @click="caretOptic(1)"></i>
                      </div>
                    </template>
                    <span v-else :style="`font-family:${n.v.ff} !important;`" v-html="getValue(n.v)"></span>
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <el-dialog :visible.sync="reviewDia" title="检验复核" width="500px">
        <div v-if="reviewDia" class="body" style="display: flex;padding: 10px;">
          <div class="search_label" style="width: 150px;"><span class="required-span">* </span>不通过的理由:</div>
          <div class="search_input" style="width: 100%;">
            <el-input v-model="noReason" :autosize="{ minRows: 4 }" clearable size="small" type="textarea"></el-input>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="reviewDia = false">取 消</el-button>
          <el-button :loading="reviewLoading" type="primary" @click="handleReviewDia">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog :visible.sync="addVerifyDia" title="指定复核人员" width="400px">
        <div class="body" style="display: flex;padding: 10px;align-items: center;">
          <div class="search_label" style="width: 150px;"><span class="required-span">*</span>复核人</div>
          <div class="search_input" style="width: 100%;">
            <el-select v-model="verifyUser" clearable filterable placeholder="请选择" size="small" style="width: 100%;">
              <el-option v-for="(item, i) in personList" :key="i" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="addVerifyDia = false">取 消</el-button>
          <el-button :loading="submitLoading" type="primary" @click="submit()">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false"
        :visible.sync="dataGetDia" custom-class="custom-dialog" title="数据采集">
        <div>
          <table border="1" cellpadding="10" class="thermal-table">
            <tr>
              <td style="width: 120px;">检验项</td>
              <td style="width: 120px;">检验子项</td>
              <td>数采数据</td>
            </tr>
            <template v-for="(item, index) in getData">
              <tr>
                <td :rowspan="item.child.length">{{ item.faName }}</td>
                <td>{{ item.child[0].name }}</td>
                <td style="text-align: left;">
                  <el-checkbox-group v-model="getDataIndex" :max="item.child[0].maxNum">
                    <el-checkbox v-for="(n, j) in item.child[0].arr" :key="j" :label="j">{{ n }}</el-checkbox>
                  </el-checkbox-group>
                </td>
              </tr>
              <tr v-for="(m, i) in item.child" v-show="i > 0" :key="i + 'bbbbbbbbbbbbbb'">
                <td>{{ m.name }}</td>
                <td style="text-align: left;">
                  <el-checkbox-group v-model="getDataIndex" :max="m.maxNum">
                    <el-checkbox v-for="(n, j) in m.arr" :key="j" :label="j">{{ n }}</el-checkbox>
                  </el-checkbox-group>
                </td>
              </tr>
            </template>
          </table>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button :loading="getDataIndexLoading" type="primary" @click="submitDataGet()">确 定</el-button>
        </span>
      </el-dialog>
      <UnPassDialog v-if="unPassDialog" ref="unPassDialog" :orderId="orderId" :unPassDialog="unPassDialog"
        @resetForm="resetForm"></UnPassDialog>
      <el-dialog :close-on-click-modal="false" :visible.sync="addCheck" title="指定报告审核人员" width="400px"
        @close="closeAddVerifyDia">
        <div class="body" style="display: flex;padding: 10px;align-items: center;">
          <div class="search_label" style="width: 150px;"><span class="required-span">*</span>审核人:</div>
          <div class="search_input" style="width: 100%;">
            <el-select v-model="checkUser" clearable filterable placeholder="请选择" size="small" style="width: 100%;">
              <el-option v-for="(item, i) in personList" :key="i" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="closeAddVerifyDia">取 消</el-button>
          <el-button :loading="reviewLoading" type="primary" @click="upInsReview(1)">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </el-dialog>
</template>
 
<script>
import excelFunction from '@/utils/excelFountion'
import UnPassDialog from "@/views/business/unpass/components/unPassDialog.vue";
import AddUnPass from "@/views/business/unpass/components/addUnPass.vue";
import {
  checkSubmitPlan,
  doInsOrder, downFile,
  getInsProductUnqualifiedRetest,
  search, selectUserCondition,
  submitPlan,
  verifyPlan
} from "@/api/business/inspectionTask";
import { getUserNow, saveUnqualifiedContext } from "@/api/business/rawMaterialOrder";
import InspectionWorker from '@/workers/InspectionWorker.worker';
import DataWorker from '@/workers/DataWorker.worker';
export default {
  props: ['sonLaboratory', 'orderId', 'state', 'inspectorList', 'typeSource', 'unPassCheck', 'rawMaterialTag','cableTag', 'repetitionTag'],
  components: {
    AddUnPass,
    UnPassDialog
  },
  data() {
    return {
      isShow: this.unPassCheck,
      sagData: [],
      sagForm: {
        sampleCode: null,
        model: null,
        inspection: null,
        methodName: null,
        tensileForce: null,
        spanLength: null,
        load: null
      },
      dataGetDia: false,
      wareTableDataLoading: false,
      fileAdd: false,
      submitLoading: false,
      searchForm: {
        sampleName: null,
        state: null
      },
      id: 0,
      componentData0: {
        entity: {
          insOrderId: ''
        },
        isIndex: true,
        showSelect: false,
        select: false,
        sort: false,
        init: false,
        do: [
          {
            id: 'handleDown',
            font: '下载',
            type: 'text',
            method: 'handleDown'
          }, {
            id: 'delete',
            font: '删除',
            type: 'text',
            method: 'doDiy',
            disabled: (row, index) => {
              return this.state != 1
            }
          }
        ],
        isPage: false,
        linkEvent: {},
        tagField: {
          type: {
            select: [
              {
                value: 1,
                label: '图片'
              },
              {
                value: 2,
                label: '文件'
              }
            ]
          }
        },
        currentId: '',
        selectField: {},
        requiredAdd: [],
        requiredUp: []
      },
      changeType: null,
      getReportModelLoading: false,
      insOrder: {},
      sampleProduct: [],
      typeList: [],
      urgentList: [],
      currentSample: {}, //当前样品信息
      tableList: [],
      loading: false,
      ps: {},
      param: {},
      currentKey0: 1,
      currentKey1: 1,
      currentKey2: 1,
      comparisonList: [],
      excelMethodList: [],
      equipOptions: [],
      userId: 0,
      reviewLoading: false,
      reviewDia: false,
      noReason: '',
      tableWidth: 1000,
      currentTable: null,
      tableLists: [],
      widthList: [],
      addVerifyDia: false,
      verifyUser: null,
      personList: [],
      enumList: [],
      tableLoading: false,
      upLoading: false,
      temptList: null,
      currentTab: null,
      wareForm: {
        inspectionItem: 1,
        inspectionItemSubclass: '20(常温)',
      },
      wareForm0: {},
      numOptions: [],
      temperatureOptions: [],
      wareTableData: [],
      otherForm: {
        humidity: null,
        temperature: null,
      },
      equipForm: {
        value0: null,
        code0: null,
        value1: null,
        code1: null,
      },
      result: null,
      worker: null,
      worker0: null,
      wareLength: [],
      dataAcquisitionInfo: {},
      dataAcquisitionInfoNew: {},
      dataAcquisitionEidtAble: false,
      isGet: false,
      dataAcquisitionLoading: false,
      collected: false,
      // 热循环---开始
      thermalCyclingInfo: {
        max: 0,
        inspectionItem: 1,
        arr: [],
        length: 1,
        inspectionItemClass: null,
      },
      thermalCyclingLoading: false,
      temDataAcquisition: false,
      getData: [
        {
          faName: '波长附加衰减',
          child: [
            {
              name: '1285nm~1330nm',
              arr: [12, 13, 14, 15],
            },
            {
              name: '1525nm~1575nm',
              arr: [12, 13, 14, 15],
            },
          ]
        },
        {
          faName: '截至波长',
          child: [
            {
              name: '截至波长',
              arr: [12, 13, 14, 15],
            }
          ]
        }
      ],
      getDataIndex: [],
      getDataIndexLoading: false,
      getDataTypeId: '',
      getDataType: null,
      unPassDialog: false, // 不合格处理弹框
      retestTag: '1', // 复测次数
      addCheck: false, // 指定审核人员弹框
      checkUser: '',
      type: '',
      unPassNumList: [
        { retestTag: '1' },
        { retestTag: '2' },
      ],
    }
  },
  // 用于上传文件的信息
  computed: {
    headers() {
      return {
        'token': sessionStorage.getItem('token')
      }
    },
    action() {
      return this.javaApi + "/insOrderPlan/uploadFile";
    }
  },
  created() {
    this.id = this.orderId;
    this.getUserInfo()
  },
  mounted() {
    this.getTypeDicts() // 获取紧急程度下拉框选项
    this.getInsStateDicts()
    this.getComparisonList()
    this.getAuthorizedPerson()
    this.startWorker()
  },
  watch: {
    // 监听任务id,获取任务信息
    id(val) {
      this.loading = true
      doInsOrder({
        id: val,
        laboratory: this.sonLaboratory
      }).then(async res => {
        this.insOrder = res.data.insOrder;
        this.componentData0.entity.insOrderId = val;
        this.urgentList.forEach(m => {
          if (m.value == this.insOrder.type) {
            this.insOrder.typeName = m.label
          }
        })
        if (!res.data.sampleProduct || res.data.sampleProduct.length == 0) {
          return this.$message.error('该任务没有样品信息')
        }
        // 赋值当前样品列表
        this.sampleProduct = res.data.sampleProduct
        this.currentSample = this.HaveJson(this.sampleProduct[0])
        let insProduct = this.HaveJson(this.currentSample.insProduct)
        // 温度、湿度赋值
        this.otherForm = {
          temperature: this.insOrder.temperature ? this.insOrder.temperature : null,
          humidity: this.insOrder.humidity ? this.insOrder.humidity : null,
        }
        if (this.typeSource == '1') {
          this.retestTag = '1'
        }
        this.getEquipOptions(1)
        // 获取当前样品的检验项
        let list = await this.getCurrentProduct(this.currentSample.id, 0)
        if (list === undefined) {
          this.$message.warning('暂无不合格复测数据')
          this.$emit('closeUnPassCheckDialog')
          return
        }
        this.currentSample.insProduct = this.HaveJson(list)
        // 初始化传递到后端的参数
        this.param = {}
        this.changeType = 0;
        this.currentSample.insProduct.forEach(a => {
          // 是否为成品电缆下的松套管项目,不是则执行初始化
          if (this.handleCasing(a.inspectionItem)) {
            this.param[a.id] = {
              insValue: [],
              comValue: [],
              resValue: null,
              equipValue: [],
              equipName: [],
              insResult: null
            }
          }
        })
        // await this.determineWhetherToCollectData()//是否需要数采
        if (this.currentSample.index == undefined) this.currentSample['index'] = 1
        let bushing = this.currentSample.bushing
        this.getTableLists();//处理模板列表信息
        this.loading = false
 
      })
    },
    // 监听当前模板变化
    currentTable(val1, val0) {
      if (val0 != null && val1 != val0) {
        if (this.changeType && this.changeType > 0) {
          // 如果是光纤、光纤带,则不执行下面操作
          return
        }
        this.tableLists.forEach(async (m, i) => {
          if (m.templateId == val1) {
            let list = await this.getCurrentProduct(this.currentSample.id, 0)
            this.currentSample.insProduct = this.HaveJson(list)//赋值当前样品的检验项
            this.param = {}//初始化传到后端的参数
            this.currentSample.insProduct.forEach((a, j) => {
              if (this.handleCasing(a.inspectionItem)) {
                this.param[a.id] = {
                  insValue: [],
                  comValue: [],
                  resValue: null,
                  equipValue: [],
                  equipName: [],
                  insResult: null
                }
              }
            })
            // 去重模板,返回有几个模板
            const mySet1 = new Set();
            this.tableLists = this.currentSample.insProduct.filter(m => {
              let num0 = mySet1.size;
              if (m.templateId != null && m.template != null) {
                try {
                  mySet1.add(JSON.stringify({
                    template: m.template,
                    templateId: m.templateId
                  }))
                } catch (error) {
                  console.log(222, error);
                }
              }
              let num1 = mySet1.size;
              if (num1 > num0) {
                return m
              }
            });
            if (this.tableLists && this.tableLists.length > 0) {
              this.tableList = null;
              this.tableList = this.tableLists.filter(m => m.templateId == val1)
              // 对模板进行处理
              this.handleTableData()
            }
          }
        })
      }
    },
    // 特殊检验项--监听设备信息改变
    equipForm: {
      deep: true,
      handler(val) {
        if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验')) && this.equipOptions && this.equipOptions.length > 0) {
          // 初始化设备信息
          this.param[this.currentSample.insProduct[0].id].equipValue = []
          this.param[this.currentSample.insProduct[0].id].equipName = []
          if (this.equipForm.code0) {
            // 赋值第一个设备的信息
            this.equipForm.value0 = this.equipOptions.find(m => m.value == this.equipForm.code0).label
            this.param[this.currentSample.insProduct[0].id].equipValue.push({
              i: this.currentSample.insProduct[0].id,
              v: {
                v: this.equipForm.code0
              }
            })
            this.param[this.currentSample.insProduct[0].id].equipName.push({
              i: this.currentSample.insProduct[0].id,
              v: {
                v: this.equipForm.value0
              }
            })
          }
          if (this.equipForm.code1) {
            // 赋值第二个设备的信息
            this.equipForm.value1 = this.equipOptions.find(m => m.value == this.equipForm.code1).label
            this.param[this.currentSample.insProduct[0].id].equipValue.push({
              i: this.currentSample.insProduct[0].id,
              v: {
                v: this.equipForm.code1
              }
            })
            this.param[this.currentSample.insProduct[0].id].equipName.push({
              i: this.currentSample.insProduct[0].id,
              v: {
                v: this.equipForm.value1
              }
            })
          }
          // 保存数据
          this.saveInsContext()
        }
      }
    },
  },
  beforeDestroy() {
    // 在组件销毁前确保停止 Worker,避免内存泄漏
    this.stopWorker();
  },
  methods: {
    closeAddVerifyDia() {
      this.addCheck = false
      this.checkUser = ''
    },
    // 关闭不合格处理弹框
    resetForm() {
      this.$refs.unPassDialog.$refs['unPassForm'].resetFields();
      this.unPassDialog = false
    },
    handleDataAcquisition(data) {
      // 是否可以编辑数采数据
      if (this.dataAcquisitionEidtAble) {
        this.getDataType = 1;
      } else {
        this.getDataType = 2;
      }
      this.dataAcquisitionInfo = {}
      this.getData = []
      for (let i in data) {
        let obj = {
          faName: i,
          child: []
        }
        // 循环数采数据
        for (let j in data[i]) {
          // 拼接字符串  检验项+检验子项
          let str0 = ''
          if (i == j) {
            str0 = i + ','
          } else {
            str0 = i + ',' + j
          }
          if (j != 'frequency' && data[i][j] && (!data[i][j].result || typeof data[i][j].result == 'string')) {
            // 处理数采信息格式
            this.dataAcquisitionInfo[str0] = {
              value: data[i][j].result,
              frequency: data[i].frequency
            }
            let list = this.tableList[0].arr
            // 循环页面列表信息,判断数采数据对应页面列表信息的检验项是哪个,并给当前检验项绑定设备信息
            list.forEach((item, index) => {
              let num0 = 0;
              let str = ''
              item.forEach(m => {
                if (m.v.ps && (m.v.ps.value == '检验子项' || m.v.ps.value == '检验项')) {
                  if (m.v.ps && m.v.ps.value == '检验项') {
                    if (num0 == 0) {
                      str = m.v.v + ','
                      num0++
                    }
                  }
                  if (m.v.ps && m.v.ps.value == '检验子项') {
                    if (num0 == 1) {
                      str = str + m.v.v
                    }
                  }
                }
                // 绑定设备信息
                if (data[i][j].equipName && data[i][j].equipValue && m.v && m.v.ps && m.v.ps.value == '设备名称' && str0 == str) {
                  if (!m.v.v) {
                    this.changeEquip(data[i][j].equipValue, m, data[i][j].equipName)
                  }
                }
              })
            })
          } else if (j != 'frequency' && data[i][j] && Array.isArray(data[i][j].result)) {
            // 如果返回的数采数据是数组,则处理数组
            // 以下逻辑为获取每个检验项可输入的检验值的最大个数
            let str0 = ''
            if (i == j) {
              str0 = i + ','
            } else {
              str0 = i + ',' + j
            }
            let list = this.tableList[0].arr
            let maxNum = 0
            list.forEach((item, index) => {
              let num0 = 0;
              let str = ''
              item.forEach(m => {
                if (m.v.ps && (m.v.ps.value == '检验子项' || m.v.ps.value == '检验项')) {
                  if (m.v.ps && m.v.ps.value == '检验项') {
                    if (num0 == 0) {
                      str = m.v.v + ','
                      num0++
                    }
                  }
                  if (m.v.ps && m.v.ps.value == '检验子项') {
                    if (num0 == 1) {
                      str = str + m.v.v
                    }
                  }
                  let num = 0;
                  list[index].forEach(n => {
                    if (n.v.ps && n.v.ps.value && typeof n.v.ps.value == 'string' && n.v.ps.value.includes('检验值')) {
                      num++
                    }
                  })
                  if (str0 == str) {
                    maxNum = num
                  }
                }
                // 绑定设备
                if (data[i][j].equipName && data[i][j].equipValue && m.v && m.v.ps && m.v.ps.value == '设备名称' && str0 == str) {
                  if (!m.v.v) {
                    this.changeEquip(data[i][j].equipValue, m, data[i][j].equipName)
                  }
                }
              })
            })
            // 获取到最大检验值输入个数后重组数据
            let obj0 = {
              name: j,
              arr: data[i][j].result,
              maxNum: maxNum,
              value: []
            }
            // 如果数采返回的数组长度大于最大输入个数,则将数采数据在弹框中展示,用户选择需要手动选择数采的信息
            if (data[i][j].result && Array.isArray(data[i][j].result) && data[i][j].result.length > maxNum) {
              obj.child.push(obj0)
            } else {
              this.dataAcquisitionInfo[str0] = {
                value: data[i][j].result
              }
            }
          }
        }
        if (obj.child.length > 0) {
          this.getData.push(obj)
        }
      }
      // 如果存在数采返回的数组长度大于最大输入个数,则弹出弹框选择
      if (this.getData.length > 0) {
        this.dataGetDia = true
        this.getDataIndex = []
      } else {
        // 如果都不存在,则,进入处理数采线程里去处理数据
        try {
          // 向 Worker 发送消息,开始处理逻辑
          this.getDataIndexLoading = false
          this.dataGetDia = false
          this.getDataTypeId = ''
          this.worker0.postMessage(JSON.stringify({
            dataAcquisitionInfo: this.dataAcquisitionInfo,
            list: this.tableList[0].arr
          }));
        } catch (error) {
          console.log(1111, error);
        }
      }
      // 监听 Worker 返回的结果
      this.worker0.onmessage = (event) => {
        let result = JSON.parse(event.data);
        if (result.method == 'changeInput') {
          // 采集后的数据,需要进行计算的线程进行计算
          let { list, n } = result.value
          this.$set(this.tableList[0], 'arr', list)
          this.changeInput('', `${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`, n)
        } else if (result.getDataTypeId) {
          // 获取到数采最后一项,检验项的ID
          this.getDataTypeId = result.getDataTypeId
        }
      };
    },
    // 如果存在数采返回的数组长度大于最大输入个数,则弹出弹框选择,这里是弹框的提交
    submitDataGet() {
      if (this.getDataIndex.length == 0) {
        this.$message.error('请选择需要采集的数据')
        return
      }
      this.getDataIndex.sort((a, b) => a - b);
      for (let i = 0; i < this.getData.length; i++) {
        for (let j = 0; j < this.getData[i].child.length; j++) {
          // 对用户选择的数采信息进行处理,赋值
          let arr = []
          for (let k = 0; k < this.getDataIndex.length; k++) {
            arr.push(this.dataAcquisitionInfoNew[this.getData[i].faName][this.getData[i].child[j].name].result[this.getDataIndex[k]])
          }
          this.dataAcquisitionInfoNew[this.getData[i].faName][this.getData[i].child[j].name].result = arr
        }
      }
      this.getDataIndexLoading = true
      // 赋值完成后需要再次进入处理数采线程里去处理数据
      this.handleDataAcquisition(this.dataAcquisitionInfoNew)
    },
    // 多线程
    startWorker() {
      if (this.worker) {
        this.stopWorker(); // 确保之前的 Worker 已停止
      }
      // 创建 Worker 实例
      this.worker = new InspectionWorker();
      if (this.worker0) {
        this.stopWorker(); // 确保之前的 Worker 已停止
      }
      // 创建 Worker 实例
      this.worker0 = new DataWorker();
    },
    // 停止多线程
    stopWorker() {
      if (this.worker) {
        this.worker.terminate();
        this.worker = null;
      }
      if (this.worker0) {
        this.worker0.terminate();
        this.worker0 = null;
      }
    },
    // 根据类型、任务id、实验室来获取样品的检验项信息
    async getCurrentProduct(id, type, cableTag) {
      this.tableLoading = true;
      type = this.typeSource == '1' ? 5 : type
      this.type = type
      const params = {
        id: id,
        type: type,
        laboratory: this.sonLaboratory,
        retestTag: this.retestTag,
        rawMaterialTag: this.rawMaterialTag,
        repetitionTag: this.repetitionTag,
        cableTag: this.cableTag,
      }
      let res = await getInsProductUnqualifiedRetest(params)
      console.log('res---', res)
      if (res.code === 200 && res.data.length > 0) {
        this.tableLoading = false;
        this.scrollInit()
        return res.data
      }
    },
    // 松套管的判断\如果changeType不等于3那么页面不展示松套管检验项
    handleCasing(inspectionItem) {
      if (this.changeType != 3) {
        if (inspectionItem.includes('松套管')) {
          return false
        } else {
          return true
        }
      } else {
        return true
      }
    },
    async handleChangeCableTag(m, type, num, m2) {
      let cableTag = ''
      if (num === 'cableTag') {
        cableTag = m2
      }
      if (!m2) {
        type = 0
      }
      this.changeType = type
      if (m) {
        let list = await this.getCurrentProduct(m, type, cableTag)
        if (list.length > 0) {
          this.param = {}
          list.forEach(a => {
            this.param[a.id] = {
              insValue: [],
              comValue: [],
              resValue: null,
              equipValue: [],
              equipName: [],
              insResult: null
            }
          })
          this.getTableLists0(list)
          this.worker.postMessage(JSON.stringify({
            type: 'saveData',
            tableList: this.tableList,
            param: this.param,
            currentTable: this.currentTable,
            bushing: m
          }));
        } else {
          this.tableLists = []
          this.tableList = []
          this.$message.error('检验项为空')
        }
      }
    },
    // 字典获取信息
    getTypeDicts() {
      this.getDicts("urgency_level").then((response) => {
        this.urgentList = this.dictToValue(response.data);
      });
    },
    // 字典获取信息
    getInsStateDicts() {
      this.getDicts("inspection_task_state").then((response) => {
        this.typeList = this.dictToValue(response.data);
      })
    },
    // 字典获取信息
    getComparisonList() {
      this.getDicts("coordinate_transformation").then((response) => {
        this.comparisonList = this.dictToValue(response.data);
      });
    },
    // 处理页面列表数据--去重,生成检验模板切换列表
    getTableLists() {
      const mySet1 = new Set();
      this.tableLists = this.currentSample.insProduct.filter(m => {
        let num0 = mySet1.size;
        if (m.templateId != null && m.template != null) {
          try {
            mySet1.add(JSON.stringify({
              template: m.template,
              templateId: m.templateId
            }))
          } catch (error) {
            console.log(222, error);
          }
        }
        let num1 = mySet1.size;
        if (num1 > num0) {
          return m
        }
      });
      if (this.tableLists && this.tableLists.length > 0) {
        this.tableList = null;
        this.tableList = [this.tableLists[0]]
        this.currentTable = this.tableLists[0].templateId;
        // 处理页面列表数据
        this.handleTableData()
      }
    },
    // 光纤配置相关模板table列表
    getTableLists0(list) {
      const mySet1 = new Set();
      this.tableLists = list.filter(m => {
        let num0 = mySet1.size;
        if (m.templateId != null && m.template != null) {
          try {
            mySet1.add(JSON.stringify({
              template: m.template,
              templateId: m.templateId
            }))
          } catch (error) {
            console.log(333, error);
          }
        }
        let num1 = mySet1.size;
        if (num1 > num0) {
          return m
        }
      });
      if (this.tableLists && this.tableLists.length > 0) {
        this.tableList = null;
        this.tableList = [this.tableLists[0]]
        this.currentTable = this.tableLists[0].templateId;
        this.currentSample.insProduct = this.HaveJson(list)
        // 处理页面列表数据
        this.handleTableData()
      }
    },
    // 处理页面列表数据
    handleTableData() {
      console.log("ttt-------->>>>", this.tableList);
      this.excelMethodList = []//excel函数列表
      this.widthList = this.tableList[0].style.columnlen;//页面宽度--根据模板来的
      // 温度循环检验原始记录--开始
      if (this.tableLists.find(m => m.templateId == this.currentTable) && this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录') {
        // 对要求值进行拆分处理,进而得出页面内容
        let ask = this.currentSample.insProduct[0].ask
        let askList = ask.split(';')
        // 获取循环次数
        this.numOptions = []
        for (let i = 1; i <= askList[askList.length - 1]; i++) {
          this.numOptions.push({
            value: i,
            label: i
          })
        }
        let mySet1 = new Set();
        askList.forEach((m, i) => {
          if (i < askList.length - 1) {
            mySet1.add(m.split(',')[0].replace('℃', ''))
          }
        })
        // 获取温度点列表
        this.temperatureOptions = []
        mySet1.forEach(m => {
          this.temperatureOptions.push({
            value: String(m),
            label: m
          })
        })
      }
      // 温度循环检验原始记录---结束
      // 热循环检验原始记录---开始
      if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) {
        // 根据要求值拆分数据,得到页面渲染的信息
        let ask = this.currentSample.insProduct[0].ask
        let askList = ask.split(';')
        this.thermalCyclingInfo.max = Number(askList[askList.length - 1])
        let arr = []
        for (let i = 0; i < askList.length - 1; i++) {
          arr.push(askList[i].split(',')[0])
        }
        arr = arr.map(item => {
          let obj = {}
          obj.name = item;
          if (obj.insResult == null || obj.insResult == undefined) {
            obj.arr = [
              {
                value0: '',
                value1: '',
              }
            ]
            obj.insResult = null;
          }
          return obj
        })
        this.thermalCyclingInfo.arr = arr;
      }
      // 热循环检验原始记录---结束
      // 本次循环主要做页面渲染层面的处理--单元格合并预处理
      this.tableList.forEach(a => {
        let mcList = []
        a.template.forEach(b => {
          if (b.v.mc != undefined && b.v.mc.cs != undefined && b.v.mc.rs != undefined) {
            mcList.push(b)
          }
        })
        let count = 0
        mcList.forEach(b => {
          for (var c in a.template) {
            for (var i = 0; i < b.v.mc.cs; i++) {
              for (var i2 = 0; i2 < b.v.mc.rs; i2++) {
                if (a.template[c].c === b.c + i && a.template[c].r === b.r + i2) {
                  let bb = this.HaveJson(b)
                  a.template[c].v.v = bb.v.v
                  a.template[c].v.ps = bb.v.ps
                  a.template[c].v.fc = bb.v.fc
                  a.template[c].v.fs = bb.v.fs
                  a.template[c].v.ht = bb.v.ht
                  a.template[c].mc = count
                  break
                }
              }
            }
          }
          count++
        })
      })
      // 本次循环主要是控制合并,以及控制检验项信息是否展示出来,以便后续检验
      this.tableList.forEach(a => {
        let dels = new Set()//需要删除的行
        let ids = []//所有检验项的id
        let set3 = new Set()
        a.template.forEach(b => {
          let size1 = set3.size
          let size2 = set3.add(b.r).size
          if (size1 < size2) {
            let str = ''
            let str2 = ''
            let unit2 = ''
            let count4 = 0
            let isThree = 0
            a.template.forEach(c => {
              // 获取到 检验项分类+检验项+检验子项的拼接,如果模板里的信息跟接口返回的检验项信息能够匹配则展示出来
              if (b.r === c.r) {
                if (c.v.ps != undefined && c.v.ps.value === '检验项分类' && count4 === 0) {
                  // 三级分类
                  isThree = 1
                } else if (c.v.ps != undefined && c.v.ps.value === '检验项' && count4 === 0) {
                  // 二级分类
                  isThree = 0
                }
                if (isThree == 0) {
                  if (c.v.ps != undefined && c.v.ps.value === '检验项') {
                    if (count4 === 0) {
                      str += c.v.v
                      count4 += 1
                    }
                  } else if (c.v.ps != undefined && c.v.ps.value === '检验子项') {
                    if (count4 === 1) {
                      str += c.v.v
                      count4 += 1
                    }
                  }
                } else if (isThree == 1) {
                  if (c.v.ps != undefined && c.v.ps.value === '检验项分类') {
                    if (count4 === 0) {
                      str += c.v.v
                      count4 += 1
                    }
                  } else if (c.v.ps != undefined && c.v.ps.value === '检验项') {
                    if (count4 === 1) {
                      str += c.v.v
                      count4 += 1
                    }
                  } else if (c.v.ps != undefined && c.v.ps.value === '检验子项') {
                    if (count4 === 2) {
                      str += c.v.v
                      count4 += 1
                    }
                  }
                }
                if (str === '机械性能干态拉伸强度(纵向)') {
                  if (c.v.ps != undefined && c.v.ps.value === '单位') {
                    str2 = str + c.v.v
                    unit2 = c.v.v
 
                  }
                }
              }
            })
            if (str != '') {
              let count2 = 0
              for (let i in this.currentSample.insProduct) {
                let inspectionItemClass = this.currentSample.insProduct[i].inspectionItemClass == null || this.currentSample.insProduct[i].inspectionItemClass == undefined ? '' : this.currentSample.insProduct[i].inspectionItemClass
                let inspectionItem = this.currentSample.insProduct[i].inspectionItem == null || this.currentSample.insProduct[i].inspectionItem == undefined ? '' : this.currentSample.insProduct[i].inspectionItem
                let inspectionItemSubclass = this.currentSample.insProduct[i].inspectionItemSubclass == null || this.currentSample.insProduct[i].inspectionItemSubclass == undefined ? '' : this.currentSample.insProduct[i].inspectionItemSubclass
                if (inspectionItemSubclass === '干态拉伸强度(纵向)') {
                  // 检验子项为'干态拉伸强度(纵向)'时,模版里是两个计算值对应相同的检验值并且计算方式不同,要根据相同的'单位'做特殊的渲染
                  const unit = this.currentSample.insProduct[i].unit
                  if ((this.currentSample.insProduct[i].templateId === a.templateId && inspectionItemClass + inspectionItem + inspectionItemSubclass + unit === str2) || (this.currentSample.insProduct[i].templateId === a.templateId && !unit2.includes('/') && inspectionItemClass + inspectionItem + inspectionItemSubclass === str)) {
                    ids.push({
                      r: b.r,
                      id: this.currentSample.insProduct[i].id,
                      product: this.currentSample.insProduct[i]
                    })
                    break
                  }
                } else {
                  // 如果相等,那么说明找到了,并且把id存起来,后续检验项也会在页面中显示出来
                  if (this.currentSample.insProduct[i].templateId === a.templateId && inspectionItemClass + inspectionItem + inspectionItemSubclass === str) {
                    ids.push({
                      r: b.r,
                      id: this.currentSample.insProduct[i].id,
                      product: this.currentSample.insProduct[i]
                    })
                    break
                  }
                }
                count2++
              }
              if (count2 == this.currentSample.insProduct.length) {
                dels.add(b.r)
              }
            }
          }
        })
        // 操作删除
        dels.forEach(del => {
          for (let b = 0; b < a.template.length; b++) {
            if (a.template[b].r === del) {
              a.template.splice(b, 1)
              b -= 1
            }
          }
        })
        // 操作赋值--主要赋值单位,试验方法等信息
        ids.forEach(id => {
          for (let b = 0; b < a.template.length; b++) {
            if (a.template[b].r === id.r) {
              a.template[b].i = id.id
              if (a.template[b].v.ps != undefined && a.template[b].v.ps.value === '单位') {
                a.template[b].v.v = id.product.unit
              }
              if (a.template[b].v.ps != undefined && (a.template[b].v.ps.value === '试验方法' || a.template[b].v
                .ps.value === '检测方法')) {
                a.template[b].v.v = id.product.methodS
              }
            }
          }
        })
        let set2 = new Set()
        // 合并的数据处理,cs  rs  代表合并的数量
        a.template.forEach(b => {
          let size1 = set2.size
          let size2 = set2.add(b.mc).size
          if (b.mc != undefined && size1 < size2) {
            b.v.mc.rs = 0
            b.v.mc.cs = 0
            a.template.forEach(c => {
              if (b.mc === c.mc) {
                if (b.r === c.r) {
                  b.v.mc.cs += 1
                }
                if (b.c === c.c) {
                  b.v.mc.rs += 1
                }
              }
            })
          }
        })
      })
      // 本次循环主要是对后端传参进行初始化,样式逻辑修改
      this.tableList.forEach(a => {
        let arrs = []
        let set = new Set()
        let count1 = 0
        let conclusionList = []; //结论列表
        let finalList = []; //最终值列表
        // 结论与最终值在这里一一对应,以下两个列表长度肯定是一样的,如果有不一样,那么多半是模板配置得问题
        conclusionList = a.template.filter(n => n.v.ps != undefined && n.v.ps.value === '结论')//结论列表
        finalList = a.template.filter(n => n.v.ps != undefined && n.v.ps.value === '最终值')//最终值列表
        a.template.forEach(b => {
          if (b.v.ps != undefined && b.v.ps.value === '序号' && (b.v.mc == undefined || Object.keys(b.v.mc).length === 4)) {
            // 对序号进行赋值
            count1++
            b.v.v = count1
          }
          if (b.v.ps != undefined && b.v.ps.value === '要求值') {
            // 对要求值进行赋值
            b.v.v = this.getAsk(b.i)
          }
          // 对页面的和给后端传参的检验值,计算值,设备编码,设备名称,最终值,结论进行初始化
          if (b.v.ps != undefined && typeof b.v.ps.value === 'string' && b.v.ps.value.includes('检验值')) {
            this.$set(b.v, 'v', '')
            // b.v.v = ''
            b.u = ''
            b.i && this.param[b.i] && this.param[b.i].insValue.push(b)
          }
          if (b.v.ps != undefined && b.v.ps.value === '计算值') {
            this.$set(b.v, 'v', '')
            // b.v.v = ''
            b.i && this.param[b.i] && this.param[b.i].comValue.push(b)
          }
          if (b.v.ps != undefined && b.v.ps.value === '设备编码') {
            // b.v.v = ''
            this.$set(b.v, 'v', '')
            b.i && this.param[b.i] && this.param[b.i].equipValue.push(b)
          }
          if (b.v.ps != undefined && b.v.ps.value === '设备名称') {
            this.$set(b.v, 'v', '')
            // b.v.v = ''
            b.i && this.param[b.i] && this.param[b.i].equipName.push(b)
          }
          if (b.v.ps != undefined && b.v.ps.value === '最终值') {
            // b.v.v = ''
            this.$set(b.v, 'v', '')
            if (b.i !== undefined && this.param[b.i] && !this.param[b.i].resValue) {
              this.param[b.i].resValue = b
            }
          }
          if (b.v.ps != undefined && b.v.ps.value === '结论') {
            if (b.i !== undefined && this.param[b.i] && !this.param[b.i].insResult) {
              this.param[b.i].insResult = b
              conclusionList.forEach((n, i) => {
                if (n.r == b.r && n.c == b.c) {
                  b.v.f =
                    `(${this.comparisonList.find(j => j.value == (finalList[i].c)).label}${finalList[i].r + 1})`
 
                }
              })
            }
          }
          set.add(b.r)
          // 如果模板列表的函数存在,那么加入到excel函数列表里面
          if (b.v.f) {
            this.excelMethodList.push(b)
          }
        })
        // 以下是样式处理逻辑
        // set = Array.sort(set)
        set = [...set]
        set.forEach(b => {
          let arr = []
          a.template.forEach(c => {
            if (c.r === b) {
              arr.push(c)
            }
          })
          arrs.push(arr)
        })
        a.arr = arrs
        this.tableWidth = 0
        for (let i = 0; i < arrs[0].length; i++) {
          this.tableWidth += (a.style.columnlen[i] === undefined ? 100 : a.style.columnlen[i])
        }
      })
      // 本次循环主要是对页面及后端传参进行初始化赋值
      this.currentSample.insProduct.forEach(async a => {
        try {
          // 计算值赋值
          let comValue = JSON.parse(a.insProductResult.comValue)
          for (var i = 0; i < comValue.length; i++) {
            this.param[a.id].comValue[i].v.v = this.toFixed(comValue[i].v, this.param[a.id].comValue[i].v.ct)
          }
        } catch (e) { }
        try {
          // 检验值赋值
          let insValue = JSON.parse(a.insProductResult.insValue)
          for (let i = 0; i < insValue.length; i++) {
            if (this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r)) {
              this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r).v.v = this.toFixed(insValue[i].v, this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r).v.ct)
              this.param[a.id].insValue.find(m => m.c == insValue[i].c && m.r == insValue[i].r).u = insValue[i].u
              // this.param[a.id].insValue[i].v.v = insValue[i].v
              // this.param[a.id].insValue[i].u = insValue[i].u
            }
          }
        } catch (e) { }
        try {
          // 设备编号赋值
          let equipValue = JSON.parse(a.insProductResult.equipValue)
          if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) {
            // 特殊项目初始化
            this.param[a.id].equipValue = []
            for (let i = 0; i < equipValue.length; i++) {
              this.param[a.id].equipValue.push({
                v: {
                  v: ''
                }
              })
            }
          }
          for (let i = 0; i < equipValue.length; i++) {
            if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) {
              // 温度循环设备赋值
              this.$set(this.equipForm, `code` + i, equipValue[i].v)
              this.param[a.id].equipValue[i].v.v = equipValue[i].v
            } else {
              // 普通设备赋值
              this.param[a.id].equipValue[i].v.v = equipValue[i].v
            }
          }
        } catch (e) { }
        try {
          // 设备名称赋值
          let equipName = JSON.parse(a.insProductResult.equipName)
          for (let i = 0; i < equipName.length; i++) {
            equipName[i].v !== '' && equipName[i].v.map(val => {
              const index = this.equipOptions.findIndex(item => item.value === val)
              if (index > -1) {
                // 根据设备编码转换为相应的设备名称
                val = this.equipOptions[index].deviceName
              }
            })
          }
          if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) {
            // 设备名称初始化
            this.param[a.id].equipName = []
            for (let i = 0; i < equipName.length; i++) {
              this.param[a.id].equipName.push({
                v: {
                  v: ''
                }
              })
            }
          }
          for (let i = 0; i < equipName.length; i++) {
            if (this.tableLists.find(m => m.templateId == this.currentTable) && (this.tableLists.find(m => m.templateId == this.currentTable).templateName == '温度循环检验原始记录' || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('热循环') || this.tableLists.find(m => m.templateId == this.currentTable).templateName.includes('温升试验'))) {
              // 温度循环赋值
              this.$set(this.equipForm, `value` + i, equipName[i].v)
              this.param[a.id].equipName[i].v.v = equipName[i].v
            } else {
              // 普通设备名称赋值
              this.param[a.id].equipName[i].v.v = equipName[i].v
            }
          }
        } catch (e) {
          console.log('设备名称赋值----', e)
        }
        try {
          // 最终值赋值
          this.param[a.id].resValue.v.v = this.toFixed(a.lastValue, this.param[a.id].resValue.v.ct)
          // 结论赋值
          this.param[a.id].insResult.v.v = a.insResult
        } catch (e) { }
      })
      // 对excel函数进行处理
      this.handleExcelMethod()
    },
    // 检验值输入后触发的函数
    changeInput(m, code, n, getDataType) {
      // 为数采定义一个逻辑参数
      if (getDataType == 'getDataType') {
        this.getDataType = 2;
      }
      let currentInsItemId = null//当前检验项id
      if (n) {
        currentInsItemId = JSON.parse(JSON.stringify(n.i))
        // 定义一个函数来验证分数是否有效
        if (typeof n.v.v == 'string') {
          function isValidFraction(fraction) {
            const [numerator, denominator] = fraction.split('/'); // 分子和分母
            return !(!denominator || !numerator);
          }
          const isTrue = isValidFraction(n.v.v)
          if (!isTrue) {
            n.v.v = n.v.v.replace('/', '')
          }
        }
      }
      try {
        // 向 Worker 发送消息,开始处理逻辑
        this.worker.postMessage(JSON.stringify({
          code: code,
          tableList: this.tableList,
          excelMethodList: this.excelMethodList,
          comparisonList: this.comparisonList,
          currentSample: this.currentSample,
          PROJECT: this.PROJECT,
          param: this.param,
          currentTable: this.currentTable,
          getDataTypeId: this.getDataTypeId,
          modelType: this.sampleProduct[0].model,
          currentInsItem: n
        }));
      } catch (error) {
        console.log(444, error);
      }
 
      // 监听 Worker 返回的结果
      this.worker.onmessage = (event) => {
        this.result = JSON.parse(event.data);
        switch (this.result.method) {
          case 'saveInsContext':
            console.log(`output->`, 11111111111111)
            this.$nextTick(() => {
              // this.$delete(this.tableList[0],'arr')
              this.$set(this.tableList[0], 'arr', this.result.value.tableList[0].arr)
              this.param = this.result.value.param
              if (this.result.value.currentInsItem) {
                currentInsItemId = this.result.value.currentInsItem.i
              }
              // 特殊处理一下结论,会有这种特殊情况
              for (var i in this.param) {
                if (this.param[i].insResult && this.param[i].insResult.v && this.param[i].insResult.v.v) {
                  if (this.param[i].insResult.v.v == '合格') {
                    this.$set(this.param[i].insResult.v, 'v', 1)
                  } else if (this.param[i].insResult.v.v == '不合格') {
                    this.$set(this.param[i].insResult.v, 'v', 0)
                  }
                }
              }
            })
            break;
          case 'tableList':
            this.$nextTick(() => {
              // 更新数据
              this.$delete(this.tableList[0], 'arr')
              this.$set(this.tableList[0], 'arr', this.result.value[0].arr)
              // this.param = this.result.value.param
              if (this.result.value.currentInsItem) {
                currentInsItemId = this.result.value.currentInsItem.i
              }
            })
            break;
          case 'getCurrentInsProduct':
            // 更新页面数据
            this.getCurrentInsProduct(this.result.value)
            break;
        }
      };
      // 保存数据
      setTimeout(() => {
        this.saveInsContext(currentInsItemId)
      }, 200)
    },
    // 是否需要数采
    // async determineWhetherToCollectData() {
    //   let res = determineWhetherToCollectData({ managementNumber: '' })
    //   this.isGet = res.data
    // },
    // 根据后端传参更新页面数据   param => this.tableList[0].insProductResult
    getCurrentInsProduct(pId) {
      if (!this.tableList[0].insProductResult) {
        this.tableList[0].insProductResult = {}
      }
      for (let m in this.param[pId]) {
        let value = this.param[pId][m]
        switch (m) {
          case 'comValue':
            // 赋值计算值
            if (value && value.length > 0) {
              this.tableList[0].insProductResult[m] = [];
              value.forEach((a, i) => {
                let obj = {
                  v: a.v.v,
                }
                this.tableList[0].insProductResult[m].push(obj);
              })
              try {
                this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m])
              } catch (error) {
                console.log(555, error);
              }
            }
            break;
          // 赋值检验值
          case 'insValue':
            if (value && value.length > 0) {
              this.tableList[0].insProductResult[m] = [];
              value.forEach((a, i) => {
                let obj = {
                  v: a.v.v,
                  u: a.u,
                }
                this.tableList[0].insProductResult[m].push(obj);
              })
              try {
                this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m])
              } catch (error) {
                console.log(666, error);
              }
            }
            break;
          // 赋值设备编号
          case 'equipValue':
            if (value && value.length > 0) {
              this.tableList[0].insProductResult[m] = [];
              value.forEach((a, i) => {
                let obj = {
                  v: a.v.v,
                }
                this.tableList[0].insProductResult[m].push(obj);
              })
              try {
                this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m])
              } catch (error) {
                console.log(777, error);
              }
            }
            break;
          // 赋值设备名称
          case 'equipName':
            if (value && value.length > 0) {
              this.tableList[0].insProductResult[m] = [];
              value.forEach((a, i) => {
                let obj = {
                  v: a.v.v,
                }
                this.tableList[0].insProductResult[m].push(obj);
              })
              try {
                this.tableList[0].insProductResult[m] = JSON.stringify(this.tableList[0].insProductResult[m])
              } catch (error) {
                console.log(888, error);
              }
            }
            break;
          // 赋值最终值
          case 'resValue':
            this.tableList[0].lastValue = value ? value.v.v : ''
            break;
          // 赋值结论
          case 'insResult':
            this.tableList[0].insResult = value ? value.v.v : ''
            break;
        }
      }
    },
    // 对EXCEL函数进行处理
    handleExcelMethod() {
      if (this.excelMethodList.length > 0) {
        this.excelMethodList.map(item => {
          // 得到每个函数的参数列表
          item.valueList = excelFunction.changeParameter(item.v.f);
          return item;
        })
      }
    },
    getValue(v) {
      // 对页面展示数据进行处理,@,代表换行
      let str = v.v ? v.v : (v.v === 0 ? v.v : (v.ct && v.ct.s ? v.ct.s.length > 0 && v.ct.s[0].v.replace(new RegExp('\n', 'g'), '<br/>').replace(new RegExp('@', 'g'), '<br/>') : ''))
      // 对数据保留小数点进行处理
      if (v.ct && v.ct.fa && v.ct.fa.includes('.') && str) {
        let num = 0
        let str0 = v.ct.fa.split('.')[1]
        num = str0.length
        str = Number(str).toFixed(num)
      }
      if (v.v && typeof v.v == 'string' && v.v.includes('@')) {
        str = v.v.replace(new RegExp('@', 'g'), '<br/>')
      }
      return str
    },
    // 获取当前输入框类型
    getInspectionValueType(id) {
      for (var a in this.currentSample.insProduct) {
        if (this.currentSample.insProduct[a].id == id) {
          return this.currentSample.insProduct[a].inspectionValueType
        }
      }
    },
    // 获取要求描述
    getTell(id) {
      for (var a in this.currentSample.insProduct) {
        if (this.currentSample.insProduct[a].id == id) {
          return this.currentSample.insProduct[a].tell
        }
      }
    },
    // 动态获取单元格宽度
    handleWidth(n) {
      let sum = 0;
      if (n.v.mc && n.v.mc.cs && n.v.mc.c != undefined) {
        for (let i = 0; i < n.v.mc.cs; i++) {
          let num = this.widthList[i + n.v.mc.c] ? this.widthList[i + n.v.mc.c] : 100
          sum += num;
        }
      } else {
        sum = this.widthList[n.c] ? this.widthList[n.c] : 100
      }
      return sum
    },
    // 对输入值进行格式校验
    handleInput(n) {
      try {
        n.v.v = n.v.v.replace(/[^\d.^e>\-/+]/g, '');
        n.v.v = n.v.v.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
        n.v.v = n.v.v.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        n.v.v = n.v.v.replace(/\/{2,}/g, "/"); //只保留第一个/清除多余的
        n.v.v = n.v.v.replace("/", "$#$").replace(/\//g, "").replace("$#$", "/");
      } catch (error) {
        console.log(error);
      }
 
    },
    getInspectionItemType(id) {
      for (var a in this.currentSample.insProduct) {
        if (this.currentSample.insProduct[a].id == id) {
          return this.currentSample.insProduct[a].inspectionItemType
        }
      }
    },
    // 获取要求值
    getAsk(id) {
      for (var a in this.currentSample.insProduct) {
        if (this.currentSample.insProduct[a].id == id) {
          return this.currentSample.insProduct[a].ask
        }
      }
    },
    getSystemValue(n) {
      let code = null
      try {
        this.param[n.i].equipValue.forEach(a => {
          if (a.r === n.r) {
            if (a.v.v == null || a.v.v == '') {
              this.$message.error('请先选择采集的设备')
              return
            } else {
              code = a.v.v
            }
          }
        })
      } catch (e) {
        // console.log(e);
        this.$message.error('找不到设备内容')
      }
      // console.log(n, code);
      fetch('http://localhost:82/微信图片_20240518100811.png').then(res => res.blob()).then(blob => {
        // console.log(blob);
        const url = URL.createObjectURL(blob)
        // console.log(url);
      })
      /* this.$message.error('采集失败【已开放手动方式】')
        for (var a in this.currentSample.insProduct) {
          if (this.currentSample.insProduct[a].id == n.i) {
            this.currentSample.insProduct[a].inspectionItemType = 0
          }
        } */
    },
    // 获取所有设备
    getEquipOptions(e, id) {
      if (e) {
        this.equipOptions = []
        search({ status: 0 }).then(res => {
          if (res.code === 200 && res.data) {
            this.equipOptions = res.data.map(m => {
              m.value = m.managementNumber
              m.label = m.deviceName
              return m
            })
          }
        }).catch(error => {
          console.error(error)
        })
      }
    },
    getUserInfo() {
      getUserNow().then(res => {
        this.userId = res.data.id
      })
    },
    // 复核
    upInsReview(e) {
      if (e == 1) {
        // 通过
        this.reviewLoading = true;
        verifyPlan({
          orderId: this.orderId,
          type: 1,
          laboratory: this.sonLaboratory,
          tell: null,
          userId: this.checkUser
        }).then(res => {
          if (res.code === 200) {
            this.$message.success("操作成功")
            this.$emit('goback')
            this.addCheck = false
          }
          this.reviewLoading = false;
        }).catch(error => {
          console.error(error)
          this.reviewLoading = false;
        })
      } else {
        // 不通过
        this.reviewDia = true;
      }
    },
    handleReviewDia() {
      if (this.noReason) {
        this.reviewLoading = true;
        verifyPlan({
          orderId: this.orderId,
          type: 0,
          laboratory: this.sonLaboratory,
          tell: this.noReason
        }).then(res => {
          if (res.code === 200) {
            this.$message.success("操作成功")
            this.$emit('goback')
          }
          this.reviewLoading = false;
        }).catch(error => {
          console.error(error)
          this.reviewLoading = false;
        })
      } else {
        this.$message.error('未输入不通过原因')
      }
    },
    submit() {
      if (this.verifyUser === null || this.verifyUser === '') {
        this.$message.error("请指定复核人员")
        return
      }
      if (!this.otherForm.humidity) {
        this.$message.error("请输入湿度")
        return
      }
      if (!this.otherForm.temperature) {
        this.$message.error("请输入温度")
        return
      }
      this.submitLoading = true;
      checkSubmitPlan({
        orderId: this.orderId,
        laboratory: this.sonLaboratory,
      }).then(res => {
        if (res.code === 200) {
          if (!res.data || res.data.length == 0) {
            this.submitLoading = true;
            submitPlan({
              orderId: this.orderId,
              laboratory: this.sonLaboratory,
              verifyUser: this.verifyUser,
              entrustCode: this.insOrder.entrustCode
            }).then(res => {
              if (res.code === 200) {
                this.$message.success("操作成功")
                this.$emit('goback')
                this.submitLoading = false;
                this.addVerifyDia = false
              }
            }).catch(error => {
              console.error(error)
              this.submitLoading = false;
            })
          } else {
            let newData = []
            const h = this.$createElement
            for (let i in res.data) {
              const lastChar = res.data[i].slice(-1);
              if (lastChar == '-') {
                res.data[i] = res.data[i].slice(0, -1);
              }
              newData.push(h('p', { style: 'font-size: 14px;color: red;' }, (Number(i) + 1) + '、' + res.data[i]))
            }
            newData.push(h('p', { style: 'font-size: 16px;color:#000;margin-top:12px;overflow-y: auto;max-height:80vh' }, '以上项目不合格,确定提交?'))
            this.$confirm('提示', {
              title: '提示',
              message: h('div', null, newData),
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: ""
            }).then(() => {
              this.submitLoading = true;
              submitPlan({
                orderId: this.orderId,
                laboratory: this.sonLaboratory,
                verifyUser: this.verifyUser
              }).then(res => {
                if (res.code === 200) {
                  this.$message.success("操作成功")
                  this.addVerifyDia = false
                  this.$emit('goback')
                }
                this.submitLoading = false;
              }).catch(error => {
                console.error(error)
                this.submitLoading = false;
              })
            }).catch(() => { })
          }
        }
      }).catch(error => {
        console.error(error)
        this.submitLoading = false;
      })
      return
    },
    // 统一在这里保存数据
    saveInsContext(currentInsItemId) {
      try {
        if (this.param) {
          let param = null
          if (currentInsItemId) {
            param = { [currentInsItemId]: this.param[currentInsItemId] }
          } else {
            param = this.param
          }
          saveUnqualifiedContext({
            param: JSON.stringify(param),
            currentTable: this.currentTable,
            sampleId: this.currentSample.id
          }).then(res => {
            this.$message.success('已保存')
          })
          // 向 Worker 发送消息,开始处理逻辑
          this.worker.postMessage(JSON.stringify({
            modelType: this.sampleProduct[0].model,
            type: 'saveData',
            tableList: this.tableList,
            param: this.param,
            currentTable: this.currentTable
          }));
        }
      } catch (error) {
        console.log(999, error);
      }
    },
    // 设备改变
    changeEquip(val, n, v) {
      try {
        // this.$set(n.v,'v',val)
        this.tableList[0].arr.forEach((item, index) => {
          item.forEach((m, i) => {
            if (this.param[m.i]) {
              this.param[m.i].state = 1
            }
            // if(m.i==n.i&&m.v.ps&&m.v.ps.value=='设备名称'&&v){
            //   this.$set(m.v,'v',v)
            // }
          })
        })
        for (let i in this.param) {
          if (this.param[i].state != 1) {
            delete this.param[i]
          }
        }
        // if(val&&v){
        //   for (let i1 in this.param[n.i].equipName) {
        //     if (this.param[n.i].equipName[i1].i === n.i && this.param[n.i].equipName[i1].r === n.r) {
        //       this.$delete(this.param[n.i].equipValue[i1].v,'v')
        //       this.$set(this.param[n.i].equipValue[i1].v,'v',val)
        //       this.$delete(this.param[n.i].equipName[i1].v,'v')
        //       this.$set(this.param[n.i].equipName[i1].v,'v',v)
        //     }
        //   }
        // }
        // this.equipOptions为设备名称下拉框选项数据
        for (let i1 in this.param[n.i].equipName) {
          if (this.param[n.i].equipName[i1].i === n.i && this.param[n.i].equipName[i1].r === n.r) {
            this.$delete(this.param[n.i].equipValue[i1].v, 'v')
            // 将数组赋值给设备编码
            this.$set(this.param[n.i].equipValue[i1].v, 'v', val.join(','))
            this.$delete(this.param[n.i].equipName[i1].v, 'v')
            // 将数组赋值给设备编码
            this.$set(this.param[n.i].equipName[i1].v, 'v', val)
            this.tableList[0].arr.forEach((item, index) => {
              item.forEach((m) => {
                if (m.i == n.i && m.v.ps && m.v.ps.value == '设备编码') {
                  this.$set(m.v, 'v', val.join(','))
                }
                if (m.i == n.i && m.v.ps && m.v.ps.value == '设备名称') {
                  this.$set(m.v, 'v', val)
                }
              })
            })
          }
        }
        // 保存数据
        this.saveInsContext(n.i)
      } catch (e) {
        console.log('changeEquip----', e)
      }
    },
    getAuthorizedPerson() {
      selectUserCondition({ type: 1 }).then((res) => {
        let data = [];
        res.data.forEach((a) => {
          data.push({
            label: a.name,
            value: a.id,
          });
        });
        this.personList = data;
      });
    },
    scrollInit() {
      // 获取要绑定事件的元素
      const nav = document.getElementById("tableBox")
      let flag; // 鼠标按下
      let downX; // 鼠标点击的x下标
      let scrollLeft; // 当前元素滚动条的偏移量
      nav.addEventListener("mousedown", function (event) {
        flag = true;
        downX = event.clientX; // 获取到点击的x下标
        scrollLeft = this.scrollLeft; // 获取当前元素滚动条的偏移量
      });
      nav.addEventListener("mousemove", function (event) {
        if (flag) { // 判断是否是鼠标按下滚动元素区域
          let moveX = event.clientX; // 获取移动的x轴
          let scrollX = moveX - downX; // 当前移动的x轴下标减去刚点击下去的x轴下标得到鼠标滑动距离
          this.scrollLeft = scrollLeft - scrollX // 鼠标按下的滚动条偏移量减去当前鼠标的滑动距离
        }
      });
      // 鼠标抬起停止拖动
      nav.addEventListener("mouseup", function () {
        flag = false;
      });
      // 鼠标离开元素停止拖动
      nav.addEventListener("mouseleave", function (event) {
        flag = false;
      });
    },
    async caretTape(num) {
      let index = this.currentKey1 + num
      if (index < 1) {
        this.$message.error('当前是第一个光纤带')
        return
      } else if (index > this.fiberOpticTape.length) {
        this.$message.error('当前是最后一个光纤带')
        return
      }
      this.currentKey1 = index
      this.currentFiberOpticTape = this.HaveJson(this.fiberOpticTape[index - 1])
      this.param = {}
      this.fiberOptic = []
      this.currentFiberOptic = null;
      this.currentFiberOpticTape.productList.forEach(a => {
        this.param[a.id] = {
          insValue: [],
          comValue: [],
          resValue: null,
          equipValue: [],
          equipName: [],
          insResult: null
        }
      })
      this.fiberOpticTapeVisible = false;
      let list = await this.getCurrentProduct(this.currentFiberOpticTape.id, 1)
      this.getTableLists0(list)
      if (this.currentFiberOpticTape.fiber && this.currentFiberOpticTape.fiber.length > 0) {
        // 配置光纤
        this.fiberOptic = this.currentFiberOpticTape.fiber;
      }
    },
    async caretOptic(num) {
      let index = this.currentKey2 + num
      if (index < 1) {
        this.$message.error('当前是第一个光纤')
        return
      } else if (index > this.fiberOptic.length) {
        this.$message.error('当前是最后一个光纤')
        return
      }
      this.currentKey2 = index
      this.currentFiberOptic = this.HaveJson(this.fiberOptic[index - 1])
      this.currentFiberOptic.productList.forEach(a => {
        this.param[a.id] = {
          insValue: [],
          comValue: [],
          resValue: null,
          equipValue: [],
          equipName: [],
          insResult: null
        }
      })
      let list = await this.getCurrentProduct(this.currentFiberOptic.id, 2)
      this.getTableLists0(list)
    },
    beforeUpload(file) {
      if (file.size > 1024 * 1024 * 10) {
        this.$message.error('上传文件不超过10M');
        this.$refs.upload.clearFiles()
        return false;
      } else {
        this.upLoading = true;
        return true;
      }
    },
    onError(err, file, fileList) {
      this.$message.error('上传失败')
      this.$refs.upload.clearFiles()
    },
    handleDown(row) {
      downFile({
        id: row.id,
      }).then(res => {
        this.$download.saveAs(res.data.fileUrl, row.fileName);
      }).catch(error => {
 
      })
    },
    /**
     * 将数值v保留ct.fa中'##'后的指定小数位数,并返回格式化后的字符串。
     *
     * @param v 要格式化的数值
     * @param ct 包含格式化配置的对象
     * @param ct.fa 格式化配置字符串,若包含'##'则按照其后的内容确定小数位数
     * @returns 格式化后的字符串或原始数值(若配置不符合要求)
     */
    toFixed(v, ct) {
      if (v && ct && ct.fa) {
        if (ct.fa.includes('.')) {
          let num = ct.fa.slice(4).length
          return Number(v).toFixed(num)
        } else {
          return v
        }
      } else {
        return v
      }
    }
  }
}
</script>
<style scoped>
.custom-table .el-table__header-wrapper th {
  background-color: #87CEEB;
  /* 只对带有my-custom-table类的表格生效 */
  color: #fff;
}
 
.container {
  overflow: auto;
  /* 确保容器能包裹浮动元素 */
  margin-bottom: 10px;
}
 
.right-button {
  float: right;
}
 
.inspection {
  height: 100%;
  overflow-y: auto;
}
 
.inspection::-webkit-scrollbar {
  width: 0;
}
 
.title {
  height: 60px;
  line-height: 60px;
}
 
.search {
  width: 100%;
  margin-bottom: 10px;
  background-color: #fff;
  border-radius: 3px;
}
 
.search .form-inline {
  padding-top: 20px;
  padding-left: 0px;
  text-align: left;
}
 
.center {
  width: calc(100% - 40px);
  /* max-height: 580px; */
  background-color: #fff;
  border-radius: 3px;
  padding: 20px;
  overflow: auto;
}
 
.center-box {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  flex-wrap: wrap;
  width: 100%;
  overflow-x: auto;
  /* overflow-x: scroll; */
  cursor: grab;
}
 
.center-box:active {
  cursor: grabbing;
}
 
.tables {
  table-layout: fixed;
  margin: 5px 5px 16px;
}
 
.tables td {
  height: 40px;
  width: 100px;
  text-align: center;
  font-size: 14px;
  word-wrap: break-word;
  white-space: normal;
}
 
.thermal-table {
  min-width: calc(100% - 10px);
  margin: 5px 5px 0;
  table-layout: fixed;
}
 
.thermal-table td {
  min-width: 70px;
  text-align: center;
  font-size: 14px;
  word-wrap: break-word;
  white-space: normal;
  padding: 5px;
}
 
.table-container {
  overflow-x: auto;
  /* 使容器支持横向滚动 */
  max-width: 100%;
  /* 限制容器的最大宽度 */
  margin-bottom: 16px;
}
 
.content {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: left;
  padding: 5px;
  box-sizing: border-box;
  overflow: hidden;
  user-select: none;
}
 
.content * {
  user-select: none;
}
 
.content-h-0 {
  justify-content: center;
}
 
.content-h-1 {
  justify-content: start;
}
 
.content-h-2 {
  justify-content: flex-end;
}
 
.content-v-0 {
  align-items: center;
}
 
.content-v-1 {
  align-items: start;
}
 
.content-v-2 {
  align-items: end;
}
 
.table_input {
  width: 100%;
  height: 100%;
}
 
.table_input>>>.el-input__inner {
  border-color: rgba(0, 0, 0, 0.5) !important;
}
 
.collection {
  width: 50px;
  height: 100%;
  margin-left: 5px;
  border-color: transparent;
  background-color: #409eff;
  color: #fff;
  border-radius: 4px;
  font-size: 12px;
}
 
.collection:active {
  opacity: .7;
}
 
.table_caret {
  font-size: 16px;
  margin: 0 5px;
  color: rgba(0, 0, 0, 0.5);
}
 
.table_caret:hover {
  color: #409eff;
  cursor: pointer;
}
 
.table_caret:active {
  opacity: .8;
}
 
>>>input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  /* 隐藏微调按钮 */
  margin: 0 !important;
  /* 移除微调按钮的边距 */
}
 
>>>input[type=number] {
  -moz-appearance: textfield !important;
  /* 针对 Firefox */
}
 
>>>.el-form-item__content {
  display: inline-flex;
  align-items: center;
}
</style>
<style>
.inspection .el-form-item__label {
  color: #000;
}
 
.inspection .el-drawer__header::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 30.24px;
  background: #3A7BFA;
  border-radius: 10px;
  margin-left: 32px;
  margin-right: 8.5px;
}
 
.inspection .el-drawer__header {
  color: #303133;
  text-align: left;
}
 
.inspection .el-input-group__append {
  padding: 0 14px;
  color: #3A7BFA;
  background-color: #fff;
  height: 100%;
  display: flex;
  align-items: center;
}
 
.inspection .center-box .el-input__inner {
  font-size: 12px;
  padding: 0 6px;
  text-align: center;
}
 
.inspection .el-textarea__inner {
  padding: 2px;
}
 
.inspection .el-textarea__inner::-webkit-scrollbar {
  width: 0;
}
 
.inspection .el-select {
  display: flex;
  align-items: center;
}
 
.inspection .el-textarea__inner {
  min-height: 100% !important;
}
 
.inspection .tables .el-input {
  display: flex;
  align-items: center;
}
 
.thermal-table .el-input {
  display: flex;
  align-items: center;
}
 
.custom-dialog .el-dialog__body {
  max-width: 1000px;
  /* 设置最大宽度 */
}
 
.unPassCheck .el-dialog__body {
  overflow: auto;
  max-height: 800px;
  /* 设置最大宽度 */
}
</style>