qq_41295110
2026-01-21 6235fa7c1cc6a5a11dbdd2a3003f1085fc65acc8
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
<template>
    <div v-loading="formLoading" v-if="formShow">
        <div style=" margin-bottom: 10px; border-bottom: 1px solid #f6f6f6;">
            <el-button type="primary" @click="submitForm" :disabled="subDisabled">保 存</el-button>
            <el-button type="primary" @click="set_CheckBill(0, form)">审 核</el-button>
            <el-button type="primary" @click="close">退 出</el-button>
            <!-- <el-button @click="cancel">取 消</el-button> -->
        </div>
        <div style="margin: 10px; font-size: 28px; font-weight: bold; text-align: center;">运单编辑新增</div>
        <div v-loading="sourceDataLoading" element-loading-text="正在处理源单数据,请稍候..."
            element-loading-spinner="el-icon-loading" element-loading-background="rgba(255, 255, 255, 0.8)">
            <el-form ref="form" :model="form" :rules="rules" label-width="130px">
                <el-tabs v-model="activeName" type="card">
                    <el-tab-pane label="基本信息" name="first">
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="单据号" prop="HBillNo">
                                    <el-input v-model="form.HBillNo" placeholder="请输入单据号" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="日期" prop="HDate">
                                    <el-date-picker v-model="form.HDate" type="date" placeholder="选择日期"
                                        value-format="yyyy-MM-dd" disabled> </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="源单号" prop="HMainSourceBillNo">
                                    <el-input v-model="form.HMainSourceBillNo" placeholder="请输入源单号">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog(12)"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="承运商" prop="HCarrierName">
                                    <el-input v-model="form.HCarrierName" placeholder="请输入承运商">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog(6)"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="客户" prop="HCusName">
                                    <el-input v-model="form.HCusName" placeholder="请输入客户">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog(7)"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="始发地" prop="HBeginAddrName">
                                    <el-input v-model="form.HBeginAddrName" placeholder="请输入始发地">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog('暂无')"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="目的地" prop="HEndAddrName">
                                    <el-input v-model="form.HEndAddrName" placeholder="请输入目的地">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog('暂无')"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="车型" prop="HCarTypeName">
                                    <el-input v-model="form.HCarTypeName" placeholder="请输入车型">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog(13)"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="车型最大容积" prop="HCarTypeMaxVolume">
                                    <el-input v-model="form.HCarTypeMaxVolume" placeholder="请输入车型最大容积" readonly />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="承运合同" prop="HContractTransportBillNo">
                                    <el-input v-model="form.HContractTransportBillNo" placeholder="请输入承运合同">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog(16)"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="距离(公里)" prop="HDistance">
                                    <el-input v-model="form.HDistance" placeholder="请输入距离" readonly />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="运输时效" prop="HTransportTimes">
                                    <el-input v-model="form.HTransportTimes" placeholder="请输入运输时效" readonly />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="运输类型" prop="HTransportTyep">
                                    <el-input v-model="form.HTransportTyep" placeholder="请输入运输类型" readonly />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="结算方式" prop="HSSName">
                                    <el-input v-model="form.HSSName" placeholder="请输入结算方式">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog('暂无')"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="币别" prop="HCurName">
                                    <el-input v-model="form.HCurName" placeholder="请输入币别" />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="汇率" prop="HExRate">
                                    <el-input v-model="form.HExRate" placeholder="请输入汇率" readonly />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="运费" prop="HMoney">
                                    <el-input v-model="form.HMoney" placeholder="请输入运费" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="总体积(立方米)" prop="HTotalVolume">
                                    <el-input v-model="form.HTotalVolume" placeholder="请输入总体积" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="装载率" prop="HLoadingRate">
                                    <el-input v-model="form.HLoadingRate" placeholder="请输入装载率" />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="提货地址" prop="HPickAddr">
                                    <el-input v-model="form.HPickAddr" placeholder="请输入提货地址" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="到货地址" prop="HArriverAddr">
                                    <el-input v-model="form.HArriverAddr" placeholder="请输入到货地址" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="运输方式" prop="HTransType">
                                    <el-select v-model="form.HTransType" placeholder="请选择运输方式">
                                        <el-option label="零单" value="零单"></el-option>
                                        <el-option label="单程" value="单程"></el-option>
                                        <el-option label="往返" value="往返"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="组织" prop="HOrgID">
                                    <el-select v-model="form.HOrgID" placeholder="请选择组织" @change="organizationChange"
                                        disabled>
                                        <el-option v-for="(item, index) in organizationList" :key="index"
                                            :label="item.Name" :value="item.ID">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="要求提货日期" prop="HDateForRequestedPick">
                                    <el-date-picker v-model="form.HDateForRequestedPick" type="date"
                                        placeholder="选择要求提货日期" value-format="yyyy-MM-dd">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="承运商确认日期" prop="HDate_CarrierSure">
                                    <el-date-picker v-model="form.HDate_CarrierSure" type="date" placeholder="选择承运商确认日期"
                                        value-format="yyyy-MM-dd">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="分配司机日期" prop="HDate_AllocationDriver">
                                    <el-date-picker v-model="form.HDate_AllocationDriver" type="date"
                                        placeholder="选择分配司机日期" value-format="yyyy-MM-dd">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="要求到达日期" prop="HDataForRequestedArrived">
                                    <el-date-picker v-model="form.HDataForRequestedArrived" type="date"
                                        placeholder="选择要求到达日期" value-format="yyyy-MM-dd">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="物流状态" prop="HCarryStatus">
                                    <el-select v-model="form.HCarryStatus" placeholder="请选择物流状态">
                                        <el-option label="申请中" value="1"></el-option>
                                        <el-option label="已审核" value="2"></el-option>
                                        <el-option label="承运商确认" value="3"></el-option>
                                        <el-option label="待提货" value="4"></el-option>
                                        <el-option label="已到厂" value="5"></el-option>
                                        <el-option label="已提货" value="6"></el-option>
                                        <el-option label="运输中" value="7"></el-option>
                                        <el-option label="已签收" value="8"></el-option>
                                        <el-option label="已核算" value="9"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="车辆" prop="HCarName">
                                    <el-input v-model="form.HCarName" placeholder="请输入车辆">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog(14)"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="司机" prop="HDriverName">
                                    <el-input v-model="form.HDriverName" placeholder="请输入司机">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog(15)"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-tab-pane>
                    <!-- <el-tab-pane label="附件信息" name="second">
                        <div style="padding: 10px;">
                            <el-upload class="upload-demo" ref="upload" action="" :on-change="handleFileChange"
                                :show-file-list="false" :on-remove="handleFileRemove" :file-list="uploadFiles"
                                :auto-upload="false" multiple>
                                <el-button slot="trigger" size="small" type="primary">选择文件</el-button>
                                <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload"
                                    :loading="uploadLoading">上传文件</el-button>
                            </el-upload>
                            <el-table :data="uploadFiles" style="width: 100%" border>
                                <el-table-column prop="name" label="文件名">
                                </el-table-column>
                                <el-table-column prop="type" label="文件类型">
                                    <template slot-scope="scope">
                                        {{ scope.row.name.substring(scope.row.name.lastIndexOf('.') + 1).toLowerCase()
                                        }}
                                    </template>
</el-table-column>
<el-table-column prop="size" label="大小">
    <template slot-scope="scope">
                                        {{ (scope.row.size / 1024).toFixed(1) + ' KB' }}
                                    </template>
</el-table-column>
<el-table-column prop="status" label="状态">
    <template slot-scope="scope">
                                        <span v-if="scope.row.status == 'ready'">未上传</span>
                                    </template>
</el-table-column>
<el-table-column label="操作" width="180">
    <template slot-scope="scope">
                                        <el-button size="mini" type="primary"
                                            @click="flieUpload(scope.row)">上传</el-button>
                                        <el-button size="mini" type="danger" @click="deleteFile(index)">删除</el-button>
                                    </template>
