master.jsx
101 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
/* eslint-disable */
import React, { useEffect, useState } from "react";
import QuotationAllprogressDetail from "./detailNew";
import commonConfig from "@/utils/config";
import { Toast, Input, Tabs, Selector, Grid, Image, Button, Checkbox, Switch, Dialog } from "antd-mobile";
import * as commonServices from "@/services/services";
import * as commonFunc from "@/components/Common/commonFunc";
import * as commonBusiness from "@/components/Common/commonBusiness";
import * as commonUtils from "@/utils/utils";
import { cloneDeep } from "lodash";
import moment from "moment";
import CommobileBase from '@/mobile/common/CommobileBase';
import CommobileBillEvent from '@/mobile/common/CommobileBillEvent';
const masterEvent = props => {
const { location, quotationData, app, sModelsId } = props;
const selectedNode = quotationData;
const { token } = app;
const [state, setState] = useState(null);
const [isInitialized, setIsInitialized] = useState(false);
const [isQuoConfig, setIsQuoConfig] = useState(false);
const [isDraftSaved, setIsDraftSaved] = useState(false);
const [reloadTrigger, setReloadTrigger] = useState(0);
const getSqlDropDownData = async (formId, name, showConfig, record, sKeyUpFilterName, pageNum) => {
const url = `${commonConfig.server_host}business/getSelectLimit/${showConfig.sId}?sModelsId=${sModelsId}`;
const body = {
sSqlCondition: {
sSqlCondition: "",
},
sKeyUpFilterName: "",
pageNum: 1,
pageSize: 20,
};
const retrunData = await commonServices.postValueService(token, body, url);
if (retrunData.data.code === 1) {
const { rows, totalPageCount, currentPageNo, totalCount } = retrunData.data.dataset;
return {
dropDownData: rows,
totalPageCount,
currentPageNo,
totalCount,
};
}
};
// 获取主表信息
useEffect(() => {
const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}`;
commonServices
.getService(token, configUrl)
.then(async ({ data: masterReturn }) => {
if (masterReturn.code === 1) {
const formData = masterReturn.dataset.rows[0].formData;
const masterConfig = formData.find(x => x.sTbName === "QuoQuotationmaster");
const processConfig = formData.find(x => x.sTbName === "QuoQuotationprocess");
const materialsConfig = formData.find(x => x.sTbName === "QuoQuotationmaterials");
const slaveConfig = formData.find(x => x.sTbName === "QuoQuotationslave");
const controlConfig = formData.find(x => x.sTbName === "QuoQuotationcontrol");
let colorConfig = formData.find(x => x.sTbName === "quoquotationparam");
const packConfig = formData.find(item => item.sTbName === "quoquotationcontrolcombine");
const manyqtysConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.sTbName.toUpperCase() === 'QuoQuotationManyQtys'.toUpperCase() && item.bGrdVisible)) ?
formData.filter(item => item.sTbName.toUpperCase() === 'QuoQuotationManyQtys'.toUpperCase() && item.bGrdVisible)[0] : {};
let checkConfig = {};
let checkColumn = {};
if (commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName === "sysbillcheckresult"))) {
checkConfig = formData.find(item => item.bGrd && item.sTbName === "sysbillcheckresult");
checkColumn = commonFunc.getHeaderConfig(checkConfig);
}
let masterData = {
handleType: "add",
iPositiveColor: 4,
sFormId: sModelsId,
maxBillNo: "sBillNo",
sId: commonUtils.createSid(),
};
setState(prevState => ({
...prevState,
masterData,
formData,
masterConfig,
processConfig,
materialsConfig,
slaveConfig,
controlConfig,
colorConfig,
packConfig,
checkConfig,
manyqtysConfig,
selectedNode,
}));
}
})
.catch(error => {
console.error("获取主表信息失败:", error);
});
}, []);
const handleSaveState = (newValues, callback) => {
setState(prevState => {
const mergedState = { ...prevState, ...newValues };
// 确保回调在状态更新后执行
if (typeof callback === "function") {
// 使用 setTimeout 确保回调在下一个事件循环中执行
setTimeout(() => {
callback(mergedState);
}, 0);
}
return mergedState;
});
};
const { slaveData = [], packData = [], colorData = [], controlData = [], processData = [], materialsData = [] } = props;
// 初始化数据
useEffect(() => {
if (!isInitialized) {
const slaveRow = {
handleType: "add",
sId: commonUtils.createSid(),
key: commonUtils.createSid(),
sParentId: commonUtils.createSid(),
sNodeId: commonUtils.createSid(),
bDefault: false,
iOrder: 1,
};
slaveData.push(slaveRow);
const packRow = {
sId: commonUtils.createSid(),
handleType: "add",
sSlaveId: commonUtils.createSid(),
iOrder: 1,
sParentId: commonUtils.createSid(),
sControlId: commonUtils.createSid(),
dProductQty: 0,
dCombineQty: 1,
};
packData.push(packRow);
const controlRow = {
dSumPQty: 2,
iPrintMode: 0,
iPositiveColor: 4,
iOppositeColor: 4,
sSlaveId: " ",
iPrintModePo: 2,
handleType: "add",
sId: commonUtils.createSid(),
sParentId: commonUtils.createSid(),
key: commonUtils.createSid(),
bDefault: false,
iOrder: 1,
sCombinedMemo: "合版信息",
sAllId: commonUtils.createSid(),
dPartsQty: 0,
};
controlData.push(controlRow);
let masterData = {
handleType: "add",
iPositiveColor: 4,
maxBillNo: "sBillNo",
sFormId: sModelsId,
sId: commonUtils.createSid(),
};
setState(prevState => ({
...prevState,
slaveData,
packData,
controlData,
colorData,
processData,
materialsData,
masterData,
refreshData: true
}));
setIsInitialized(true);
}
}, [isInitialized, slaveData, packData, controlData, colorData, processData, materialsData]);
useEffect(() => {
if (isQuoConfig) return ''
if (!state?.masterConfig) return ''
if (!state?.masterData?.sId) return ''
const handleGetDataOne = async (sId, configDataId) => {
const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
const condition = {
pageNum: '',
pageSize: '',
sId
}
const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
if (dataReturn.code === 1) {
const returnData = dataReturn.dataset.rows[0].dataSet;
if (returnData && returnData.length) {
const { masterData } = state
const masterNew = {
...masterData,
...returnData[0],
}
const onGetFilterState = (state, bInit) => {
const result = Object.keys(state).reduce((pre, cur) => {
if (cur.endsWith("Column") || cur.endsWith("Config") || ["formData", "treeData", "downAbleConfigs", "finishedConfigs"].includes(cur)) {
return pre;
}
pre[cur] = state[cur];
return pre;
}, {});
const { slaveData = [], manyData = [], masterData = {} } = result;
const materialInfoFields = [
"sMaterialsName",
"sMaterialsNo",
"sMaterialsId",
"sAuxiliaryUnit",
"sMaterialsUnit",
"bReel",
"dCoefficient",
"bInverse",
"sMaterialsStyle",
"sComputeId",
"sReComputeId",
"dGramWeight",
"sReConversionComputeId",
"sConversionComputeId",
"sMaterialsType",
"bComMaterials",
"dWlcd",
"dWlkd",
];
const slaveDataNew = bInit
? slaveData.map(item => {
const { materialsInfo = [], sMaterialsName } = item;
if (!materialsInfo.length && sMaterialsName) {
return {
...item,
materialsInfo: [
materialInfoFields.reduce((pre, cur) => {
pre[cur] = item[cur];
return pre;
}, {}),
],
};
} else {
return item;
}
})
: slaveData;
const manyDataNew = manyData.map(item => {
delete item.manyData;
return item;
});
const { sType, sCustomerId, sCustomerName } = props.app.userinfo;
const bCustomer = sType === "Customer";
if (bCustomer && !masterData.sCustomerId) {
masterData.sCustomerName = sCustomerName;
masterData.sCustomerId = sCustomerId;
}
return { ...result, masterData, slaveData: slaveDataNew, manyData: manyDataNew };
};
const masterNewData = {
...masterNew,
handleType: masterNew.sBillNo ? 'update' : 'add'
}
masterNew.sBillNo && delete masterNewData.maxBillNo;
const sQuoConfig = commonUtils.convertStrToObj(masterNewData.sQuoConfig, {});
const sQuoData = onGetFilterState(sQuoConfig, true)
const { selectedNode, slaveData } = sQuoData
if (sQuoData) {
setState(prevState => ({
...prevState,
masterData: masterNewData,
selectedNode,
// slaveData,
// ...addStateSlave,
sQuoData: true,
isSlave: false,
}));
} else {
setState(prevState => ({
...prevState,
masterData: masterNewData,
sQuoData: false,
isSlave: false,
}));
}
setIsQuoConfig(true)
}
}
}
handleGetDataOne(quotationData?.sId, state?.masterConfig?.sId)
}, [state?.masterData?.sId]);
useEffect(() => {
if (!state?.masterData?.sId && !state?.slaveConfig && !state?.controlConfig && !state?.materialsConfig && !state?.processConfig && !state?.packConfig && !state?.colorConfig) return
const sId = state?.masterData?.sId || '';
const handleGetDataSets = async () => {
const addStateSlave = await props?.handleGetDataSet({
name: 'slave', configData: state?.slaveConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
const addStateControl = await props?.handleGetDataSet({
name: 'control', configData: state?.controlConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
const addStateMaterials = await props?.handleGetDataSet({
name: 'materials', configData: state?.materialsConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
const addStateProcess = await props?.handleGetDataSet({
name: 'process', configData: state?.processConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
const addStatePack = await props?.handleGetDataSet({
name: 'pack', configData: state?.packConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
const addStateSlave2 = await props?.handleGetDataSet({
name: 'slave', configData: state?.slaveConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
let addStateColor = {}
if (state?.colorConfig) {
addStateColor = await props.handleGetDataSet({
name: 'color', configData: state?.colorConfig, condition: { sSqlCondition: { sParentId: sId } }, isWait: true,
});
}
setState(prevState => ({
...prevState,
// ...addStateMaster,
...addStateSlave,
// ...addStateCheck,
...addStateProcess,
...addStateControl,
...addStateMaterials,
...addStatePack,
...addStateColor,
...addStateSlave2,
// ...addStateManyqtys,
isSlave: false,
loading: false,
}));
}
const { masterData } = state
const handleGetDataOne = async (sId, configDataId) => {
const dataUrl = `${commonConfig.server_host}business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}`;
const condition = {
pageNum: '',
pageSize: '',
sId
}
const dataReturn = (await commonServices.postValueService(token, condition, dataUrl)).data;
if (dataReturn.code === 1) {
const returnData = dataReturn.dataset.rows[0].dataSet;
if (returnData && returnData.length) {
const masterNew = {
...masterData,
sBillNo: returnData[0]?.sBillNo
}
delete masterNew.maxBillNo;
setState(prevState => ({
...prevState,
masterData: masterNew,
}));
await handleGetDataSets()
}
}
}
handleGetDataOne(state?.masterData?.sId, state?.masterConfig?.sId)
}, [reloadTrigger, state?.masterData?.sId])
const triggerReload = () => setReloadTrigger(prev => prev + 1);
// 确保 state 数据已加载
if (!state) {
return null; // 或者加载状态组件
}
return {
...props,
selectedNode: quotationData,
manyDataCache: [],
token,
getSqlDropDownData,
onMaterialsChange: handleMaterialsChange,
sortData,
handleCalculation,
onSaveState: handleSaveState,
onSaveData: handleSaveData,
onSubmit: handleSave,
isDraftSaved,
setIsDraftSaved,
triggerReload,
// onButtonClick: handleButtonClick,
...state,
};
};
// 遍历下所有配置sButtonEnabled的字段,生成配置
/* 获取表数据 */
/** 获取部件树 */
const handleGetControlTreeData = (props, controlData, isWait) => {
/* 生成部件树结构 */
let treeData = [];
if (isWait) {
return { treeData };
} else {
props.onSaveState({
treeData,
// expandedKeys,
});
}
};
const sortData = (tableData, processData) => {
processData.sort((g1, g2) => {
const iIndex1 = tableData.findIndex(item => item.sId === g1.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g1.sControlId);
if (g1.iOrder === undefined) {
g1.iOrder = '';
}
if (g2.iOrder === undefined) {
g2.iOrder = '';
}
let sPartOrder1 = `0000${iIndex1}`;
sPartOrder1 = sPartOrder1.substring(sPartOrder1.length - 3);
let sOrder1 = `00000${g1.iOrder.toString()}`;
sOrder1 = sOrder1.indexOf('.') > -1 ? sOrder1 : `${sOrder1}.00`;
sOrder1 = sOrder1.replace('.', '');
sOrder1 = sOrder1.substring(sOrder1.length - 5);
const iIndex2 = tableData.findIndex(item => item.sId === g2.sControlId) === -1 ? 999 : tableData.findIndex(item => item.sId === g2.sControlId);
let sPartOrder2 = `0000${iIndex2}`;
sPartOrder2 = sPartOrder2.substring(sPartOrder2.length - 3);
let sOrder2 = `00000${g2.iOrder.toString()}`;
sOrder2 = sOrder2.indexOf('.') > -1 ? sOrder2 : `${sOrder2}.00`;
sOrder2 = sOrder2.replace('.', '');
sOrder2 = sOrder2.substring(sOrder2.length - 5);
return parseFloat(sPartOrder1 + sOrder1) - parseFloat(sPartOrder2 + sOrder2);
});
return processData;
};
const handleMaterialsChange = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models) => {
const { sComputeId, sConversionComputeId, sReConversionComputeId } = tableDataRow;
if (
sFieldName === "sMaterialsNo" ||
sFieldName === "sMaterialsName" ||
sFieldName === "dAuxiliaryQty" ||
sFieldName === "dReelAuxiliaryQty" ||
sFieldName === "dConversionQty" ||
sFieldName === "sMaterialsStyle" ||
sFieldName === "dProductQty"
) {
if (sFieldName === "dReelAuxiliaryQty") {
if (tableDataRow.sMaterialsUnit === "吨" && tableDataRow.bReel && tableDataRow.dGramWeight > 0) {
tableDataRow = commonBusiness.getMaterialsQty(
app,
{ ...tableDataRow, sMaterialsStyle: tableDataRow.sReelMaterialsStyle },
"dReelAuxiliaryQty",
"dMaterialsQty"
);
tableDataRow.dAuxiliaryQty = tableDataRow.dMaterialsQty;
tableDataRow.sMaterialsStyle =
tableDataRow.sMaterialsStyle !== undefined && tableDataRow.sMaterialsStyle.split("*").length > 1
? tableDataRow.sMaterialsStyle.split("*")[0]
: tableDataRow.sMaterialsStyle;
tableDataRow.sAuxiliaryUnit = tableDataRow.sMaterialsUnit;
} else if (tableDataRow.sMaterialsUnit.toUpper() === "M2" && tableDataRow.bReel) {
tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, "dReelAuxiliaryQty", "dMaterialsQty");
tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty;
} else {
tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty;
}
}
if (commonUtils.isEmpty(sComputeId) && sFieldName !== "dConversionQty") {
if (sFieldName === "dProductQty") {
tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, "dProductQty", "dMaterialsQty");
} else {
tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, "dAuxiliaryQty", "dMaterialsQty");
}
} else if (!commonUtils.isEmpty(sComputeId)) {
tableDataRow.dMaterialsQty = await commonBusiness.getFormulaValue({
token,
sModelsId,
masterData,
tableDataRow,
sComputeId,
});
}
if (sFieldName !== "dConversionQty" && !commonUtils.isEmpty(sConversionComputeId)) {
tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({
token,
sModelsId,
masterData,
tableDataRow,
sComputeId: sConversionComputeId,
});
}
} else if (sFieldName === "dMaterialsQty") {
const { sReComputeId } = tableDataRow;
if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) {
tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, "dAuxiliaryQty");
} else if (tableDataRow.bInverse) {
tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({
token,
sModelsId,
masterData,
tableDataRow,
sComputeId: sReComputeId,
});
if (commonUtils.isNotEmptyArr(tableDataRow.dAuxiliaryQty) && tableDataRow.dAuxiliaryQty !== 0) {
tableDataRow.dProductQty = tableDataRow.dAuxiliaryQty;
}
}
if (!commonUtils.isEmpty(sReConversionComputeId)) {
tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({
token,
sModelsId,
masterData,
tableDataRow,
sComputeId: sReConversionComputeId,
});
}
} else if (sFieldName === "dAuxiliaryLossQty") {
if (commonUtils.isEmpty(sComputeId)) {
tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, sFieldName, "dLossQty");
} else {
tableDataRow.dLossQty = await commonBusiness.getFormulaValue({
token,
sModelsId,
masterData,
tableDataRow,
sComputeId,
});
}
if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) {
tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty;
tableDataRow.dMaterialsQty = commonUtils.convertFixNum(tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty, 6);
}
} else if (sFieldName === "dLossQty") {
const { sReComputeId } = tableDataRow;
if (commonUtils.isEmpty(sReComputeId)) {
tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, "dAuxiliaryLossQty");
} else {
tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({
token,
sModelsId,
masterData,
tableDataRow,
sComputeId: sReComputeId,
});
}
if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) {
tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty;
tableDataRow.dMaterialsQty = tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty;
}
} else if (sFieldName === "sProcessId" || sFieldName === "sProcessNo" || sFieldName === "sProcessName") {
const sProcessId = changeValue.sProcessId;
const url = `${commonConfig.server_host}process/outsideprocess?sModelsId=${sModelsId}&sProcessId=${sProcessId}`;
const dataReturn = (await commonServices.getService(token, url)).data;
if (dataReturn.code === 1) {
if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows)) {
tableDataRow.dMaterialsPrice = dataReturn.dataset.rows[0].dMaterialsPrice;
}
tableDataRow = commonBusiness.getCalculateAllMoney(app, models, "dMaterialsPrice", masterData, tableDataRow);
}
}
return tableDataRow;
};
// 计算数量
const handleCalculation = async (bSave, nextProps, isWait, props) => {
const dataUrl = `${commonConfig.server_host}business/addQuotationsheet?sModelsId=${nextProps.sModelsId}`;
const {
masterConfig,
slaveConfig,
slaveDelData,
controlConfig,
controlDelData,
colorConfig,
colorData,
colorDelData,
materialsConfig,
materialsDelData,
processConfig,
processDelData,
app,
manyqtysConfig,
manyqtysDelData,
packConfig,
packDelData,
manyDataCache = [],
} = nextProps;
const { dQuickQuoteProductQty, isChangeDProductQty } = props.state;
let { slaveData, controlData, materialsData, processData, masterData, manyqtysData, packData } = nextProps;
const sMakePerson = masterData.sMakePerson;
const data = [];
slaveData.forEach(item => {
if (dQuickQuoteProductQty) {
item.dProductQty = dQuickQuoteProductQty;
}
})
data.push(commonBusiness.mergeData("master", `${masterConfig.sTbName.toLowerCase()}_Tmp`, [masterData], [], true));
data.push(commonBusiness.mergeData("slave", `${slaveConfig.sTbName.toLowerCase()}_tmp`, slaveData, [], true));
data.push(commonBusiness.mergeData("control", `${controlConfig.sTbName.toLowerCase()}_tmp`, controlData, [], true));
data.push(commonBusiness.mergeData("materials", `${materialsConfig.sTbName.toLowerCase()}_tmp`, materialsData, [], true));
data.push(commonBusiness.mergeData("process", `${processConfig.sTbName.toLowerCase()}_tmp`, processData, [], true));
if (commonUtils.isNotEmptyObject(manyqtysConfig)) {
data.push(
commonBusiness.mergeData(
"manyqtys",
`${manyqtysConfig.sTbName.toLowerCase()}_tmp`,
manyqtysData?.map(item => {
delete item.manyData;
item.handleType = item.handleType || 'update';
return item;
}),
[],
true
)
);
}
data.push(commonBusiness.mergeData("pack", `${packConfig.sTbName.toLowerCase()}_tmp`, packData, [], true));
// 默认添加一个handleType状态
data.forEach(item => {
item.column.forEach(col => {
col.handleType = col.handleType || 'add'
})
})
const value = { data, sClientType: "1", sGuid: masterData.sId };
// const cacheIndex = dQuickQuoteProductQty === undefined ? -1 : manyDataCache.findIndex(item => item.dManyQty === dQuickQuoteProductQty);
const cacheIndex = -1
const calculating = commonFunc.showLocalMessage(props, 'calculating', '自动计算中,请稍后再试。');
Toast.show({
content: calculating,
});
const dataReturn = cacheIndex === -1 ? (await commonServices.postValueService(props.app.token, value, dataUrl)).data : manyDataCache[cacheIndex];
if (dataReturn.code === 1) {
/* 成功 */
const valueReturn = dataReturn.dataset.rows[0];
const masterDataArr = valueReturn[`${masterConfig.sTbName.toLowerCase()}_tmp`];
if (commonUtils.isNotEmptyArr(masterDataArr)) {
masterData = masterDataArr[0];
}
if (cacheIndex !== -1) {
// masterData.handleType = nextProps.masterData.handleType || "update";
masterData.sQuoConfig = nextProps.masterData.sQuoConfig;
masterData.sFormId = nextProps.masterData.sFormId;
masterData.sBillNo = nextProps.masterData.sBillNo;
}
// masterData.handleType = nextProps.handleType && nextProps.handleType === "update" ? "update" : "add";
masterData.handleType = masterData.sBillNo ? "update" : props.handleType ? props.handleType : 'add';
if (masterData.handleType === "update" && !commonUtils.isEmpty(sMakePerson)) {
masterData.sMakePerson = sMakePerson;
}
slaveData = valueReturn[`${slaveConfig.sTbName.toLowerCase()}_tmp`].map(item => {
item.handleType = dQuickQuoteProductQty ? "add" : item.handleType;
item.sId = commonUtils.createSid();
if (dQuickQuoteProductQty) {
item.dProductQty = dQuickQuoteProductQty;
}
// 这里需要改变数量 看看是否是多数量报价dProductQty
return item;
});
controlData = valueReturn[`${controlConfig.sTbName.toLowerCase()}_tmp`].map(item => {
item.handleType = dQuickQuoteProductQty ? "add" : item.handleType;
// item.sId = commonUtils.createSid();
return item;
});
materialsData = valueReturn[`${materialsConfig.sTbName.toLowerCase()}_tmp`].map(item => {
item.handleType = dQuickQuoteProductQty ? "add" : item.handleType;
// item.sId = commonUtils.createSid();
return item;
});
processData = valueReturn[`${processConfig.sTbName.toLowerCase()}_tmp`].map(item => {
item.handleType = dQuickQuoteProductQty ? "add" : item.handleType;
// item.sId = commonUtils.createSid();
return item;
});
processData = sortData(controlData, processData);
processData = processData.map((item, index) => ({
...item,
sCombinePartsName: slaveData[0].sId
}));
const addState = {};
if (commonUtils.isNotEmptyObject(manyqtysConfig)) {
const manyqtysDataOld = cloneDeep(manyqtysData);
manyqtysData = valueReturn[`${manyqtysConfig.sTbName.toLowerCase()}_tmp`]?.map((item, index) => {
return {
...item,
sId: manyqtysData[index] ? manyqtysData[index].sId : item.sId,
handleType: dQuickQuoteProductQty ? 'add' : (manyqtysDataOld[index]?.handleType || item.handleType)
}
});
if (cacheIndex === -1 && manyqtysData?.some(item => item.manyData)) {
addState.manyDataCache = manyqtysData.map((item, index) => {
let result = {};
if (index === 0) {
result = Object.keys(valueReturn).reduce((pre, cur) => {
if (cur !== `${manyqtysConfig.sTbName.toLowerCase()}_tmp`) {
pre[cur] = valueReturn[cur];
}
return pre;
}, {})
} else {
result = commonUtils.convertStrToObj(item.manyData);
}
result[`${manyqtysConfig.sTbName.toLowerCase()}_tmp`] = cloneDeep(manyqtysData).map(item => {
delete item.manyData;
return item;
});
const { sId, sBillNo, sFormId } = masterData;
const row = Object.keys(result).reduce((pre, cur) => {
if (cur === `${masterConfig.sTbName.toLowerCase()}_tmp`) {
pre[cur] = result[cur].map(item => ({
...item,
sId,
sBillNo: sBillNo || item.sBillNo,
sFormId,
}));
} else if (cur.includes('_tmp')) {
pre[cur] = result[cur].map(item => ({
...item,
sParentId: sId,
handleType: "add"
}))
} else {
pre[cur] = result[cur];
}
return pre;
}, {});
return {
code: 1,
dManyQty: item.dManyQty,
dataset: {
rows: [row],
}
}
});
}
}
packData = valueReturn[`${packConfig.sTbName.toLowerCase()}_tmp`];
/* 计算成功后自动调用保存 */
if (bSave) {
const data = [];
// masterData.handleType = "update";
// masterData.sFormId = commonUtils.createSid()
// masterData.sId = commonUtils.createSid();
if (masterData.sBillNo !== '') {
delete masterData.maxBillNo;
}
data.push(commonBusiness.mergeData("master", masterConfig.sTbName, [masterData]));
data.push(commonBusiness.mergeData("slave", slaveConfig.sTbName, slaveData, slaveDelData));
data.push(commonBusiness.mergeData("control", controlConfig.sTbName, controlData, controlDelData));
data.push(commonBusiness.mergeData("materials", materialsConfig.sTbName, materialsData, materialsDelData));
data.push(commonBusiness.mergeData("process", processConfig.sTbName, processData, processDelData));
if (commonUtils.isNotEmptyObject(manyqtysConfig)) {
data.push(commonBusiness.mergeData("manyqtys", manyqtysConfig.sTbName, manyqtysData, manyqtysDelData));
}
data.push(commonBusiness.mergeData("color", colorConfig.sTbName, colorData, colorDelData));
data.push(commonBusiness.mergeData("pack", packConfig.sTbName, packData, packDelData));
props.onSaveData(
{
data,
sClientType: "1",
loading: false,
sSysLogSrcId: masterData.sId,
},
props
);
props.onSaveState({
slaveData,
packData,
controlData,
materialsData,
processData,
masterData,
manyqtysData,
manyData: manyqtysData,
...addState,
});
// nextProps?.state?.setState({
// manyData:manyqtysData,
// })
} else {
// masterData.handleType = "update";
if (isWait) {
return {
slaveData,
controlData,
materialsData,
processData,
masterData,
manyqtysData,
loading: false,
packData,
handleType: "update",
...addState,
};
} else {
props.onSaveState({
slaveData,
controlData,
materialsData,
processData,
masterData,
manyqtysData,
loading: false,
packData,
...addState,
handleType: "update",
});
}
// message.success(commonFunc.getConfigShowName(masterConfig, "BtnCalculation") + commonFunc.showMessage(app.commonConst, "handleSuccess"));
}
} else {
/* 失败 */
// props.onSaveState({
// loading: false,
// });
Toast.show({
content: dataReturn.erroMsg,
});
props.triggerReload();
// props.getServiceError(dataReturn);
}
};
/** 按钮操作事件 */
const handleButtonClick = async (name, props) => {
if (name === "BtnDraft") {
const {
masterConfig,
masterData,
slaveConfig,
slaveData,
slaveDelData,
controlConfig,
controlData, // 需要
controlDelData,
materialsConfig,
materialsData,
materialsDelData,
processConfig,
processData,
processDelData,
colorConfig,
colorData,
colorDelData,
packConfig,
packData, // 需要
packDelData,
} = props;
const data = [];
slaveConfig.gdsconfigformslave.forEach(itemConfig => {
slaveData
.filter(itemData => itemData.handleType === "add" || itemData.handleType === "update")
.forEach(itemData => {
itemData.NoVerify = "NoVerify";
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] =
firstDataIndex === "s"
? ""
: firstDataIndex === "d" || firstDataIndex === "i"
? 0
: firstDataIndex === "b"
? false
: firstDataIndex === "t"
? moment(new Date()).format(props.app.dateFormat)
: undefined;
}
});
});
controlConfig.gdsconfigformslave.forEach(itemConfig => {
controlData
.filter(itemData => itemData.handleType === "add" || itemData.handleType === "update")
.forEach(itemData => {
itemData.NoVerify = "NoVerify";
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] =
firstDataIndex === "s"
? ""
: firstDataIndex === "d" || firstDataIndex === "i"
? 0
: firstDataIndex === "b"
? false
: firstDataIndex === "t"
? moment(new Date()).format(props.app.dateFormat)
: undefined;
}
});
});
materialsConfig.gdsconfigformslave.forEach(itemConfig => {
materialsData
.filter(itemData => itemData.handleType === "add" || itemData.handleType === "update")
.forEach(itemData => {
itemData.NoVerify = "NoVerify";
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] =
firstDataIndex === "s"
? ""
: firstDataIndex === "d" || firstDataIndex === "i"
? 0
: firstDataIndex === "b"
? false
: firstDataIndex === "t"
? moment(new Date()).format(props.app.dateFormat)
: undefined;
}
});
});
processConfig.gdsconfigformslave.forEach(itemConfig => {
processData
.filter(itemData => itemData.handleType === "add" || itemData.handleType === "update")
.forEach(itemData => {
itemData.NoVerify = "NoVerify";
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] =
firstDataIndex === "s"
? ""
: firstDataIndex === "d" || firstDataIndex === "i"
? 0
: firstDataIndex === "b"
? false
: firstDataIndex === "t"
? moment(new Date()).format(props.app.dateFormat)
: undefined;
}
});
});
if (commonUtils.isNotEmptyObject(packConfig)) {
packConfig.gdsconfigformslave.forEach(itemConfig => {
packData
.filter(itemData => itemData.handleType === "add" || itemData.handleType === "update")
.forEach(itemData => {
itemData.NoVerify = "NoVerify";
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] =
firstDataIndex === "s"
? ""
: firstDataIndex === "d" || firstDataIndex === "i"
? 0
: firstDataIndex === "b"
? false
: firstDataIndex === "t"
? moment(new Date()).format(props.app.dateFormat)
: undefined;
}
});
});
}
if (commonUtils.isNotEmptyObject(colorConfig)) {
colorConfig.gdsconfigformslave.forEach(itemConfig => {
colorData
?.filter(itemData => itemData.handleType === "add" || itemData.handleType === "update")
.forEach(itemData => {
itemData.NoVerify = "NoVerify";
const firstDataIndex = itemConfig.sName.substring(0, 1);
if (commonUtils.isEmpty(itemData[itemConfig.sName])) {
itemData[itemConfig.sName] =
firstDataIndex === "s"
? ""
: firstDataIndex === "d" || firstDataIndex === "i"
? 0
: firstDataIndex === "b"
? false
: firstDataIndex === "t"
? moment(new Date()).format(props.app.dateFormat)
: undefined;
}
});
});
}
if (masterData.sBillNo !== '') {
delete masterData.maxBillNo;
}
data.push(commonBusiness.mergeData("master", masterConfig.sTbName, [masterData]));
data.push(commonBusiness.mergeData("slave", slaveConfig.sTbName, slaveData, slaveDelData));
data.push(commonBusiness.mergeData("control", controlConfig.sTbName, controlData, controlDelData));
data.push(commonBusiness.mergeData("materials", materialsConfig.sTbName, materialsData, materialsDelData));
data.push(commonBusiness.mergeData("process", processConfig.sTbName, processData, processDelData));
if (commonUtils.isNotEmptyObject(colorConfig)) {
data.push(commonBusiness.mergeData("color", colorConfig.sTbName, colorData, colorDelData));
}
if (commonUtils.isNotEmptyObject(packConfig)) {
data.push(commonBusiness.mergeData("pack", packConfig.sTbName, packData, packDelData));
}
// 核价后保存
props.onSaveData(
{
data,
sClientType: "1",
loading: false,
sSysLogSrcId: masterData.sId,
bIsUnCcg: false,
},
props
), () => {
props.onSaveState({
masterData: { ...masterData },
});
};
}
};
const handleSaveData = async (params, props) => {
const {
token,
sModelsId,
currentId,
masterData,
masterConfig,
slaveConfig,
checkConfig,
billnosetting,
app,
sModelsType,
controlConfig,
materialsConfig,
processConfig,
colorConfig,
packConfig,
orderDetailConfig,
dispatch,
slaveChildConfig,
} = props;
const { userinfo } = app;
const { copyTo } = app.currentPane;
// const onSendSocketMessage = props.handleSendSocketMessage;
const BtnSave = commonFunc.showMessage(app.commonConst, "BtnSave"); /* 保存 */
params.optName = BtnSave;
const returnData = await commonBusiness.saveData({ token, value: params, sModelsId });
if (commonUtils.isNotEmptyObject(returnData)) {
if (commonUtils.isNotEmptyObject(copyTo)) {
const { slaveData } = copyTo;
const sIdArray = [];
slaveData.forEach(item => {
const redisKey = item.sSlaveId;
sIdArray.push(redisKey);
});
const sId = sIdArray.toString();
// onSendSocketMessage("copyfinish", "noAction", sId, userinfo.sId, null, null);
}
// onSendSocketMessage("release", "noAction", currentId, userinfo.sId, null, null);
Toast.show({
content: "保存成功",
});
// masterData.handleType = "update";
props.setIsDraftSaved(true);
props.onSaveState({
enabled: false,
currentId: masterData.sId,
masterData: { ...masterData },
});
// 保存后更新panes,currentPane的checkedId,防止浏览器刷新时重新又变成新增。
const iPaneIndex = app.panes.findIndex(item => item.key === app.currentPane.key);
app.panes[iPaneIndex].checkedId = masterData.sId;
app.currentPane.checkedId = masterData.sId;
// dispatch({ type: "app/savePanesAndCurrentPane", payload: { panes: app.panes, currentPane: app.currentPane } });
// if (billnosetting.bAutoCheck) {
// await this.handleAudit(1);
// } else {
// await this.handleGetData(masterConfig, slaveConfig, checkConfig);
// if ((sModelsType.includes("sales/salesOrder") || sModelsType.includes("manufacture/workOrder")) && !commonUtils.isEmpty(controlConfig)) {
// await this.handleGetMemoData(controlConfig, materialsConfig, processConfig, colorConfig, packConfig);
// } else if (sModelsType === "purchase/purchaseOrder") {
// await this.handleGetOneMemoData("orderDetail", orderDetailConfig);
// } else if (sModelsType === "sales/salesSgoods" && !commonUtils.isEmpty(slaveChildConfig)) {
// await this.handleGetOneMemoData("slaveChild", slaveChildConfig);
// }
// if (props.app.currentPane.refresh !== undefined) {
// props.app.currentPane.refresh();
// }
// }
// props.masterConfig.sId sModelsId
props.triggerReload();
return true;
} else {
props.onSaveState({
loading: false,
});
return false;
}
};
// 保存
const handleSave = async (skipCalculation, props) => {
/* 验证成功 */
const {
masterConfig,
masterData,
slaveConfig,
slaveData,
slaveDelData,
controlConfig,
controlData,
controlDelData,
colorConfig,
colorData,
colorDelData,
materialsConfig,
materialsData,
materialsDelData,
processConfig,
processData,
processDelData,
app,
manyqtysConfig,
manyqtysData,
manyqtysDelData,
packConfig,
packData,
packDelData,
state
} = props;
if (commonUtils.isEmptyArr(slaveData)) {
// message.warning(`从表${commonFunc.showMessage(props.app.commonConst, "isNotNull")}`);
props.onSaveState({
loading: false,
});
return;
}
if (
!commonBusiness.validateTable(slaveConfig, slaveData, props) ||
!commonBusiness.validateTable(controlConfig, controlData, props) ||
!commonBusiness.validateTable(materialsConfig, materialsData, props) ||
!commonBusiness.validateTable(processConfig, processData, props) ||
!commonBusiness.validateTable(colorConfig, colorData, props) ||
!commonBusiness.validateTable(packConfig, packData, props)
) {
props.onSaveState({
loading: false,
});
return;
}
const data = [];
if (masterData.sBillNo !== '') {
delete masterData.maxBillNo;
}
data.push(commonBusiness.mergeData("master", masterConfig.sTbName, [masterData]));
data.push(commonBusiness.mergeData("slave", slaveConfig.sTbName, slaveData, slaveDelData));
data.push(commonBusiness.mergeData("control", controlConfig.sTbName, controlData, controlDelData));
data.push(commonBusiness.mergeData("materials", materialsConfig.sTbName, materialsData, materialsDelData));
data.push(commonBusiness.mergeData("process", processConfig.sTbName, processData, processDelData));
if (commonUtils.isNotEmptyObject(manyqtysConfig)) {
data.push(commonBusiness.mergeData("manyqtys", manyqtysConfig.sTbName, manyqtysData, manyqtysDelData));
}
data.push(commonBusiness.mergeData("color", colorConfig.sTbName, colorData, colorDelData));
data.push(commonBusiness.mergeData("pack", packConfig.sTbName, packData, packDelData));
let skipFlag = 1; /* 默认不调用自动计算 若column有值 代表数据有更改 为0则调用自动计算 */
if (commonUtils.isNotEmptyArr(data)) {
for (const table of data) {
for (const key of Object.keys(table)) {
if (key.includes("column")) {
/* 只要一个column有值 代表有更改 要走自动计算 */
if (commonUtils.isNotEmptyArr(table[key])) {
skipFlag = 0;
break;
}
}
}
if (skipFlag === 0) {
/* skipFlag=0 代表不自动计算 */
break;
}
}
}
if ((skipFlag === 0 || masterData.bNoVerify) && !skipCalculation) {
const { masterData: masterData1 } = props
const newState = {
materialsConfig,
masterData: { ...masterData1, ...masterData },
slaveData,
controlData,
materialsData,
processData,
fastOrderModalVisible: false,
quotationAllprogress: 0,
materialsSelectedRowKeys: [],
...state.addState,
// bVisiblesInfo: !!commonUtils.isNotEmptyArr(sInfoArr),
Loading: false,
// quickQuoteModel: false,
};
delete newState.masterData.sQuoConfig;
const masterProps = {
...props,
};
handleCalculation(true, { ...masterProps, ...newState, state }, false, props);
} else {
props.onSaveData({
data,
sClientType: "1",
loading: false,
sSysLogSrcId: masterData.sId,
}, props);
}
};
/** 表格数据更改 */
// name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData)
const handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData, props) => {
/* 从CommonBase获取默认参数 */
if (name === "slave") {
const { sModelsId, [`${name}Data`]: tableData, masterConfig, controlConfig, controlData: controlDataOld, masterData, app, packData } = props;
const { dNetMoney } = app.decimals;
let tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
const iIndex = tableData.findIndex(item => item.sId === sId);
tableData[iIndex] = tableDataRow;
let bCkxNoTaxProcessPrice = "0";
const filterData = app.systemData.filter(item => item.sName === "CkxNoTaxProcessPrice");
if (commonUtils.isNotEmptyArr(filterData) && filterData.length > 0) {
bCkxNoTaxProcessPrice = filterData[0].sValue;
}
const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(tableDataRow.dCurrencyRate); /* 汇率 */
const addState = {};
/* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */
let bProductQtySelf = false;
if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) {
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "bProductQtySelf");
if (iIndex > -1) {
bProductQtySelf = true;
}
}
if (sFieldName === "dProductQty" || sFieldName === "dGiveQty" || sFieldName === "dStockupQty") {
let dPartsQty = 0;
tableData.forEach(item => {
if (bProductQtySelf) {
dPartsQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dPartsQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
/* 找到所有一级部件 */
const controlRootData = commonUtils.isNotEmptyArr(controlDataOld)
? controlDataOld.filter(item => commonUtils.isEmpty(item.sControlParentId))
: [];
if (commonUtils.isNotEmptyArr(controlRootData)) {
controlRootData.forEach(item => {
let itemNew = { ...item };
/* 父级的dPartsQty为dPartsQty */
itemNew.dPartsQty = dPartsQty;
itemNew = singlePQtyChange(itemNew);
/* 找到子部件 */
const controlChildData = controlDataOld.filter(
itemOld => commonUtils.isNotEmptyObject(itemOld.sAllId) && itemOld.sAllId.indexOf(item.sId) > -1 && itemOld.sId !== item.sId
);
if (commonUtils.isNotEmptyArr(controlChildData)) {
const { dMachineQty } = itemNew;
controlChildData.forEach(child => {
let tableDataRow = { ...child };
const iIndex = controlDataOld.findIndex(item => item.sId === child.sId);
if (iIndex > -1) {
/* 子部件部件数量为父部件上机数量 */
tableDataRow.dPartsQty = dMachineQty;
tableDataRow = singlePQtyChange(tableDataRow);
controlDataOld[iIndex] = tableDataRow;
}
});
}
const addStata = {};
addStata.dPartsQty = dPartsQty;
const iRootIndex = controlDataOld.findIndex(itemControl => itemControl.sId === item.sId);
controlDataOld[iRootIndex] = { ...controlDataOld[iRootIndex], ...itemNew };
});
}
addState.controlData = controlDataOld;
} else if (sFieldName === "sCustomerId" || sFieldName === "sCustomerNo" || sFieldName === "sCustomerName") {
// commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductId', []);
// commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductNo', []);
// commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductName', []);
tableDataRow.sProductId = "";
tableDataRow.sProductNo = "";
tableDataRow.sProductName = "";
tableData[iIndex] = tableDataRow;
} else if (
(sFieldName === "dProductMoney" || sFieldName === "dProductPrice" || sFieldName === "dProductForeignMoney") &&
!commonUtils.isEmpty(tableDataRow.dStandardMoney)
) {
let dProductMoney = commonUtils.isNull(tableDataRow.dProductMoney, 0);
if (sFieldName === "dProductForeignMoney") {
const dProductForeignMoney = commonUtils.isNull(tableDataRow.dProductForeignMoney, 0);
dProductMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? dProductForeignMoney * dCurrencyRate : 0, dNetMoney); /* 本位币金额 */
}
/* 不启用工序价格不含税 则计算利润时 无需减掉含税金额 */
if (bCkxNoTaxProcessPrice === "0") {
tableDataRow.dProfitMoney = commonUtils.convertFixNum(
commonUtils.isNull(dProductMoney, 0) -
commonUtils.isNull(tableDataRow.dStandardMoney, 0) -
commonUtils.isNull(masterData.dPackMoney, 0) -
commonUtils.isNull(masterData.dTransportMoney, 0),
dNetMoney
);
} else {
tableDataRow.dProfitMoney = commonUtils.convertFixNum(
commonUtils.isNull(dProductMoney, 0) -
commonUtils.isNull(tableDataRow.dProductTaxMoney, 0) -
commonUtils.isNull(tableDataRow.dStandardMoney, 0) -
commonUtils.isNull(masterData.dPackMoney, 0) -
commonUtils.isNull(masterData.dTransportMoney, 0),
dNetMoney
);
}
// eslint-disable-next-line no-mixed-operators
tableDataRow.dProfitRate =
commonUtils.isNull(tableDataRow.dStandardMoney, 0) !== 0
? commonUtils.convertFixNum(
(commonUtils.isNull(tableDataRow.dProfitMoney, 0) / commonUtils.isNull(tableDataRow.dStandardMoney, 0)) * 100,
2
)
: 0;
} else if (sFieldName === "dProfitRate" && !commonUtils.isEmpty(tableDataRow.dStandardMoney)) {
/* 利润 = 标准金额 dStandMoney * 利润率 dProfitRate */
tableDataRow.dProfitMoney = commonUtils.convertFixNum(
commonUtils.isNull(tableDataRow.dStandardMoney, 0) * (commonUtils.isNull(tableDataRow.dProfitRate, 0) / 100),
dNetMoney
);
if (bCkxNoTaxProcessPrice === "0") {
/* 不启用 则计算利润时 无需减掉含税金额 */
tableDataRow.dProductMoney = commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0);
} else {
/* 启用工序价格含税 代表金额已含税 */
// eslint-disable-next-line no-mixed-operators
tableDataRow.dProductMoney = commonUtils.convertFixNum(
(commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0)) * (1 + tableDataRow.dTaxRate / 100),
dNetMoney
);
}
tableDataRow = commonBusiness.getCalculateAllMoney(app, "Product", "dProductMoney", masterData, tableDataRow);
} else if (sFieldName === "dTaxRate" || sFieldName === "sTaxId" || sFieldName === "sTaxName") {
// eslint-disable-next-line no-mixed-operators
const iIndex = app.systemData.findIndex(item => item.sName === "CkxNoTaxProcessPrice");
if (iIndex > -1 && app.systemData[iIndex] === "1") {
if (
!commonUtils.isEmpty(tableDataRow.dStandardMoney) &&
!commonUtils.isEmpty(tableDataRow.dProfitMoney) &&
!commonUtils.isEmpty(tableDataRow.dTaxRate)
) {
// eslint-disable-next-line no-mixed-operators
tableDataRow.dProductMoney = commonUtils.convertFixNum(
(commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0)) *
(1 + tableDataRow.dTaxRate / 100),
dNetMoney
);
tableDataRow = commonBusiness.getCalculateAllMoney(app, "Product", "dProductMoney", masterData, tableDataRow);
}
}
} else if (sFieldName === "sProductId" || sFieldName === "sProductNo" || sFieldName === "sProductName") {
// const productIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'slave', sFieldName);
const iProductIdIndex = dropDownData.findIndex(item => item.sId === tableData[0].sProductId);
if (tableDataRow.handleType === "add" && iProductIdIndex > -1 && tableDataRow.sProductId !== tableDataRow.sProductName) {
if (!commonUtils.isEmpty(tableDataRow.sProductId) && commonUtils.isEmptyArr(controlDataOld)) {
const changeData = dropDownData[iProductIdIndex];
const sParentId = commonUtils.isEmpty(changeData) ? "" : changeData.sParentId;
if (!commonUtils.isEmpty(sParentId)) {
const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === "sProductClassifyName");
if (iIndex > -1) {
let dProductQty = 0;
tableData.forEach(item => {
if (bProductQtySelf) {
dProductQty += commonUtils.isNull(item.dProductQty, 0);
} else {
dProductQty +=
commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0);
}
});
const sqlDropDownData = await props.getSqlDropDownData(sModelsId, "master", masterConfig.gdsconfigformslave[iIndex]);
const dropDownData = sqlDropDownData.dropDownData;
const [changeData] = dropDownData.filter(item => item.sId === sParentId);
const sAllPartsName = commonUtils.isEmpty(changeData) ? "" : changeData.sAllPartsName;
if (commonUtils.isNotEmptyStr(sAllPartsName)) {
const sAssignFieldObj = sAllPartsName.split(",");
const controlData = [];
for (const child of sAssignFieldObj) {
let allTableData = {};
allTableData = {};
allTableData.master = masterData;
allTableData.slave = commonUtils.isEmptyArr(tableData) ? {} : tableData[0];
const tableDataRow = commonFunc.getDefaultData(controlConfig, allTableData);
tableDataRow.handleType = "add";
tableDataRow.sId = commonUtils.createSid();
tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null;
tableDataRow.key = tableDataRow.sId;
tableDataRow.bDefault = false;
tableDataRow.iOrder = controlData.length + 1;
tableDataRow.sPartsName = child;
tableDataRow.dPartsQty = dProductQty;
tableDataRow.sAllId = tableDataRow.sId;
tableDataRow.sControlParentId = "";
controlData.push(tableDataRow);
}
addState.controlData = controlData;
}
}
}
}
}
/* 从表产品改变带动合版表产品与部件表合版信息 同步改变 */
const controlDataNew = commonUtils.isNotEmptyArr(addState.controlData) ? addState.controlData : controlDataOld;
/* 如果packData只有一条数据 则同步合版数据 及增加控制表合版备注 */
if (commonUtils.isNotEmptyArr(packData) && packData.length === 1 && packData[0].sSlaveId === tableDataRow.sId) {
let packDataRow = packData[0];
const sControlId = packDataRow.sControlId;
packDataRow = handlePackDataAdd(tableDataRow, 0, sControlId);
packDataRow.dCombineQty = 1;
packData[0] = { ...packData[0], ...packDataRow };
if (commonUtils.isNotEmptyObject(packData[0])) {
const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[0];
const tableCombineSelectedData = [];
const jsonObj = {};
jsonObj.sId = sId;
jsonObj.sProductNo = sProductNo; /* 产品编号 */
jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */
jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
tableCombineSelectedData.push(jsonObj);
const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData)
? JSON.stringify(tableCombineSelectedData)
: ""; /* JSON对象转换为字符串存放到合版信息中 */
// const controlDataNew =commonUtils.isNotEmptyArr(addState.controlData)? addState.controlData: controlDataOld;
if (commonUtils.isNotEmptyArr(controlDataNew)) {
const iControlIndex = controlDataNew.findIndex(item => item.sId === sControlId);
if (iControlIndex > -1) {
controlDataNew[iControlIndex].sCombinedMemo = sCombinedMemo;
controlDataNew[iControlIndex].sPartsName = tableDataRow.sProductName;
}
addState.controlData = controlDataNew;
}
}
} else if (packData.length > 1) {
const packFilterData = packData.filter(item => item.sSlaveId === tableDataRow.sId);
if (commonUtils.isNotEmptyArr(packFilterData)) {
packFilterData.forEach((itemPack, index) => {
let packDataRow = itemPack;
const sControlId = packDataRow.sControlId;
packDataRow = handlePackDataAdd(tableDataRow, 0, sControlId);
// packDataRow.dCombineQty = 1;
const pIndex = packData.findIndex(item => item.sId === itemPack.sId);
if (pIndex > -1) {
packData[pIndex] = { ...packData[pIndex], ...packDataRow }; /* 根据选中的从表 找到所有的合版数据,将合版数据中的产品换成切换后的产品 */
let sCombinedMemoStr = ""; /* 将控制表合版信息中的产品换成新选择的产品 */
if (commonUtils.isNotEmptyArr(controlDataNew)) {
const iControlIndex = controlDataNew.findIndex(item => item.sId === sControlId);
if (iControlIndex > -1) {
sCombinedMemoStr = controlDataNew[iControlIndex].sCombinedMemo;
if (sCombinedMemoStr) {
const sCombinedMemoArr = commonUtils.isNotEmptyObject(sCombinedMemoStr) ? JSON.parse(sCombinedMemoStr) : {};
if (commonUtils.isNotEmptyArr(sCombinedMemoArr)) {
const iIndex = sCombinedMemoArr.findIndex(item => item.sId === itemPack.sId);
if (iIndex > -1) {
const addState = {};
addState.sProductId = tableDataRow.sProductId; /* 产品id */
addState.sCustomerId = tableDataRow.sCustomerId; /* 客户id */
addState.sCustomerName = tableDataRow.sCustomerName; /* 客户名称 */
addState.sProductName = tableDataRow.sProductName; /* 产品名称 */
addState.sProductNo = tableDataRow.sProductNo; /* 产品编号 */
sCombinedMemoArr[iIndex] = { ...sCombinedMemoArr[iIndex], ...addState };
const sCombinedMemo = commonUtils.isNotEmptyArr(sCombinedMemoArr)
? JSON.stringify(sCombinedMemoArr)
: ""; /* JSON对象转换为字符串存放到合版信息中 */
controlDataNew[iControlIndex].sCombinedMemo = sCombinedMemo;
controlDataNew[iControlIndex].sPartsName = tableDataRow.sProductName;
}
}
}
}
}
}
});
addState.controlData = controlDataNew;
}
}
addState.packData = packData;
}
props.onSaveState({ [`${name}Data`]: tableData, ...addState });
} else if (name === "control") {
const {
[`${name}Data`]: tableData,
materialsData: materialsDataOld,
processData: processDataOld,
sModelsType,
packData,
slaveSelectedRowKeys,
slaveData,
} = props;
let tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
if (
sFieldName === "dSinglePQty" ||
sFieldName === "dPartsQty" ||
sFieldName === "dSumPQty" ||
sFieldName === "iPrintModePo" ||
sFieldName === "iPrintMode" ||
sFieldName === "iPrintModePo" ||
sFieldName === "iPositiveColor" ||
sFieldName === "iPositiveSpecialColor" ||
sFieldName === "iOppositeColor" ||
sFieldName === "iOppositeSpecialColor"
) {
if (sFieldName === "iPrintModePo") {
if (tableDataRow.iPrintModePo === 0) {
tableDataRow.iPrintMode = 3;
if (tableDataRow.iPositiveColor === 0) {
tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = 0;
tableDataRow.iOppositeSpecialColor = 0;
} else {
tableDataRow.iOppositeColor = 0;
tableDataRow.iOppositeSpecialColor = 0;
}
} else if (tableDataRow.iPrintModePo === 1) {
tableDataRow.iPrintMode = 3;
if (tableDataRow.iPositiveColor === 0) {
tableDataRow.iPositiveColor = 0;
tableDataRow.iPositiveSpecialColor = 0;
tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? 4 : tableDataRow.iOppositeColor;
} else {
tableDataRow.iPositiveColor = 0;
tableDataRow.iPositiveSpecialColor = 0;
}
} else {
tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor;
}
} else if (sFieldName === "iPrintMode") {
if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) {
tableDataRow.iPositiveColor =
commonUtils.isEmpty(tableDataRow.iPositiveColor) || tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = tableDataRow.iPositiveColor;
tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor;
} else if (tableDataRow.iPrintMode === 2) {
tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor;
} else if (tableDataRow.iPrintMode === 3) {
tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor;
tableDataRow.iOppositeColor = 0;
tableDataRow.iOppositeSpecialColor = 0;
} else if (tableDataRow.iPrintMode === 4) {
tableDataRow.iPositiveColor = 0;
tableDataRow.iPositiveSpecialColor = 0;
tableDataRow.iOppositeColor = 0;
tableDataRow.iOppositeSpecialColor = 0;
}
} else if (sFieldName === "iPositiveColor" || sFieldName === "iPositiveSpecialColor") {
if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) {
tableDataRow.iOppositeColor = tableDataRow.iPositiveColor;
tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor;
}
} else if (sFieldName === "dSinglePQty") {
/* 排版数改变时 如果该控制表合版数据只有一条 则改变packData该条的拼版数 改变备注 */
if (commonUtils.isNotEmptyArr(packData)) {
const packFilterData = packData.filter(item => item.sControlId === tableDataRow.sId);
if (commonUtils.isNotEmptyArr(packFilterData) && packFilterData.length === 1) {
const iIndex = packData.findIndex(itemPack => itemPack.sId === packFilterData[0].sId);
const addState = {};
if (tableDataRow.dSinglePQty > 0) {
addState.dCombineQty = tableDataRow.dSinglePQty;
addState.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? "update" : tableDataRow.handleType;
if (iIndex > -1) {
packData[iIndex] = { ...packData[iIndex], ...addState };
const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[iIndex];
const tableCombineSelectedData = [];
const jsonObj = {};
jsonObj.sId = sId;
jsonObj.sProductNo = sProductNo; /* 产品编号 */
jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */
jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
tableCombineSelectedData.push(jsonObj);
const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData)
? JSON.stringify(tableCombineSelectedData)
: ""; /* JSON对象转换为字符串存放到合版信息中 */
tableDataRow.sCombinedMemo = commonUtils.isNotEmptyObject(sCombinedMemo) ? sCombinedMemo : "合版信息";
}
}
}
}
}
tableDataRow = singlePQtyChange(tableDataRow);
/* 上机数量改变时,子级部件数量同步改变 */
const { dMachineQty } = tableDataRow;
/* 查找该节的所有子节点,将上机数量改为部件数量 */
tableData.forEach((item, index) => {
if (commonUtils.isNotEmptyObject(item.sAllId) && item.sAllId.indexOf(tableDataRow.sId) > -1 && item.sId !== tableDataRow.sId) {
const addstate = {};
addstate.dPartsQty = dMachineQty;
tableData[index] = { ...tableData[index], ...addstate };
}
});
}
if (
sFieldName === "dPartsLength" ||
sFieldName === "dPartsWidth" ||
sFieldName === "dMachineLength" ||
sFieldName === "dMachineWidth" ||
sFieldName === "sPrintingPlate" ||
sFieldName === "sCutMethod" ||
sFieldName === "sSpineDirection" ||
sFieldName === "iPrintMode" ||
sFieldName === "dBite" ||
sFieldName === "dBlood"
) {
/* 计算材料开数 */
if (true) {
// if (commonUtils.isNotEmptyArr(slaveData)) {
// dProductLength = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[0] : 0;
// dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(dProductLength, 0)); /* 产品长 */
// dProductLength = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductLength : 0; /* 产品长 */
// dProductWidth = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[1] : 0;
// dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(dProductWidth, 0)); /* 产品宽 */
// dProductWidth = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductWidth : 0; /* 产品宽 */
// }
let slaveDataRow = {};
if (commonUtils.isNotEmptyArr(slaveData)) {
if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
slaveDataRow = slaveData[0];
} else if (commonUtils.isEmptyObject(tableDataRow.sCombinedMemo) || tableDataRow.sCombinedMemo === "合版信息") {
const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId));
if (iIndex > -1) {
slaveDataRow = slaveData[iIndex];
}
} else {
const iIndex = slaveData.findIndex(item => tableDataRow.sCombinedMemo.includes(item.sProductNo));
if (iIndex > -1) {
slaveDataRow = slaveData[iIndex];
}
}
}
if (commonUtils.isNotEmptyObject(slaveDataRow)) {
/* 如果有展开尺寸 则取展开尺寸 否则取产品规格 */
let sProductStyle = "";
if (slaveDataRow.sPartsStyle) {
sProductStyle = slaveDataRow.sPartsStyle;
} else if (slaveDataRow.sProductStyle) {
sProductStyle = slaveDataRow.sProductStyle;
}
if (sProductStyle) {
let dProductLength = !commonUtils.isEmpty(sProductStyle) && sProductStyle.split("*").length > 1 ? sProductStyle.split("*")[0] : 0;
dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(dProductLength, 0)); /* 产品长 */
dProductLength = typeof dProductLength === "number" && !isNaN(dProductLength) ? dProductLength : 0; /* 产品长 */
let dProductWidth = !commonUtils.isEmpty(sProductStyle) && sProductStyle.split("*").length > 1 ? sProductStyle.split("*")[1] : 0;
dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(dProductWidth, 0)); /* 产品宽 */
dProductWidth = typeof dProductLength === "number" && !isNaN(dProductLength) ? dProductWidth : 0; /* 产品宽 */
tableDataRow.dPartsWidth = dProductLength;
tableDataRow.dPartsLength = dProductWidth;
/* 控制表增加 如果 产品长>产品宽 sSpineDirection 默认1 否则 2 */
if (dProductLength > dProductWidth) {
tableDataRow.sSpineDirection = "2"; /* 短书脊 */
} else {
tableDataRow.sSpineDirection = "1"; /* 长书脊 */
}
tableDataRow.sCutMethod = "2"; /* 默认四边裁 */
tableDataRow.sPrintingPlate = "1"; /* 默认四边裁 */
}
}
const dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dPartsWidth, 0)); /* 产品长 */
const dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dPartsLength, 0)); /* 产品宽 */
const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */
const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */
// const dMaterialsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsLength, 0)); /* 材料长 */
// const dMaterialsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsWidth, 0)); /* 材料宽 */
/* 算材料开数 */
// const mapMaterialsKQty = props.onResolveMachineComposing(dMachineLength, dMachineWidth, dMaterialsLength, dMaterialsWidth);
// if (commonUtils.isNotEmptyObject(mapMaterialsKQty)) {
// const dMaterialsKQty = mapMaterialsKQty.totalNum;
// tableDataRow.dMaterialsKQty = dMaterialsKQty;
// }
/* 根据裁切方式、脊背方向、版式方向进行计算排版数 */
if (dProductLength !== 0 && dProductWidth !== 0) {
const dSinglePQty = props.onResolveSinglePQty(tableDataRow);
if (commonUtils.isNotEmptyNumber(dSinglePQty)) {
tableDataRow.dSinglePQty = dSinglePQty;
}
}
/* 算拼版数 */
// if (dProductLength !== 0 && dProductWidth !== 0) {
// const mapSinglePQty = props.onResolveMachineComposing(dProductLength, dProductWidth, dMachineLength, dMachineWidth);
// if (commonUtils.isNotEmptyObject(mapSinglePQty)) {
// const dSinglePQty = mapSinglePQty.totalNum;
// tableDataRow.dSinglePQty = dSinglePQty;
// }
// }
if (commonUtils.isNotEmptyArr(packData)) {
const packFilterData = packData.filter(item => item.sControlId === tableDataRow.sId);
if (commonUtils.isNotEmptyArr(packFilterData) && packFilterData.length === 1) {
const iIndex = packData.findIndex(itemPack => itemPack.sId === packFilterData[0].sId);
const addState = {};
if (tableDataRow.dSinglePQty > 0) {
addState.dCombineQty = tableDataRow.dSinglePQty;
addState.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? "update" : tableDataRow.handleType;
if (iIndex > -1) {
packData[iIndex] = { ...packData[iIndex], ...addState };
const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[iIndex];
const tableCombineSelectedData = [];
const jsonObj = {};
jsonObj.sId = sId;
jsonObj.sProductNo = sProductNo; /* 产品编号 */
jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */
jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
tableCombineSelectedData.push(jsonObj);
const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData)
? JSON.stringify(tableCombineSelectedData)
: ""; /* JSON对象转换为字符串存放到合版信息中 */
tableDataRow.sCombinedMemo = commonUtils.isNotEmptyObject(sCombinedMemo) ? sCombinedMemo : "合版信息";
}
}
}
} else {
/* packData没数据时 */
const packDataRow = handlePackDataAdd(slaveItem, 0, tableDataRow.sId, "add");
packDataRow.dCombineQty = tableDataRow.dSinglePQty;
packDataRow.dFactProductQty = commonUtils.isNull(slaveItem.dProductQty, 0); /* 排版数为1时,实际生产数 = 产品数 */
if (tableDataRow.dSinglePQty > 0) {
const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packDataRow;
const tableCombineSelectedData = [];
const jsonObj = {};
jsonObj.sId = sId;
jsonObj.sProductNo = sProductNo; /* 产品编号 */
jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */
jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */
jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */
jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
tableCombineSelectedData.push(jsonObj);
const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData)
? JSON.stringify(tableCombineSelectedData)
: ""; /* JSON对象转换为字符串存放到合版信息中 */
tableDataRow.sCombinedMemo = commonUtils.isNotEmptyObject(sCombinedMemo) ? sCombinedMemo : "合版信息";
packData.push(packDataRow);
}
}
}
} else if (sModelsType.includes("quotation/quotation")) {
/* 计算材料开数 */
// if (sFieldName === 'dMachineLength' || sFieldName === 'dMachineWidth' || sFieldName === 'dMaterialsLength' || sFieldName === 'dMaterialsWidth') {
// let dProductLength = 0; /* 产品长 */
// let dProductWidth = 0; /* 产品宽 */
// if (commonUtils.isNotEmptyArr(slaveData)) {
// dProductLength = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[0] : 0;
// dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(dProductLength, 0)); /* 产品长 */
// dProductLength = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductLength : 0; /* 产品长 */
// dProductWidth = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[1] : 0;
// dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(dProductWidth, 0)); /* 产品宽 */
// dProductWidth = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductWidth : 0; /* 产品宽 */
// }
// const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */
// const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */
// const dMaterialsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsLength, 0)); /* 材料长 */
// const dMaterialsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsWidth, 0)); /* 材料宽 */
//
// /* 算材料开数 */
// const mapMaterialsKQty = props.onResolveMachineComposing(dMachineLength, dMachineWidth, dMaterialsLength, dMaterialsWidth);
// if (commonUtils.isNotEmptyObject(mapMaterialsKQty)) {
// const dMaterialsKQty = mapMaterialsKQty.totalNum;
// tableDataRow.dMaterialsKQty = dMaterialsKQty;
// }
//
// /* 算拼版数 */
// if (dProductLength !== 0 && dProductWidth !== 0) {
// const mapSinglePQty = props.onResolveMachineComposing(dProductLength, dProductWidth, dMachineLength, dMachineWidth);
// if (commonUtils.isNotEmptyObject(mapSinglePQty)) {
// const dSinglePQty = mapSinglePQty.totalNum;
// tableDataRow.dSinglePQty = dSinglePQty;
// }
// }
// }
}
const materialsData = [];
const processData = [];
materialsDataOld.forEach(item => {
const itemNew = { ...item };
if (itemNew.sControlId === sId) {
itemNew.sPartsName = tableDataRow.sPartsName;
}
materialsData.push(itemNew);
});
processDataOld.forEach(item => {
const itemNew = { ...item };
if (itemNew.sControlId === sId) {
itemNew.sPartsName = tableDataRow.sPartsName;
}
processData.push(itemNew);
});
const materialsDataNew = sortData(tableData, materialsData);
const processDataNew = sortData(tableData, processData);
if (sFieldName === "sPartsName") {
/* 部件名称与子部件同步 */
const { sPartsName } = tableDataRow;
const { treeSelectedKeys, treeData } = props;
if (commonUtils.isNotEmptyArr(treeSelectedKeys)) {
handleSearchNodes(treeSelectedKeys[0], treeData, sPartsName);
}
}
const iIndex = tableData.findIndex(item => item.sId === sId);
tableData[iIndex] = tableDataRow;
props.onSaveState({ [`${name}Data`]: tableData, materialsData: materialsDataNew, processData: processDataNew, packData });
} else if (name === "materials") {
const { [`${name}Data`]: tableData, controlData, controlSelectedRowKeys, app, sModelsId } = props;
const tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === "dMaterialsStockAuxiliaryQty") > -1) {
const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsStock = {
sProName: "Sp_Inventory_MaterialsInventoryV56",
paramsMap: {
sMaterialsGuid: tableDataRow.sMaterialsId,
sMaterialsStyle: tableDataRow.sMaterialsStyle,
sWarehouseGuid: tableDataRow.sWarehouseId,
sLocationalGuid: tableDataRow.sLocationId,
sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId,
sDefine_no: tableDataRow.sDefineNo,
sDefine_no2: tableDataRow.sDefineNo2,
iGetQty: 1,
iHasZero: 1,
},
};
const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data;
if (returnDataMaterialsStock.code === 1) {
tableDataRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === "dMaterialsStockAvailableQty") > -1) {
const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`;
const valueMaterialsAvailableQty = {
sProName: "Sp_Inventory_MaterialsInventoryV56",
paramsMap: {
sMaterialsGuid: tableDataRow.sMaterialsId,
sMaterialsStyle: tableDataRow.sMaterialsStyle,
sWarehouseGuid: tableDataRow.sWarehouseId,
sLocationalGuid: tableDataRow.sLocationId,
sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId,
sDefine_no: tableDataRow.sDefineNo,
sDefine_no2: tableDataRow.sDefineNo2,
iGetQty: 2,
iHasZero: 1,
},
};
const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty))
.data;
if (returnDataMaterialsAvailableQty.code === 1) {
tableDataRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty;
}
}
const iIndex = tableData.findIndex(item => item.sId === sId);
if (iIndex > -1) {
tableData[iIndex] = tableDataRow;
}
if (sFieldName === "sType") {
if (tableData[iIndex].sType === "2") {
tableData[iIndex].sControlId = "";
tableData[iIndex].sPartsName = "";
} else {
const iControlIndex = commonUtils.isEmptyArr(controlSelectedRowKeys)
? -1
: controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]);
if (iControlIndex > -1) {
tableData[iIndex].sControlId = controlData[iControlIndex].sId;
tableData[iIndex].sPartsName = controlData[iControlIndex].sPartsName;
}
}
}
props.onSaveState({ [`${name}Data`]: tableData });
} else if (name === "materials0" || name === "materials1" || name === "materials2" || name === "materials0Child") {
name = "materials";
const { [`${name}Data`]: tableData, controlData, controlSelectedRowKeys, materials0Data, materials0SelectedRowKeys } = props;
let oldRowMap = {};
if (sFieldName === "sInkBOM") {
const iOldIndex = tableData.findIndex(item => item.sId === sId);
if (iOldIndex > -1) {
const tableDataOldRow = JSON.parse(JSON.stringify(tableData[iOldIndex]));
oldRowMap = {
sInkBOMId: tableDataOldRow.sInkBOMId,
sInkBOMsSlaveId: tableDataOldRow.sInkBOMsSlaveId,
sInkBOMsMaterialsId: tableDataOldRow.sInkBOMsMaterialsId,
};
}
}
const tableDataRow = await props.onDataChange("materials", sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
tableDataRow.oldRowMap = oldRowMap;
const iIndex = tableData.findIndex(item => item.sId === sId);
if (iIndex > -1) {
tableData[iIndex] = tableDataRow;
}
props.onSaveState({ [`${name}Data`]: tableData });
} else if (name === "materialsChild") {
/* 替代料 */
name = "materials";
const { [`${name}Data`]: tableData, controlData, controlSelectedRowKeys, materials0Data, materials0SelectedRowKeys } = props;
const tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (sFieldName === "dPackageQty") {
if (commonUtils.isNotEmptyArr(controlSelectedRowKeys)) {
const iControlIndex = controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]);
if (iControlIndex > -1) {
tableDataRow.dAuxiThousheetQty = ((controlData[iControlIndex].dSinglePQty * 1000.0) / tableDataRow.dPackageQty).toFixed(3);
}
}
}
if (tableDataRow === undefined) return;
const iIndex = tableData.findIndex(item => item.sId === sId);
if (iIndex > -1) {
tableData[iIndex] = tableDataRow;
}
props.onSaveState({ [`${name}Data`]: tableData });
} else if (name === "process") {
const {
[`${name}Data`]: tableData,
sModelsId,
masterData,
slaveData,
controlData,
controlSelectedRowKeys,
materialsData,
processConfig,
token,
} = props;
let { processDelData, materialsDelData } = props;
const tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
let iIndex = tableData.findIndex(item => item.sId === sId);
let tableDataRowOld = {};
let iMaterialsIndex = -1;
let sControlId = "";
if (iIndex > -1) {
iMaterialsIndex = materialsData.findIndex(
item => item.sControlId === tableData[iIndex].sControlId && item.sProcessId === tableData[iIndex].sProcessId
);
tableDataRowOld = tableData[iIndex];
tableData[iIndex] = tableDataRow;
sControlId = tableData[iIndex].sControlId;
}
const addState = {};
if (sFieldName === "sProcessId" || sFieldName.includes("sProcessName")) {
const bProcessAssort = true;
let returnProcessAssort = [];
let processAssignAssort = "";
let dropDownDataProcessName;
const sProcessParamStriIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === "sProcessParamStr" && item.bVisible);
if (sProcessParamStriIndex > -1 && commonUtils.isNotEmptyObject(tableData[iIndex].sProcessParam)) {
tableData[iIndex].sProcessParamStr = "工艺参数";
} else if (sProcessParamStriIndex > -1) {
tableData[iIndex].sProcessParamStr = "";
}
/* 设置工艺参数下拉 */
if (commonUtils.isNotEmptyObject(tableData[iIndex].sProcessParam)) {
tableData[iIndex] = { ...tableData[iIndex], ...commonUtils.convertStrToObj(tableData[iIndex].sProcessParam) };
}
if (bProcessAssort) {
const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`;
const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data;
if (dataProcessAssort.code === 1) {
returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort;
const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === "sProcessName");
if (iIndex > -1) {
const sqlDropDownData = await props.getSqlDropDownData(sModelsId, "slave", processConfig.gdsconfigformslave[iIndex]);
dropDownDataProcessName = sqlDropDownData.dropDownData;
processAssignAssort = processConfig.gdsconfigformslave[iIndex].sAssignField;
}
}
}
const iControlIndex = commonUtils.isEmptyArr(controlSelectedRowKeys)
? -1
: controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]);
// 配套工序
if (bProcessAssort) {
const newCopyTo = {};
newCopyTo.master = masterData;
if (commonUtils.isNotEmptyArr(slaveData)) {
newCopyTo.slave = slaveData[0];
}
/* 切换工序时 先删除原工序配套工序 */
if (commonUtils.isEmptyArr(processDelData)) {
processDelData = [];
}
if (commonUtils.isEmptyArr(materialsDelData)) {
materialsDelData = [];
}
returnProcessAssort
.filter(item => item.sParentId === tableDataRowOld.sProcessId)
.forEach(itemProcessAssort => {
const iProcessIndex = tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === sControlId);
if (iProcessIndex > -1) {
const processDataRow = tableData[iProcessIndex];
tableData.splice(iProcessIndex, 1);
processDataRow.handleType = "del";
processDelData.push(processDataRow);
/* 删除配套材料 */
const iMaterialsIndex = materialsData.findIndex(
item => item.sMaterialsName === processDataRow.sProcessName && item.sControlId === sControlId
);
if (iMaterialsIndex > -1) {
const materialsDataRow = materialsData[iMaterialsIndex];
materialsData.splice(iMaterialsIndex, 1);
materialsDataRow.handleType = "del";
materialsDelData.push(materialsDataRow);
}
}
});
if (commonUtils.isNotEmptyArr(processDelData)) {
addState.processDelData = processDelData;
}
if (commonUtils.isNotEmptyArr(materialsDelData)) {
addState.materialsDelData = materialsDelData;
}
iIndex = tableData.findIndex(item => item.sId === tableDataRow.sId);
returnProcessAssort
.filter(item => item.sParentId === tableDataRow.sProcessId)
.forEach(itemProcessAssort => {
const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId);
if (iIndex > -1) {
const iNewProcessIndex =
dropDownDataProcessName[iIndex].sType === "3"
? tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId)
: tableData.findIndex(
item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlData[iControlIndex].sId
);
if (iIndex > -1 && iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段
processRow.handleType = "add";
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
if (iControlIndex > -1 && processRow.sType !== "3") {
processRow.sControlId = controlData[iControlIndex].sId;
processRow.sPartsName = controlData[iControlIndex].sPartsName;
}
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
tableData.push(processRow);
if (itemProcessAssort.sType === "all") {
controlData
.filter(item => item.sId !== controlData[iControlIndex].sId)
.forEach(controlTableRow => {
const iNewProcessIndex =
dropDownDataProcessName[iIndex].sType === "3"
? tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId)
: tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlTableRow.sId);
if (iNewProcessIndex < 0) {
let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
processRow = {
...processRow,
...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo),
}; // 取赋值字段
processRow.handleType = "add";
processRow.sId = commonUtils.createSid();
processRow.sParentId = masterData.sId;
processRow.sType = dropDownDataProcessName[iIndex].sType;
if (iControlIndex > -1 && processRow.sType !== "3") {
processRow.sControlId = controlTableRow.sId;
processRow.sPartsName = controlTableRow.sPartsName;
}
// const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]);
// if (iSlaveIndex > -1) {
// processRow.sSlaveId = slaveData[iSlaveIndex].sId;
// }
tableData.push(processRow);
}
});
}
}
}
});
}
if (tableData[iIndex].sType === "3") {
tableData[iIndex].sControlId = "";
tableData[iIndex].sPartsName = "";
} else if (iControlIndex > -1) {
tableData[iIndex].sControlId = controlData[iControlIndex].sId;
tableData[iIndex].sPartsName = controlData[iControlIndex].sPartsName;
if (iMaterialsIndex > -1) {
materialsData[iMaterialsIndex].sProcessId = tableData[iIndex].sProcessId;
materialsData[iMaterialsIndex].sProcessTbId = tableData[iIndex].sId;
materialsData[iMaterialsIndex].sMaterialsProcessName = tableData[iIndex].sProcessName;
}
}
}
props.onSaveState({ [`${name}Data`]: tableData, materialsSelectedRowKeys: [], ...addState });
} else if (name === "pack") {
const { packData, packSelectedRowKeys } = props;
const tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true);
if (tableDataRow === undefined) return;
const iIndex = packData.findIndex(item => item.sId === sId);
packData[iIndex] = tableDataRow;
if (sFieldName === "dCombineQty" || sFieldName === "dProductQty") {
handleGetdFactProductQty(packSelectedRowKeys, packData);
props.onSaveState({ packData });
}
} else {
props.onDataChange(name, sFieldName, changeValue, sId, dropDownData);
}
};
const singlePQtyChange = tableDataRow => {
const bZfZf = tableDataRow.iPrintMode === 2; // 正反版
const bSample = tableDataRow.dSumPQty >= 4; // 样本
tableDataRow.iPrintModePo = tableDataRow.iPrintMode <= 2 ? 2 : tableDataRow.iPrintMode === 3 ? 0 : -1;
if (bSample) {
if (tableDataRow.dSinglePQty > 0) {
tableDataRow.dPlateQty = Math.ceil(tableDataRow.dSumPQty / tableDataRow.dSinglePQty);
}
if (bZfZf && tableDataRow.iPrintModePo === 2) {
// 双面样本,正反
if (tableDataRow.dPlateQty < 2) {
// 不管建议放正自翻版了,点方式什么是什么
tableDataRow.dPlateQty = 2;
tableDataRow.iStick = Math.ceil(commonUtils.isNull(tableDataRow.dPlateQty, 0) / 2);
tableDataRow.dSumPlateQty =
tableDataRow.iStick *
(commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
} else {
if (tableDataRow.iPrintModePo !== 2) {
// 单面样本
tableDataRow.dPlateQty = Math.ceil((commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty);
tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty);
tableDataRow.dSumPlateQty =
tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
} else {
tableDataRow.dPlateQty = Math.ceil(
commonUtils.isNull(tableDataRow.dSumPQty, 0) / commonUtils.isNull(commonUtils.nullIf(tableDataRow.dSinglePQty, 0), 1)
);
tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty / 2);
}
tableDataRow.dSumPlateQty =
tableDataRow.iStick *
(commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
}
} else {
if (tableDataRow.iPrintModePo !== 2) {
// 单面样本
tableDataRow.dPlateQty = Math.ceil((commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty);
} else {
tableDataRow.dPlateQty = Math.ceil(
commonUtils.isNull(tableDataRow.dSumPQty, 0) / commonUtils.isNull(commonUtils.nullIf(tableDataRow.dSinglePQty, 0), 1)
);
}
tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty);
tableDataRow.dSumPlateQty =
tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
}
if (tableDataRow.iStick > 0 && tableDataRow.dSinglePQty > 0) {
tableDataRow.dMachineQty = commonUtils.convertFixNum(
(commonUtils.isNull(tableDataRow.dPartsQty, 0) * commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) /
tableDataRow.dSinglePQty /
tableDataRow.iStick,
0
);
tableDataRow.dSumMachineQty = tableDataRow.dMachineQty * tableDataRow.iStick;
}
} else {
tableDataRow.iStick = 1;
tableDataRow.dSumPlateQty =
tableDataRow.iStick *
(commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
if (bZfZf && tableDataRow.iPrintModePo === 2) {
tableDataRow.dPlateQty = 2;
tableDataRow.dSumPlateQty =
tableDataRow.iStick *
(commonUtils.isNull(tableDataRow.iPositiveColor, 0) +
commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeColor, 0) +
commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0));
} else {
tableDataRow.dPlateQty = 1;
tableDataRow.dSumPlateQty =
tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0));
}
if (tableDataRow.dSinglePQty > 0) {
if (tableDataRow.iPage > 1) {
// 笔记本 用 非样本 来做, 倍率是每页都一样才可以用 原先 /2 是指页数, 现在直接按张数
tableDataRow.dMachineQty = commonUtils.convertFixNum((tableDataRow.dPartsQty * tableDataRow.iPage) / tableDataRow.dSinglePQty, 0);
} else {
tableDataRow.dMachineQty = commonUtils.convertFixNum(commonUtils.isNull(tableDataRow.dPartsQty, 0) / tableDataRow.dSinglePQty, 0);
tableDataRow.dSumMachineQty = tableDataRow.dMachineQty * tableDataRow.iStick;
}
}
}
/* 计算材料开数 */
// const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */
// const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */
// const dMaterialsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsLength, 0)); /* 材料长 */
// const dMaterialsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsWidth, 0)); /* 材料宽 */
// const sResult = props.onResolveMachineComposing(dMachineLength, dMachineWidth, dMaterialsLength, dMaterialsWidth);
// if (commonUtils.isNotEmptyObject(sResult)) {
// const dMaterialsKQty = sResult.totalNum;
// tableDataRow.dMaterialsKQty = dMaterialsKQty;
// }
return tableDataRow;
};
const handlePackDataAdd = (item, index, sControlId, handleType) => {
const tableDataRow = {};
if (handleType === "add") {
tableDataRow.sId = commonUtils.createSid();
tableDataRow.handleType = "add";
tableDataRow.sSlaveId = item.sId;
tableDataRow.iOrder = item.iOrder;
}
tableDataRow.sParentId = item.sParentId;
if (commonUtils.isNotEmptyObject(sControlId)) {
tableDataRow.sControlId = sControlId;
}
// if (commonUtils.isNotEmptyObject(index)) {
// tableDataRow.iOrder = index + 1;
// }
tableDataRow.sProductId = item.sProductId; /* 产品id */
tableDataRow.sCustomerId = item.sCustomerId; /* 客户id */
tableDataRow.sCustomerName = item.sCustomerName; /* 客户名称 */
tableDataRow.sProductName = item.sProductName; /* 产品名称 */
tableDataRow.sProductNo = item.sProductNo; /* 产品编号 */
/* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */
let bProductQtySelf = false;
if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) {
const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "bProductQtySelf");
if (iIndex > -1) {
bProductQtySelf = true;
}
}
if (bProductQtySelf) {
tableDataRow.dProductQty = commonUtils.isNull(item.dProductQty, 0);
} else {
tableDataRow.dProductQty =
commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0); /* 生产数量 */
}
tableDataRow.sProductUnit = item.sProductUnit; /* 单位 */
tableDataRow.sProductStyle = item.sProductStyle; /* 产品规格 */
return tableDataRow;
};
const QuotationAllMaster = baseProps => {
const props = masterEvent(baseProps);
if (!props) {
return null; // 或者加载状态组件
}
if (props && !props.masterConfig) {
return null;
}
return <QuotationAllprogressDetail {...props} onDataChange={handleTableChange} onButtonClick={handleButtonClick} />;
};
// export default QuotationAllMaster;
export default CommobileBase(CommobileBillEvent(QuotationAllMaster));