schangxiang@126.com
2025-09-19 9be9c3784b2881a3fa25e93ae2033dc2803c0ed0
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
 
<template>
  <div class="page-list-container">
    <!--数据Table-->
    <yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes" :tab-nav-list="tabNavList" :is-init-load="false" @on-load-dropdown-after="onLoadDropdownAfter">
      <!-- 字段插槽 -->
      <template slot="common-column-slot" slot-scope="{ row, col }">
        <template v-if="col.prop == 'orderStatus'">
 
          <state-flow :load-options="stateLoadOptions" :where="{wayBillCode: row.wayBillCode}">
            <template slot="content">
              <el-tag :color="setStatusBgColor(row[col.prop])" :style="setStatusColor(row[col.prop])">
                {{ row[col.prop] }}
              </el-tag>
            </template>
          </state-flow>
        </template>
        <!--审核字段-->
        <template v-else-if="col.prop=='auditing'">
          <template>
            <el-tag v-if="row[col.prop]==0" color="#ffff33" style="color:black;border:0">
              {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]==1" color="#ff0033" style="color:white;border:0">
              {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <el-tag v-else-if="row[col.prop]==2" color="#33cc33" style="color:black;border:0;color:#fff;">
              {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
            </el-tag>
            <span v-else>
              {{ row[col.prop] }}
            </span>
          </template>
        </template>
        <!-- 单据类型 -->
        <template v-else-if="col.prop=='wayBillType'">
          <template>
            <el-tag v-if="row[col.prop]=='仓配单'" color="#ffff33" style="color:black;border:0">
              {{ row[col.prop] }}
            </el-tag>
          </template>
        </template>
        <!--图片列处理-->
        <template v-else-if="['returnImageUrl'].indexOf(col.prop)>=0">
          <template v-for="(pic, index) in getReturnPicList(row[col.prop])">
            <img :key="index" :src="BASE_API + pic" class="pic" @click="showReturnPic(pic)">
          </template>
        </template>
        <!-- 连接字段 -->
        <template v-else-if="col.prop==dataOptions.linkColumn">
          <el-link type="primary" @click.native="()=>{linkEditor(row[dataOptions.idField]);}">{{ row[col.prop] }}</el-link>
        </template>
        <!--托盘号-->
        <template v-else-if="col.prop == 'plateCode'">
          {{ row[col.prop] }}
          <el-button v-if="row['orderStatus']==='已组板'" type="text" @click="()=>{modifyPlateCode([row])}">改</el-button>
        </template>
        <template v-else-if="col.dropdown_Id>0">
          {{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
        </template>
        <template v-else>
          <template v-if="['date', 'datetime'].indexOf(col.dataType)>=0 && col.formatter">
            {{ common.formatDate(row[col.prop], col.formatter) }}
          </template>
          <template v-else-if="['byte', 'int32', 'int64', 'decimal', 'double'].indexOf(col.dataType)>=0 && col.formatter">
            {{ common.formatNumber(row[col.prop], col.formatter) }}
          </template>
          <template v-else>
            {{ row[col.prop] }}
          </template>
        </template>
      </template>
      <template slot="button-tool2-slot">
        <el-checkbox v-model="dataOptions.isLoadHisotry" @change="$refs[dataListRef].reload()">查询历史</el-checkbox>
      </template>
    </yrt-data-list>
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :edit-button-click="editButtonClick" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :btn-read-only="btnReadOnly" :audit-disabled="auditDisabled" :on-save-before="onSaveBefore" @on-change="onChange" @on-add-load-after="onEditLoadAfter" @on-edit-load-after="onEditLoadAfter" @on-detail-change="onDetailChange" @on-save-after="onSaveAfter">
      <!--自定义按钮插槽-->
      <template slot="footer-button-region" slot-scope="{ formData, details }">
        <!--打印条码按钮-->
        <el-button :disabled="btnReadOnly.viewPicture" type="success" icon="el-icon-view" @click.native="viewPicture(formData, details)">查看图片</el-button>
        <el-button v-show="(formData.expressCorpType==11&&formData.expressCode)?true:false" type="success" icon="el-icon-yrt-weibiaoti7" @click.native="getSortingCode(formData, details)">获取大头笔</el-button>
      </template>
    </yrt-editor>
 
    <!-- 批量审核对话框 -->
    <el-dialog :visible.sync="showBatchAuditingDialog" title="批量审核" width="500px">
      <el-form :label-width="formLabelWidth" :model="formDataAudit">
        <el-form-item label="口岸名称">
          <el-select v-model="formDataAudit.port_Id" filterable clearable placeholder="请选择口岸名称" @change="getExpressCorp(formDataAudit.port_Id)">
            <el-option v-for="(item, index) in portOptions" :key="index" :label="item.portName" :value="item.port_Id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="快递类别">
          <el-select v-model="formDataAudit.expressCorpType" filterable clearable placeholder="请选择快递类别" @change="changeExpressCorpType(formDataAudit.expressCorpType)">
            <el-option v-for="(item, index) in expressCorpTypeList" :key="index" :label="item.expressCorpName" :value="item.expressCorpType">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="快递名称">
          <el-select v-model="formDataAudit.expressCorp_Id" filterable clearable placeholder="请选择快递名称">
            <el-option v-for="(item, index) in expressCorpNameList" :key="index" :label="item.expressCorpName" :value="item.expressCorp_Id">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showBatchAuditingDialog=false">取 消</el-button>
        <el-button type="primary" @click="saveBatchAuditing">确 定</el-button>
      </div>
    </el-dialog>
 
    <!-- 修改口岸对话框 -->
    <el-dialog :visible.sync="portDialogVisible" width="500px" title="修改口岸">
      <el-form :model="formData">
        <el-form-item label="口岸名称">
          <el-select v-model="formData.port_Id" placeholder="请选择口岸名称" @change="getExpressCorp(formData.port_Id)">
            <el-option v-for="item in portOptions" :key="item.port_Id" :label="item.portName" :value="item.port_Id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="快递类别">
          <el-select v-model="formData.expressCorpType" filterable clearable placeholder="请选择快递类别" @change="changeExpressCorpType(formData.expressCorpType)">
            <el-option v-for="(item, index) in expressCorpTypeList" :key="index" :label="item.expressCorpName" :value="item.expressCorpType">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="快递名称">
          <el-select v-model="formData.expressCorp_Id" filterable clearable placeholder="请选择快递名称">
            <el-option v-for="(item, index) in expressCorpNameList" :key="index" :label="item.expressCorpName" :value="item.expressCorp_Id">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="portDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="saveUpdatePort">确 定</el-button>
      </div>
    </el-dialog>
 
    <!-- 溢装处理对话框 -->
    <el-dialog :visible.sync="overloading" width="500px" title="溢装处理">
      <el-form :model="formDataOverload">
        <el-form-item label="口岸名称">
          <el-select v-model="formDataOverload.port_Id" placeholder="请选择口岸名称" @change="getExpressCorp(formDataOverload.port_Id)">
            <el-option v-for="item in portOptions" :key="item.port_Id" :label="item.portName" :value="item.port_Id">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="快递类别">
          <el-select v-model="formDataOverload.expressCorpType" filterable clearable placeholder="请选择快递类别" @change="changeExpressCorpType(formDataOverload.expressCorpType)">
            <el-option v-for="(item, index) in expressCorpTypeList" :key="index" :label="item.expressCorpName" :value="item.expressCorpType">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="快递名称">
          <el-select v-model="formDataOverload.expressCorp_Id" filterable clearable placeholder="请选择快递名称">
            <el-option v-for="(item, index) in expressCorpNameList" :key="index" :label="item.expressCorpName" :value="item.expressCorp_Id">
            </el-option>
          </el-select>
          <el-checkbox v-model="formDataOverload.getExpressCode">从接口重新获取快递单号</el-checkbox>
        </el-form-item>
        <el-form-item label="航空主单号">
          <el-input v-model="formDataOverload.voyageCode">
          </el-input>
        </el-form-item>
        <el-form-item label="托盘号">
          <el-input v-model="formDataOverload.plateCode">
          </el-input>
        </el-form-item>
        <el-form-item label="运单状态">
          <el-select :disabled="!formDataOverload.isValidateProductCode" v-model="formDataOverload.orderStatusName" filterable clearable placeholder="请选择运单状态">
            <el-option v-for="(item, index) in orderStatusNameList" :key="index" :label="item.orderStatusName" :value="item.orderStatusName">
            </el-option>
          </el-select>
          <span class="sub-item">
            <span class="sub-label">更改状态:</span>
            <el-switch v-model="formDataOverload.isValidateProductCode"></el-switch>
          </span>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="overloading = false">取 消</el-button>
        <el-button type="primary" @click="saveOverloading">确 定</el-button>
      </div>
    </el-dialog>
 
    <el-dialog :visible.sync="dialogLandingTime">
      <el-form>
        <el-upload ref="upload" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" :auto-upload="true" :action="upLoadUrl()" :limit="1" class="upload-bill">
          <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
          <el-button style="margin-left: 10px;" size="small" type="success" @click="submitImport()">开始导入</el-button>
          <el-button style="margin-left: 10px;" size="small" type="primary" plain>
            <a :href="common.ossDomain+'/node-wms/template/运单信息批量修改模板.xlsx'" style="color:while;font-size:12px;">下载模板</a>
          </el-button>
          <div slot="tip" class="el-upload__tip">只能上传扩展名为.xlsx的excel文件</div>
        </el-upload>
        <el-scrollbar :noresize="false" :native="false" wrap-class="scrollbar-wrap">
          <ul class="msg-container">
            <li v-for="(item, index) in msgList" :key="index" class="msg-item" v-html="item">
              {{ index + 1 }}、{{ item }}
            </li>
          </ul>
        </el-scrollbar>
      </el-form>
      <!-- <div class="margin-10" v-html="importMsg">{{ importMsg }}</div> -->
      <div slot="footer" class="dialog-footer">
        <!-- <el-button type="primary" @click="EditlogLandingTimesave">确 定</el-button> -->
      </div>
    </el-dialog>
 
    <!--预览图片-->
    <el-dialog v-dialogDrag :visible.sync="dialogPicVisible" :modal="false" :append-to-body="true" class="pic-dialog">
      <img :src="dialogImageUrl" style="max-width:100%;">
    </el-dialog>
 
    <!--明细选择器-->
    <yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" @on-selected="onSelected"></yrt-selector>
 
    <!--退货预览图片-->
    <el-dialog :visible.sync="dialogReturnPicVisible" :append-to-body="true">
      <img :src="dialogReturnImageUrl" style="max-width:100%;">
    </el-dialog>
  </div>
</template>
 
<script>
import baseLayout from "@/components/common/base-layout.vue";
import stateFlow from "./components/stateflow.vue";
import yrtSelector from "@/components/common/yrtSelector.vue";
import * as moment from "moment";
 
export default {
  name: "tms-way-bill",
  components: {
    yrtSelector,
    stateFlow
  },
  mixins: [baseLayout],
  data() {
    return {
      // 弹出导入框
      dialogLandingTime: false,
      fileList: [],
      // 导入消息
      importMsg: null,
      fileUrl: null,
      // 消息内容
      msgList: [],
      // 导入获得消息interval handle
      intervalHandler: null,
      // 导入key
      uploadKey: null,
      // 选择器配置参数
      selectorConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/s-product-selector"
      },
      // 修改口岸对话框数据集合
      formData: {
        port_Id: null,
        expressCorp_Id: null,
        expressCorpType: null
      },
      // 审核对话框数据集合
      formDataAudit: {
        port_Id: null,
        expressCorp_Id: null,
        expressCorpType: null
      },
      // 溢装处理对话框数据集合
      formDataOverload: {
        isValidateProductCode: true,
        orderStatusName: null,
        code: null,
        port_Id: null,
        expressCorp_Id: null,
        expressCorpType: null,
        voyageCode: null,
        plateCode: null,
        getExpressCode: false
      },
      expressCorpoptions: null,
      // 列表固定条件
      // fixedWhere: {orderStatus: {operator: "!=", value: '新建'}}",
      // 分配快递公司对话框
      showBatchAuditingDialog: false,
      // 显示口岸对话框
      portDialogVisible: false,
      formLabelWidth: "120px",
      //
      overloading: false,
      // 快递类别下拉框数据列表
      expressCorpTypeList: [],
      // 快递名称下拉框数据列表
      expressCorpNameList: [],
      // 运单状态列表
      orderStatusNameList: [
        {
          status_Id: "0",
          orderStatusName: "航空已发运"
        },
        {
          status_Id: "1",
          orderStatusName: "航班到达"
        },
        {
          status_Id: "2",
          orderStatusName: "清关中"
        }
      ],
      expressCorpType: "",
      expressCorpName: "",
      expressCorp_Id: "",
      dialogPortName: false,
      // 域名地址
      BASE_API: process.env.BASE_API,
      ALI_API: this.common.ossDomain,
      // 口岸名称下拉框数据列表
      portOptions: [],
      wayBill_Ids: [], // 运单ID
      portName: "",
      form: {
        voyageCode: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: ""
      },
      // 状态流加载参数
      stateLoadOptions: {
        folder: "express/tms",
        projectName: "Interface.Express",
        tableView: "TMS_WayBillTracking",
        idField: "wayBillTracking_Id",
        sortName: "wayBillTracking_Id DESC",
        pageIndex: 1,
        pageSize: 100,
        menu_Id: -1
      },
      // 状态值
      statusValueList: [
        {
          status: "审核成功",
          bgColor: "#00ff99",
          color: "black"
        },
        {
          status: "新建",
          bgColor: "#ffff66",
          color: "#000"
        },
        {
          status: "已提交",
          bgColor: "#cc99ff",
          color: "#fff"
        },
        {
          status: "已组板",
          bgColor: "#ffcc66",
          color: "#fff"
        },
        {
          status: "录入异常",
          bgColor: "#ff6600",
          color: "#fff"
        },
        {
          status: "组板异常",
          bgColor: "#ff6600",
          color: "#fff"
        },
        {
          status: "已退货",
          bgColor: "#ff9966",
          color: "#fff"
        },
        {
          status: "航空已发运",
          bgColor: "#00cccc",
          color: "#fff"
        },
        {
          status: "取消组板",
          bgColor: "#cc6633",
          color: "#fff"
        },
        {
          status: "已签收",
          bgColor: "#009900",
          color: "#fff"
        },
        {
          status: "航班到达",
          bgColor: "#6699cc",
          color: "#fff"
        },
        {
          status: "终止",
          bgColor: "#ff6600",
          color: "#fff"
        },
        {
          status: "待中转",
          bgColor: "#ffff33",
          color: "#000"
        },
        {
          status: "未揽收",
          bgColor: "#ffff33",
          color: "#000"
        },
        {
          status: "已入库",
          bgColor: "#00cc00",
          color: "#fff"
        },
        {
          status: "已卸车",
          bgColor: "#11C2EE",
          color: "#fff"
        },
        {
          status: "待配送",
          bgColor: "#806B1A",
          color: "#fff"
        },
        {
          status: "提货中",
          bgColor: "#00cc00",
          color: "#fff"
        },
        {
          status: "配送中",
          bgColor: "#00cc00",
          color: "#fff"
        }
      ],
      // 导航筛选条件
      tabNavList: [],
      dialogPicVisible: false, // 图片弹框
      dialogImageUrl: null, // 图片URL
      dialogReturnPicVisible: false, // 退货图片弹框
      dialogReturnImageUrl: null, // 退货图片URL
      editStartDate: null // 编辑开始时时间,不允许超过10分钟
    };
  },
  mounted() {
    this.uploadKey = this.common.getGUID();
    var addListString = localStorage.getItem("addList");
    if (addListString) {
      var the = this;
      var addList = JSON.parse(addListString);
      window.setTimeout(function() {
        the.dataList.addSearchFields(addList);
        the.dataList.loadData();
      }, 1000);
      localStorage.removeItem("addList");
    }
    this.getPortList();
    this.getExpressCorpList();
    // this.multiDistributionExpress(); // 获取快递下拉框值
  },
  methods: {
    // 编辑器保存时事件
    editButtonClick(authNode) {
      switch (authNode) {
        case "save":
          // 审核
          alert(123);
          return false;
      }
    },
    // 点击文件时的钩子
    handlePreview(file) {},
    handleRemove(file, fileList) {
      this.fileUrl = null;
    },
    // 上传附件Url
    upLoadUrl: function() {
      var domain = this.common.domain;
      return domain + "/api/common/uploadSingleFile";
    },
    // 上传成功后
    handleSuccess(res, file) {
      this.common.showMsg("上传成功!");
      this.fileUrl = res.data.url;
    },
    // 状态背景颜色
    setStatusBgColor(status) {
      var colorItem = this.statusValueList.find(item => {
        return item.status === status;
      });
      var bgColor = "#ffffff";
      if (colorItem) bgColor = colorItem.bgColor;
 
      return bgColor;
    },
    // 状态字体颜色
    setStatusColor(status) {
      var colorItem = this.statusValueList.find(item => {
        return item.status === status;
      });
      var color = "#888";
      if (colorItem) color = colorItem.color;
 
      return {
        border: 0,
        color: color,
        cursor: "pointer"
      };
    },
    // 列表页面按钮点击事件
    buttonClick(authNode) {
      switch (authNode) {
        case "batchAuditing":
          // 批量审核
          return this.showMultiAuditingDialog();
        case "returngoods":
          // 批量退货
          this.multiReturngoods();
          return false;
        case "cancelReturn":
          // 批量取消退货
          this.multiCancelReturn();
          return false;
        case "distributionExpress":
          // 批量分配快递
          this.multiDistributionExpress();
          return false;
        case "upPort":
          // 修改口岸
          this.showUpdatePortDialog();
          return false;
        case "cancelpanel":
          // 取消组板
          this.cancelpanel();
          return false;
        case "xiAnExport":
          // 西安口岸导出
          this.exportxian();
          return false;
        case "beijingExport":
          // 北京口岸导出
          this.exportbeijing();
          return false;
        case "fuzhouExport":
          // 福州口岸导出
          this.exportfuzhou();
          return false;
        case "jinjiangExport":
          // 晋江口岸导出
          this.exportjinjiang();
          return false;
        case "guangzhouExport":
          // 广州口岸导出
          this.exportguangzhou();
          return false;
        case "xiamenExport":
          // 厦门口岸导出
          this.exportxiamen();
          return false;
        case "modifyPlateCode":
          // 批量修改托盘号
          this.modifyPlateCode(this.dataListSelections);
          return false;
        case "overloading":
          // 溢装处理
          this.showOverloading();
          return false;
        case "billCodeContExport":
          // 运单快递统计导出
          this.exportBillCodeCont();
          return false;
        case "batchOpen":
          // 批量开启
          this.multiBatchOpen();
          return true;
        case "batchStop":
          // 批量终止
          this.multiBatchStop();
          return true;
        case "importUpdate":
          // 导入修改
          this.allImport();
          return false;
        case "synchroSfAddress":
          this.synchroSfAddress();
          return true;
      }
    },
    // 保存事件
    onSaveAfter() {},
    // 明细字段改变
    onDetailChange(ref, val, row, field) {
      // 合计数量求和
      let totalQuantityOrder = 0;
      let grandTotal = 0.0;
      // 物料数量合计
      var totalQuantityProducts = 0;
 
      var formData = this.editor.formData;
      var detailRows = formData["TMS_WayBillList"].rows;
      detailRows.forEach(item => {
        if (item.quantityOrder !== null || item.salePrice !== null) {
          // 行金额
          item.rowTotal = Math.Round(item.quantityOrder * item.salePrice, 2);
        }
        if (field) {
          if (field.prop === "quantityOrder" || field.prop === "weight") {
            item.grossWeight = item.quantityOrder * item.weight;
          }
        }
        totalQuantityProducts += item.quantityOrder;
        // totalQuantityOrder += item.Quantity;
        totalQuantityOrder += item.quantityOrder;
        grandTotal += item.rowTotal;
      });
 
      this.editor.changeValue("totalQuantityProducts", totalQuantityProducts);
      this.editor.changeValue("totalQuantityOrder", parseInt(totalQuantityOrder));
      this.editor.changeValue("grandTotal", Math.Round(grandTotal, 2));
    },
    // 将选择器选择中的数据填充到明细表中
    onSelected(rows) {
      this.editor.addDetailDataRow(rows);
      this.selectorConfig.visible = false;
    },
    // 明细添加
    detailAdd() {
      this.selectorConfig.visible = true;
      this.$refs["selector-dialog"].setSearchValue("provider_Id", []);
      this.$refs["selector-dialog"].loadData();
    },
    // 取消组板
    cancelpanel() {
      var isOrderStatus = true; // 运单状态
      const selectIDs = this.dataListSelections.map((item, index, Array) => {
        if (item.orderStatus !== "已组板") {
          isOrderStatus = false;
        } else {
          isOrderStatus = true;
        }
        return item.wayBill_Id;
      });
      if (!selectIDs.length) {
        this.$message({
          message: "至少选中一行!",
          type: "warning"
        });
        return false;
      }
      this.wayBill_Ids = selectIDs;
      if (isOrderStatus === false) {
        this.$message({
          message: "已组板后才能取消!",
          type: "warning"
        });
        return false;
      }
      this.$prompt("确定要批量取消组板操作吗", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消"
      })
        .then(({ value }) => {
          // 获得已选中的ID
          const selectIDs = this.dataListSelections.map((item, index, Array) => {
            return item.wayBill_Id;
          });
          const url = "/api/tms/wayBill/cancelpanel";
          const params = {
            ids: selectIDs,
            value: value
          };
          this.common.ajax(url, params, res => {
            this.common.showMsg(res);
            const ref = this.dataList;
            if (res.result) {
              ref.loadData();
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入"
          });
        });
    },
    // 显示批量审核对话框
    showMultiAuditingDialog() {
      this.formDataAudit = {};
      // 获得已选中的ID
      var isOrderStatus = true; // 运单状态
      const selectIDs = this.dataListSelections.map((item, index, Array) => {
        if (
          item.orderStatus === "已提交" ||
          // item.orderStatus === "组板异常" ||
          item.orderStatus === "处理中" ||
          item.orderStatus === "处理完成"
        ) {
          isOrderStatus = true;
        } else {
          isOrderStatus = false;
        }
        return item.wayBill_Id;
      });
      if (!selectIDs.length) {
        this.$message({
          message: "至少选中一行!",
          type: "warning"
        });
        return false;
      }
      this.wayBill_Ids = selectIDs;
      if (isOrderStatus === false) {
        this.$message({
          message: "只有运单状态为已提交、处理中、处理完成的运单才允许操作审核!",
          type: "warning"
        });
        return false;
      }
      this.showBatchAuditingDialog = true;
 
      return true;
    },
    // 批量审核
    saveBatchAuditing() {
      const expressCorp_Id = this.formDataAudit.expressCorp_Id;
      if (!expressCorp_Id) {
        this.$message({
          message: "请先选择快递名称!",
          type: "warning"
        });
        return;
      }
      const url = "/api/tms/wayBill/batchAuditingTms";
      const params = {
        wayBill_Ids: this.wayBill_Ids,
        expressCorp_Id: this.formDataAudit.expressCorp_Id,
        expressCorpType: this.formDataAudit.expressCorpType,
        port_Id: this.formDataAudit.port_Id
      };
      const ref = this.dataList;
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          // 关闭弹出框
          this.showBatchAuditingDialog = false;
          this.wayBill_Ids = "";
          ref.loadData();
 
          // 重置选中项
          this.expressCorp_Id = null;
          this.expressCorpType = null;
          this.expressCorpName = null;
          this.portName = null;
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 级联改变数据
    onChange(ref, val, field, formData) {
      // 所有状态都可以编辑
      // this.editorOptions.config.disabled = false;
 
      var editor = this.editor;
      if (field.options.prop === "portName") {
        var url = "/api/tms/wayBill/getGoodsRegion";
        var parsms = {
          portName: formData.portName
        };
        this.common.ajax(url, parsms, res => {
          if (res.result) {
            editor.formData.planDropOffPort = res.data.RegionName; // 落口名称
          }
        });
      }
 
      // 省市区联动
      if (field.options.prop === "provinceName") {
        formData.city_Id = null;
        formData.cityName = null;
        // 设置表单数据
        const item = ref.getOption(val);
        // 改变市级下拉框
        this.loadChildrenNode(item.value, 614, field.options.prop);
      } else if (field.options.prop === "cityName") {
        formData.region_Id = null;
        formData.regionName = null;
        // 设置表单数据
        const item = ref.getOption(val);
        // 改变区级下拉框
        this.loadChildrenNode(item.value, 615, field.options.prop);
      } else if (field.options.prop === "regionName") {
        const item = ref.getOption(val);
        this.loadChildrenNode(item.value, 615, field.options.prop);
      }
    },
    // 根据省ID获得市
    loadChildrenNode(id, dropdown_Id, prop) {
      var editorRef = this.$refs[this.editorRef];
 
      var where = { parentId: id };
      var url = "/api/common/loadTreeNode";
      var params = {
        openNodeApi: true,
        folder: "basicInfo/base",
        DBServer: "Sys",
        tableName: "Base_City",
        tableView: "Base_City",
        keyName: "city_Id",
        nodeName: "cityName",
        fixHasChild: false,
        isBreakWay: false,
        displayBreakWay: false,
        parentName: "parentId",
        orderBy: "orderNo desc, city_Id",
        where: where,
        extendColumns: ""
      };
      this.common.ajax(
        url,
        params,
        res => {
          if (res.result) {
            var data = res.data.map(item => {
              if (prop === "provinceName") {
                const newItem = {
                  city_Id: item.value,
                  cityName: item.label,
                  value: item.value,
                  label: item.label
                };
                return newItem;
              } else if (prop === "cityName") {
                const newItem = {
                  region_Id: item.value,
                  regionName: item.label,
                  value: item.value,
                  label: item.label
                };
                return newItem;
              }
            });
            editorRef.setDropdownData(dropdown_Id, data);
          } else {
            this.$message.error(res.msg);
          }
        },
        true
      );
    },
    // 批量退货操作
    multiReturngoods() {
      this.$prompt("确定要批量进行退货操作吗? 请输入退货原因:", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消"
      })
        .then(({ value }) => {
          // 获得已选中的ID
          // var IsOrderType = ""; // 运单类型=仓配,=直邮
          var isOrderStatus = ""; // 可操作状态
          const selectIDs = this.dataListSelections.map((item, index, Array) => {
            // IsOrderType = item.OrderType;
            isOrderStatus = item.orderStatus;
            return item.wayBill_Id;
          });
          if (!selectIDs.length) {
            this.$message({
              message: "至少选中一行!",
              type: "warning"
            });
            return;
          }
          const statusList = ["新建", "已提交", "面单已录入", "审核成功", "录入异常", "组板异常", "取消组板"];
          if (statusList.indexOf(isOrderStatus) >= 0) {
            this.updateOrderStatus(selectIDs, value);
          } else {
            this.$message({
              message: "提交的数据订单状态不符合直邮退货条件!",
              type: "warning"
            });
            return;
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 修改满足条件数据的退货状态
    updateOrderStatus(selectIDs, value) {
      const url = "/api/tms/wayBill/billReturnGoods";
      const params = {
        ids: selectIDs,
        abnormalReason: value
      };
      const ref = this.dataList;
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          ref.loadData();
        }
      };
      this.common.ajax(url, params, callback, ref);
    },
    // 批量取消退货
    multiCancelReturn() {
      this.$confirm("确定要批量取消退货操作吗?", "批量取消退货", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // 获得已选中的ID
          var isOrderStatus = true; // 运单状态
          const selectIDs = this.dataListSelections.map((item, index, Array) => {
            if (item.orderStatus !== "已退货") {
              isOrderStatus = false;
            }
            return item.wayBill_Id;
          });
          if (selectIDs === "") {
            this.$message({
              message: "至少选中一行!",
              type: "warning"
            });
            return;
          }
          if (!isOrderStatus) {
            this.$message({
              message: "运单状态为已退货才能取消退货!",
              type: "warning"
            });
            return;
          }
          const url = "/api/tms/wayBill/billmultiCancelReturn";
          const params = {
            ids: selectIDs
          };
          const ref = this.dataList;
          var callback = res => {
            this.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          this.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 选择口岸之后获取关联的快递类别
    getExpressCorp(port_Id) {
      // this.expressCorpTypeList = [];
      const url = "/api/basicInfo/base/expressCorp/getWayBillExpressCorpType";
      const params = {
        port_Id: port_Id
      };
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          // 批量审核
          this.formDataAudit.expressCorpType = null;
          this.formDataAudit.expressCorp_Id = null;
          // 修改口岸
          this.formData.expressCorpType = null;
          this.formData.expressCorp_Id = null;
          // 溢装处理
          this.formDataOverload.expressCorpType = null;
          this.formDataOverload.expressCorp_Id = null;
          this.expressCorpTypeList = res.data;
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 获取快递类别下拉框值
    multiDistributionExpress() {
      const url = "/api/basicInfo/base/expressCorp/getExpressCorpType";
      const params = {};
      var callback = res => {
        if (res.result) {
          this.expressCorpTypeList = res.data;
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 选择快递单号后加载快递名称
    changeExpressCorpType(value) {
      const expressCorpType = value;
      const url = "/api/basicInfo/base/expressCorp/getList";
      const params = {
        expressCorpType: expressCorpType
      };
      this.expressCorpName = "";
      this.formData.expressCorp_Id = "";
      this.common.ajax(url, params, res => {
        this.common.showMsg(res);
        if (res.result) {
          this.expressCorpNameList = res.data;
 
          this.formData.expressCorpName = this.expressCorpNameList[0].expressCorpName;
          this.formData.expressCorp_Id = this.expressCorpNameList[0].expressCorp_Id;
 
          this.formDataAudit.expressCorpName = this.expressCorpNameList[0].expressCorpName;
          this.formDataAudit.expressCorp_Id = this.expressCorpNameList[0].expressCorp_Id;
 
          this.formDataOverload.expressCorpName = this.expressCorpNameList[0].expressCorpName;
          this.formDataOverload.expressCorp_Id = this.expressCorpNameList[0].expressCorp_Id;
        } else {
          this.expressCorpNameList = [];
        }
      });
    },
    // 选择弹框的快递名称后赋值
    currentCorpName(value) {
      this.expressCorp_Id = value;
      this.expressCorpNameList.forEach(item => {
        if (item.expressCorp_Id === value) {
          this.expressCorpName = item.expressCorpName;
        }
      });
    },
    // 下拉框加载后事件
    onLoadDropdownAfter(dropdownData) {
      // 将前三个值移到后面
      // var removeItems = dropdownData["dropdown934"].splice(0, 3);
      // var dropdown934 = dropdownData["dropdown934"].concat(removeItems);
 
      // // 处理tabsNav - 状态
      // this.tabNavList.push({
      //   type: "radio", // checkbox=多选, radio=单选
      //   field: "orderStatus",
      //   items: dropdown934,
      //   showCount: 8, // 显示平铺项个数
      //   value: null // 选中值:当type=radio时value为数组,当type=checkbox时value为字符串
      // });
      // // 处理tabsNav - 货主
      // this.tabNavList.push({
      //   type: "radio", // checkbox=多选, radio=单选
      //   field: "ConsignorName",
      //   items: dropdownData["dropdown797"],
      //   showCount: 6, // 显示平铺项个数
      //   value: null // 选中值:当type=radio时value为数组,当type=checkbox时value为字符串
      // });
      // 弹出框
      this.dialogPortName = true;
    },
    // 修改口岸弹出对话框
    showUpdatePortDialog() {
      this.formData = {};
      let isok = true;
      const selectIDs = this.dataListSelections.map((item, index, Array) => {
        return item.wayBill_Id;
      });
      const orderStatus = this.dataListSelections.map((item, index, Array) => {
        return item.orderStatus;
      });
      if (!selectIDs.length) {
        this.$message.error("请至少选择一行数据!");
        return false;
      }
      this.wayBill_Ids = selectIDs;
      orderStatus.forEach(rowData => {
        if (rowData !== "审核成功" && rowData !== "处理中" && rowData !== "组板异常" && rowData !== "取消组板") {
          isok = false;
        }
      });
      if (isok === false) {
        this.$message.error("只有审核成功,取消组板,处理中或者组板异常才可以修改口岸!");
        return false;
      } else {
        this.portDialogVisible = true;
        this.formData = {
          port_Id: null,
          expressCorp_Id: null,
          expressCorpType: null
        };
      }
    },
    // 修改口岸
    saveUpdatePort() {
      if (!this.formData.port_Id) {
        this.$message.error("请选择口岸!");
        return;
      }
 
      if (!this.formData.expressCorpType) {
        this.$message.error("请选择快递类型!");
        return;
      }
 
      if (!this.formData.expressCorp_Id) {
        this.$message.error("请选择快递!");
        return;
      }
 
      const params = {
        wayBill_Ids: this.wayBill_Ids,
        port_Id: this.formData.port_Id, // 口岸
        expressCorp_Id: this.formData.expressCorp_Id, // 快递
        expressCorpType: this.formData.expressCorpType // 快递类型
      };
      const url = "/api/tms/wayBill/updatePort";
      const ref = this.dataList;
      const callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          this.portDialogVisible = false;
          ref.loadData();
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 获取口岸下拉框
    getPortList() {
      const url = "/api/basicInfo/base/port/getList";
      const params = {};
      var callback = res => {
        if (res.result) {
          this.portOptions = res.data;
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 获快递下拉框
    getExpressCorpList() {
      const url = "/api/basicInfo/base/expressCorp/getList";
      const params = {};
      var callback = res => {
        if (res.result) {
          this.expressCorpoptions = res.data;
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 溢装处理弹出对话框
    showOverloading() {
      this.formDataOverload = {};
      var isok = true;
      const selectIDs = this.dataListSelections.map((item, index, Array) => {
        return item.wayBill_Id;
      });
      const orderStatus = this.dataListSelections.map((item, index, Array) => {
        return item.orderStatus;
      });
      if (!selectIDs.length) {
        this.$message.error("请至少选择一行数据!");
        return false;
      }
      this.wayBill_Ids = selectIDs;
      orderStatus.forEach(rowData => {
        if (rowData !== "已组板" && rowData !== "航空已发运" && rowData !== "航班到达" && rowData !== "清关中") {
          isok = false;
        }
      });
      if (isok === false) {
        this.$message.error("只有已组板,航空已发运,航班到达或者清关中才可以操作溢装处理!");
        return false;
      } else {
        this.overloading = true;
        this.formDataOverload = {
          port_Id: null,
          expressCorp_Id: null,
          expressCorpType: null,
          getExpressCode: false
        };
      }
    },
    // 修改溢装
    saveOverloading() {
      if (!this.formDataOverload.port_Id) {
        this.$message.error("请选择口岸!");
        return;
      }
 
      if (!this.formDataOverload.expressCorpType) {
        this.$message.error("请选择快递类型!");
        return;
      }
 
      if (!this.formDataOverload.expressCorp_Id) {
        this.$message.error("请选择快递!");
        return;
      }
      if (this.formDataOverload.isValidateProductCode === false) {
        this.formDataOverload.orderStatusName = null;
      }
      if (this.formDataOverload.getExpressCode === true) {
        var IsGouxuan = 1;
      } else {
        IsGouxuan = 0;
      }
      // var formData = this.editor.formDataOverload;
      const params = {
        wayBill_Ids: this.wayBill_Ids,
        port_Id: this.formDataOverload.port_Id, // 口岸
        expressCorp_Id: this.formDataOverload.expressCorp_Id, // 快递
        expressCorpType: this.formDataOverload.expressCorpType, // 快递类型
        voyageCode: this.formDataOverload.voyageCode, // 航空主单号
        plateCode: this.formDataOverload.plateCode, // 托盘号
        IsGouxuan: IsGouxuan,
        //  运单状态
        orderStatus: this.formDataOverload.orderStatusName
      };
      const url = "/api/tms/wayBill/saveOverloading";
      const ref = this.dataList;
      const callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          this.overloading = false;
          ref.loadData();
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 导出身份证
    exportIdCard() {
      if (!this.dataListSelections.length) {
        this.$message.error("至少选中一行!");
        return;
      }
      var isOrderStatus = true; // 运单状态
      const selectIDs = this.dataListSelections.map((item, index, Array) => {
        if (item.orderStatus === "终止") {
          isOrderStatus = false;
        }
        return item.wayBill_Id;
      });
      if (isOrderStatus === false) {
        this.$message({
          message: "已终止的运单不允许进行操作!",
          type: "warning"
        });
        return false;
      }
      var formData = this.editor.formData;
      const url = "/api/TMS_WayBill/ExportIdCard";
      const params = {
        ids: selectIDs,
        port_Id: formData.port_Id,
        wayBillCode: formData.wayBillCode
      };
      this.common.ajax(
        url,
        params,
        res => {
          this.common.showMsg(res);
          if (res.result) {
            window.open(this.common.domain + res.data.url);
          }
        },
        this.dataList
      );
    },
    // 西安导出
    exportxian() {
      var where = this.dataList.getAllWhere();
      const ids = this.dataListSelections.map(item => item.wayBill_Id);
      // 如果勾选了,将勾选的条件覆盖筛选条件
      if (ids.length) {
        where = [
          {
            prop: "wayBill_Id",
            value: ids
          }
        ];
      }
      // where.push({
      //   prop: "wayBill_Id",
      //   value: ids
      // });
      var url = "/api/tms/wayBill/exportXianDeclaration";
      const params = {
        idField: "wayBill_Id",
        operator: "=",
        where: where
      };
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          const url = this.common.domain + "/api/common/download?url=" + res.data.url;
          window.open(url);
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 北京导出
    exportbeijing() {
      var where = this.dataList.getAllWhere();
      const ids = this.dataListSelections.map(item => item.wayBill_Id);
      // where.push({
      //   prop: "wayBill_Id",
      //   value: ids
      // });
 
      // 如果勾选了,将勾选的条件覆盖筛选条件
      if (ids.length) {
        where = [
          {
            prop: "wayBill_Id",
            value: ids
          }
        ];
      }
      var url = "/api/tms/wayBill/exportBeijinDeclaration";
      const params = {
        idField: "wayBill_Id",
        operator: "=",
        where: where
      };
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          // const url =
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url);
          //  const url =
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url2);
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 福州导出
    exportfuzhou() {
      var where = this.dataList.getAllWhere();
      const ids = this.dataListSelections.map(item => item.wayBill_Id);
      // 如果勾选了,将勾选的条件覆盖筛选条件
      if (ids.length) {
        where = [
          {
            prop: "wayBill_Id",
            value: ids
          }
        ];
      }
      // where.push({
      //   prop: "wayBill_Id",
      //   value: ids
      // });
      var url = "/api/tms/wayBill/exportFuzhouDeclaration";
      const params = {
        idField: "wayBill_Id",
        operator: "=",
        where: where
      };
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url);
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url2);
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 晋江导出
    exportjinjiang() {
      var where = this.dataList.getAllWhere();
      const ids = this.dataListSelections.map(item => item.wayBill_Id);
      // 如果勾选了,将勾选的条件覆盖筛选条件
      if (ids.length) {
        where = [
          {
            prop: "wayBill_Id",
            value: ids
          }
        ];
      }
      // where.push({
      //   prop: "wayBill_Id",
      //   value: ids
      // });
      var url = "/api/tms/wayBill/exportjinjiangDeclaration";
      const params = {
        idField: "wayBill_Id",
        operator: "=",
        where: where
      };
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url);
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url2);
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 广州导出
    exportguangzhou() {
      var where = this.dataList.getAllWhere();
      const ids = this.dataListSelections.map(item => item.wayBill_Id);
      // 如果勾选了,将勾选的条件覆盖筛选条件
      if (ids.length) {
        where = [
          {
            prop: "wayBill_Id",
            value: ids
          }
        ];
      }
      var url = "/api/tms/wayBill/exportguangzhouDeclaration";
      const params = {
        idField: "wayBill_Id",
        operator: "=",
        where: where
      };
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url);
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 厦门导出
    exportxiamen() {
      var where = this.dataList.getAllWhere();
      const ids = this.dataListSelections.map(item => item.wayBill_Id);
      // 如果勾选了,将勾选的条件覆盖筛选条件
      if (ids.length) {
        where = [
          {
            prop: "wayBill_Id",
            value: ids
          }
        ];
      }
      var url = "/api/tms/wayBill/exportxiamenDeclaration";
      const params = {
        idField: "wayBill_Id",
        operator: "=",
        where: where
      };
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url2);
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 运单快递统计导出
    exportBillCodeCont() {
      var where = this.dataList.getAllWhere();
      const ids = this.dataListSelections.map(item => item.wayBill_Id);
      // 如果勾选了,将勾选的条件覆盖筛选条件
      if (ids.length) {
        where = [
          {
            prop: "wayBill_Id",
            value: ids
          }
        ];
      }
      var url = "/api/tms/wayBill/exportBillCodeCont";
      const params = {
        idField: "wayBill_Id",
        operator: "=",
        where: where
      };
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          window.open(this.common.domain + "/api/common/download?url=" + res.data.url);
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    viewPicture(formData, details) {
      var url = "/api/tms/wayBill/getWayBillPruture";
      var params = { wayBillCode: formData.wayBillCode };
      this.common.ajax(url, params, res => {
        if (res.result) {
          if (!res.data) {
            this.$message.error("图片不存在");
            return;
          }
          this.dialogPicVisible = true; // 图片弹框
          this.dialogImageUrl = this.ALI_API + res.data.filePath + "?x-oss-process=style/big";
        }
      });
    },
    // 获取大头笔
    getSortingCode(formData, details) {
      var url = "/api/tms/wayBill/getSortingCode";
      var parsms = { wayBill_Id: formData.wayBill_Id };
      this.common.ajax(url, parsms, res => {
        this.common.showMsg(res);
        if (res.result) {
          this.editor.reload();
          this.dataList.reload();
        }
      });
    },
    // 测试自动获取快递单号 AutoGetExpressCode
    AutoGetExpressCode() {
      var url = "/api/Base_ExpressSpareCode/AutoGetExpressCode";
      const params = {};
      var callback = res => {
        this.common.showMsg(res);
      };
      this.common.ajax(url, params, callback, true);
    },
    // 数据加载后事件
    onEditLoadAfter(formData) {
      if (formData.orderStatus === "终止") {
        // 不可以编辑
        this.editorOptions.config.disabled = true; // 整个对话框不可编辑
      } else {
        this.editorOptions.config.disabled = false; // 整个对话框可编辑
      }
      // 记录编辑开始时间
      this.editStartDate = new Date();
    },
    // 保存前事件
    onSaveBefore() {
      var formData = this.editor.formData;
      const dataList = formData["TMS_WayBillList"].rows;
 
      var totalQuantityProducts = 0;
      dataList.forEach(item => {
        totalQuantityProducts += item.quantityOrder;
      });
      this.editor.changeValue("totalQuantityProducts", totalQuantityProducts);
 
      const miniutes = moment(new Date()).diff(moment(this.editStartDate), "minutes");
      if (miniutes > 10) {
        this.$message.error("编辑打开窗口超时,请关闭编辑窗口重新打开修改");
        return false;
      }
 
      return;
    },
    // 批量/单个修改组板信息
    modifyPlateCode(rows) {
      // 获得已选中的ID
      var isOrderStatus = true; // 运单状态
      const selectIDs = rows.map((item, index, Array) => {
        if (item.orderStatus !== "已组板") {
          isOrderStatus = false;
        }
        return item.wayBill_Id;
      });
      if (selectIDs === "") {
        this.$message({
          message: "至少选中一行!",
          type: "warning"
        });
        return;
      }
      if (!isOrderStatus) {
        this.$message.error("只有已组板的才能修改托盘号!");
        return;
      }
 
      this.$prompt("请输入新托盘号", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputPattern: /\S{2,}/,
        inputErrorMessage: "托盘号至少2位以上"
      })
        .then(({ value }) => {
          const url = "/api/tms/waybill/modifyPlateCode";
          const params = {
            ids: selectIDs,
            code: value
          };
          this.common.ajax(url, params, res => {
            this.common.showMsg(res);
            if (res.result) {
              this.dataList.reload();
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入"
          });
        });
    },
    // 审核后是否可以编辑处理方法
    auditDisabled(formData, config) {},
    // 显示退货大图
    showReturnPic(pic) {
      this.dialogReturnPicVisible = true;
      this.dialogReturnImageUrl = this.BASE_API + pic;
    },
    // 将图片字符串转为数组
    getReturnPicList(pics) {
      var picList = pics ? pics.split(",") : [];
      return picList;
    },
    // 批量开启操作
    multiBatchOpen() {
      const the = this;
      var isOrderStatus = true;
      const selectIDs = the.dataListSelections.map((item, index, Array) => {
        if (item.orderStatus !== "终止") {
          isOrderStatus = false;
        }
        return item.wayBill_Id;
      });
      if (!selectIDs.length) {
        this.$message({
          message: "至少选中一行!",
          type: "warning"
        });
        return;
      }
      this.$confirm("确定要批量进行开启操作吗?", "批量开启", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // 获得已选中的ID
          if (isOrderStatus !== true) {
            this.$message({
              message: "只有终止的运单才可以开启!",
              type: "warning"
            });
            return;
          }
          const url = "/api/tms/wayBill/multiBatchOpen";
          const params = {
            ids: selectIDs
          };
          const ref = the.dataList;
          var callback = res => {
            the.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          the.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          the.$message({
            type: "info",
            message: "已取消"
          });
        });
    }, // 批量修改导入
    allImport() {
      this.dialogLandingTime = true;
    },
    // 导入
    submitImport() {
      // this.importMsg = null;
      if (!this.fileUrl) {
        this.$message.error("请上传文件!");
        return;
      }
      const url = "/api/tms/wayBill/importExel";
      const params = {
        url: this.fileUrl,
        key: this.uploadKey
        // StorageName: StorageName
      };
      var callback = res => {
        if (res.result) {
          window.clearTimeout(this.intervalHandler);
          this.intervalHandler = false;
          this.getMsg();
          this.fileList = [];
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 获得导入消息
    getMsg() {
      // 获得同步消息
      const url = "/api/common/getUploadMsg";
      const params = {
        openNodeApi: true,
        key: this.uploadKey
      };
      // const ref = this.dataList;
      var callBack = res => {
        if (!res.result) {
          window.clearTimeout(this.intervalHandler);
          this.intervalHandler = false;
          if (Array.isArray(res.data)) {
            this.msgList = this.msgList.concat(res.data);
          }
          return;
        }
        if (Array.isArray(res.data)) {
          this.msgList = this.msgList.concat(res.data.filter(item => item !== "-1"));
        }
        if (res.data.indexOf("-1") >= 0) {
          window.clearTimeout(this.intervalHandler);
          this.intervalHandler = null;
          return;
        }
        this.intervalHandler = window.setTimeout(this.getMsg, 1000);
      };
      this.common.ajax(url, params, callBack, true, this.$refs.uploadRef);
    },
    // 批量终止操作
    multiBatchStop() {
      const the = this;
      var isOrderStatus = true;
      var isCollectStatus = true;
      const selectIDs = the.dataListSelections.map((item, index, Array) => {
        if (item.orderStatus !== "新建" && item.orderStatus !== "已提交") {
          isOrderStatus = false;
        }
        if (item.CollectStatus === "已揽收") {
          isCollectStatus = false;
        }
        return item.wayBill_Id;
      });
      if (!selectIDs.length) {
        this.$message({
          message: "至少选中一行!",
          type: "warning"
        });
        return;
      }
      this.$confirm("确定要批量进行终止操作吗?", "批量终止", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          // 获得已选中的ID
          if (isOrderStatus !== true) {
            this.$message({
              message: "只有新建或已提交的运单才可以终止!",
              type: "warning"
            });
            return;
          }
          if (isCollectStatus === false) {
            this.$message({
              message: "已揽收的运单不允许操作终止!",
              type: "warning"
            });
            return;
          }
          const url = "/api/tms/wayBill/multiBatchStop";
          const params = {
            ids: selectIDs
          };
          const ref = the.dataList;
          var callback = res => {
            the.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          the.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          the.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 同步泉州顺丰陆地港信息
    synchroSfAddress() {
      const the = this;
      let msg = "";
      const selectIDs = the.dataListSelections.map((item, index, Array) => {
        if (!item.expressCode) {
          msg += item.wayBillCode + "运单的快递单号不能为空";
        }
        if (item.expressCorpName !== "泉州顺丰") {
          msg += item.wayBillCode + "运单必须是泉州顺丰单";
        }
        return item.wayBill_Id;
      });
      if (!selectIDs.length) {
        this.$message({
          message: "至少选中一行!",
          type: "warning"
        });
        return;
      }
      if (msg) {
        this.$message({
          message: msg,
          type: "warning"
        });
        return;
      }
      this.$confirm("确定要同步选中单据的泉州顺丰陆地港信息吗?", "同步泉州顺丰陆地港", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          const url = "/api/tms/wayBill/synchroSfAddress";
          const params = {
            ids: selectIDs
          };
          const ref = the.dataList;
          var callback = res => {
            the.common.showMsg(res);
            if (res.result) {
              ref.loadData();
            }
          };
          the.common.ajax(url, params, callback, ref);
        })
        .catch(() => {
          the.$message({
            type: "info",
            message: "已取消"
          });
        });
    }
  }
};
</script>
 
<style lang="scss" scoped>
.page-list-container {
  min-height: calc(100vh - 110px);
  overflow: hidden;
  position: relative;
}
 
@media screen and (max-height: 900px) {
  .page-list-container {
    min-height: 600px;
  }
}
</style>
 
<style lang="scss">
.pic-dialog {
  position: static !important;
  top: 0;
  left: 0;
  bottom: 800px;
  .el-dialog {
    z-index: 1000000;
    top: 0;
    left: 0;
    position: absolute;
  }
}
</style>