</el-table-column>
</el-table>
</div>
</el-tab-pane> -->
                    <el-tab-pane label="制单信息" name="third">
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="制单人" prop="HMaker">
                                    <el-input v-model="form.HMaker" placeholder="请输入制单人" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="修改人" prop="HUpDater">
                                    <el-input v-model="form.HUpDater" placeholder="请输入修改人" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="审核人" prop="HChecker">
                                    <el-input v-model="form.HChecker" placeholder="请输入审核人" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="关闭人" prop="HCloseMan">
                                    <el-input v-model="form.HCloseMan" placeholder="请输入关闭人" disabled />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="制单日期" prop="HMakeDate">
                                    <el-date-picker v-model="form.HMakeDate" type="date" placeholder="选择制单日期" disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="修改日期" prop="HUpDateDate">
                                    <el-date-picker v-model="form.HUpDateDate" type="date" placeholder="选择审核日期"
                                        disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="审核日期" prop="HCheckDate">
                                    <el-date-picker v-model="form.HCheckDate" type="date" placeholder="选择审核日期" disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="关闭日期" prop="HCloseDate">
                                    <el-date-picker v-model="form.HCloseDate" type="date" placeholder="选择关闭日期" disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="作废人" prop="HDeleteMan">
                                    <el-input v-model="form.HDeleteMan" placeholder="请输入作废人" disabled />
                                </el-form-item>
 
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="作废日期" prop="HDeleteDate">
                                    <el-date-picker v-model="form.HDeleteDate" type="date" placeholder="选择作废日期"
                                        disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="到厂确认人" prop="HSurer_Arrive">
                                    <el-input v-model="form.HSurer_Arrive" placeholder="请输入到厂确认人" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="到厂确认时间" prop="HDate_Arrive">
                                    <el-date-picker v-model="form.HDate_Arrive" type="date" placeholder="选择到厂确认时间"
                                        disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="提货确认人" prop="HSurer_Pick">
                                    <el-input v-model="form.HSurer_Pick" placeholder="请输入提货确认" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="提货确认时间" prop="HDate_Pick">
                                    <el-date-picker v-model="form.HDate_Pick" type="date" placeholder="选择提货确认时间"
                                        disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="出厂运输确认人" prop="HSurer_Trans">
                                    <el-input v-model="form.HSurer_Trans" placeholder="请输入到厂确认人" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="出厂运输确认时间" prop="HDate_Trans">
                                    <el-date-picker v-model="form.HDate_Trans" type="date" placeholder="选择到出厂运输确认时间"
                                        disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="签收确认人" prop="HSurer_Receive">
                                    <el-input v-model="form.HSurer_Receive" placeholder="请输入签收确认人" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="签收确认时间" prop="HDate_Receive">
                                    <el-date-picker v-model="form.HDate_Receive" type="date" placeholder="选择签收确认时间"
                                        disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="核算人" prop="HSurer_Accounting">
                                    <el-input v-model="form.HSurer_Accounting" placeholder="请输入核算人" disabled />
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="核算时间" prop="HDate_Accounting">
                                    <el-date-picker v-model="form.HDate_Accounting" type="date" placeholder="选择核算时间"
                                        disabled>
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-tab-pane>
                </el-tabs>
                <el-card class="box-card">
                    <div slot="header" class="clearfix">
                        <span>检验项信息</span>
                    </div>
                    <div>
                        <div style="margin-bottom: 10px;">
                            <el-button type="success" plain icon="el-icon-plus" @click="handleCopyZbRow"
                                size="mini">复制一行</el-button>
                        </div>
                        <el-table :data="editData" style="width: 100%" height="300" width="100%" ref="zbTable"
                            @selection-change="handleTableZbEdit" :row-class-name="rowSysZbIndex" show-summary border>
                            <el-table-column type="selection" width="55" align="center" />
                            <el-table-column align="center" label="序号" type="index" width="80" />
                            <el-table-column align="center" label="源单单据号" width="120">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.HSourceBillNo }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="物料代码" width="120">
                                <template slot-scope="scope">{{ scope.row.HMaterNumber }} </template>
                            </el-table-column>
                            <el-table-column align="center" label="物料名称" width="120">
                                <template slot-scope="scope">{{ scope.row.HMaterName }} </template>
                            </el-table-column>
                            <el-table-column align="center" label="器具代码" width="120">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.HMouldNumber" placeholder="请输入器具代码" />
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="器具名称" width="120">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.HMouldName }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="容器长度" width="120">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.HMouldLength }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="容器宽度" width="120">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.HMouldWidth }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="容器高度" width="120">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.HMouldHeight }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="折叠高度" width="120">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.HMouldFoldHeight }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="标准包装数量" width="120">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.HSNP }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="包装容器数量" width="120">
                                <template slot-scope="scope">
                                    <el-input-number v-model="scope.row.HMouldQty" :min="0" style="width: 90px;"
                                        controls-position="right"></el-input-number>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="物料数量" width="120">
                                <template slot-scope="scope">
                                    <el-input-number v-model="scope.row.HQty" :min="0" style="width: 90px;"
                                        controls-position="right"></el-input-number>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="体积" width="120">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.HVolume }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="零单占用体积" width="120">
                                <template slot-scope="scope">
                                    <el-input-number v-model="scope.row.HScatteredVolume" :min="0" style="width: 90px;"
                                        controls-position="right"></el-input-number>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="操作" width="55" fixed="right">
                                <template slot-scope="scope">
                                    <el-button type="danger" icon="el-icon-delete" size="mini" circle
                                        @click="handleDeleteSysZb(scope.row)"></el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </el-card>
            </el-form>
            <!-- 数据弹窗 -->
            <el-dialog :title="dialogTitle" :visible.sync="openData" width="1280px" append-to-body>
                <!-- 部门 -->
                <Dept @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="deptShow" />
                <!-- 仓库 -->
                <Warehouse @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="warehouseShow" />
                <!-- 物料 -->
                <Material @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="materialShow" />
                <!-- 发货通知单 -->
                <XsSeOutStockBill @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName"
                    :propsHOrgID="form.HOrgID" v-if="xsSeOutStockBillShow" />
                <GyCustomer @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyCustomerShow" />
                <GySupplier @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gySupplierShow" />
                <GyCartype @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyCartypeShow" />
                <GyCar @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyCarShow" />
                <GyDriver @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyDriverShow" />
                <ContractTransport @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName"
                    v-if="ContractTransportShow" />
                <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="deptClickSub">确 定</el-button>
                    <el-button @click="deptClose">取 消</el-button>
                </div>
            </el-dialog>
            <el-dialog title="隐藏列设置" :visible.sync="openRowHide" width="816px" append-to-body>
                <RowSettings :colName="btResList" HModName="Kf_SellOutBillList" @rowEditClose="rowSetClose"
                    v-if="rowHideShow" />
            </el-dialog>
        </div>
    </div>
</template>
 
