无人机管理后台前端(已迁走)
张含笑
2025-09-01 2ca94de8ede18ac07ccfd8dec7b6f6a707adde9b
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
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
<template>
  <basic-container>
    <el-tabs v-model="activeTab" @tab-click="handleTabChange">
      <el-tab-pane
        v-for="tab in filteredTabs"
        :key="tab.name"
        :label="`${tab.label} (${tab.count})`"
        :name="tab.name"
      >
        <basic-main-content>
          <!-- 查询条件筛选栏 -->
          <div class="filter-bar">
            <el-input
              v-model="filters.keyword"
              placeholder="请输入关键字"
              class="filter-item"
              clearable
              @clear="handleKeyWords"
              @keyup.enter="handleSearch"
            />
            <!-- <el-select
              v-model="filters.department"
              placeholder="请选择所属单位"
              class="filter-item"
              clearable
            >
              <el-option
                v-for="item in departments"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select> -->
            <!-- <el-select
              v-model="filters.type"
              placeholder="请选择工单类型"
              class="filter-item"
              clearable
              @change="handleSearch"
            >
              <el-option
                v-for="item in types"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select> -->
            <el-date-picker
              v-model="filters.dateRange"
              type="daterange"
              class="filter-item"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :default-value="datePickerDefaultVal"
            >
            </el-date-picker>
            <el-select
              v-model="filters.status"
              placeholder="请选择状态"
              class="filter-item"
              clearable
              @change="handleSearch"
            >
              <el-option
                v-for="item in statuses"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
            <!-- <el-select
              v-model="filters.algorithm"
              placeholder="请选择关联算法"
              class="filter-item"
              clearable
              @change="handleSearch"
            >
              <el-option
                v-for="item in algorithms"
                :key="item.dict_key"
                :label="item.dict_value"
                :value="item.dict_key"
              />
            </el-select> -->
            <!-- <el-tree-select
              popper-class="custom-tree-select"
              :style="{ width: pxToRem(186) }"
              placeholder="请选择关联算法"
              v-model="dictKey"
              :data="dataList"
              :default-expanded-keys="[dictKey]"
              check-strictly
              node-key="id"
              :props="treePropsSF"
              @node-click="handleSFNodeClick"
              clearable
              @clear="handleClear"
            /> -->
            <el-tree-select
              style="z-index: 1000"
              :teleported="false"
              class="custom-tree-select"
              :style="{ width: pxToRem(186) }"
              v-model="dictKey"
              :data="dataList"
              :default-expanded-keys="[dictKey]"
              :props="treePropsSF"
              :render-after-expand="false"
              :default-checked-keys="checkedKeys"
              node-key="id"
              multiple
              show-checkbox
              collapse-tags
              collapse-tags-tooltip
              clearable
              @check="handleCheck"
              @node-click="handleSFNodeClick"
              @clear="handleClear"
            />
            <el-select
              v-model="filters.isReview"
              placeholder="请选择复核状态"
              class="filter-item"
              clearable
              @change="handleSearch"
            >
              <el-option
                v-for="item in reviewStatuses"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
            <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
            <el-button icon="el-icon-refresh" @click="handleReset">清空</el-button>
          </div>
 
          <!-- 表格部分 -->
          <avue-crud class="ztzf-public-general-avue-crud" ref="avueCrud" v-model="tableData" :option="option"
            :data="tableData" v-model:page="page" @size-change="sizeChange" @current-change="handleCurrentChange"
            @refresh-change="refreshChange" :table-loading="loading" @selection-change="handleSelectionChange"
            :permission="permissionList" v-if="activeTab === tab.name">
            <template #orderNumber="{ row }">
              <el-tooltip-copy :content="row.orderNumber" :showCopyText="true" textAlign="left">
                {{ row.orderNumber }}
              </el-tooltip-copy>
            </template>
            <template #orderName="{ row }">
              <el-tooltip-copy :content="row.orderName" :showCopyText="true" textAlign="left">
                {{ row.orderName }}
              </el-tooltip-copy>
            </template>
            <template #menu-left>
              <el-button
                v-if="(activeTab === 'all' || activeTab === 'myTickets') && permissionList.addBtn"
                type="primary"
                icon="el-icon-plus"
                @click="handleAdd"
                >新建工单</el-button
              >
              <el-button
                v-if="activeTab === 'pending' && permissionList.reviewBtn"
                type="success"
                icon="el-icon-check"
                @click="openReviewDialog"
                >批量审核</el-button
              >
              <el-button
                v-if="permissionList.exportBtn"
                type="success"
                plain
                icon="el-icon-download"
                @click="exportData"
                >导出</el-button
              >
            </template>
            <template #menu="{ row }">
              <template v-if="row.status === -1">
                <el-button type="text" icon="el-icon-edit" @click="handleEdit(row)">编辑</el-button>
                <el-button
                  type="text"
                  icon="el-icon-delete"
                  class="danger-button"
                  @click="handleDelete(row)"
                  >删除</el-button
                >
              </template>
 
              <template v-else>
                <el-button type="text" icon="el-icon-view" @click="handleViewDetail(row)"
                  >详情</el-button
                >
              </template>
 
              <template v-if="permission.tickets_repeat_review">
                <el-button
                  v-if="row.status === 4 && row.isReview !== 1"
                  type="text"
                  icon="el-icon-check"
                  @click="reCheck(row)"
                  >复核</el-button
                >
              </template>
            </template>
            <template #status="{ row }">
              <span
                :style="getStatusTagType(row.status) ? 'color:' + getStatusTagType(row.status) : ''"
              >
                {{ mapStatus(row.status) }}
              </span>
            </template>
            <template #keyData="{ row }">
              <span>{{ row.address }}</span>
            </template>
 
            <template #isReview="{ row }">
              <span>{{ showIsReviewText(row) }}</span>
            </template>
          </avue-crud>
        </basic-main-content>
      </el-tab-pane>
    </el-tabs>
 
    <!-- 新建工单对话框 -->
    <el-dialog
      v-model="dialogVisible"
      v-if="dialogVisible"
      title="新建工单"
      width="70%"
      :close-on-click-modal="false"
      @close="resetForm"
    >
      <el-form
        :model="form"
        :rules="rules"
        ref="form"
        label-width="90px"
        class="create-ticket-form"
      >
        <div class="form-section">
          <el-row :gutter="16">
            <el-col :span="12">
              <el-form-item label="工单名称" prop="name">
                <el-input v-model="form.name" placeholder="请输入工单名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="工单类型" prop="type">
 
                <el-select  @change="handleTypeChange" v-model="form.type" placeholder="请选择工单类型" class="full-width" >
                  <el-option
                    v-for="item in types"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
 
          <el-row :gutter="16">
            <el-col :span="12">
              <el-form-item label="所属部门" prop="department">
                <el-select
                  v-model="form.department"
                  placeholder="请选择所属部门"
                  @change="handleDepartmentChange"
                  class="full-width"
                >
                  <el-option
                    v-for="dept in departments"
                    :key="dept.value"
                    :label="dept.label"
                    :value="dept.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="处理人员" prop="handler">
                <el-select
                  v-model="form.handler"
                  placeholder="请先选择所属部门"
                  :disabled="!form.department"
                  class="full-width"
                >
                  <el-option
                    v-for="user in availableHandlers"
                    :key="user.id"
                    :label="user.name"
                    :value="user.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
 
          <el-row :gutter="16">
            <el-col :span="12">
              <el-form-item label="关联算法" prop="algorithm">
                <el-select
                  v-model="form.algorithm"
                  multiple
                  placeholder="请选择关联算法"
                  class="full-width"
                  :disabled="!form.type"
                >
                  <el-option
                    v-for="item in algorithms2"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="选择位置" prop="location">
                <div class="location-wrapper">
                  <avue-input-map
                    v-model="form.location"
                    :clearable="false"
                    :params="mapParams"
                    @change="handleLocationChange"
                    type="button"
                  >
                    <el-button type="primary" plain class="map-button">
                      <i class="el-icon-map-location"></i> 地图选点
                    </el-button>
                  </avue-input-map>
                  <!-- <div v-if="form.location?.length >= 3">
    {{ form.location[2] || '获取地址中...' }}
  </div> -->
                </div>
              </el-form-item>
            </el-col>
          </el-row>
 
          <el-row :gutter="16">
            <el-col :span="12">
              <el-form-item label="工单内容" prop="content">
                <el-input
                  type="textarea"
                  v-model="form.content"
                  :rows="4"
                  placeholder="请输入工单内容描述"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="附件图片" prop="photos" required class="upload-wrapper">
                <el-upload
                  v-if="createoredit === 1"
                  ref="upload"
                  :action="'#'"
                  :auto-upload="false"
                  list-type="picture-card"
                  :on-change="handleFileChange"
                  :on-remove="handleUploadRemove"
                  :before-upload="beforeUpload"
                  :file-list="form.photos"
                  :limit="1"
                  accept="image/*"
                  class="create-upload"
                >
                  <template v-if="form.photos.length < 1">
                    <!-- <i class="el-icon-plus">+</i> -->
                    <div class="el-icon-plus">
                      <span>+</span>
                    </div>
                  </template>
                </el-upload>
                <el-upload
                  v-else
                  ref="upload"
                  :action="'#'"
                  :auto-upload="false"
                  list-type="picture-card"
                  :on-change="handleFileChange"
                  :on-remove="handleUploadRemove"
                  :before-upload="beforeUpload"
                  :file-list="popupShowImage(form.photos)"
                  :limit="1"
                  accept="image/*"
                  class="create-upload"
                >
                  <template v-if="form.photos.length < 1">
                    <div class="el-icon-plus">
                      <span>+</span>
                    </div>
                  </template>
                </el-upload>
                <div class="upload-tip">需上传含有地址信息的照片(jpg、jpeg、png),且不超过5M</div>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
 
          <el-button type="danger" :loading="submitLoading" @click="submitForm">发布</el-button>
          <el-button type="infoprimary" plain :loading="draftLoading" @click="saveDraft"
            >存草稿</el-button
          >
 
 
          <el-button  @click="handleCancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
 
    <!-- 工单详情对话框 -->
    <el-dialog   class="custom-dialog" align-center v-model="detailVisible" title="工单详情" width="80%"  append-to-body>
      <div class="detail-container">
        <div class="detail-top-title">
          <div class="event-title-center event-orderNumber">
            {{ currentDetail.orderNumber || '工单编号' }}
          </div>
          <div class="event-title-center">{{ currentDetail.orderName || '事件名称' }}</div>
        </div>
        <div v-if="totalTime" class="event-total-time">总耗时:{{ totalTime }}</div>
        <!-- 工单状态流程 -->
        <div class="custom-steps-container">
          <!-- 标题行 -->
          <div class="steps-titles">
            <div
              v-for="(status, index) in stepStatusList"
              :key="index"
              :class="{
                'step-title': true,
                active: index <= stepStatusList.indexOf(String(currentDetail.status)),
              }"
            >
              {{ mapStatus(status) }}
            </div>
          </div>
 
          <!-- Element Steps 组件 -->
          <el-steps :active="getActiveStep() - 1" align-center class="custom-steps">
            <el-step v-for="(status, index) in stepStatusList" :key="index">
              <template #description>
                <span class="step-description">
                  {{ getStepHandler(status) }}
                </span>
                <div class="step-description" v-if="getStepTime(status)">
                  <span class="step-timer"> 耗时:{{ getStepTime(status) }} </span>
                </div>
                <div class="step-description">
                  {{ getStepCreateTime(status) }}
                </div>
              </template>
            </el-step>
          </el-steps>
        </div>
 
      <div class="PopUpTableScrolls">
          <!-- 基本信息表格 -->
        <el-table :show-header="false" :data="formattedDetailFields" border class="tableCss">
          <el-table-column prop="label1" label="基本信息" width="150">
            <template #default="{ row }">
              <!-- 添加必填星号的标签 -->
              <span
                v-if="currentDetail.status === 0 &&(row.label1 === '关联算法' ||  row.label1 === '工单名称')"
                class="required-label"
              >
                <span class="required-star">*</span>{{ row.label1 }}
              </span>
              <span v-else>{{ row.label1 }}</span>
            </template>
          </el-table-column>
          <el-table-column>
            <template #default="{ row }">
              <template
                v-if="
                  currentDetail.status === 0 &&
                  row.label1 === '工单名称' &&
                  hasProcessingBtnPermission()
                "
              >
                <el-input
                  v-model="currentDetail.orderName"
                  placeholder="请输入工单名称"
                  class="required-input"
                />
              </template>
               <template
                v-else-if="
                  currentDetail.status === 0 &&
                  row.label1 === '关联算法' &&
                  hasProcessingBtnPermission()
                "
              >
                <el-select
                  v-model="currentDetail.aiType"
                  placeholder="请选择关联算法"
                  class="required-input"
                >
                  <el-option
                    v-for="item in algorithms2"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </template>
              <template v-else>{{ row.value1 }}</template>
            </template>
          </el-table-column>
          <el-table-column prop="label2" label="基本信息" width="150">
            <template #default="{ row }">
              <!-- 添加必填星号的标签 -->
 
              <span
                v-if="
                  currentDetail.status === 0 &&
                   row.label2 === '工单内容'
                "
                class="required-label"
              >
                <span class="required-star">*</span>{{ row.label2 }}
              </span>
              <span v-else>{{ row.label2 }}</span>
            </template>
          </el-table-column>
          <el-table-column>
            <template #default="{ row }">
              <!-- 修改工单类型和工单内容的显示 -->
 
 
              <template
                v-if="
                  currentDetail.status === 0 &&
                  row.label2 === '工单内容' &&
                  hasProcessingBtnPermission()
                "
              >
                <el-input
                  type="textarea"
                  v-model="currentDetail.content"
                  placeholder="请输入工单内容"
                  class="required-input"
                />
              </template>
              <template v-else>{{ row.value2 }}</template>
            </template>
          </el-table-column>
        </el-table>
 
        <!-- 事件处理详情 -->
        <div v-if="[3, 4].includes(currentDetail.status)" class="form-section">
          <div class="section-title">
            <!-- 处理中状态显示必填星号 -->
            <template v-if="currentDetail.status === 3">
              <span class="required-label"> <span class="required-star">*</span>事件处理详情 </span>
            </template>
            <template v-else> 事件处理详情 </template>
          </div>
          <!-- 处理中状态显示输入框 -->
          <template v-if="currentDetail.status === 3 && hasProcessedAndOverBtnPermission()">
            <el-input
              type="textarea"
              v-model="currentDetail.processingDetail"
              placeholder="请输入事件处理详情"
              :rows="4"
              style="width: 100%; margin-bottom: 10px"
            />
          </template>
          <!-- 已完成和已完结状态显示只读文本 -->
          <template v-else>
            <div class="readonly-processing-detail">
              {{ currentDetail.processingDetail }}
            </div>
          </template>
        </div>
 
        <!-- 上传图片 -->
        <div v-if="[3].includes(currentDetail.status)" class="form-section uploadImg">
          <div class="section-title" v-if="hasProcessedAndOverBtnPermission()">
            <!-- 已完成状态显示必填星号 -->
            <template v-if="currentDetail.status === 3">
              <span class="required-label"> <span class="required-star">*</span>上传图片 </span>
            </template>
            <template v-else> 上传图片 </template>
          </div>
          <el-upload
            v-if="hasProcessedAndOverBtnPermission()"
            ref="upload"
            :action="'#'"
            :auto-upload="false"
            list-type="picture-card"
            :on-change="handleFileChange"
            :on-remove="handleUploadRemove"
            :before-upload="beforeUpload"
            :file-list="currentDetail.photos || []"
            :limit="1"
            accept="image/*"
            class="detail-upload"
          >
            <template v-if="!currentDetail.photos || currentDetail.photos.length < 1">
              <!-- <i class="el-icon-plus">+</i> -->
              <div class="el-icon-plus">
                <span>+</span>
              </div>
            </template>
          </el-upload>
          <div class="el-upload__tip" v-if="hasProcessedAndOverBtnPermission()">
            (上传照片即可完结工单,只能上传jpg、jpeg、png照片,且不超过5M)
          </div>
        </div>
 
        <!-- 图片和地图部分 -->
        <div class="media-section">
          <el-row :gutter="20">
 
            <el-col :span="12">
              <div class="media-box">
                <div class="media-title">事件图片</div>
                <div class="media-content">
                  <el-image
                    v-if="currentDetail.mediaUrl"
                    :src="getThumbUrl(currentDetail.mediaUrl)"
                    :preview-src-list="[getPreviewUrl(currentDetail.mediaUrl)]"
                    fit="contain"
                    style="width: 700px; height: 520px; cursor: pointer"
                  >
                    <template #placeholder>
                      <div class="image-placeholder">
                        <i class="el-icon-picture-outline"></i>
                        <span>加载中...</span>
                      </div>
                    </template>
                    <template #error>
                      <div class="image-error">
                        <i class="el-icon-picture-outline"></i>
                        <span>加载失败</span>
                      </div>
                    </template>
                  </el-image>
                  <div v-else class="no-media">暂无图片/视频</div>
                </div>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="media-box">
                <!-- 根据状态显示不同的标题和内容 -->
 
                <template v-if="currentDetail.status === 4">
                  <div class="media-title">工单处理图片</div>
                  <div class="media-content">
                    <el-image
                      v-if="currentDetail.updatePhotoUrl"
                      :src="getThumbUrl(currentDetail.updatePhotoUrl)"
                      :preview-src-list="[getPreviewUrl(currentDetail.updatePhotoUrl)]"
                      fit="fill"
                    >
                      <template #placeholder>
                        <div class="image-placeholder">
                          <i class="el-icon-picture-outline"></i>
                          <span>加载中...</span>
                        </div>
                      </template>
                      <template #error>
                        <div class="image-error">
                          <i class="el-icon-picture-outline"></i>
                          <span>加载失败</span>
                        </div>
                      </template>
                    </el-image>
                    <div v-else class="no-media">暂无处理图片</div>
                  </div>
                </template>
                <template v-else>
                  <div class="media-title">地图标记事件点
                    <el-popover   v-if="currentDetail.status === 3 || currentDetail.status === 0"
                                popper-class="custom-qrcode-popover"
                                :width="120"
                                :visible="currentDetail.showQR && detailVisible"
                                placement="top"
                                title=""
                                trigger="click"
 
                            >
                                <template #reference>
                                    <img @click.stop="handleQRCode(currentDetail)"  class="QRCodeImg" src="@/assets/images/dataCenter/qrCode.svg" alt="" title="事件导航" />
                                </template>
                                <div class="qrcode-content">
                                    <CreateQRcode v-if="currentDetail.showQR && detailVisible" :latAndLon="currentDetail.location"></CreateQRcode>
                                </div>
                            </el-popover>
                  </div>
                  <div class="media-content">
                    <map-container v-if="detailVisible" ref="MapContainer"></map-container>
                  </div>
                </template>
              </div>
            </el-col>
 
 
          </el-row>
        </div>
      </div>
 
        <!-- 操作按钮 -->
        <div class="dialog-footer1">
            <div
                class="leftBtn"
                :class="currentIndex === 0 ? 'disableds' : ''"
                @click="leftClick"
              >
               上一页
              </div>
       <div class="btngroups">
           <template v-if="currentDetail.status === 2">
            <!-- 待审核 -->
            <el-button
              v-if="hasReviewBtnPermission()"
              type="primary"
              :loading="approveLoading"
              @click="approveTicket"
              >通过</el-button
            >
            <el-button
              v-if="hasReviewBtnPermission()"
              type="danger"
              :loading="rejectLoading"
              @click="rejectTicket"
              >不通过</el-button
            >
            <el-button @click="detailVisible = false">取消</el-button>
          </template>
          <template v-else-if="currentDetail.status === 0">
            <el-button
              v-if="hasProcessingBtnPermission()"
              type="primary"
              :loading="dispatchLoading"
              @click="approveAndDispatch"
              >受理</el-button
            >
            <el-button
              v-if="hasProcessingBtnPermission()"
              type="danger"
              :loading="rejectLoading"
              @click="rejectTicket"
              >不受理</el-button
            >
            <el-button @click="detailVisible = false">取消</el-button>
          </template>
          <template v-if="currentDetail.status === 3">
            <!-- 处理中 -->
            <el-button
              v-if="hasProcessedAndOverBtnPermission()"
              type="primary"
              :loading="completeLoading"
              @click="completeTicket"
              >完成工单</el-button
            >
            <el-button @click="detailVisible = false">取消</el-button>
          </template>
          <template v-else-if="currentDetail.status === 4">
            <!-- 已完成 -->
            <!-- <el-button v-if="hasProcessedAndOverBtnPermission()" type="primary" :loading="finalizeLoading"
              @click="finalizeTicket">完结工单</el-button> -->
            <el-button @click="detailVisible = false">取消</el-button>
          </template>
       </div>
            <div
                :class="currentIndex === tableData.length - 1 ? 'disableds' : ''"
                class="leftBtn"
                @click="rightClick"
              >
              下一页
              </div>
        </div>
      </div>
    </el-dialog>
 
    <!-- 派发工单对话框 -->
    <el-dialog
      v-model="dispatchDialogVisible"
      title="派发工单"
      width="40%"
      :close-on-click-modal="false"
    >
      <el-form :model="dispatchForm" :rules="dispatchRules" ref="dispatchForm" label-width="100px">
        <el-form-item label="选择部门" prop="department">
          <el-select
 
            v-model="dispatchForm.department"
            placeholder="请选择部门"
            @change="handleDispatchDepartmentChange"
          >
            <el-option
              v-for="dept in departments"
              :key="dept.value"
              :label="dept.label"
              :value="dept.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="选择处理人" prop="handler">
          <el-select
          filterable
            v-model="dispatchForm.handler"
            placeholder="请选择处理人"
            :disabled="!dispatchForm.department"
          >
            <el-option
              v-for="user in availableDispatchHandlers"
              :key="user.id"
              :label="user.name"
              :value="user.id"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="dispatchDialogVisible = false">取消</el-button>
        <el-button type="primary" :loading="dispatchLoading" @click="submitDispatch"
          >确认派发</el-button
        >
      </template>
    </el-dialog>
 
    <!-- 添加在其他 dialog 组件之后 -->
    <el-dialog
      v-model="reviewDialogVisible"
      title="批量审核"
      width="1100"
      append-to-body
      custom-class="review-dialog"
      @close="cancleBatchReject"
    >
      <div class="review-container">
        <div class="review-image-wrapper">
          <!-- 修改左右箭头的显示条件 -->
          <div
            v-if="selections.length > 1 && currentReviewImage"
            class="arrow-button left"
            @click="handlePrevImage"
          >
            <i class="el-icon-arrow-left"></i>
          </div>
 
          <div class="review-image-container">
            <!-- <el-image v-if="currentReviewImage" :src="getThumbUrl(currentReviewImage)" fit="fill"
              :preview-src-list="getImageList()" :initial-index="currentImageIndex - 1" class="preview-image"
              style="cursor: pointer"> -->
            <el-image
              v-if="currentReviewImage"
              :src="getPreviewUrl(currentReviewImage)"
              fit="fill"
              :initial-index="currentImageIndex - 1"
              class="preview-image"
              style="cursor: pointer"
            >
              <template #error>
                <div class="image-error">
                  <i class="el-icon-picture-outline"></i>
                  <span>图片加载失败</span>
                </div>
              </template>
            </el-image>
            <div v-else class="no-image">暂无图片</div>
          </div>
 
          <!-- 修改右箭头的显示条件 -->
          <div
            v-if="selections.length > 1 && currentReviewImage"
            class="arrow-button right"
            @click="handleNextImage"
          >
            <i class="el-icon-arrow-right"></i>
          </div>
        </div>
 
        <!-- 修改分页器的显示条件 -->
        <div class="review-pagination" v-if="selections.length > 1 && currentReviewImage">
          <el-pagination
            small
            layout="prev, pager, next"
            hide-on-single-page
            :total="selections.length"
            :current-page="currentImageIndex"
            :page-size="1"
            @current-change="handleImagePageChange"
          >
          </el-pagination>
        </div>
      </div>
 
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="handleBatchApprove">通过</el-button>
          <el-button type="danger" @click="handleBatchReject">不通过</el-button>
          <el-button @click="cancleBatchReject">取消</el-button>
        </div>
      </template>
    </el-dialog>
 
    <!-- 复核弹出层 -->
 
    <el-dialog
      v-model="reCheckDialog"
      title="工单复核"
      width="30%"
      append-to-body
      custom-class="re-check-dialog"
      @close="reCheckDialog = false"
    >
      <div class="dialog-footer">
        <el-button type="primary" @click="reCheckConfirm(1)">人工复核</el-button>
        <el-button type="primary" @click="reCheckConfirm(2)">无人机复核</el-button>
      </div>
    </el-dialog>
  </basic-container>