<script>
import axios from 'axios'
import moment from 'moment';
import RowSettings from '@/views/component/rowSettings'
import Dept from '@/views/component/dept'
import Warehouse from '@/views/component/warehouse'
import Material from '@/views/component/material'
import XsSeOutStockBill from '@/views/sell/XsSeOutStockBill.vue'
import GyCustomer from '@/views/GyCustomer'
import GySupplier from "@/views/basic/gy/gySupplier.vue";
import GyCartype from "@/views/basic/gyCartypelist/gyCartypelist.vue"
import GyCar from "@/views/basic/gyCar/gyCarList.vue"
import GyDriver from "@/views/system/user/GyDriver.vue"
import ContractTransport from "@/views/basic/gytransport/cgContractTransportBillList/Cg_ContractTransportBillList.vue"
export default {
    name: 'SellOutBill',
    components: { Dept, Warehouse, Material, RowSettings, XsSeOutStockBill, GyCustomer, GySupplier, GyCartype, GyCar, GyDriver, ContractTransport },
    props: {
        OperationType: { type: Number, },
        linterid: { type: Number, },
        HSouceBillType: { type: String, },
        propsData: { type: String, },
        copyType: { type: Number, },
    },
    data() {
        return {
            baseURL: process.env.VUE_APP_BASE_API,                                     //后端接口前缀(后端服务器IP)
            HModName: "Add_Edit_Gy_QCVerificationBill",
            organizationList: JSON.parse(sessionStorage.getItem('organizationList')),  //页面初始化组织列表
 
            loading: true,                                                             // 遮罩层
 
            addBtnShow: false,                                                         //新增按钮显示标记
            subDisabled: false,                                                        //保存按钮禁用标记
 
            formShow: false,                                                           //表单是否显示标记
            formLoading: true,                                                         //表单加载遮罩
            sourceDataLoading: false,                                                    //源单数据处理加载遮罩
            zzSelDis: false,                                                           //组织下拉列表禁用标记
 
            rowHideShow: false,                                                        //列设置组件容器显示标记
            openRowHide: false,                                                        //列设置组件显示标记
 
            dialogTitle: '',                                                           //弹窗标题
            openData: false,                                                           //数据弹窗
            dialogTypeNum: null,                                                       //部门弹窗1,仓库弹窗2
            deptShow: false,                                                           //部门数据组件显示标记
            warehouseShow: false,                                                      //仓库数据组件显示标记
            materialShow: false,                                                       //物料数据组件显示标记
            stockPlaceShow: false,                                                     //仓位数据组件显示标记
            xsSeOutStockBillShow: false,                                               //原单(发货通知单)数据组件显示标记
            gyCustomerShow: false,                                                     //客户数据组件显示标记
            gySupplierShow: false,                                                     //承运商数据组件显示标记
            gyCartypeShow: false,                                                      //车型数据组件显示标记
            gyCarShow: false,                                                          //车辆数据组件显示标记
            gyDriverShow: false,                                                       //司机数据组件显示标记
            ContractTransportShow: false,                                              //承运合同数据组件显示标记
            deptform: {},                                                              //弹窗选中数据
 
            temp: undefined,                                                           //临时变量
            btResList: [],                                                             // 列设置
            form: {},                                                                  // 表单参数
            rules: {                                                                   // 表单校验
                HCarrierName: [
                    { required: true, message: "承运商不能为空", trigger: "change" }
                ],
                HCusName: [
                    { required: true, message: "客户不能为空", trigger: "blur" }
                ],
                HBeginAddrName: [
                    { required: true, message: "始发地不能为空", trigger: "blur" }
                ],
                HEndAddrName: [
                    { required: true, message: "目的地不能为空", trigger: "blur" }
                ],
                HDate: [
                    { required: true, message: "日期不能为空", trigger: "blur" }
                ],
                HExRate: [
                    { required: true, message: "汇率不能为空", trigger: "blur" }
                ]
            },
 
            checkedSysZb: [],
            editData: [],                                                              //子表数据
            editBtData: [],                                                            //子表表头
            activeName: 'first',
            zbIndex: null,
            zbSelForm: {},                                                             //子表选中数据,用于子表复制、上移、下移等操作
 
            HInterID: null,
            hPriceTypeList: ['成本价', '结算价'],
            title: "",                                                                 // 弹出层标题
            open: false,                                                               // 是否显示弹出层
            dateRange: [],                                                             // 日期范围
            // 查询参数
            queryParams: {
                HBillNo: '',
                HInitTimeCycle: 29,
                HProjectNumber: '',
                HCusID: null,
                HMaterNumber: '',
                HMaterName: '',
                ColName1: '',
                ColName2: '',
                ColName: '',
                Comparator1: '',
                Comparator2: '',
                Comparator: '',
                ColContent1: '',
                ColContent2: '',
                ColContent: '',
            },
            showSearch: true,                                                          // 显示搜索条件
            ids: [],                                                                   // 子表选中数据
            single: true,                                                              // 非单个禁用
            multiple: true,                                                            // 非多个禁用
 
            // 附件上传相关数据
            fileList: [],                                                              // 已上传文件列表
            uploadFiles: [],                                                           // 待上传文件列表
            uploadLoading: false,                                                      // 上传加载状态
            uploadUrl: '',                                                             // 上传接口地址
 
        };
    },
    created() {
        this.getdata()
    },
    beforeDestroy() {
        // 下面的代码会导致页面崩溃,先注释掉
        // this.$destroy()
    },
    methods: {
        //#region 表单数据初始化
        getdata() {
            this.formShow = false
            this.formLoading = true
            if ((this.OperationType == 1 && this.copyType != 1) || (!this.OperationType && !this.copyType)) {
                this.handleAdd()
            }
            else if (this.OperationType == 3 || this.copyType == 1) {
                this.handleUpdate()
            }
            else if (this.OperationType == 4) {
                this.zzSelDis = true
                this.handleAdd()
                var data = this.getUrlVars_JSON();
                var dataArray = [];
                for (var i = 0; i < data.length; i++) {
                    // this.getPushSourceBillInit(data[i].hmainid, data[i].hsubid);
                    axios.get(this.$baseUrl + '/Xs_SeOrderBill/loadXs_SeOrderBill_Push', {
                        params: {
                            "HInterID": data[i].hmainid
                            , "HSubID": data[i].hsubid
                        },
                    }).then(response => {
                        let result = response.data
                        if (result.code == 1) { // 说明验证成功了,
                            this.temp = result.data[0];
                        } else {
                            this.temp = result.data;
                        }
                        if (this.temp) {
                            dataArray.push(this.temp);
                            this.form.HDeptID = dataArray[0].HDeptID
                            this.form.HDeptName = dataArray[0].部门
                            this.form.HEmpID = dataArray[0].HEmpID
                            this.form.HEmpName = dataArray[0].业务员
                            this.form.HManagerID = dataArray[0].HManagerID
                            this.form.HManagerName = dataArray[0].主管
                            this.form.HMainSourceInterID = "0"
                            this.form.HMainSourceEntryID = "0"
                            this.form.HMainSourceBillNo = ""
                            this.form.HMainSourceBillType = dataArray[0].HBillType
                            this.form.HSupID = dataArray[0].HCusID
                            this.form.HSupName = dataArray[0].客户
                            this.form.HLinkMan = dataArray[0].联系人
                            this.form.HLinkPhone = dataArray[0].联系电话
                            this.form.HSellSID = dataArray[0].HSellSID
                            this.form.HSellSName = dataArray[0].销售方式
                            this.form.HCurID = dataArray[0].HCurID
                            this.form.HCurName = dataArray[0].币别
                            this.form.HExRate = dataArray[0].汇率
                            for (var i = 0; i < dataArray.length; i++) {
                                this.editData.push(
                                    {
                                        "HMaterID": dataArray[i].HMaterID
                                        , "物料代码": dataArray[i].物料代码
                                        , "物料名称": dataArray[i].物料名称
                                        , "规格型号": dataArray[i].规格型号
                                        , "HUnitID": dataArray[i].HUnitID
                                        , "计量单位": dataArray[i].计量单位
                                        , "HQtyMust": dataArray[i].数量.toFixed(6)
                                        , "HQty": dataArray[i].数量.toFixed(6)
                                        , "HPieceQty": "0"
                                        , "HPrice": dataArray[i].单价.toFixed(4)
                                        , "HTaxPrice": dataArray[i].实际含税单价.toFixed(4)
                                        , "HTaxRate": dataArray[i].税率
                                        , "HMoney": dataArray[i].金额.toFixed(2)
                                        , "HTaxMoney": dataArray[i].价税合计.toFixed(2)
                                        , "HWHID": dataArray[i].HWHID
                                        , "发货仓库": dataArray[i].HWHName
                                        , "HRemark": ""
                                        , "HQty_Full": "0"
                                        , "HQty_Empty": "0"
                                        , "HQty_Back": "0"
                                        , "HCostPrice": "0"
                                        , "HCostMoney": "0"
                                        , "HSalePrice": "0"
                                        , "HSeOrderInterID": dataArray[i].hmainid
                                        , "HSeOrderEntryID": dataArray[i].hsubid
                                        , "HSeOrderBillNo": dataArray[i].单据号
                                        , "HSourceInterID": dataArray[i].hmainid
                                        , "HSourceEntryID": dataArray[i].hsubid
                                        , "HSourceBillNo": dataArray[i].单据号
                                        , "HSourceBillType": dataArray[i].HBillType
                                        , "HRelationQty": "0"
                                        , "HRelationMoney": "0"
                                        , 'HSPID': "0"
                                        , 'HSPName': ""
                                        , 'HSPGroupID': "0"
                                        , "HSPGroupName": ""
                                        , 'HSCWHID': "0"
                                        , 'HSCWHName': ""
                                        , 'HSCSPID': "0"
                                        , 'HSCSPName': ""
                                        , 'HBatchNo': ""
                                        , 'HPOOrderInterID': "0"
                                        , 'HPOOrderEntryID': "0"
                                        , 'HPOOrderBillNo': ""
                                        , 'HPropertyID': "0"
                                        , 'HPropertyName': ""
                                        , 'HSecUnitID': "0"
                                        , 'HSecUnitName': ""
                                        , 'HSecUnitRate': "0"
                                        , 'HEngineNum': ""
                                        , 'HUnderPanNum': ""
                                        , 'HLeaveFactCard': ""
                                        , 'HReqBuyQty': "0"
                                        , 'HReqOutQty': "0"
                                        , 'HCurrentInventory': "0"
                                    }
                                );
                            }
                        }
                        this.$nextTick(() => {
                            this.formShow = true
                            this.formLoading = false
                        })
                    }).catch(error => {
                        this.$modal.msgError("接口请求失败!");
                    });
                }
            }
        },
        //#endregion
 
        //#region 页面数据初始化
        reset() {
            this.form = {
                HInterID: 0,
                HBillNo: "",
                HDate: moment(new Date()).format('YYYY-MM-DD'),
                HOrgID: sessionStorage["OrganizationID"] - 0,
                HMaker: sessionStorage["HUserName"],
                HChecker: "",
                HCloseMan: "",
                HUpDater: "",
                HDeleteMan: "",
                HMakeDate: "",
                HCheckDate: "",
                HCloseDate: "",
                HUpDateDate: "",
                HDeleteDate: "",
                HExRate: 0,
                HMainSourceInterID: 0,
                HMainSourceEntryID: 0,
                HMainSourceBillType: '',
                HMainSourceBillNo: '',
                HInnerBillNo: "",
 
                HCarrierID: 0,
                HCarrierName: "",
                HCusID: 0,
                HCusName: "",
                HBeginAddr: 0,
                HBeginAddrName: "",
                HEndAddr: 0,
                HEndAddrName: "",
                HPickAddr: "",
                HArriverAddr: "",
                HTransType: "",
                HCarTypeID: 0,
                HCarTypeName: "",
                HCarTypeMaxVolume: 0,
                HTotalVolume: 0,
                HLoadingRate: 0,
                HContractTransportInterID: 0,
                HContractTransportEntryID: 0,
                HContractTransportBillNo: "",
                HDistance: 0,
                HTransportTimes: "",
                HTransportTyep: "",
                HSSID: 0,
                HSSName: "",
                HMoney: 0,
                HDateForRequestedPick: "",
                HDataForRequestedArrived: "",
                HCarryStatus: "0",
                HDate_CarrierSure: "",
                HDate_AllocationDriver: "",
                HCarID: 0,
                HCarName: "",
                HDriverID: 0,
                HDriverName: "",
                HSurer_Arrive: "",
                HDate_Arrive: "",
                HSurer_Pick: "",
                HDate_Pick: "",
                HSurer_Trans: "",
                HDate_Trans: "",
                HSurer_Receive: "",
                HDate_Receive: "",
                HSurer_Accounting: "",
                HDate_Accounting: "",
            }
            this.editData = []
            this.editBtData = []
            this.ids = []
            this.subDisabled = false
            this.addBtnShow = false
            // this.$refs.tableData.clearSelection()
            this.activeName = 'first'
            this.resetForm("form");
        },
        //#endregion
 
        //#region 新增按钮操作
        handleAdd() {
            this.reset()
            //新增获取单据号
            this.getHBillNo()
            this.$nextTick(() => {
                this.formShow = true
                this.formLoading = false
            })
        },
        //#endregion
 
        //#region 编辑页面初始化
        handleUpdate() {
            this.reset()
            let rowHmainid = this.linterid
            axios.get(this.$baseUrl + "/Kf_POStockInBill/cx", {
                params: { 'HInterID': rowHmainid }
            }).then(response => {
                console.log(response.data.data.h_v_WL_YayBillEdit)
                if (response.data.code == 1) {
                    var result = { data: response.data.data.h_v_WL_YayBillEdit }
                    var data = response.data.data.h_v_WL_YayBillEdit[0]
                    if (this.copyType == 1) {
                        this.getHBillNo()
                    } else {
                        this.form.HInterID = this.linterid.toString()
                        this.form.HBillNo = data.单据号
                        this.form.HDate = data.日期 //moment(data.日期moment).format('YYYY-MM-DD')
                        this.form.HMaker = data.制单人
                        this.form.HUpDater = data.修改人
                        this.form.HChecker = data.审核人
                        this.form.HMakeDate = data.制单日期 == null ? "" : moment(data.制单日期).format('YYYY-MM-DD')
                        this.form.HUpDateDate = data.修改日期 == null ? "" : moment(data.修改日期).format('YYYY-MM-DD')
                        this.form.HCheckDate = data.审核日期 == null ? "" : moment(data.审核日期).format('YYYY-MM-DD')
                        this.form.HCloseMan = data.关闭人
                        this.form.HDeleteMan = data.作废人
                        this.form.HCloseDate = data.关闭日期 == null ? "" : moment(data.关闭日期).format('YYYY-MM-DD')
                        this.form.HDeleteDate = data.作废日期 == null ? "" : moment(data.作废日期).format('YYYY-MM-DD')
                        this.form.HSurer_Arrive = data.到厂确认人
                        this.form.HDate_Arrive = data.到厂确认时间
                        this.form.HSurer_Pick = data.提货确认人
                        this.form.HDate_Pick = data.提货确认时间
                        this.form.HSurer_Trans = data.出厂运输确认人
                        this.form.HDate_Trans = data.出厂运输确认时间
                        this.form.HSurer_Receive = data.签收确认人
                        this.form.HDate_Receive = data.签收确认时间
                        this.form.HSurer_Accounting = data.核算人
                        this.form.HDate_Accounting = data.核算时间
                    }
                    this.form.HOrgID = data.HOrgID.toString()
                    this.form.HExRate = !data.汇率 ? 0 : data.汇率
                    this.form.HMainSourceInterID = data.HMainSourceInterID
                    this.form.HMainSourceEntryID = data.HMainSourceEntryID
                    this.form.HMainSourceBillType = data.HMainSourceBillType
                    this.form.HMainSourceBillNo = data.HMainSourceBillNo
                    this.form.HInnerBillNo = data.内部单据号
                    this.form.HCarrierID = data.承运商ID
                    this.form.HCarrierName = data.承运商名称
                    this.form.HCusID = data.HCusID
                    this.form.HCusName = data.客户名称
                    this.form.HBeginAddr = data.始发地
                    this.form.HBeginAddrName = data.始发地名称
                    this.form.HEndAddr = data.目的地
                    this.form.HEndAddrName = data.目的地名称
                    this.form.HPickAddr = data.提货地址
                    this.form.HArriverAddr = data.到货方式
                    this.form.HTransType = data.运输方式
                    this.form.HCarTypeID = data.车型ID
                    this.form.HCarTypeName = data.车型名称
                    this.form.HCarTypeMaxVolume = data.车型最大容积
                    this.form.HTotalVolume = data.总体积
                    this.form.HLoadingRate = data.装载率
                    this.form.HContractTransportInterID = data.承运合同ID
                    this.form.HContractTransportEntryID = data.承运合同子ID
                    this.form.HContractTransportBillNo = data.承运合同单据号
                    this.form.HDistance = data.距离
                    this.form.HTransportTimes = data.运输时效
                    this.form.HTransportTyep = data.运输类型
                    this.form.HSSID = data.结算方式
                    this.form.HSSName = data.结算方式名称
                    this.form.HCurID = data.币别
                    this.form.HCurName = data.币别名称
                    this.form.HMoney = data.运输费用
                    this.form.HDateForRequestedPick = data.要求提货时间
                    this.form.HDataForRequestedArrived = data.要求到货时间
                    this.form.HCarryStatus = data.物流状态
                    this.form.HDate_CarrierSure = data.承运商确认时间
                    this.form.HDate_AllocationDriver = data.分配司机时间
                    this.form.HCarID = data.车辆ID
                    this.form.HCarName = data.车辆名称
                    this.form.HDriverID = data.司机ID
                    this.form.HDriverName = data.司机名称
 
                    //子表  赋值
                    for (var i = 0; i < result.data.length; i++) {
                        var qty = parseFloat(result.data[i].HQty) || 0;
                        var snp = parseFloat(result.data[i].标准包装数量) || 1;
                        var mouldQty = Math.ceil(qty / snp);
 
                        var length = parseFloat(result.data[i].容器长度) || 0;
                        var width = parseFloat(result.data[i].容器宽度) || 0;
                        var height = parseFloat(result.data[i].容器高度) || 0;
                        var rowVolume = (length * width * height).toFixed(2);
 
                        this.editData.push(
                            {
                                "HSourceInterID": result.data[i].源单主内码,
                                "HSourceEntryID": result.data[i].源单子内码,
                                "HSourceBillNo": result.data[i].源单单据,
                                "HMaterID": result.data[i].HMaterID,
                                "HMaterNumber": result.data[i].物料代码,
                                "HMaterName": result.data[i].物料名称,
                                "HUnitID": result.data[i].HUnitID,
                                "HMouldID": result.data[i].HMouldID,
                                "HMouldNumber": result.data[i].器具号,
                                "HMouldName": result.data[i].器具名称,
                                "HMouldLength": result.data[i].容器长度,
                                "HMouldWidth": result.data[i].容器宽度,
                                "HMouldHeight": result.data[i].容器高度,
                                "HMouldFoldHeight": result.data[i].容器折叠高度,
                                "HSNP": result.data[i].标准包装数量,
                                "HMouldQty": result.data[i].包装容器数量,
                                "HQty": result.data[i].物料数量,
                                "HQty_origin": result.data[i].HQty,
                                "HVolume": rowVolume,
                                "HScatteredVolume": result.data[i].零单占用体积
                            }
                        )
                    }
                    this.formShow = true
                    this.formLoading = false
 
                    // 加载已上传的文件列表
                    this.getFileList();
 
                } else {
                    this.$modal.msgError(response.data.msg);
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 列设置
        handleRowHide() {
            this.rowHideShow = true
            this.openRowHide = true
        },
        rowSetClose(val) {
 
            this.rowHideShow = false
            this.openRowHide = val
            this.$destroy()
        },
        //#endregion
 
        //#region 组织值变更事件
        organizationChange(val) {
            // let options=undefined
            //  this.form=this.organizationList.find(option => option.ID === val)?.Name || '';
        },
        //#endregion
 
        //#region 数据弹窗
        //#region 打开数据列表弹窗
        openDataDialog(num, row) {
            if (row) {
                this.zbIndex = row.index - 1
            }
            this.showReset()
            if (num == 1) {
                this.dialogTitle = '部门列表'
                this.deptShow = true
                this.openData = true
            } else if (num == 2) {
                this.dialogTitle = '出库仓库列表'
                this.warehouseShow = true
                this.openData = true
            } else if (num == 3) {
                this.dialogTitle = '物料列表'
                this.materialShow = true
                this.openData = true
            } else if (num == 4) {
                this.dialogTitle = '仓位列表'
                this.stockPlaceShow = true
                this.openData = true
            } else if (num == 6) {
                this.dialogTitle = '承运商列表'
                this.gySupplierShow = true
                this.openData = true
            } else if (num == 7) {
                this.dialogTitle = '客户列表'
                this.gyCustomerShow = true
                this.openData = true
            } else if (num == 12) {
                this.dialogTitle = '源单列表'
                this.xsSeOutStockBillShow = true
                this.openData = true
            } else if (num == 13) {
                this.dialogTitle = '车型列表'
                this.gyCartypeShow = true
                this.openData = true
            } else if (num == 14) {
                this.dialogTitle = '车辆列表'
                this.gyCarShow = true
                this.openData = true
            } else if (num == 15) {
                this.dialogTitle = '车辆列表'
                this.gyDriverShow = true
                this.openData = true
            } else if (num == 16) {
                this.dialogTitle = '承运合同列表'
                this.ContractTransportShow = true
                this.openData = true
            }
        },
        //#region 将数据弹窗全部取消加载
        showReset() {
            this.deptShow = false
            this.warehouseShow = false
            this.materialShow = false
            this.gyCustomerShow = false
            this.xsSeOutStockBillShow = false
            this.gySupplierShow = false
            this.gyCartypeShow = false
            this.gyCarShow = false
            this.gyDriverShow = false
            this.ContractTransportShow = false
        },
        //#endregion
        //#endregion
 
        //#region 弹窗数据双击返回表单赋值事件
        dbEmitData(deptRow, num) {
            if (num == 1) {
                this.form.HDeptName = deptRow.部门名称                                  //部门
                this.form.HDeptID = deptRow.HItemID
                this.form.HEmpID = deptRow.HEmpID
                this.form.HManagerName = deptRow.负责人
                this.openData = false
            } else if (num == 2) {                                                      //收料仓库
                this.editData[this.zbIndex].HWHID = deptRow.HItemID;
                this.editData[this.zbIndex].收料仓库 = deptRow.仓库名称;
                this.openData = false
            } else if (num == 4) {                                                      //仓位
                this.editData[this.zbIndex].HSPID = deptRow.HItemID;
                this.editData[this.zbIndex].仓位名称 = deptRow.仓位名称;
                this.openData = false
            } else if (num == 3) {                                                      //物料
                this.editData[this.zbIndex].HMaterID = deptRow.HItemID;
                this.editData[this.zbIndex].物料代码 = deptRow.物料代码;
                this.editData[this.zbIndex].物料名称 = deptRow.物料名称;
                this.editData[this.zbIndex].HUnitID = deptRow.HUnitID;
                this.editData[this.zbIndex].规格型号 = deptRow.规格型号
                this.editData[this.zbIndex].计量单位 = deptRow.计量单位名称
                this.editData[this.zbIndex].HTaxPrice = deptRow.含税成本价
                this.editData[this.zbIndex].HTaxRate = deptRow.默认税率
                this.openData = false
            } else if (num == 6) {
                this.form.HCarrierName = deptRow.供应商名称
                this.form.HCarrierID = deptRow.HItemID
                this.gySupplierShow = false
                this.openData = false
            } else if (num == 7) {
                this.form.HCusName = deptRow.客户名称
                this.form.HCusID = deptRow.HItemID
                this.gyCustomerShow = false
                this.openData = false
            } else if (num == 12) {
                // 使用异步方式处理源单数据
                this.processSourceDataAsync(deptRow);
            } else if (num == 13) {
                this.form.HCarTypeName = deptRow.车型名称
                this.form.HCarTypeID = deptRow.HItemID
                this.form.HCarTypeMaxVolume = deptRow["最大体积(立方米)"]
                this.calculateLoadingRate(parseFloat($('#HTotalVolume').val()) || 0);
                this.gyCartypeShow = false
                this.openData = false
            } else if (num == 14) {
                this.form.HCarName = deptRow.车辆名称
                this.form.HCarID = deptRow.HItemID
                this.gyCarShow = false
                this.openData = false
            } else if (num == 15) {
                this.form.HDriverName = deptRow.驾驶员名称
                this.form.HDriverID = deptRow.HItemID
                this.gyDriverShow = false
                this.openData = false
            } else if (num == 16) {
                this.form.HContractTransportBillNo = deptRow.单据号
                this.form.HContractTransportInterID = deptRow.HInterID
                this.form.HContractTransportEntryID = deptRow.HInterID
                this.form.HDistance = deptRow.距离
                this.form.HTransportTimes = deptRow.运输时效
                this.form.HTransportTyep = deptRow.运输类型
                this.form.HSSID = deptRow.结算方式
                this.form.HSSName = deptRow.结算方式名称
                this.form.HCurID = deptRow.币别
                this.form.HCurName = deptRow.币别名称
                this.form.HMoney = deptRow.运输费用
                this.form.HExRate = deptRow.汇率 == null ? 0 : deptRow.汇率
                this.form.HCarrierID = deptRow.HSupID
                this.form.HCarrierName = deptRow.供应商名称
                this.ContractTransportShow = false
                this.openData = false
            }
        },
        //#endregion
 
        //#region 弹窗数据单击事件
        emitData(deptRow, num) {
            this.dialogTypeNum = num
            this.deptform = deptRow
        },
        //#endregion
 
        //#region 弹窗确定事件
        deptClickSub() {
            this.dbEmitData(this.deptform, this.dialogTypeNum)
            this.deptform = {}
        },
        //#endregion
 
        //#region 弹窗取消事件
        deptClose() {
            this.deptform = {}
            this.openData = false
        },
        //#endregion
        //#endregion
        //#region 检查源单是否已经在子表中存在
        checkDuplicateSource(newSourceData) {
            // 获取当前子表数据
            var currentTableData = this.editData || [];
 
            // 遍历新选择的源单数据
            for (var i = 0; i < newSourceData.length; i++) {
                var newSourceInterID = newSourceData[i].hmainid;
                var newSourceEntryID = newSourceData[i].hsubid;
 
                // 检查是否已经在当前子表中存在
                for (var j = 0; j < currentTableData.length; j++) {
                    var existingSourceInterID = currentTableData[j].HSourceInterID;
                    var existingSourceEntryID = currentTableData[j].HSourceEntryID;
 
                    // 如果主内码和子内码都相同,则说明已存在
                    if (existingSourceInterID == newSourceInterID &&
                        existingSourceEntryID == newSourceEntryID) {
                        return true; // 存在重复
                    }
                }
            }
            return false; // 无重复
        },
        //#endregion
 
        //#region 异步处理源单数据
        async processSourceDataAsync(deptRow) {
            try {
                // 设置客户信息
                if (!this.form.HCusID && deptRow.length > 0) {
                    this.form.HCusID = deptRow[0]["HCusID"];
                    this.form.HCusName = deptRow[0]["客户"];
                }
                console.log(deptRow)
                this.form.HMainSourceInterID=deptRow[0]["hmainid"]
                this.form.HMainSourceEntryID=deptRow[0]["hsubid"]
                this.form.HMainSourceBillType=deptRow[0]["HBillType"]
                this.form.HMainSourceBillNo=deptRow[0]["单据号"]
                // 检查是否所有记录属于同一客户
                for (var i = 0; i < deptRow.length; i++) {
                    if (deptRow[i]["HCusID"] != this.form.HCusID) {
                        this.$modal.msgError("下推失败!已经选中的记录中存在不同客户,请确保选择的源单属于同一客户!");
                        this.xsSeOutStockBillShow = false;
                        this.openData = false;
                        return;
                    }
                }
 
                // 检查新选择的源单是否已经在子表中存在
                var isDuplicate = this.checkDuplicateSource(deptRow);
                if (isDuplicate) {
                    this.$modal.msgError("选择的源单中已存在重复记录,请勿重复选择相同的源单!");
                    this.xsSeOutStockBillShow = false;
                    this.openData = false;
                    return;
                }
 
                // 异步处理源单数据
                await this.appendInitBySeOutStockBill(deptRow);
 
                // 关闭对话框
                this.xsSeOutStockBillShow = false;
                this.openData = false;
            } catch (error) {
                console.error("处理源单数据时发生错误:", error);
                this.$modal.msgError("处理源单数据时发生错误,请稍后重试!");
                this.xsSeOutStockBillShow = false;
                this.openData = false;
            }
        },
        //#endregion
 
        //#region 选择源单-发货通知单(追加方式)
        //改为异步方法,优化源单数据处理逻辑
        async appendInitBySeOutStockBill(checkStatus) {
            try {
                // 显示源单数据加载状态
                this.sourceDataLoading = true;
 
                var dataArray = [];
 
                // 使用Promise.all等待所有异步请求完成
                const promises = checkStatus.map(async (item) => {
                    const temp = await this.getPushSeOutStockBillInit(item.hmainid, item.hsubid);
                    return temp;
                });
 
                const results = await Promise.all(promises);
 
                // 过滤掉null值
                for (const result of results) {
                    if (result) {
                        dataArray.push(result);
                    } else {
                        // 如果有任何请求失败,终止处理
                        this.sourceDataLoading = false;
                        return;
                    }
                }
 
                // 获取现有子表数据
                var existingData = this.editData || [];
                var orginHQTY = 0;
 
                // 创建物料ID映射
                var materialMap = {};
                for (var i = 0; i < dataArray.length; i++) {
                    orginHQTY = dataArray[i].数量;
                    var materialId = dataArray[i].HMaterID;
                    if (!materialMap[materialId]) {
                        materialMap[materialId] = [];
                    }
                    materialMap[materialId].push({
                        hmainid: dataArray[i].hmainid,
                        hsubid: dataArray[i].hsubid,
                        单据号: dataArray[i].单据号
                    });
                }
 
                // 获取所有物料ID
                var ListMaterial = "";
                for (var materialId in materialMap) {
                    if (ListMaterial) ListMaterial += ";";
                    ListMaterial += materialId;
                }
 
                if (!ListMaterial) {
                    this.$modal.msgError("没有找到物料信息,请检查选择的源单是否包含有效的物料数据!");
                    this.sourceDataLoading = false;
                    return;
                }
 
                const response = await axios.get(this.$baseUrl + '/WLYayBillController/GetMesByOrginBill', {
                    params: {
                        "ListMaterial": ListMaterial
                    },
                });
 
                let result = response.data;
                if (result.count == 1) {
                    let res = result.data;
                    var newRows = [];
 
                    // 为每个源单行创建对应的子表行
                    for (var materialId in materialMap) {
                        var sourceInfos = materialMap[materialId];
 
                        // 查找该物料ID对应的包装容器信息
                        var materialInfo = null;
                        for (var i = 0; i < res.length; i++) {
                            if (res[i].HMaterID == materialId) {
                                materialInfo = res[i];
                                break;
                            }
                        }
 
                        if (materialInfo) {
                            // 为每个源单行创建一条记录
                            for (var j = 0; j < sourceInfos.length; j++) {
                                var sourceInfo = sourceInfos[j];
 
                                // 再次检查是否已存在(双重保险)
                                var isExist = false;
                                for (var k = 0; k < existingData.length; k++) {
                                    if (existingData[k].HSourceInterID == sourceInfo.hmainid &&
                                        existingData[k].HSourceEntryID == sourceInfo.hsubid) {
                                        isExist = true;
                                        break;
                                    }
                                }
 
                                if (isExist) {
                                    this.$modal.msgError(`源单${sourceInfo.单据号}已存在,跳过`);
                                    continue;
                                }
 
                                // 计算相关数量
                                var qty = materialInfo.HSNP || 0;
                                var snp = materialInfo.HSNP || 1;
                                var mouldQty = snp > 0 ? Math.ceil(qty / snp) : 0;
 
                                var length = parseFloat(materialInfo.长度) || 0;
                                var width = parseFloat(materialInfo.宽度) || 0;
                                var height = parseFloat(materialInfo.高度) || 0;
                                var rowVolume = (length * width * height * mouldQty).toFixed(2);
 
                                newRows.push({
                                    "HSourceInterID": sourceInfo.hmainid,
                                    "HSourceEntryID": sourceInfo.hsubid,
                                    "HSourceBillNo": sourceInfo.单据号,
                                    "HMaterID": materialInfo.HMaterID,
                                    "HMaterNumber": materialInfo.物料代码,
                                    "HMaterName": materialInfo.物料名称,
                                    "HUnitID": materialInfo.HUnitID,
                                    "HMouldID": materialInfo.HMouldID,
                                    "HMouldNumber": materialInfo.HMouldNumber,
                                    "HMouldName": materialInfo.HMouldName,
                                    "HMouldLength": materialInfo.长度,
                                    "HMouldWidth": materialInfo.宽度,
                                    "HMouldHeight": materialInfo.高度,
                                    "HMouldFoldHeight": materialInfo.折叠高度,
                                    "HQty": orginHQTY,
                                    "HQty_origin": orginHQTY,
                                    "HMouldQty": mouldQty,
                                    "HVolume": rowVolume,
                                    "HSNP": materialInfo.HSNP,
                                    HScatteredVolume: 0,
                                });
                            }
                        }
                    }
 
                    if (newRows.length === 0) {
                        this.$modal.msgError("没有可添加的新记录,可能是源单数据已存在或物料信息不完整!");
                        this.sourceDataLoading = false;
                        return;
                    }
 
                    // 合并现有数据和新数据
                    var allData = existingData.concat(newRows);
 
                    // 渲染表格
                    this.editData = allData;
 
                    this.$modal.msgSuccess(`成功添加${newRows.length}条记录`);
                } else {
                    this.$modal.msgError(result.msg || "获取包装容器信息失败");
                }
            } catch (error) {
                console.error("处理源单数据时发生错误:", error);
                this.$modal.msgError("处理源单数据时发生错误,请稍后重试!");
            } finally {
                // 无论成功还是失败,都关闭源单数据加载状态
                this.sourceDataLoading = false;
            }
        },
        //#endregion
        //#region 根据主内码与子内码获取源单发货通知单数据
        //改为异步方法,返回Promise
        async getPushSeOutStockBillInit(HSourceInterID, HSourceEntryID) {
            try {
                const response = await axios.get(this.$baseUrl + '/Kf_SellOutBill/loadXs_SeOutStockBill_Push', {
                    params: {
                        "HInterID": HSourceInterID,
                        "HSubID": HSourceEntryID
                    },
                });
 
                if (response.data.code == 1) {
                    return response.data.data[0];
                } else {
                    this.$modal.msgError(response.data.msg || "获取源单数据失败");
                    return null;
                }
            } catch (error) {
                console.error("获取源单数据时发生错误:", error);
                this.$modal.msgError("获取源单数据时发生错误,请稍后重试!");
                return null;
            }
        },
        //#region 工具栏按钮操作
        //#region 编辑提交保存
        submitForm() {
            this.$refs["form"].validate(valid => {
                if (valid) {
                    let fhck = false
                    this.editData.map((item, index) => {
                        if (!item.发货仓库) {
                            fhck = true
                            this.$modal.msgError("第" + (index + 1) + "行:发货仓库未选择!");
                        }
                    })
                    this.$nextTick(() => {
                        if (!fhck) {
                            var sMainStr = JSON.stringify(this.form);
                            var sSubStr = JSON.stringify(this.editData);
                            var sMainSub = sMainStr + ';' + sSubStr + ';' + sessionStorage["HUserName"] + ';' + this.OperationType;
                            axios({
                                method: 'post',
                                url: this.$baseUrl + "/Kf_SellOutBill/SaveSellOutBillList",
                                data: {
                                    'msg': sMainSub
                                },
                            }).then(response => {
                                if (response.data.count == 1) {
                                    this.subDisabled = true//设置保存按钮不可用
                                    this.$modal.msgSuccess(response.data.Message);
                                    this.get_MAXNum_Task(1);//设置流水号增加
                                    if (response.data.Verify == "Y") //自动审核
                                    {
                                        this.set_CheckBill(0, this.form); //审核
                                    }
                                    this.addBtnShow = true
                                }
                            }).catch(error => {
                                this.$modal.msgError("接口请求失败!");
                            });
                        }
                    })
                }
            });
        },
        //#endregion
 
        //#region 反审核/审核数据
        set_CheckBill(num, form) {
            var InterID = form.hmainid || form.HInterID
            //逻辑审核方法
            axios.get(this.$baseUrl + "/Kf_SellOutBill/AuditKf_SellOutBill", {
                params: { "HInterID": InterID, "IsAudit": num, "CurUserName": sessionStorage["HUserName"] }
            }).then(response => {
                let result = response.data
                if (result.code == 1) {
                    this.$modal.msgSuccess('操作成功');
                }
                else {
                    this.$modal.msgError("错误:" + result.code + result.Message,);
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 退出按钮操作
        close() {
            this.reset()
 
            if (!this.OperationType && !this.copyType) {
                // this.$router.back()
                window.close()
            } else {
                this.formShow = false
                this.$emit('editClose', false)
            }
        },
        //#endregion
        //#endregion
 
        //#region 子表操作
        //#region 设置子表序号列
        rowSysZbIndex({ row, rowIndex }) {
            row.index = rowIndex + 1;
        },
        //#endregion
 
        //#region 子表复制按钮
        handleCopyZbRow() {
            if (!this.zbIndex) {
                this.$modal.msgError("请选择一行数据")
            } else {
                let copyRow = JSON.parse(JSON.stringify(this.zbSelForm))
                this.editData.push(copyRow);
            }
        },
        //#endregion
 
        //#region 子表上移按钮
        handleMoveRowUp(zbSelForm) {
            if (!this.zbIndex) {
                this.$modal.msgError("请选择一行数据")
            } else {
                if (zbSelForm.index == 1) {
                    this.$modal.msgError("第一行数据无法上移");
                } else { // 确保不是第一行
                    let num = zbSelForm.index - 1
                    const record = this.editData.splice(num, 1)[0];
                    this.editData.splice(num - 1, 0, record);
                }
            }
        },
        //#endregion
 
        //#region 子表下移按钮
        handleMoveRowDown(zbSelForm) {
            if (!this.zbIndex) {
                this.$modal.msgError("请选择一行数据")
            } else {
                if (zbSelForm.index == this.editData.length) {
                    this.$modal.msgError("最后一行数据无法下移");
                } else { // 确保不是第一行
                    let num = zbSelForm.index - 1
                    const record = this.editData.splice(num, 1)[0];
                    this.editData.splice(num + 1, 0, record);
                }
            }
        },
        //#endregion
 
        //#region 子表删除按钮
        handleDeleteSysZb(row) {
            this.checkedSysZb = []
            this.checkedSysZb.push(row.index)
            if (this.checkedSysZb.length == 0) {
                this.$modal.msgError("请先选择要删除的商品订单明细数据");
            } else {
                const editData = this.editData;
                const checkedSysZb = this.checkedSysZb;
                this.editData = editData.filter(function (item) {
                    return checkedSysZb.indexOf(item.index) == -1
                });
            }
        },
        //#endregion
 
        //#region 子表复选框选中数据
        handleTableZbEdit(selection) {
            this.checkedSysZb = selection.map(item => item.index)
            this.zbSelForm = selection[0]
            this.zbIndex = this.checkedSysZb[0]
            if (selection.length > 1) {
                const del_row = selection.shift()
                this.$refs.zbTable.toggleRowSelection(del_row, false) //设置这一行取消选中
            }
        },
        //#endregion
        //#endregion
 
        //#region 通用方法。
        //#region 获取参数_传递的JSON格式参数
        getUrlVars_JSON() {
            var datajson;
            var str = this.propsData; //获取链接中传递的参数
            var arr = str.substring(str.lastIndexOf("=") + 1);
            datajson = JSON.parse(decodeURI(arr));
            return datajson;
        },
        //#endregion
 
        //#region 组织下拉列表数据初始化
        fetchData() {
            axios.get(this.$baseUrl + "/Web/GetOrganizations", {
            }).then(response => {
                if (response.data.count == 1) {
                    this.organizationList = response.data.data;//组织列表
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 获取内码、单据号
        getHBillNo() {
            axios.get(this.$baseUrl + "/WEBSController/GetMaxBillNoAndID_Json", {
                params: {
                    HBillType: '3321'
                }
            }).then(response => {
                this.form.HBillNo = response.data.data[0].HBillNo
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 获取最大单据号
        get_MAXNum_Task(Type) {
            var sql = `exec h_p_Xt_GetMaxBillNo_SubType '1201','${this.form.HDate}',0,0,0,'${Type}','${this.form.HDeptID}'`;
            axios({
                method: 'get',
                url: this.$baseUrl + "/CommonModel/searchMethod",
                params: { "sql": sql, "user": sessionStorage["HUserName"], "ModRightNameCheck": "" },
            }).then(response => {
                if (response.data.count == 1) {
                    this.form.HBillNo = response.data.data[0].HBillNo;
                } else {
                    this.$modal.msgError(response.data.code + response.data.Message);
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 根据用户获取对应职员、部门、销售主管
        getCzyglByUser() {
            axios.get(this.$baseUrl + '/Xs_SeOrderBill/getCzyglByUser', {
                params: { "CurUserName": sessionStorage["HUserName"] }
            }).then(response => {
                let dataForm = response.data.data[0]
                this.form.HDeptID = dataForm.HDeptID
                this.form.HDeptName = dataForm.HDeptName
                this.form.HEmpID = dataForm.HEmpID
                this.form.HEmpName = dataForm.HEmpName
                this.form.HManagerID = dataForm.HManagerID
                this.form.HManagerName = dataForm.HManagerName
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 根据客户获取客户余额
        getCustomerBalance(HCusID) {
            axios.get(this.$baseUrl + '/Xs_CusRatingChangeBill/getCustomerBalance', {
                params: { "HCusID": HCusID, 'CurUserName': sessionStorage["HUserName"] }
            }).then(response => {
                var data = response.data.data[0];
                this.form.HCusBalance = data.HCusBalance
                this.form.HCreditRating_Now = data.HCreditRating_Now
                this.form.HAvailableBalance = data.HAvailableBalance
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 根据客户带出联系人、联系电话
        getCustomerByCusID(HCusID) {
            axios.get(this.$baseUrl + "/Xs_SeOrderBill/getCustomerByCusID", {
                params: {
                    HCusID: HCusID
                }
            }).then(response => {
                this.form.联系人 = response.data.data[0].HLinkMan
                this.form.联系电话 = response.data.data[0].HLinkPhone
                // this.form = response.data.data[0]
 
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 获取销售出库单对应的条码明细
        getBarCodeNoteBySellOutBill(rowHmainid) {
            axios.get(this.$baseUrl + '/Kf_SellOutBill/BarCodeNote', {
                params: { "HInterID": rowHmainid }
            }).then(response => {
                if (response.data.count == 1) {
                    if (response.data.data[2].length > 0) {
                        this.$modal.msgError("当前单据由扫码生成,不可以编辑!");
                        this.subDisabled = true
                    }
                } else { }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        //#region 根据主内码与子内码获取源单销售订单数据
        getPushSourceBillInit(HSourceInterID, HSourceEntryID) {
            axios.get(this.$baseUrl + '/Xs_SeOrderBill/loadXs_SeOrderBill_Push', {
                params: {
                    "HInterID": HSourceInterID
                    , "HSubID": HSourceEntryID
                },
            }).then(response => {
                let result = response.data
                if (result.code == 1) { // 说明验证成功了,
                    this.temp = result.data[0];
                } else {
                    this.temp = result.data;
                }
            }).catch(error => {
                this.$modal.msgError("接口请求失败!");
            });
        },
        //#endregion
 
        // 计算装载率函数
        calculateLoadingRate(totalVolume) {
            var maxVolume = parseFloat((this.form.HCarTypeMaxVolume).val()) || 0;
            if (maxVolume > 0) {
                var loadingRate = (totalVolume / maxVolume * 100).toFixed(2);
                this.form.HLoadingRate = loadingRate + "%"
            } else {
                this.form.HLoadingRate == ''
            }
        },
        //#endregion
 
        //#region 附件上传相关方法
        // 文件选择变化时的处理
        handleFileChange(file, fileList) {
            this.uploadFiles = fileList;
            this.fileList = this.uploadFiles.map(item => {
                // 获取文件扩展名
                const fileName = item.name;
                const fileExt = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
                return {
                    ...item,
                    HFileName: item.name,
                    HFileSize: item.size,
                    HFileType: fileExt,
                    HFileStatus: '未上传'
                };
            });
        },
 
        // 文件移除时的处理
        handleFileRemove(file, fileList) {
            this.uploadFiles = fileList;
        },
        flieUpload(row) {
            // 创建FormData对象
            const formData = new FormData();
 
            // 添加文件到FormData
            formData.append('files', row);
 
            // 添加其他参数
            formData.append('HBillNo', this.form.HBillNo);
            formData.append('HRemark', '');
            formData.append('HUserName', sessionStorage["HUserName"]);
            // 设置上传URL
            this.uploadUrl = this.$baseUrl + '/Gy_QCVerificationBillMain/UploadFile_Gy_QCVerification';
            // 发送上传请求
            axios.post(this.uploadUrl, formData, {
                headers: {
                    'Content-Type': 'multipart/form-data'
                }
            }).then(response => {
                if (response.data.code === 1) {
                    this.$message.success('文件上传成功');
 
                    // 重新获取已上传文件列表
                    this.getFileList();
                } else {
                    this.$message.error(response.data.Message || '上传失败');
                }
            }).catch(error => {
                this.uploadLoading = false;
                this.$message.error('上传请求失败');
                console.error('上传错误:', error);
            });
        },
        // 提交上传文件
        submitUpload() {
            if (this.uploadFiles.length === 0) {
                this.$message.warning('请先选择要上传的文件');
                return;
            }
 
            if (!this.form.HBillNo) {
                this.$message.warning('请先保存表单获取单据号');
                return;
            }
 
            this.uploadLoading = true;
 
            // 创建FormData对象
            const formData = new FormData();
 
            // 添加文件到FormData
            this.uploadFiles.forEach(file => {
                formData.append('files', file.raw);
            });
 
            // 添加其他参数
            formData.append('HBillNo', this.form.HBillNo);
            formData.append('HUserName', sessionStorage.getItem('HUserName') || '');
 
            // 设置上传URL
            this.uploadUrl = this.$baseUrl + '/Gy_QCVerificationBillMain/UploadFile_Gy_QCVerification';
 
            // 发送上传请求
            axios.post(this.uploadUrl, formData, {
                headers: {
                    'Content-Type': 'multipart/form-data'
                }
            }).then(response => {
                this.uploadLoading = false;
                if (response.data.code === 1) {
                    this.$message.success('文件上传成功');
                    // 清空待上传文件列表
                    this.uploadFiles = [];
                    // 重新获取已上传文件列表
                    this.getFileList();
                } else {
                    this.$message.error(response.data.Message || '上传失败');
                }
            }).catch(error => {
                this.uploadLoading = false;
                this.$message.error('上传请求失败');
                console.error('上传错误:', error);
            });
        },
 
        // 获取已上传文件列表
        getFileList() {
        },
 
        // 删除文件
        deleteFile(index) {
            this.uploadFiles.splice(index, 1)
        },
        //#endregion
        //#endregion 
    }
};
</script>
<style>
.xsckdBox .el-date-editor.el-input {
    width: 100%;
}
</style>