</template>
 
<script>
import { getSmallImg, getShowImg } from '@/utils/util';
import { ElMessageBox, ElLoading } from 'element-plus';
import { calculateDefaultRange } from '@/utils/util';
import { gcj02ToWgs84, wgs84ToGcj02 } from '@/utils/coordinateTransformation';
import _ from 'lodash';
import {
  getList,
  createTicket,
  getTicketInfo,
  flowEvent,
  getstatusCount,
  getStepInfo,
  getReviewById,
  getCreateEventJob,
} from '@/api/tickets/ticket'
import { getSFDictionaryTree  } from '@/api/job/task';
import { export_json_to_excel } from '@/utils/exportExcel'
import geoJson from '@/assets/geoJson.json'
import { mapGetters } from 'vuex'
import { getAdcodeObj } from '@/utils/disposeData'
import elTooltipCopy from '@/components/ElTooltipCopy.vue'
import getBaseConfig from '@/buildConfig/config'
import CreateQRcode from '@/components/CreateQRcode/CreateQRcode.vue'
const { envName } = getBaseConfig()
function regExp (label, name) {
  var reg = new RegExp(label + '=([^&]*)(&|$)', 'g')
  return name.match(reg)[0].split('=')[1]
}
 
export default {
  components: { elTooltipCopy,CreateQRcode },
  name: 'TicketPage',
  data() {
    return {
      currentIndex: null, // 当前显示的数据索引
      submitLoading: false, // 新增loading状态
      draftLoading: false,
      approveLoading: false,
      rejectLoading: false,
      dispatchLoading: false,
      completeLoading: false,
      finalizeLoading: false,
      createoredit: '',
      activeTab: 'all',
      // tabs 只保留静态结构,不做权限判断
      tabs: [
        { label: '全部工单', name: 'all', value: null, count: 0 },
        { label: '待审核', name: 'pending', value: 2, count: 0 },
        { label: '待处理', name: 'processing', value: 0, count: 0 },
        { label: '处理中', name: 'inProgress', value: 3, count: 0 },
        { label: '已完成', name: 'completed', value: 4, count: 0 },
        // { label: "已完结", name: "closed", value: 5, count: 0 },
        { label: '我发起的工单', name: 'myTickets', value: null, count: 0 },
      ],
      filters: {
        keyword: '',
        department: '',
        type: '',
        dateRange: [],
        status: '',
        algorithm: '', // 新增算法筛选字段
        isReview: '', // 添加复核状态筛选字段
      },
      departments: [],
      types: [],
      allAlgorithms: [],
      handlers: [
        { label: '处理人A', value: 'handlerA' },
        { label: '处理人B', value: 'handlerB' },
      ],
 
      algorithms: [],
      algorithms2: [],
      statuses: [
        { label: '待审核', value: '2' },
        { label: '待处理', value: '0' },
        { label: '处理中', value: '3' },
        { label: '已完成', value: '4' },
      ],
      reviewStatuses: [
        { label: '否', value: 0 },
        { label: '是', value: 1 },
      ],
      tableData: [],
      option: {
        border: true,
        stripe: true,
        selection: true, // 添加多选功能
        index: true, // 保留序号功能
        indexLabel: '序号',
        indexWidth: 60,
        menuWidth: 150,
        searchMenuSpan: 6,
        viewBtn: false,
        editBtn: false,
        delBtn: false,
        addBtn: false,
        menu: true,
        page: true,
 
        height: 'auto',
        calcHeight: 196,
 
        column: [
          // { label: "序号", prop: "id", width: 70 },
          { label: '工单编号', prop: 'orderNumber', width: 170 },
          { label: '工单名称', prop: 'orderName', width: 150, overHidden: true, tooltip: true },
          { label: '所属单位', prop: 'department', overHidden: true, tooltip: true },
          { label: '发起时间', prop: 'startTime', width: 160 },
          { label: '关联算法', prop: 'aiType', overHidden: true, tooltip: true },
          {
            label: '工单类型',
            prop: 'type',
            width: 110,
            overHidden: true,
            tooltip: true,
            type: 'select',
            dicData: [],
          },
          {
            label: '工单内容',
            prop: 'content',
            slot: true,
            width: 152,
            overHidden: true,
          },
          { label: '创建人', prop: 'creator', width: 70 },
          { label: '处理人', prop: 'handler', width: 70 },
          {
            slot: true,
            hide: envName === 'jiangwu'? true : false,
            label: '复核状态',
            prop: 'isReview',
            width: 90,
          },
          { label: '工单状态', prop: 'status', slot: true, width: 90 },
        ],
      },
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      dialogVisible: false,
      detailVisible: false,
      currentDetail: {},
      form: {
        name: '',
        type: '',
        department: '',
        handler: '',
        algorithm: [], // 关联算法改为数组
        location: [], // 将存储为[经度, 纬度, 地址]格式
        address: '',
        photos: [],
        content: '', // 新增字段,用于存储后端返回的 content
      },
      rules: {
        name: [{ required: true, message: '请输入工单名称', trigger: 'blur' }],
        type: [{ required: true, message: '请选择工单类型', trigger: 'change' }],
        department: [{ required: true, message: '请选择所属部门', trigger: 'change' }],
        handler: [{ required: true, message: '请选择处理人员', trigger: 'change' }],
        content: [{ required: true, message: '请输入工单内容', trigger: 'blur' }],
        algorithm: [{ required: true, message: '请选择关联算法', trigger: 'change' }],
        location: [
          {
            required: true,
            validator: (rule, value, callback) => {
              if (!value || value.length < 2) {
                callback(new Error('请选择位置信息'));
              } else if (!value[0] || !value[1]) {
                callback(new Error('请选择位置信息'));
              } else {
                callback();
              }
            },
            trigger: 'change',
          },
        ],
        photos: [
          {
            validator: (rule, value, callback) => {
              if (!this.form.photos || this.form.photos.length === 0) {
                callback(new Error('请上传工单图片'));
              } else {
                callback();
              }
            },
            trigger: 'change',
          },
        ],
      },
      departmentUsers: {},
      loading: false,
      globalCounts: {},
      mapLoaded: false,
      isFetching: false,
      mapParams: {
        zoom: 15,
        center: null, // 初始设为 null,等待动态设置
      },
      dispatchDepartment: '', // 新增:派发部门
      dispatchHandler: '', // 新增:派发处理人
      dispatchDialogVisible: false, // 新增:派发对话框可见性
      dispatchForm: {
        department: '',
        handler: '',
      }, // 新增:派发表单数据
      dispatchRules: {
        department: [{ required: true, message: '请选择部门', trigger: 'change' }],
        handler: [{ required: true, message: '请选择处理人', trigger: 'change' }],
      }, // 新增:派发表单验证规则
      stepInfos: [], // 新增:存储步骤信息
      fixedStatuses: ['2', '0', '3', '4'], // 固定的五个状态
      userNameToIdMap: {}, // 新增用户名到ID的映射
      workType: 0, // 新增:当前工单work_type
      selections: [], // 添加选中行数据数组
      reviewDialogVisible: false, // 新增:审核对话框可见性
      currentReviewImage: '', // 新增:当前审核图片
      currentImageIndex: 1, // 新增:当前图片索引
      totalTime: '',
      isShowInfo: false,
 
      // 配置时间选择器默认配置
      datePickerDefaultVal: calculateDefaultRange(),
 
      // 复核弹窗
      reCheckDialog: false,
      treePropsSF: {
        label: 'dictValue',
        value: 'id',
        children: 'children',
      },
      dictKey: '',
      dataList: [],
      checkedKeys: [],
    };
  },
  created() {
    this.inputMapShowDefaultCenter = null;
 
    this.loadAMapScripts();
    this.fetchDropdownData();
    // console.log('permission.tickets_processing_btn', this.permission.tickets_processing_btn);
    // console.log('permission', this.permission.tickets_tab_pending);
  },
 
  mounted() {
 
    this.getAlgorithmList()
 
    const href = this.$route.href;
    if (this.$route?.query?.status !== undefined && this.$route?.query?.status !== null) {
      this.filters.status = this.$route?.query?.status + '';
      this.$router.replace({});
    }
 
    let curQueryParams = {};
 
    if (href.indexOf('?') != -1 && href.split('?').length > 0) {
      curQueryParams = href
        .split('?')[1]
        .split('&')
        .reduce((pre, cur) => {
          let newArr = cur.split('=');
 
          pre[newArr[0]] = newArr[1];
 
          return pre;
        }, {});
 
      const { orderNumber = undefined, day = undefined } = curQueryParams;
 
      // 日历传值
      if (day) {
        const date = new Date(day + 'T00:00:00+08:00');
        const dateArray = [date, date];
        const handler = {
          get(target, prop) {
            if (typeof prop === 'string' && /^\d+$/.test(prop)) {
              const index = parseInt(prop);
              const dateObj = target[index];
              return dateObj.toDateString() + ' 00:00:00 GMT+0800 (中国标准时间)';
            }
            return Reflect.get(target, prop);
          },
        };
 
        const proxyArray = new Proxy(dateArray, handler);
        this.filters.dateRange = proxyArray;
      }
 
      if (orderNumber) {
        this.filters.keyword = orderNumber;
        this.$nextTick(() => {
          this.isShowInfo = true;
          const find = this.$store.state.tags.bsTagList.find(i => i.path === '/tickets/ticket')
          find && (find.query = {})
        });
 
      }
    }
 
    this.fetchTabCounts(); // 新增:初始化时获取 tab 数据
    this.fetchTableData();
  },
  computed: {
    firstRowData() {
      return this.tableData.length > 0 ? this.tableData[0] : null;
    },
    availableHandlers() {
      return this.form.department ? this.departmentUsers[this.form.department] || [] : [];
    },
    availableDispatchHandlers() {
      return this.dispatchForm.department
        ? this.departmentUsers[this.dispatchForm.department] || []
        : [];
    },
    detailTableData() {
      return [
        {
          label: '工单名称',
          value: this.currentDetail.orderName,
          editable: this.currentDetail.status === 0,
          type: 'input',
        },
        {
          label: '关键任务',
          value: this.currentDetail.keyData,
          editable: false,
        },
        {
          label: '任务发起人',
          value: this.currentDetail.creator,
          editable: false,
        },
        {
          label: '当前状态',
          value: this.mapStatus(this.currentDetail.status),
          editable: false,
        },
        {
          label: '事件地址',
          value: this.currentDetail.address,
          editable: false,
        },
        {
          label: '工单类型',
          value: this.currentDetail.type,
          editable: this.currentDetail.status === 0,
          type: 'select',
          options: this.types,
        },
        {
          label: '关联算法',
          value: this.currentDetail.aiType,
          editable: false,
        },
        {
          label: '发起单位',
          value: this.currentDetail.department,
          editable: false,
        },
        {
          label: '发起任务时间',
          value: this.currentDetail.startTime,
          editable: false,
        },
        {
          label: '工单内容',
          value: this.currentDetail.content,
          editable: this.currentDetail.status === 0,
          type: 'textarea',
        },
      ];
    },
    detailFields() {
      return [
        {
          label: '工单名称',
          value: this.currentDetail.orderName,
          editable: this.currentDetail.status === 0,
          type: 'input',
        },
        { label: '关键任务', value: this.currentDetail.keyData, editable: false },
        { label: '任务发起人', value: this.currentDetail.creator, editable: false },
        { label: '当前状态', value: this.mapStatus(this.currentDetail.status), editable: false },
        { label: '事件地址', value: this.currentDetail.address, editable: false },
        {
          label: '工单类型',
          value: this.currentDetail.type,
          editable: this.currentDetail.status === 0,
          type: 'select',
          options: this.types,
        },
        { label: '关联算法', value: this.currentDetail.aiType, editable: false },
        { label: '发起单位', value: this.currentDetail.department, editable: false },
        { label: '发起任务时间', value: this.currentDetail.startTime, editable: false },
        {
          label: '工单内容',
          value: this.currentDetail.content,
          editable: this.currentDetail.status === 0,
          type: 'textarea',
        },
      ];
    },
    formattedDetailFields() {
      const fields = [
        { label: '工单名称', value: this.currentDetail.orderName },
        {
          label: '工单类型',
          // 修改这里:使用 types 数组查找对应的 label
          value:
            this.types.find(t => t.value === this.currentDetail.type)?.label ||
            this.currentDetail.type ||
            '/',
        },
        { label: '关联任务', value: this.currentDetail.job_name || '/' },
        { label: '任务发起人', value: this.currentDetail.creator },
        { label: '当前状态', value: this.mapStatus(this.currentDetail.status) },
        { label: '事件地址', value: this.currentDetail.address || this.currentDetail.latAndLon }, // 包含经纬度信息
        { label: '关联算法',
         value:
            this.algorithms.find(t => t.value === this.currentDetail.aiType)?.label ||
            this.currentDetail.aiType ||
            '/',
 
        },
        { label: '发起单位', value: this.currentDetail.department },
        { label: '发起任务时间', value: this.currentDetail.startTime },
        { label: '工单内容', value: this.currentDetail.content },
      ];
 
      // 过滤掉值为 '/' 的列
      const filteredFields = fields.filter(field => field.value !== '/');
      // 将字段分成两列
      const formattedFields = [];
      for (let i = 0; i < filteredFields.length; i += 2) {
        formattedFields.push({
          label1: filteredFields[i]?.label || '',
          value1: filteredFields[i]?.value || (filteredFields[i]?.label ? '暂无数据' : ''),
          label2: filteredFields[i + 1]?.label || '',
          value2: filteredFields[i + 1]?.value || (filteredFields[i + 1]?.label ? '暂无数据' : ''),
        });
      }
 
      return formattedFields;
 
    },
    dynamicFixedStatuses() {
      // 直接使用接口返回的 stepInfos
      return this.stepInfos.map(step => String(step.status));
    },
    ...mapGetters(['userInfo', 'permission']),
    // 动态过滤tabs,保证isShow为true/false
    filteredTabs() {
      // 统一处理权限,undefined视为false
      const tabStatus = this.permission?.tickets_tab_status === true;
      const tabPending = this.permission?.tickets_tab_pending === true;
      const tabMyTickets = this.permission?.tickets_tab_mytickets === true;
      return this.tabs
        .map(tab => {
          if (tab.name === 'all') {
            return { ...tab, isShow: true };
          }
          if (tab.name === 'pending') {
            return { ...tab, isShow: tabPending };
          }
          if (['processing', 'inProgress', 'completed', 'closed'].includes(tab.name)) {
            return { ...tab, isShow: tabStatus };
          }
          if (tab.name === 'myTickets') {
            return { ...tab, isShow: tabMyTickets };
          }
          return { ...tab, isShow: false };
        })
        .filter(tab => tab.isShow);
    },
    permissionList() {
      // 可根据实际后端权限key调整
      return {
        addBtn: this.validData(this.permission.tickets_add, false),
        delBtn: this.validData(this.permission.tickets_delete, false),
        exportBtn: this.validData(this.permission.tickets_export, false),
        reviewBtn: this.validData(this.permission.tickets_review, false),
      };
    },
    stepStatusList() {
      // “我发起的工单”tab用默认流程,其它tab用接口返回的stepInfos
      if (this.activeTab === 'myTickets') {
        if (this.workType === 1) {
          return ['3', '4'];
        }
        return this.fixedStatuses;
      }
 
      // 其它tab直接用接口返回的stepInfos
      return this.stepInfos.map(step => String(step.status));
    },
 
    showIsReviewText() {
      return row => {
        if (['4'].includes(String(row.status))) return row.isReview === 1 ? '是' : '否';
 
        return '/';
      };
    },
 
    popupShowImage() {
      return list => {
        return list.map(item => ({
          ...item,
          url: getShowImg(item.url),
        }));
      };
    },
  },
 
  methods: {
    handleCheck(data, { checkedKeys, checkedNodes }) {
      this.checkedKeys = checkedKeys
      // 获取所有选中节点的 dictKey
      const selectedDictKeys = checkedNodes.map(node => node.dictKey).filter(Boolean)
      this.filters.type = selectedDictKeys
      this.fetchTableData();
    },
    // 算法
    getAlgorithmList() {
      getSFDictionaryTree({code:'SF'}).then((res) => {
          if (res.data.code === 200) {
              const result = res.data.data[0].children
              // 过滤第一层数据
              const filteredData = result.map(item => {
                  // 过滤第二层数据
                  const children = item.children?.map(child => ({
                      ...child,
                      children: [] // 清空第三层数据
                  }))
                  return {
                      ...item,
                      children: children || []
                  }
              })
              this.dataList = filteredData
          }
      })
    },
 
    handleSFNodeClick(data) {
      console.log(data.dictKey, '666666666')
      this.filters.type = ''
      this.filters.algorithm = ''
      this.filters.type = data.dictKey
      // 更新列表请求
      this.fetchTableData();
    },
    handleClear() {
        this.dictKey = ''
        this.filters.algorithm = ''
         this.filters.type = ''
        this.fetchTableData();
    },
    handleCellClick(row, column) {
      console.log(row, column.no);
      if (column.no === 2) {
        navigator.clipboard.writeText(row.orderNumber).then(() => {
          this.$message.success('复制工单编号成功');
        });
      } else if (column.no === 3) {
        navigator.clipboard.writeText(row.orderName).then(() => {
          this.$message.success('复制工单名称成功');
        });
      } else if (column.no === 4) {
        navigator.clipboard.writeText(row.department).then(() => {
          this.$message.success('复制所属单位成功');
        });
      }
    },
    // 左切换
    leftClick() {
      if (this.tableData.length === 0) return;
      this.currentIndex = Math.max(0, this.currentIndex - 1);
      this.updateCurrentDetail();
    },
    // 右切换
    rightClick() {
      if (this.tableData.length === 0) return;
      this.currentIndex = Math.min(this.tableData.length - 1, this.currentIndex + 1);
      this.updateCurrentDetail();
    },
    // 更新当前详情
    updateCurrentDetail() {
      this.currentDetail = this.tableData[this.currentIndex];
      this.currentDetail.mediaUrl = this.currentDetail.photo_url;
      this.currentDetail.updatePhotoUrl = this.currentDetail.update_photo_url;
      this.currentDetail.processingDetail = this.currentDetail.content;
      this.handleViewDetail(this.currentDetail);
 
 
      // 如果使用地图组件,需要更新地图标记
      this.$nextTick(() => {
        if (this.$refs.MapContainer && this.currentDetail.location) {
          this.$refs.MapContainer.initAddEntity('point', this.currentDetail.location);
        }
      });
    },
    async handleQRCode (val){
    val.showQR = !val.showQR
    },
    async loadAMapScripts() {
      try {
        const areaCode = this.userInfo.detail.areaCode;
        const subAreaCode = areaCode ? areaCode.substring(0, 6) : '';
        const adcodeObj = getAdcodeObj(geoJson, 'adcode', subAreaCode);
 
       // console.log('区域代码:', subAreaCode);
 
        // 直接从返回对象中获取正确的路径
        const center = adcodeObj?.payload?.objects?.collection?.geometries?.[0]?.properties?.center;
 
        if (Array.isArray(center) && center.length === 2) {
          this.inputMapShowDefaultCenter = center;
        } else {
          // 如果找不到中心点,尝试使用 bbox 的中心点
          const bbox = adcodeObj?.payload?.bbox;
          if (Array.isArray(bbox) && bbox.length === 4) {
            const centerX = (bbox[0] + bbox[2]) / 2;
            const centerY = (bbox[1] + bbox[3]) / 2;
            this.inputMapShowDefaultCenter = [centerX, centerY];
          } else {
            this.inputMapShowDefaultCenter = [115.861365, 28.621311];
          }
        }
        this.mapParams.center = [...this.inputMapShowDefaultCenter];
 
        this.mapLoaded = true;
      } catch (error) {
        this.$message.error('地图加载失败,请检查网络或API Key配置');
      }
    },
    async handleBatchApprove() {
      try {
        if (this.selections.length === 0) {
          this.$message.warning('没有选中的工单');
          return;
        }
 
        const currentItem = this.selections[this.currentImageIndex - 1];
        if (!currentItem) {
          this.$message.warning('当前工单数据无效');
          return;
        }
 
        await this.$confirm('确认审核通过当前工单?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        });
 
        const data = {
          id: currentItem.id,
          status: currentItem.status,
          isPass: 0,
          eventNum: currentItem.orderNumber,
          eventName: currentItem.orderName,
        };
 
        const response = await flowEvent(data);
        if (response.data.code === 0) {
          this.$message.success('工单审核通过');
 
          // 创建新的数组而不是修改原数组
          const newSelections = [...this.selections];
          newSelections.splice(this.currentImageIndex - 1, 1);
          this.selections = newSelections;
 
          // 修正索引并更新图片
          if (this.selections.length > 0) {
            if (this.currentImageIndex > this.selections.length) {
              this.currentImageIndex = this.selections.length;
            }
            this.updateCurrentReviewImage();
          } else {
            this.reviewDialogVisible = false;
            this.currentImageIndex = 1;
            this.currentReviewImage = '';
          }
 
          // 刷新表格数据
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '审核失败');
        }
      } catch (error) {
        if (error === 'cancel') return;
        this.$message.error(error.message || '审核失败,请稍后重试');
      }
    },
    async fetchDropdownData() {
      try {
        const response = await getTicketInfo();
 
        const { dept_data, event_type, ai_type,info } = response.data.data;
 
        this.departments = dept_data.map(item => ({
          label: item.dept_name,
          value: item.id,
        }));
 
        this.departmentUsers = dept_data.reduce((acc, dept) => {
          acc[dept.id] = dept.user_data || [];
          return acc;
        }, {});
 
        this.types = Object.entries(event_type).map(([key, value]) => ({
          label: value,
          value: key,
        }));
 
        const columnType = this.findObject(this.option.column, 'type');
        columnType.dicData = this.types;
        this.allAlgorithms  = info
 
        console.log('工单类型',this.types);
        console.log('关联算法',this.allAlgorithms );
        // 确保算法数据的映射一致
        this.algorithms =
          ai_type?.map(item => ({
            dict_key: item.dict_key,
            dict_value: item.dict_value,
            // 同时添加 label 和 value 以兼容两处使用
            label: item.dict_value,
            value: item.dict_key,
          })) || [];
 
        this.algorithms2 = _.cloneDeep(this.algorithms)
 
        // 构建用户ID和名称的映射关系
        this.userNameToIdMap = {};
        dept_data.forEach(dept => {
          (dept.user_data || []).forEach(user => {
            this.userNameToIdMap[user.name] = user.id;
          });
        });
      } catch (error) {
        this.$message.error('加载下拉框数据失败');
      }
    },
    // 工单类型变化时触发
    handleTypeChange(typeValue) {
      this.form.algorithm = []
      if (!typeValue) {
        // 未选择类型时清空算法列表
        this.algorithms2 = [];
        return;
      }
 
      const matchedCategory = this.allAlgorithms.find(
        category => category.dict_key === typeValue
      );
 
      if (!matchedCategory || !matchedCategory.algorithms || matchedCategory.algorithms.length === 0) {
        // 无匹配的算法时清空
        this.algorithms2 = [];
        this.$message.info('该工单类型暂无关联算法');
        return;
      }
      this.algorithms2 = matchedCategory.algorithms.map(algo => ({
        label: algo.dict_value,
        value: algo.dict_key,
        dict_key: algo.dict_key,
        dict_value: algo.dict_value
      }));
 
    },
 
    async fetchTableData() {
      if (this.isFetching) return;
      this.isFetching = true;
      this.loading = true;
      try {
        const currentTab = this.tabs.find(tab => tab.name === this.activeTab);
        const params = {
          word_order_types: this.filters.type || undefined,
          status:
            currentTab?.name === 'myTickets'
              ? undefined
              : this.filters.status !== ''
              ? Number(this.filters.status)
              : currentTab?.value,
          event_name: this.filters.keyword || undefined,
          dept_id: this.filters.department || undefined,
          start_date: this.filters.dateRange?.[0]
            ? this.formatDate(this.filters.dateRange[0])
            : undefined,
          end_date: this.filters.dateRange?.[1]
            ? this.formatDate(this.filters.dateRange[1]).replace('00:00:00', '23:59:59')
            : undefined,
          current: Number(this.page.currentPage), // 使用当前页码
          size: Number(this.page.pageSize), // 使用每页条数
          ai_type: this.filters.algorithm || undefined, // 添加算法参数
          // 添加 is_draft 参数,仅在"我发起的"标签页时设置为1
          is_draft: currentTab?.name === 'myTickets' ? 1 : undefined,
 
          user_id: currentTab?.name === 'myTickets' ? this.userInfo.user_id : undefined,
          is_review: this.filters.isReview === '' ? undefined : this.filters.isReview, // 添加复核状态查询参数
        };
 
        const response = await getList(params);
        if (!response?.data?.data?.records) {
          throw new Error('接口返回数据格式不正确');
        }
 
        const { total, records } = response.data.data;
        let filteredRecords = records;
 
        // 如果是"我发起的"tab,过滤数据
        // if (currentTab?.name === 'myTickets') {
        //   filteredRecords = records.filter(item =>
        //     String(item.create_user_id) === String(item.user_id)
        //   );
        // }
 
        this.tableData = filteredRecords.map(item => {
          const longitude = Number(item.longitude) || 0;
          const latitude = Number(item.latitude) || 0;
          return {
            id: item.id,
            orderNumber: item.event_num, // 修改这里:优先使用 event_num
            orderName: item.event_name,
            department:
              this.departments.find(d => d.value === item.dept_id)?.label || item.dept_name,
            startTime: item.create_time,
            aiType: item.ai_types,
            content: item.content, // 将后端返回的 content 映射为 content
            type: item.work_order_type_dict_key,
            keyData:
              !isNaN(longitude) && !isNaN(latitude)
                ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`
                : '未知位置',
            address: item.address,
            creator: item.event_num?.slice(0, 2) === 'AI' ? 'AI 小飞' : item.create_user,
            handler: item.update_user || '未分配',
            status: Number(item.status || 0),
            // 保存原始字段
            photo_url: item.photo_url || '', // 保存原始 photo_url
            video_url: item.video_url || '', // 保存原始 video_url
            location: !isNaN(longitude) && !isNaN(latitude) ? [longitude, latitude] : null,
            processing_details: item.processing_details || '', // 添加处理详情字段
            update_photo_url: item.update_photo_url || '', // 添加处理图片字段
            work_type: item.work_type !== undefined ? Number(item.work_type) : 0, // 保留work_type字段并转为数字
            job_name: item.job_name || '',
            job_create_time: item.job_create_time || '',
            isReview: item.is_review, // 添加复核状态字段映射
          };
        });
 
        // 更新总数显示
        this.page.total = total || 0;
 
        // 是否弹出详情页
        if (this.isShowInfo) {
          this.handleViewDetail(this.firstRowData);
          this.isShowInfo = false; // 生效一次
        }
        await this.fetchTabCounts();
      } catch (error) {
        this.$message.error(error.message || '获取数据失败');
        this.tableData = [];
        this.page.total = 0;
      } finally {
        this.loading = false;
        this.isFetching = false;
      }
    },
 
    async submitForm() {
      if (this.submitLoading) return; // 防止重复提交
      this.submitLoading = true;
      try {
        // 提交时需要完整验证
        await this.$refs.form.validate();
 
        // 验证位置信息
        if (!this.form.location || this.form.location.length < 2) {
          this.$message.warning('请在地图上选择位置');
          return;
        }
 
        // 修改图片验证逻辑
        if (!this.form.photos || this.form.photos.length === 0) {
          this.$message.warning('请上传工单图片');
          return;
        }
 
        let [lng, lat] = this.disposeLocation(true, this.form);
 
        const submitData = {
          eventName: this.form.name,
          content: this.form.content,
          workType: '1',
          longitude: lng,
          latitude: lat,
          address: this.form.address,
          workOrderTypeDictKey: this.form.type,
          aiType: Array.isArray(this.form.algorithm) ? this.form.algorithm : [this.form.algorithm], // 传数组
          updateUser: this.form.handler,
          createDept: this.form.department,
          isDraft: 0,
        };
 
        if (this.form.id) {
          submitData.id = this.form.id;
        }
 
        // 修改获取文件的逻辑
        let file = null;
        const photoInfo = this.form.photos[0];
 
        if (photoInfo.raw) {
          // 如果有新上传的文件,使用新文件
          file = photoInfo.raw;
        } else if (photoInfo.existingUrl) {
          // 如果是已存在的图片,将URL添加到提交数据中
          submitData.photoUrl = photoInfo.existingUrl;
        } else {
          this.$message.warning('图片文件无效,请重新上传');
          return;
        }
 
        const response = await createTicket(submitData, file);
        if (response.data.code === 0) {
          this.$message.success('工单创建成功');
          this.dialogVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '创建失败');
        }
      } catch (error) {
        if (error.message.includes('验证未通过')) {
          this.$message.warning('请填写完整的工单信息');
        } else {
          this.$message.error(error.message || '工单创建失败,请稍后重试');
        }
      } finally {
        this.submitLoading = false;
      }
    },
 
    async saveDraft() {
      if (this.draftLoading) return; // 防止重复提交
      this.draftLoading = true;
      try {
        let handlerValue = this.form.handler;
        if (!handlerValue || handlerValue === '未分配') {
          handlerValue = undefined;
        }
 
        // 验证位置信息
        if (
          !this.form.location ||
          this.form.location.length < 2 ||
          !this.form.location[0] ||
          !this.form.location[1]
        ) {
          this.$message.warning('请在地图上选择位置');
          return;
        }
 
        let [lng, lat] = this.disposeLocation(true, this.form);
 
        const submitData = {
          id: this.form.id,
          eventName: this.form.name || undefined,
          content: this.form.content || undefined,
          workType: '1',
          longitude: lng,
          latitude: lat,
          address: this.form.address || undefined,
          workOrderTypeDictKey: this.form.type || undefined,
          aiType:
            this.form.algorithm && this.form.algorithm.length > 0 ? this.form.algorithm : undefined, // 传数组
          updateUser: handlerValue,
          createDept: this.form.department || undefined,
          isDraft: 1,
        };
 
        // 草稿时也至少需要工单名称
        if (!submitData.eventName) {
          this.$message.warning('请输入工单名称');
          return;
        }
 
        // 过滤掉所有 undefined 的字段
        Object.keys(submitData).forEach(
          key => submitData[key] === undefined && delete submitData[key]
        );
 
        let file = null;
        if (this.form.photos && this.form.photos.length > 0) {
          file = this.form.photos[0].raw;
        }
 
        const response = await createTicket(submitData, file);
        if (response.data.code === 0) {
          this.$message.success('草稿保存成功');
          this.dialogVisible = false;
          (this.form = {
            name: '',
            type: '',
            department: '',
            handler: '',
            algorithm: [], // 关联算法改为数组
            location: [], // 将存储为[经度, 纬度, 地址]格式
            address: '',
            photos: [],
            content: '', // 新增字段,用于存储后端返回的 content
          }),
            this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '保存失败');
        }
      } catch (error) {
        this.$message.error(error.message || '保存草稿失败,请稍后重试');
      } finally {
        this.draftLoading = false;
      }
    },
    handleCancel (){
      this.resetForm();
       this.dialogVisible = false;
},
    handleLocationChange(val) {
      let locationValue = val.value;
      if (locationValue && locationValue.length >= 2) {
        // 兼容第三项为地址
        const [lng, lat] = gcj02ToWgs84(locationValue[0], locationValue[1]);
        this.form.location = [Number(lng), Number(lat), locationValue[2] || ''];
        this.form.address = locationValue[2] || '';
      } else {
        this.form.location = [];
        this.form.address = '';
      }
    },
 
    formatDate(date) {
      if (!date) return undefined;
      const d = new Date(date);
      return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(
        d.getDate()
      ).padStart(2, '0')} 00:00:00`;
    },
 
    mapStatus(status) {
      const statusTextMap = {
        '-1': '草稿', // 添加草稿状态
        2: '待审核',
        0: '待处理',
        3: '处理中',
        4: '已完成',
      };
      return statusTextMap[status] || '未知状态';
    },
 
    getStatusTagType(status) {
      // 草稿不加颜色
      if (status === -1 || status === '-1') return '';
      // 状态颜色映射
      const colorMap = {
        0: '#FF7411', // 待处理-淡红
        3: '#FFC300', // 处理中-更淡红
        2: '#FF472F', // 待审核-橙色
        4: '#0291A1', // 已完成-淡蓝
      };
      return colorMap[String(status)] || '';
    },
 
    async fetchTabCounts() {
      try {
        // 判断是否有部门筛选
        let params = {};
        if (this.filters.department) {
          params.deptId = this.filters.department;
        }
        const response = await getstatusCount(params);
        const { statusCount, totalCount, userCount } = response.data.data;
        this.tabs.forEach(tab => {
          if (tab.name === 'all') {
            tab.count = totalCount || 0; // 总工单数
          } else if (tab.name === 'myTickets') {
            tab.count = userCount || 0; // 我发起的工单数
          } else {
            tab.count = statusCount[String(tab.value)] || 0; // 根据状态值映射
          }
        });
      } catch (error) {
        this.$message.error('获取 tab 数据失败');
      }
    },
 
    handleTabChange(tab) {
      this.activeTab = tab.props?.name || tab.name;
 
      const isReview = this.findObject(this.option.column, 'isReview');
      // 根据条件切换显隐
      isReview.hide = !['all', 'completed', 'myTickets'].includes(this.activeTab);
 
      this.handleReset();
      this.page.currentPage = 1;
      this.fetchTableData();
      this.fetchTabCounts(); // 切换 tab 时重新获取数据
    },
 
    handleSearch() {
      this.page.currentPage = 1;
      this.fetchTableData();
      this.fetchTabCounts();
    },
 
    handleReset() {
      this.dictKey = '';
      this.filters = {
        keyword: '',
        department: '',
        type: '',
        dateRange: [],
        status: '',
        algorithm: '', // 重置时清空算法筛选
        isReview: '', // 重置时清空复核状态
      };
      this.page.currentPage = 1;
      this.$router.replace({});  //清除url参数
      this.fetchTableData();
    },
    handleKeyWords(){
      this.$router.replace({});  //清除url参数
    },
 
    async handleCurrentChange(val) {
      // 先更新页码
      this.page.currentPage = val;
      // 等待 DOM 更新后再请求数据
      await this.$nextTick();
      await this.fetchTableData();
    },
 
    async sizeChange(val) {
      this.page.pageSize = val;
      this.page.currentPage = 1; // 重置到第一页
      await this.$nextTick();
      await this.fetchTableData();
    },
 
    handleAdd() {
      this.createoredit = 1;
      this.dialogVisible = true;
      this.mapParams.center = [...this.inputMapShowDefaultCenter];
      this.form.location = [];
    },
 
    resetForm() {
      this.form = {
        name: '',
        type: '',
        department: '',
        handler: '',
        algorithm: [], // 关联算法改为数组
        location: [], // 将存储为[经度, 纬度, 地址]格式
        address: '',
        content: '',
        photos: [],
        content: '', // 新增字段,用于存储后端返回的 content
      };
      if (this.$refs.form) {
        this.$refs.form.resetFields();
      }
    },
 
    formatLocation(location) {
      if (!Array.isArray(location)) {
        return '未知位置';
      }
      return `${location[0].toFixed(6)}, ${location[1].toFixed(6)}`;
    },
 
    async handleViewDetail(row) {
      // 找到当前行在tableData中的索引
      this.currentIndex = this.tableData.findIndex(item => item.id === row.id);
      // 先设置workType,直接从row读取
      this.workType = row.work_type !== undefined ? Number(row.work_type) : 0;
 
      // 重置上传组件的文件列表
      this.$nextTick(() => {
        if (this.$refs.MapContainer && this.$refs.MapContainer.initAddEntity) {
          this.$refs.MapContainer.initAddEntity('point', this.currentDetail.location);
        }
      });
 
      const detailData = {
        ...row,
        processingDetail: row.processing_details || '',
        mediaUrl: row.photo_url || row.video_url || '',
        updatePhotoUrl: row.update_photo_url || '',
        photos: [],
        job_name: row.job_name || '', // 新增
      };
 
      let stepArr = [];
      try {
        const stepResponse = await getStepInfo(row.orderNumber);
        const steps = Array.isArray(stepResponse.data.data)
          ? stepResponse.data.data
          : stepResponse.data.data?.steps || [];
        const finishedStep = steps.find(s => String(s.status) === '4');
        this.totalTime = finishedStep && finishedStep.total_time ? finishedStep.total_time : '';
        if (this.activeTab !== 'myTickets') {
          this.stepInfos = steps.map(step => ({
            status: String(step.status),
            name: step.name,
            time: step.time,
            create_time: step.create_time,
          }));
        } else {
          const statusArr = this.workType === 1 ? ['3', '4'] : this.fixedStatuses;
          this.stepInfos = statusArr.map(status => {
            const step = steps.find(s => String(s.status) === String(status));
            return {
              status,
              name: step ? step.name : '',
              time: step ? step.time : null,
              create_time: step ? step.create_time : null,
            };
          });
        }
        this.currentDetail.status = row.status;
      } catch (error) {
        if (this.activeTab === 'myTickets') {
          const statusArr = this.workType === 1 ? ['3', '4'] : this.fixedStatuses;
          this.stepInfos = statusArr.map(status => ({
            status,
            name: status === row.status ? row.handler || '未分配' : '未处理',
            time: status === row.status ? row.startTime || '未知时间' : null,
          }));
        } else {
          this.stepInfos = [];
        }
      }
      console.log(detailData, 'detailDatadetailDatadetailData');
      this.currentDetail = {
        ...detailData,
        // address: null,
        showQR: false,
        latAndLon: _.round(detailData.location[0], 6) + ',' + _.round(detailData.location[1], 6),
      };
 
      console.log('this.currentDetail', this.currentDetail);
      this.detailVisible = true;
      this.handleTypeChange(this.currentDetail.type)
      console.log('this.currentDetail.location',this.currentDetail.location);
 
      this.$nextTick(() => {
        if (this.$refs.MapContainer && this.$refs.MapContainer.initAddEntity) {
          this.$refs.MapContainer.initAddEntity('point', this.currentDetail.location);
        }
      });
    },
 
    getStepHandler(status) {
      const step = this.stepInfos.find(step => step.status === status);
      return step ? step.name : '';
    },
 
    getStepTime(status) {
      const step = this.stepInfos.find(step => step.status === status);
      // 如果 step 不存在或 step.time 为 0,返回 false
      return step && step.time && step.time !== '0' ? step.time : false;
    },
    getStepCreateTime(status) {
      const step = this.stepInfos.find(step => step.status === status);
      return step ? step.create_time : null;
    },
    getActiveStep() {
      // 步骤索引适配
      const arr = this.stepStatusList;
      const index = arr.indexOf(String(this.currentDetail.status));
      return index !== -1 ? index + 2 : 1;
    },
 
    openMap() {
      const areaCode = this.userInfo.detail.areaCode;
      const subAreaCode = areaCode ? areaCode.substring(0, 6) : '';
      getAdcodeObj(geoJson, 'adcode', subAreaCode);
      this.$message.info('地图选址功能暂未实现');
    },
 
    handlePreview(file) {
      this.$message.info(`预览图片:${file.name}`);
    },
 
    handleRemove(file) {
      this.$message.info(`移除图片:${file.name}`);
    },
 
    refreshChange() {
      if (this.isFetching) return;
      this.fetchTableData();
    },
 
    onLoad() {
      if (this.isFetching) return;
      this.fetchTableData();
    },
 
    async exportData() {
      try {
        this.loading = true;
        let exportData = [];
 
        // 如果有选中的数据,则导出选中的数据
        if (this.selections.length > 0) {
          exportData = this.selections.map(item => this.formatExportItem(item));
        } else {
          // 没有选中数据时,导出当前页面的数据
          exportData = this.tableData.map(item => this.formatExportItem(item));
        }
 
        if (exportData.length === 0) {
          this.$message.warning('没有数据可供导出');
          return;
        }
 
        const headers = [
          '工单编号',
          '工单名称',
          '所属单位',
          '发起时间',
          '关联算法',
          '工单内容',
          '工单类型',
          '经纬度',
          '创建人',
          '处理人',
          '工单状态',
        ];
 
        export_json_to_excel(headers, exportData, '工单数据');
        this.$message.success('数据导出成功');
      } catch (error) {
        // console.error('导出失败:', error);
        this.$message.error(error.message || '导出失败,请稍后重试');
      } finally {
        this.loading = false;
      }
    },
 
    formatExportItem(item) {
      const longitude = Number(item.longitude) || Number(item.location?.[0]) || 0;
      const latitude = Number(item.latitude) || Number(item.location?.[1]) || 0;
 
      return {
        工单编号: item.orderNumber || item.event_num || '',
        工单名称: item.orderName || item.event_name || '',
        所属单位: item.department || item.dept_name || '',
        发起时间: item.startTime || item.create_time || '',
        关联算法: item.aiType || item.ai_types || '',
        工单内容: item.address || item.content || '',
        工单类型:
          this.types.find(t => t.value === (item.type || item.work_order_type_dict_key))?.label ||
          '',
        经纬度:
          !isNaN(longitude) && !isNaN(latitude)
            ? `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`
            : '',
        创建人: item.creator || item.create_user || '',
        处理人: item.handler || item.update_user || '',
        工单状态: this.mapStatus(Number(item.status || 0)),
      };
    },
 
    handleDepartmentChange(deptId) {
      this.form.handler = '';
    },
 
    handleDispatchDepartmentChange(deptId) {
      this.dispatchForm.handler = ''; // 清空处理人选择
    },
 
    // 文件改变时的钩子
    handleFileChange(file, fileList) {
      // 保持最新的文件列表
      this.form.photos = fileList.map(item => ({
        ...item,
        existingUrl: item.url && !item.raw ? item.url : null, // 标记已存在的图片URL
      }));
      this.currentDetail.photos = this.form.photos;
    },
 
    // 文件移除时的钩子
    handleUploadRemove(file, fileList) {
      this.form.photos = fileList;
      this.currentDetail.photos = fileList;
    },
 
    // 上传前的验证
    beforeUpload(file) {
      const isImage = file.type.includes('image');
      const isLt5M = file.size / 1024 / 1024 < 5;
 
      if (!isImage) {
        this.$message.error('只能上传图片文件!');
        return false;
      }
      if (!isLt5M) {
        this.$message.error('图片大小不能超过5MB!');
        return false;
      }
      return true;
    },
 
    async approveTicket() {
      if (this.approveLoading) return;
      this.approveLoading = true;
      try {
        const data = {
          id: this.currentDetail.id,
          status: this.currentDetail.status,
          isPass: 0, // 0 表示通过
          eventNum: this.currentDetail.orderNumber,
        };
 
        const file = this.currentDetail.file || null; // 如果没有文件,则为 null
 
        const response = await flowEvent(data, file);
        if (response.data.code === 0) {
          this.$message.success('工单已通过');
          this.detailVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '操作失败');
        }
      } catch (error) {
        this.$message.error(error.message || '操作失败,请稍后重试');
      } finally {
        this.approveLoading = false;
      }
    },
    async rejectTicket() {
      if (this.rejectLoading) return;
      this.rejectLoading = true;
      try {
        const data = {
          id: this.currentDetail.id,
          status: this.currentDetail.status,
          isPass: 1, // 1 表示不通过
        };
 
        const response = await flowEvent(data);
        if (response.data.code === 0) {
          this.$message.success('工单未通过');
          this.detailVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '操作失败');
        }
      } catch (error) {
        this.$message.error(error.message || '操作失败,请稍后重试');
      } finally {
        this.rejectLoading = false;
      }
    },
    async submitProcessing() {
      if (this.currentDetail.status !== 3) {
        this.$message.warning('只有处理中状态的工单可以提交处理详情');
        return;
      }
 
      try {
        const data = {
          id: this.currentDetail.id, // 当前工单 ID
          status: this.currentDetail.status, // 当前工单状态
          processing_details: this.currentDetail.processingDetail, // 事件处理详情
        };
 
        // 如果有图片,添加 file 参数
        const file = this.currentDetail.photos?.[0]?.raw || null;
 
        const response = await flowEvent(data, file);
        if (response.data.code === 0) {
          this.$message.success('处理详情提交成功');
          this.detailVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '提交失败');
        }
      } catch (error) {
        console.error('处理详情提交失败:', error);
        this.$message.error(error.message || '提交失败,请稍后重试');
      }
    },
    markAsCompleted() {
      this.$message.success('工单已标记为完成');
    },
    async completeTicket() {
      if (this.completeLoading) return;
      this.completeLoading = true;
      try {
        if (!this.currentDetail.processingDetail) {
          this.$message.warning('请先填写事件处理详情');
          return;
        }
        // 检查图片上传
        if (!this.currentDetail.photos || this.currentDetail.photos.length === 0) {
          this.$message.warning('请选择上传图片');
          this.completeLoading = false;
          return;
        }
 
        const data = {
          id: this.currentDetail.id,
          status: this.currentDetail.status,
          processingDetails: this.currentDetail.processingDetail,
          eventNum: this.currentDetail.orderNumber,
        };
 
        // 如果有上传的图片,添加到请求中
        const file = this.currentDetail.photos?.[0]?.raw || null;
 
        const response = await flowEvent(data, file);
 
        if (response.data.code === 0) {
          this.$message.success('工单已完成');
          this.detailVisible = false;
          this.fetchTableData(); // 刷新列表数据
        } else {
          throw new Error(response.data.msg || '操作失败');
        }
      } catch (error) {
        console.error('完成工单失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
      } finally {
        this.completeLoading = false;
      }
    },
    async approveAndDispatch() {
      if (this.dispatchLoading) return;
 
      // 添加必填项检查
      if (!this.currentDetail.orderName || !this.currentDetail.orderName.trim()) {
        this.$message.warning('请填写工单名称');
        return;
      }
      if (!this.currentDetail.aiType) {
        this.$message.warning('请选择关联算法');
        return;
      }
      if (!this.currentDetail.content || !this.currentDetail.content.trim()) {
        this.$message.warning('请填写工单内容');
        return;
      }
 
      // 通过验证后,打开派发对话框
      this.dispatchDialogVisible = true;
 
      console.log('受理',this.currentDetail);
 
    },
    hasProcessingBtnPermission() {
      // undefined 或 false 都返回 false,只有 true 返回 true
      //  console.log('权限检查:', this.permission.tickets_processing_btn)
      return this.permission && this.permission.tickets_processing_btn === true;
    },
    hasProcessedAndOverBtnPermission() {
      // undefined 或 false 都返回 false,只有 true 返回 true
      //console.log('权限检查:', this.permission)
      return this.permission && this.permission.tickets_view_processedAndOver === true;
    },
    hasReviewBtnPermission() {
      // undefined 或 false 都返回 false,只有 true 返回 true
      // console.log('权限检查:', this.permission)
      return this.permission && this.permission.tickets_review_btn === true;
    },
    async submitDispatch() {
      if (this.dispatchLoading) return;
      if (!this.currentDetail.orderName || !this.currentDetail.orderName.trim()) {
        this.$message.warning('请填写工单名称');
        return;
      }
      if (!this.currentDetail.type) {
        this.$message.warning('请选择工单类型');
        return;
      }
      if (!this.currentDetail.content || !this.currentDetail.content.trim()) {
        this.$message.warning('请填写工单内容');
        return;
      }
      if (!this.dispatchForm.department) {
        this.$message.warning('请选择部门');
        return;
      }
      if (!this.dispatchForm.handler) {
        this.$message.warning('请选择处理人');
        return;
      }
      this.dispatchLoading = true;
      console.log('派发成功',this.currentDetail);
 
      this.$refs.dispatchForm.validate(async valid => {
        if (valid) {
          try {
            const data = {
              id: this.currentDetail.id,
              status: this.currentDetail.status,
              isPass: 0, // 0 表示通过
              eventName: this.currentDetail.orderName, // 工单名称
              eventNum: this.currentDetail.orderNumber,
              workOrderTypeDictKey: this.currentDetail.type, // 直接使用原始的 dict_key
              content: this.currentDetail.content, // 使用 content 替代原来的 remark
              createDept: this.dispatchForm.department, // 派发部门 ID
              updateUser: this.dispatchForm.handler, // 处理人 ID
              aiType:this.currentDetail.aiType
            };
           console.log('派发',data);
 
            const file = this.currentDetail.file || null; // 如果没有文件,则为 null
 
            const response = await flowEvent(data, file);
            if (response.data.code === 0) {
              this.$message.success('工单已成功派发');
              this.dispatchDialogVisible = false;
              this.detailVisible = false;
              this.fetchTableData();
            } else {
              throw new Error(response.data.msg || '派发失败');
            }
          } catch (error) {
            console.error('派发失败:', error);
            this.$message.error(error.message || '派发失败,请稍后重试');
          } finally {
            this.dispatchLoading = false;
          }
        } else {
          this.dispatchLoading = false;
        }
      });
    },
    async finalizeTicket() {
      if (this.finalizeLoading) return;
      this.finalizeLoading = true;
      try {
        // 检查是否上传了图片
        if (!this.currentDetail.photos || !this.currentDetail.photos.length) {
          this.$message.warning('请上传事件处理照片,或飞行任务结束核验工单是否完结');
          return;
        }
 
        const data = {
          id: this.currentDetail.id,
          status: this.currentDetail.status,
          eventNum: this.currentDetail.orderNumber,
        };
 
        const file = this.currentDetail.photos[0].raw;
 
        const response = await flowEvent(data, file);
 
        if (response.data.code === 0) {
          this.$message.success('工单已完结');
          this.detailVisible = false;
          this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '操作失败');
        }
      } catch (error) {
        console.error('完结工单失败:', error);
        this.$message.error(error.message || '操作失败,请稍后重试');
      } finally {
        this.finalizeLoading = false;
      }
    },
 
    // 添加编辑方法
    handleEdit(row) {
      this.createoredit = 2;
      console.log('编辑原始数据:', row);
 
      // 尝试从row.dept_id或通过部门名称查找对应的部门ID
      let deptId = row.dept_id; // 优先使用原始数据中的dept_id
 
      // 如果没有dept_id,则通过部门名称查找
      if (!deptId) {
        // 输出所有可用的部门数据用于调试
        console.log('可用部门列表:', this.departments);
        console.log('当前部门名称:', row.department);
 
        const deptInfo = this.departments.find(
          dept => dept.label && dept.label.trim() === row.department.trim()
        );
        deptId = deptInfo?.value;
      }
 
      // 获取工单类型值 - 从types中找到匹配的值
      const typeValue =
        this.types.find(t => t.value === row.type)?.value || row.work_order_type_dict_key;
      // 获取处理人ID - 使用userNameToIdMap映射
      const handlerId = this.userNameToIdMap[row.handler] || row.handler;
 
      console.log('数据映射:', {
        部门名称: row.department,
        找到的部门ID: deptId,
        原始处理人: row.handler,
        处理人ID: handlerId,
        原始工单类型: row.type,
        映射后类型值: typeValue,
      });
 
      // 修改算法数组的处理逻辑
      let algorithmArr = [];
      if (Array.isArray(row.aiType)) {
        algorithmArr = row.aiType;
      } else if (typeof row.aiType === 'string' && row.aiType) {
        // 首先尝试将字符串按照逗号或顿号分割
        algorithmArr = row.aiType.split(/[,、]/).map(item => item.trim());
      }
 
      // 确保算法值与选项匹配
      algorithmArr = algorithmArr
        .map(item => {
          // 如果是字符串值,尝试找到对应的 dict_key
          if (typeof item === 'string') {
            const matchedAlgorithm = this.algorithms.find(
              algo => algo.dict_value === item || algo.dict_key === item
            );
            return matchedAlgorithm ? matchedAlgorithm.dict_key : item;
          }
          return item;
        })
        .filter(Boolean); // 过滤掉无效值
 
      console.log('算法处理:', {
        原始值: row.aiType,
        分割后: algorithmArr,
      });
 
      this.form = {
        id: row.id,
        name: row.orderName,
        type: typeValue,
        department: deptId,
        handler: handlerId,
        algorithm: algorithmArr,
        location:
          Array.isArray(row.location) && row.location.length >= 2
            ? [Number(row.location[0]), Number(row.location[1])]
            : [],
        address: row.address || '',
        content: row.content,
        photos: [],
      };
 
      let curLocation = [];
 
      if (Array.isArray(row.location) && row.location.length >= 2) {
        let [lng, lat] = this.disposeLocation(false, row);
 
        curLocation = [lng, lat, row.location[2] || row.address || ''];
      }
 
      this.form.location = curLocation;
      this.form.address = this.form.location[2] || '';
      // 设置地图中心点
      if (Array.isArray(this.form.location) && this.form.location.length >= 2) {
        this.mapParams.center = [Number(this.form.location[0]), Number(this.form.location[1])];
      } else {
        this.mapParams.center = [...this.inputMapShowDefaultCenter];
      }
      // 如果有图片,添加到表单中
      if (row.photo_url) {
        // 创建一个带有必要信息的文件对象
        this.form.photos = [
          {
            name: 'existing-photo.jpg', // 添加默认扩展名
            url: row.photo_url, // 用于预览的URL
            status: 'success', // 标记为已上传成功
            raw: null, // 初始化为null
            existingUrl: row.photo_url, // 保存原始URL,用于区分是否为已存在的图片
          },
        ];
      }
 
      // 调试输出
      console.log('编辑表单数据:', {
        原始算法值: row.aiType,
        处理后算法值: algorithmArr,
        表单数据: this.form,
      });
 
      this.dialogVisible = true;
    },
 
    // 添加删除方法
    handleDelete(row) {
      this.$confirm('确认删除该工单?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(async () => {
          try {
            const response = await flowEvent({
              id: row.id,
              status: 0,
              isDelete: 1,
            });
 
            if (response.data.code === 0) {
              this.$message.success('删除成功');
              this.fetchTableData();
            } else {
              throw new Error(response.data.msg || '删除失败');
            }
          } catch (error) {
            console.error('删除失败:', error);
            this.$message.error(error.message || '删除失败,请稍后重试');
          }
        })
        .catch(() => {});
    },
 
    // 添加选择变化处理方法
    handleSelectionChange(selection) {
      this.selections = selection;
      console.log('已选择的行:', selection);
    },
 
    // 添加全选方法
    handleSelectAll(val) {
      this.$refs.avueCrud.toggleSelection(val);
    },
 
    // 添加单行选择方法
    handleSelect(selection, row) {
      console.log('选中行变化:', selection, row);
    },
 
    // 如果需要手动选中某些行
    setSelection(rows) {
      this.$nextTick(() => {
        rows.forEach(row => {
          this.$refs.avueCrud.toggleSelection(row, true);
        });
      });
    },
 
    // 清空选择
    clearSelection() {
      this.$refs.avueCrud.clearSelection();
    },
 
    // 打开审核对话框
    openReviewDialog() {
      if (this.selections.length === 0) {
        this.$message.warning('请先选择要审核的工单');
        return;
      }
      this.currentImageIndex = 1;
      this.updateCurrentReviewImage();
      this.reviewDialogVisible = true;
    },
 
    // 更新当前审核图片
    updateCurrentReviewImage() {
      // 修正索引范围
      if (!this.selections || this.selections.length === 0) {
        this.currentReviewImage = '';
        this.currentImageIndex = 1;
        return;
      }
      // 如果当前索引超出范围,自动回退到最后一张
      if (this.currentImageIndex > this.selections.length) {
        this.currentImageIndex = this.selections.length;
      }
      if (this.currentImageIndex < 1) {
        this.currentImageIndex = 1;
      }
      const index = this.currentImageIndex - 1;
      if (index >= 0 && index < this.selections.length) {
        const currentItem = this.selections[index];
        this.currentReviewImage = currentItem.photo_url || '';
      } else {
        this.currentReviewImage = '';
      }
    },
 
    // 处理图片分页变化
    handleImagePageChange(page) {
      if (page > 0 && page <= this.selections.length) {
        this.currentImageIndex = page;
        this.updateCurrentReviewImage();
      }
    },
 
    // 批量审核通过
    async handleBatchApprove() {
      try {
        if (this.selections.length === 0) {
          this.$message.warning('没有选中的工单');
          return;
        }
 
        const currentItem = this.selections[this.currentImageIndex - 1];
        if (!currentItem) {
          this.$message.warning('当前工单数据无效');
          return;
        }
 
        await this.$confirm('确认审核通过当前工单?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        });
 
        const data = {
          id: currentItem.id,
          status: currentItem.status,
          isPass: 0,
          eventNum: currentItem.orderNumber,
        };
        console.log('删除前:', this.selections);
        const response = await flowEvent(data);
        if (response.data.code === 0) {
          this.$message.success('工单审核通过');
 
          // 创建新的数组而不是修改原数组
          const newSelections = [...this.selections];
          newSelections.splice(this.currentImageIndex - 1, 1);
 
          // 修正索引并更新图片
          if (newSelections.length > 0) {
            if (this.currentImageIndex > this.selections.length) {
              this.currentImageIndex = this.selections.length;
            }
            this.updateCurrentReviewImage();
          } else {
            this.reviewDialogVisible = false;
            this.currentImageIndex = 1;
            this.currentReviewImage = '';
            this.fetchTableData();
          }
 
          // 刷新表格数据
          // this.fetchTableData();
          this.selections = newSelections;
        } else {
          throw new Error(response.data.msg || '审核失败');
        }
      } catch (error) {
        if (error === 'cancel') return;
        this.$message.error(error.message || '审核失败,请稍后重试');
      }
    },
 
    cancleBatchReject() {
      this.reviewDialogVisible = false;
      this.selections = [];
      this.currentImageIndex = 1;
      this.currentReviewImage = '';
      this.fetchTableData();
    },
    // 批量审核不通过
    async handleBatchReject() {
      try {
        if (this.selections.length === 0) {
          this.$message.warning('没有选中的工单');
          return;
        }
 
        const currentItem = this.selections[this.currentImageIndex - 1];
        if (!currentItem) {
          this.$message.warning('当前工单数据无效');
          return;
        }
 
        await this.$confirm('确认该工单审核不通过?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        });
 
        const data = {
          id: currentItem.id,
          status: currentItem.status,
          isPass: 1,
          eventNum: currentItem.orderNumber,
          eventName: currentItem.orderName,
        };
 
        const response = await flowEvent(data);
        if (response.data.code === 0) {
          this.$message.success('工单审核不通过');
 
          // 创建新的数组而不是修改原数组
          const newSelections = [...this.selections];
          newSelections.splice(this.currentImageIndex - 1, 1);
          this.selections = newSelections;
 
          // 修正索引并更新图片
          if (this.selections.length > 0) {
            if (this.currentImageIndex > this.selections.length) {
              this.currentImageIndex = this.selections.length;
            }
            this.updateCurrentReviewImage();
          } else {
            this.reviewDialogVisible = false;
            this.currentImageIndex = 1;
            this.currentReviewImage = '';
            this.fetchTableData();
          }
 
          // 刷新表格数据
          // this.fetchTableData();
        } else {
          throw new Error(response.data.msg || '驳回失败');
        }
      } catch (error) {
        if (error === 'cancel') return;
        this.$message.error(error.message || '驳回失败,请稍后重试');
      }
    },
 
    // 获取所有图片列表用于预览
    getImageList() {
      return this.selections.map(item => this.getPreviewUrl(item.photo_url)).filter(url => url); // 过滤掉空值
    },
 
    // 处理图片点击
    handleImageClick() {
      // 图片点击事件由 el-image 的预览功能处理
    },
 
    // 处理上一张图片
    handlePrevImage() {
      if (this.currentImageIndex > 1) {
        this.currentImageIndex--;
        this.updateCurrentReviewImage();
      }
    },
 
    // 处理下一张图片
    handleNextImage() {
      if (this.currentImageIndex < this.selections.length) {
        this.currentImageIndex++;
        this.updateCurrentReviewImage();
      }
    },
 
    /**
     * 获取缩略图地址
     * @param {string} url 原图地址
     * @returns {string} 缩略图地址
     */
    getThumbUrl(url) {
      if (!url) return '';
      const lastDot = url.lastIndexOf('.');
      if (lastDot === -1) return url;
      return url.slice(0, lastDot) + '_small' + url.slice(lastDot);
    },
 
    // 添加新方法:获取预览图地址
    getPreviewUrl(url) {
      if (!url) return '';
      const lastDot = url.lastIndexOf('.');
      if (lastDot === -1) return url;
      return url.slice(0, lastDot) + '_show' + url.slice(lastDot);
    },
 
    /**
     * 坐标转换方法处理
     * @param goWgs84 是否由国测转换到84,默认false----由84转换到国测
     */
    disposeLocation(goWgs84 = false, data) {
      let lng = '',
        lat = '';
 
      if (Array.isArray(data.location) && data.location.length > 0) {
        if (goWgs84) {
          lng = data.location?.[0] ? String(data.location[0]) : undefined;
          lat = data.location?.[1] ? String(data.location[1]) : undefined;
 
          if (lng && lat) {
            [lng, lat] = gcj02ToWgs84(Number(lng), Number(lat));
          }
        } else {
          lng = Number(data.location[0]);
          lat = Number(data.location[1]);
 
          if (lng && lat) {
            [lng, lat] = wgs84ToGcj02(Number(lng), Number(lat));
          }
        }
      }
 
      return [String(lng), String(lat)];
    },
 
    // 复核按钮
    reCheck(row) {
      this.reCheckData = row;
      this.reCheckDialog = true;
    },
 
    // 复核确认框按钮事件
    reCheckConfirm(key) {
      const that = this;
      if (key == 1) {
        getReviewById(that.reCheckData.id).then(res => {
          that.reCheckDialog = false;
          that.page.currentPage = 1;
          that.fetchTableData();
          that.fetchTabCounts();
        });
      } else {
        const loading = ElLoading.service({
          lock: true,
          text: '复核任务创建中……',
          background: 'rgba(0, 0, 0, 0.7)',
        });
 
        function closeConfirm() {
          that.reCheckDialog = false;
          that.page.currentPage = 1;
          that.fetchTableData();
          that.fetchTabCounts();
          loading.close();
        }
 
        // 获取时间的接口
        getCreateEventJob(that.reCheckData.id)
          .then(res => {
            ElMessageBox.confirm(`预计复核执行时间为${res.data.data}`, '提示', {
              confirmButtonText: '确定',
              showCancelButton: false, // 关键配置
              closeOnClickModal: false,
              closeOnPressEscape: false,
              type: 'warning',
            })
              .then(() => {
                closeConfirm();
              })
              .catch(() => {
                closeConfirm();
              });
          })
          .catch(() => {
            closeConfirm();
          });
      }
    },
  },
  activated() {
    this.handleReset();
  },
 
};
</script>
<style lang="scss">
.custom-dialog {  max-height: 96vh; }
.custom-qrcode-popover {
min-width: 120px !important;
}
</style>
<style lang="scss" scoped>
 
::v-deep(.el-tabs) {
  height: 100%;
  display: flex;
  flex-direction: column;
 
  .el-tabs__header {
    order: 1;
  }
 
  .el-tabs__content {
    order: 2;
  }
 
  .el-tabs__content {
    height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
 
    .el-tab-pane {
      height: 0;
      flex: 1;
      display: flex;
      flex-direction: column;
    }
  }
}
 
.filter-bar {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 8px; // 使用 gap 统一设置间距
 
  .filter-item {
    width: 280px; // 减小宽度
  }
 
  .date-picker {
    // width: 240px; // 日期选择器宽度适当调整
  }
 
  .el-button {
    margin-left: 0; // 覆盖 element-ui 默认的按钮间距
  }
}
 
.uploadImg {
  margin-bottom: 32px;
}
 
.tableCss {
  width: 100%;
  margin-bottom: 10px;
}
 
.step-timer {
  position: absolute;
  right: 80%;
  top: 50%;
  transform: translateY(-50%);
  width: 100px;
  margin-left: 4px;
  color: #666;
  font-size: 12px;
}
 
.event-total-time {
  text-align: center;
  color: #666;
  font-size: 15px;
  margin-bottom: 12px;
}
 
.action-bar {
  margin-bottom: 16px;
}
 
.el-dialog {
  .el-form-item {
    margin-bottom: 20px;
  }
}
 
.el-upload {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
 
  :deep(.el-upload-list__item) {
    transition: all 0.3s ease;
  }
 
  :deep(.el-upload-list__item:hover) {
    background-color: #f5f7fa;
  }
}
 
.el-upload__tip {
  font-size: 12px;
  color: #909399;
  margin-top: 12px;
}
 
.create-ticket-form {
  padding: 20px 10px;
 
  .form-section {
    background-color: #fff;
    border-radius: 4px;
 
    .el-row {
      margin-bottom: 16px;
 
      &:last-child {
        margin-bottom: 0;
      }
    }
  }
 
  .location-wrapper {
    width: 100%; // 修改为100%以适应父容器
    height: auto; // 修改为auto以自适应内容
 
    .map-button {
      width: 100%; // 让按钮填满容器宽度
      height: 36px; // 与其他输入框保持一致的高度
      display: flex;
      align-items: center;
      justify-content: center;
 
      i {
        margin-right: 4px;
      }
    }
 
    .location-text {
      margin-top: 8px;
      padding: 8px 12px;
      background-color: #f5f7fa;
      border-radius: 4px;
      color: #606266;
      font-size: 13px;
      line-height: 1.4;
    }
  }
 
  .upload-wrapper {
    .uploader {
      :deep(.el-upload--picture-card) {
        width: 120px;
        height: 100px;
        line-height: 128px;
      }
 
      :deep(.el-upload-list__item) {
        width: 120px;
        height: 120px;
      }
    }
 
    .upload-tip {
      font-size: 12px;
      color: #909399;
      line-height: 1.4;
      margin-top: 8px;
    }
  }
 
  .el-form-item {
    margin-bottom: 18px;
 
    &:last-child {
      margin-bottom: 0;
    }
  }
 
  :deep(.el-form-item__label) {
    font-weight: 500;
    color: #606266;
  }
 
  // :deep(.el-input__inner) {
  //   height: 36px;
  //   line-height: 36px;
  // }
 
  :deep(.el-textarea__inner) {
    padding: 8px 12px;
  }
 
  // :deep(.el-input__inner),
  // :deep(.el-select),
  // :deep(.el-select .el-input) {
  //   width: 100%; // 确保所有输入框和选择框宽度一致
  // }
 
  .full-width {
    width: 100%;
  }
}
 
.dialog-footer {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid #ebeef5;
 
  .el-button + .el-button {
    margin-left: 12px;
  }
 
  .el-button {
    padding: 9px 20px;
 
    &:last-child {
      margin-left: 12px;
    }
  }
}
.dialog-footer1 {
  position: sticky;
    bottom: 28px;
    left: 0;
    right: 0;
    background: white;
    z-index: 10;
    padding: 16px 20px;
    border-top: 1px solid #ebeef5;
    display: flex;
    justify-content: space-between;
    align-items: center;
  .el-button + .el-button {
    margin-left: 12px;
  }
.btngroups {
margin-left: 12px;
}
  .el-button {
    padding: 9px 20px;
 
    &:last-child {
      margin-left: 12px;
      margin-right: 12px;
    }
  }
}
.map-container {
  width: 100%;
  height: 400px;
  margin-bottom: 15px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  overflow: hidden;
 
  :deep(.el-input-map) {
    height: 100%;
  }
}
 
.location-info {
  margin-top: 10px;
  padding: 10px;
  background-color: #f5f7fa;
  border-radius: 4px;
 
  p {
    margin: 5px 0;
    color: #606266;
    font-size: 14px;
  }
}
 
.map-select {
  display: flex;
  align-items: flex-start;
  gap: 15px;
 
  .selected-location {
    flex: 1;
    padding: 5px 10px;
    background-color: #f5f7fa;
    border-radius: 4px;
 
    p {
      margin: 5px 0;
      color: #606266;
      font-size: 14px;
    }
  }
}
 
.preview-image {
  border-radius: 4px;
  overflow: hidden;
  background-color: #f5f7fa;
}
 
.image-placeholder,
.image-error,
.no-media {
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #909399;
  background-color: #f5f7fa;
  border-radius: 4px;
 
  i {
    font-size: 32px;
    margin-bottom: 8px;
  }
}
 
.no-media {
  border: 1px dashed #d9d9d9;
}
 
.detail-container {
  padding:0 20px;
 
  .detail-top-title {
    display: flex;
    justify-content: center;
    align-items: center;
 
    .event-orderNumber {
      margin-right: 10px;
    }
  }
}
 
.status-flow {
  margin-bottom: 20px;
 
  .custom-steps {
    .el-step__description {
      position: relative;
      margin: 0;
      padding: 0;
    }
 
    // 添加发起任务步骤的特殊样式
    .init-step-info {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      width: 130px;
 
      .creator-name {
        font-size: 14px;
        font-weight: bold;
        color: #303133;
        margin-bottom: 4px;
      }
 
      .create-time {
        font-size: 10px;
        color: #909399;
      }
    }
 
    // 保持其他步骤的原有样式
    .step-info {
      display: flex;
      margin: 0;
      padding: 0;
      justify-content: space-between;
      align-items: center;
      width: 200px;
 
      .process-time {
        font-size: 10px;
        color: #909399;
        text-align: left;
        margin-left: -50%;
        padding-left: 0%;
        flex: 1;
      }
 
      .handler-name {
        font-size: 14px;
        font-weight: bold;
        color: #303133;
        text-align: left;
        flex: 1;
      }
    }
  }
}
 
.basic-info {
  margin-bottom: 20px;
}
 
.media-section {
  // margin-bottom: 20px;
 
  .el-row {
    display: flex;
    align-items: center;
  }
}
 
.leftBtn {
  width: 70px;
  height: 32px;
  background-color: #999;
  border-radius: 5px;
  text-align: center;
line-height: 32px;
  color: #fff;
  cursor: pointer;
  opacity: 0.8;
 
}
 
.disableds {
  background: #999 !important;
  cursor: not-allowed !important;
  pointer-events: none;
  opacity: 0.3 !important;
}
.PopUpTableScrolls{
height: 600px;
overflow-y: scroll;
overflow-x: hidden;
}
.media-box {
  width: 100%;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  padding: 10px;
  background: #fff;
  box-sizing: border-box;
 
  .media-title {
    font-weight: bold;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    .QRCodeImg{
    width: 18px;
    height: 18px;
    cursor: pointer;
    padding-bottom: 1px;
    }
  }
 
  .media-content {
    position: relative;
    height: 500px;
 
    :deep(.el-image) {
      width: 100% !important;
      max-width: 100%;
      max-height: 100%;
 
      .el-image__inner {
        width: 100%;
        height: 100%;
        object-fit: cover !important;
      }
    }
  }
}
 
.image-placeholder,
.image-error,
.no-media {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #909399;
  background-color: #f5f7fa;
  border-radius: 4px;
}
 
.image-placeholder i,
.image-error i {
  font-size: 32px;
  margin-bottom: 8px;
}
 
.no-media {
  border: 1px dashed #d9d9d9;
}
 
.info-table {
  margin-bottom: 20px;
}
 
.info-item {
  display: flex;
  margin-bottom: 10px;
}
 
.info-label {
  font-weight: bold;
  width: 120px;
  color: #606266;
}
 
.info-value {
  flex: 1;
  color: #303133;
  word-break: break-word;
}
 
.readonly-processing-detail {
  background-color: #f5f7fa;
  padding: 12px;
  border-radius: 4px;
  min-height: 30px;
  color: #606266;
  line-height: 1.5;
  display: block;
  text-align: left;
margin-bottom: 5px;
  &:first-child {
    font-weight: bold;
    margin-bottom: 4px;
  }
}
 
// 添加删除按钮样式
.danger-button {
  color: #f56c6c;
}
 
.danger-button:hover {
  color: #f78989;
}
 
.custom-steps-container {
  width: 100%;
  margin: 10px 0;
}
 
.steps-titles {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  position: relative;
}
 
.step-title {
  text-align: center;
  flex: 1;
  font-size: 14px;
  color: #999;
  position: relative;
  padding-bottom: 5px;
}
 
.step-title.active {
  color: #409eff;
  font-weight: bold;
}
 
.event-title-center {
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 5px;
  color: #333;
}
 
.custom-steps {
  margin-top: -20px;
 
  :deep(.el-step__description) {
    margin-top: 8px;
    padding: 0 20px;
  }
}
 
.step-description {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
  display: block;
  text-align: center;
 
  &:first-child {
    font-weight: bold;
    margin-bottom: 4px;
  }
}
 
// 覆盖其他相关样式
.status-flow {
  .custom-steps {
    .el-step__description {
      position: relative;
      margin: 0;
      padding: 0;
    }
 
    // 移除之前的样式
    .init-step-info,
    .step-info {
      display: block;
      width: auto;
      text-align: center;
    }
  }
}
 
// 添加新的样式
.review-dialog {
  :deep(.el-dialog__body) {
    padding: 0;
    background-color: #f5f7fa;
  }
}
 
.re-check-dialog {
  :deep(.el-dialog__body) {
    padding: 0;
    background-color: #f5f7fa;
  }
}
 
.review-container {
  position: relative;
 
  .review-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 600px;
    background-color: #f5f7fa;
  }
 
  .review-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
 
    :deep(.el-image) {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
 
      .el-image__inner {
        max-height: 100%;
        max-width: 100%;
        object-fit: contain;
      }
    }
  }
 
  .arrow-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 100;
 
    &:hover {
      background: rgba(0, 0, 0, 0.6);
    }
 
    i {
      color: #fff;
      font-size: 24px;
    }
 
    &.left {
      left: 20px;
    }
 
    &.right {
      right: 20px;
    }
  }
 
  .preview-image {
    max-width: 100%;
    max-height: 100%;
  }
 
  .review-pagination {
    padding: 16px 0;
    display: flex;
    justify-content: center;
    background-color: #fff;
 
    :deep(.el-pagination) {
      .btn-prev,
      .btn-next {
        display: none;
      }
 
      .el-pager {
        .number {
          margin: 0 4px;
        }
      }
    }
  }
 
  .image-error {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #909399;
 
    i {
      font-size: 48px;
      margin-bottom: 16px;
    }
 
    span {
      font-size: 16px;
    }
  }
}
 
/* 新建工单和处理工单的上传组件样式 */
.create-upload,
.detail-upload {
  :deep(.el-upload--picture-card) {
    width: 120px;
    height: 100px;
    line-height: 100px;
  }
 
  /* 隐藏额外的上传按钮 */
  :deep(.el-upload.el-upload--picture-card) {
    display: none;
  }
 
  /* 当没有图片时显示上传按钮 */
  :deep(.el-upload.el-upload--picture-card:first-child) {
    display: flex;
  }
 
  /* 上传组件的预览图片样式 */
  :deep(.el-upload-list--picture-card .el-upload-list__item) {
    width: 120px;
    height: 100px;
  }
}
 
/* 原有图片预览的样式 */
.el-image-viewer__wrapper {
  :deep(.el-image-viewer__img) {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
}
 
/* 必填项样式 */
.required-label {
  position: relative;
  display: inline-block;
 
  .required-star {
    color: #f56c6c;
    margin-right: 4px;
  }
}
 
/* 必填输入框样式 */
.required-input {
  width: 100%;
 
  :deep(.el-input__inner),
  :deep(.el-textarea__inner) {
    &:focus {
      border-color: #409eff;
    }
  }
}
</style>