MesToolbar.js
41 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
/* eslint-disable */
import { message, Progress } from "antd";
import * as commonUtils from "@/utils/utils";
import * as commonFunc from "@/components/Common/commonFunc";
import commonConfig from "@/utils/config";
import * as commonServices from "@/services/services";
let xlyProcessTimer = null;
const ToolbarFun = async (props) => {
const { btnConfig, bMesBill, name } = props;
const currentMesPane = commonUtils.getAppData("currentMesPane");
const { sModelType = '' } = currentMesPane;
const { sControlName, sButtonParam } = btnConfig;
const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase();
if ((btnName.includes('btnscanface')) && !bMesBill) {
handleScanFace(props);
return true
} else if (!["/indexPage/commonList", "/indexPage/commonBill"].includes(sModelType) && !bMesBill) {
return false;
} else if (btnName.includes('btnfooter')) {
return false
}
// const { sControlName } = btnConfig;
// const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase();
let flag = 0;
let interfaceArr = btnConfig.interface;
if (btnName === 'btnadd') {
handleAdd(props);
} else if (btnName === 'btnsave') {
handleSave(props);
} else if (btnName === 'btnupd') {
props.onSaveState({ enabled: true });
} else if (btnName.includes('btnscanface')) {
handleScanFace(props);
} else if (btnName === 'btncancel') {
props.onCancel()
} else if (btnName === 'btndel') {
props.onDel(props)
} else if (btnName.includes('btnexamine')) {
// 审核
if (commonUtils.isNotEmptyArr(interfaceArr)) {
const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
/* 之前调用 */
const asyncFunc = async () => {
for (let i = 0; i < beforeInterfaceArr.length; i++) {
const data = await handleInterfaceCall(props, beforeInterfaceArr[i]);
if (!data) {
flag += 1;
return;
}
}
};
await asyncFunc();
}
let result;
if (flag == 0) {
result = await props.onBtnExamine(1);
} else {
props.onSaveState({
loading: false,
});
}
if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
/* 之后调用 */
// const result = await props.onBtnExamine();
if (result) {
/* 只有审核成功 才能调用接口 -5代表审核失败 */
const asyncFunc = async () => {
for (let i = 0; i < afterInterfaceArr.length; i++) {
await handleInterfaceCall(props, afterInterfaceArr[i], true);
}
};
await asyncFunc();
}
}
} else {
// console.log(props, 'masterData');
props.onBtnExamine(1);
}
} else if (btnName.includes('btncancelexamine')) {
if (commonUtils.isNotEmptyArr(interfaceArr)) {
const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
/* 之前调用 */
let flag = 0;
const asyncFunc = async () => {
for (let i = 0; i < beforeInterfaceArr.length; i++) {
const data = await handleInterfaceCall(props, beforeInterfaceArr[i]);
if (!data) {
flag += 1;
return;
}
}
};
await asyncFunc();
if (flag == 0) {
props.onBtnCancelExamine(0);
} else {
props.onSaveState({
loading: false,
});
}
}
if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
/* 之后调用 */
const result = await props.onBtnCancelExamine(0);
if (result) {
/* 只有审核成功 才能调用接口 -5代表审核失败 */
const asyncFunc = async () => {
for (let i = 0; i < afterInterfaceArr.length; i++) {
await handleInterfaceCall(props, afterInterfaceArr[i], true);
}
};
await asyncFunc();
}
}
} else {
props.onBtnCancelExamine(0);
}
} else if (['btnevent', 'btnsubmit', 'btnsubmitcancel'].includes(btnName)) {
const {
slaveSelectedRowKeys,
slaveData,
formRoute,
slave0Child1Data: controlData,
materialsData: materialsData,
slave0Data: processData,
} = props;
let { slaveSelectedData } = props;
if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData) && slaveSelectedRowKeys) {
slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
}
props.onSaveState({
loading: true,
});
// const btnConfig = props.masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0]; // sButtonEnabled sButtonParam
if (commonUtils.isNotEmptyObject(btnConfig) && commonUtils.isNotEmptyStr(btnConfig.sButtonParam)) {
/* 根据接口返回是之前调用还是之后调用 */
if (commonUtils.isNotEmptyArr(interfaceArr)) {
const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
const bProgressBar = btnConfig.sRelation === "progressBar";
let bContinue = true;
if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
/* 之前调用 */
let flag = 0;
const asyncFunc = async () => {
for (let i = 0; i < beforeInterfaceArr.length; i++) {
if (bProgressBar) {
let xlyProcessPercent = 0;
clearInterval(xlyProcessTimer);
message.loading({
content: <Progress percent={xlyProcessPercent} />,
key: "xlyProcess",
duration: 0,
className: styles.xlyProcess,
});
for (let j = 0; j < slaveSelectedRowKeys.length; j++) {
const slaveSelectedRowOneKey = slaveSelectedRowKeys[j];
const data = await handleInterfaceCall(beforeInterfaceArr[i], false, key, slaveSelectedRowOneKey, slaveSelectedRowOneKey);
if (!data) {
message.destroy("xlyProcess");
flag += 1;
break;
}
xlyProcessPercent = ((((i + 1) * (j + 1)) / (beforeInterfaceArr.length * slaveSelectedRowKeys.length)) * 100).toFixed(2);
message.loading({
content: <Progress percent={xlyProcessPercent} />,
key: "xlyProcess",
duration: xlyProcessPercent >= 100 ? 3 : 0,
className: styles.xlyProcess,
});
}
} else {
const data = await handleInterfaceCall(beforeInterfaceArr[i], false, key, slaveSelectedRowKeys);
if (!data) {
flag += 1;
return;
}
}
}
};
await asyncFunc();
if (flag == 0) {
await handleBtnEent(props, btnConfig);
} else {
bContinue = false;
}
}
if (commonUtils.isNotEmptyArr(afterInterfaceArr) && bContinue) {
/* 之后调用 */
const result = await handleBtnEent(props, btnConfig);
if (result === 1) {
/* 只有按钮成功 才能调用接口 -5代表审核失败 */
const asyncFunc = async () => {
for (let i = 0; i < afterInterfaceArr.length; i++) {
if (bProgressBar) {
let xlyProcessPercent = 0;
clearInterval(xlyProcessTimer);
message.loading({
content: <Progress percent={xlyProcessPercent} />,
key: "xlyProcess",
duration: 0,
className: styles.xlyProcess,
});
for (let j = 0; j < slaveSelectedRowKeys.length; j++) {
const slaveSelectedRowOneKey = slaveSelectedRowKeys[j];
const data = await handleInterfaceCall(afterInterfaceArr[i], false, key, slaveSelectedRowOneKey, slaveSelectedRowOneKey);
if (!data) {
message.destroy("xlyProcess");
break;
}
xlyProcessPercent = ((((i + 1) * (j + 1)) / (afterInterfaceArr.length * slaveSelectedRowKeys.length)) * 100).toFixed(2);
message.loading({
content: <Progress percent={xlyProcessPercent} />,
key: "xlyProcess",
duration: xlyProcessPercent >= 100 ? 3 : 0,
className: styles.xlyProcess,
});
}
} else {
await handleInterfaceCall(afterInterfaceArr[i], false, key, slaveSelectedRowKeys);
}
}
};
await asyncFunc();
}
}
// for (const child of slaveSelectedDataNew) {
//
// }
} else if (btnConfig.sButtonParam?.includes("Sp_BtnEven_CalcJsHs") && btnConfig.showName?.includes("工资核算")) {
// 工资核算特殊处理
const { slave3Data = [], slave3SelectedRowKeys = [] } = props;
const slave3SelectedData = slave3Data.filter(item => slave3SelectedRowKeys.includes(item.sId));
if (slave3SelectedData.length) {
for (let i = 0; i < slave3SelectedData.length; i++) {
const slave3DataOne = slave3SelectedData[i];
const { sCalcProName: sCalcProDetail, sId, sCalcDepart } = slave3DataOne;
const inParams = [
{
key: "slave3",
value: [{ sId, sCalcProDetail }],
},
];
const percent = ((i / slave3SelectedData.length) * 100).toFixed(2);
message.loading({ content: <Progress percent={percent} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
await handleBtnEent(props, btnConfig, undefined, undefined, inParams);
// message.success(`【${sCalcDepart}】核算完成。`);
}
message.loading({ content: <Progress percent={99} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
message.success(`全部方案计算成功。`);
setTimeout(() => {
message.loading({ content: <Progress percent={100} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
}, 1000);
setTimeout(() => {
message.destroy("xlyProcess");
}, 2000);
} else {
message.warning("请先选择计算方案!");
}
} else {
handleBtnEent(props, btnConfig);
}
props.onSaveState({
loading: false,
});
} else {
message.error(confirmSetting);
props.onSaveState({
loading: false,
});
}
} else if (btnName.includes('btnrepair')) {
if (btnName.toLowerCase().endsWith("choosedate")) {
handleForceComplete(props, btnName, "chooseDate");
} else if (btnName.includes("btnrepairgroup") || btnName.includes("btnrepairuser")) {
/* 复制组权限单独处理 */
props.onButtonClick(btnName);
} else {
/* 根据接口返回是之前调用还是之后调用 */
if (false) {
const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
const afterInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "2");
if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
/* 之前调用 */
let flag = 0;
const asyncFunc = async () => {
for (let i = 0; i < beforeInterfaceArr.length; i++) {
const data = await handleInterfaceCall(beforeInterfaceArr[i]);
if (!data) {
flag += 1;
return;
}
}
};
await asyncFunc();
if (flag == 0) {
handleForceComplete(key);
}
}
if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
/* 之后调用 */
const result = await handleForceComplete(key);
if (result !== -5) {
/* 只有审核成功 才能调用接口 -5代表审核失败 */
const asyncFunc = async () => {
for (let i = 0; i < afterInterfaceArr.length; i++) {
await handleInterfaceCall(afterInterfaceArr[i], true);
}
};
await asyncFunc();
}
}
} else {
handleForceComplete(props, btnName);
}
}
}
return true;
}
// 进行存储过程按钮存储过程参数解析拼接 根据存储过程按钮参数配置进行解析,配置是json格式 {"sproName":"cal_sss","inMap":"master.sSlaveId,slave.sId"}
const handleBtnEent = async (props, btnConfig, name, sValue, nextInParams) => {
let xlyProcessPercent = 0;
clearInterval(xlyProcessTimer);
if (props.app?.currentPane?.title === "工单损耗及无形损跟踪" && btnConfig?.sControlName === "BtnEventAllWork") {
message.loading({ content: <Progress percent={0} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
xlyProcessTimer = setInterval(() => {
if (xlyProcessPercent >= 50) {
xlyProcessPercent += 0.2;
} else if (xlyProcessPercent >= 90) {
return;
} else {
xlyProcessPercent += 0.5;
}
message.loading({ content: <Progress percent={xlyProcessPercent} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
}, 500);
}
props.onSaveState({
pageLoading: true,
});
const menuData = []
// const { menuData } = state;
let iResult = 0;
let bFirst = false;
if (
commonUtils.isNotEmptyObject(btnConfig) &&
(btnConfig.sControlName === "BtnEventReceiveReturn" || btnConfig.sControlName === "BtnEventReceive")
) {
// 刀模归还, 刀模领用判断是否选择数据
const { slaveSelectedRowKeys, app } = props;
if (slaveSelectedRowKeys && commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录
props.onSaveState({
pageLoading: false,
});
return;
}
}
if (commonUtils.isNotEmptyObject(btnConfig) && btnConfig.sControlName.includes("BtnEventAutoOrder")) {
// 刀模归还, 刀模领用判断是否选择数据
bFirst = true; /* 沒有选中行时 默认第一条 */
}
const { masterData, sCurrMemoProps, masterConditionData } = props;
if (commonUtils.isNotEmptyObject(name) && name.indexOf("BtnRepair") > -1 && commonUtils.isNotEmptyObject(sCurrMemoProps)) {
sCurrMemoProps.bVisibleMemo = false;
props.onSaveState({ sCurrMemoProps });
}
const sButtonParam = btnConfig.sButtonParam;
const btn = commonUtils.convertStrToObj(sButtonParam);
const sProName = btn.sproName;
const inParams = [];
const inMap = btn.inMap;
const inlist = inMap ? inMap.split(",") : [];
const masterArr = [];
const masterConditionArr = [];
const slaveArr = [];
const slaveInfoArr = [];
const controlArr = [];
const materialsArr = [];
const processArr = [];
const sTableName = btn.sTableName;
if (!sTableName && !inMap) {
// 都为undefined时直接退出
props.onSaveState({
pageLoading: false,
});
return;
}
if (inlist.length > 0) {
inlist.forEach(item => {
const itemArr = item.split(".");
if (itemArr.length > 0) {
const sname = itemArr[0];
const stype = itemArr[1];
const stypeNew = itemArr.length > 2 ? itemArr[2] : stype;
if (commonUtils.isNotEmptyStr(sname) && sname === "master") {
masterArr.push([stype, stypeNew]);
}
if (commonUtils.isNotEmptyStr(sname) && sname === "masterCondition") {
/* 参数数据集 */
masterConditionArr.push([stype, stypeNew]);
}
if (commonUtils.isNotEmptyStr(sname) && sname === "slave") {
slaveArr.push([stype, stypeNew]);
}
if (commonUtils.isNotEmptyStr(sname) && sname === "slaveInfo") {
slaveInfoArr.push([stype, stypeNew]);
}
if (commonUtils.isNotEmptyStr(sname) && sname === "control") {
controlArr.push([stype, stypeNew]);
}
if (commonUtils.isNotEmptyStr(sname) && sname === "materials") {
materialsArr.push([stype, stypeNew]);
}
if (commonUtils.isNotEmptyStr(sname) && sname === "process") {
processArr.push([stype, stypeNew]);
}
if (
commonUtils.isNotEmptyStr(sname) &&
!["master", "masterCondition", "slave", "slaveInfo", "control", "materials", "process"].includes(sname)
) {
const addState = handleProParams(sname, [[stype, stypeNew]]);
if (commonUtils.isNotEmptyObject(addState)) {
inParams.push({ ...addState });
}
}
}
});
if (commonUtils.isNotEmptyArr(masterArr) && commonUtils.isNotEmptyObject(masterData)) {
const addState = {};
addState.key = "master";
const val = [];
const currVal = {};
masterArr.forEach(([stype, stypeNew]) => {
currVal[`${stypeNew}`] = masterData[`${stype}`];
});
val.push(currVal);
addState.value = val;
inParams.push({ ...addState });
}
if (commonUtils.isNotEmptyArr(masterConditionArr) && commonUtils.isNotEmptyObject(masterConditionData)) {
const addState = {};
addState.key = "masterCondition";
const val = [];
const currVal = {};
masterConditionArr.forEach(filed => {
currVal[`${filed}`] = masterConditionData[`${filed}`];
});
val.push(currVal);
addState.value = val;
inParams.push({ ...addState });
}
if (commonUtils.isNotEmptyArr(slaveArr)) {
const addState = handleProParams("slave", slaveArr, bFirst);
if (commonUtils.isNotEmptyObject(addState)) {
inParams.push({ ...addState });
}
}
if (commonUtils.isNotEmptyArr(slaveInfoArr)) {
const addState = handleProParams("slaveInfo", slaveInfoArr);
if (commonUtils.isNotEmptyObject(addState)) {
inParams.push({ ...addState });
}
}
if (commonUtils.isNotEmptyArr(controlArr)) {
const addState = handleProParams("control", controlArr);
if (commonUtils.isNotEmptyObject(addState)) {
inParams.push({ ...addState });
}
}
if (commonUtils.isNotEmptyArr(materialsArr)) {
const addState = handleProParams("materials", materialsArr);
if (commonUtils.isNotEmptyObject(addState)) {
inParams.push({ ...addState });
}
}
if (commonUtils.isNotEmptyArr(processArr)) {
const addState = handleProParams("process", processArr);
if (commonUtils.isNotEmptyObject(addState)) {
inParams.push({ ...addState });
}
}
}
if (commonUtils.isNotEmptyStr(sTableName) && commonUtils.isNotEmptyArr(inParams)) {
inParams.forEach(item => {
if (commonUtils.isNotEmptyArr(item.value)) {
item.value.forEach(item1 => {
item1.sTableName = sTableName;
});
}
});
}
/* 列表增加查询条件的传参 */
if (
location.pathname?.includes("indexPage/commonList") &&
(btnConfig?.sControlName === "BtnEventOneWork" || btnConfig?.sControlName === "BtnEventAllWork")
) {
const { slaveFilterCondition = [] } = props;
if (commonUtils.isNotEmptyArr(slaveFilterCondition) && commonUtils.isNotEmptyArr(inParams)) {
inParams.forEach(item => {
item.bFilter = slaveFilterCondition;
});
}
}
const iIndex = commonUtils.isNotEmptyObject(btnConfig) ? menuData.findIndex(item => item.sControlName === btnConfig.sControlName) : -1;
let interfaceArr = [];
if (iIndex > -1) {
interfaceArr = menuData[iIndex].interface;
}
if (commonUtils.isNotEmptyArr(interfaceArr) && commonUtils.isNotEmptyObject(btnConfig) && btnConfig.sControlName.includes("BtnRepair")) {
if (true) {
const { slaveSelectedRowKeys, app, slaveData } = props;
if (inMap && inMap.includes("slave.") && slaveSelectedRowKeys && commonUtils.isEmptyArr(slaveSelectedRowKeys)) {
message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录
props.onSaveState({
pageLoading: false,
});
return;
}
let slaveRow = {};
const iSlaveDataIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId));
if (iSlaveDataIndex > -1) {
slaveRow = slaveData[iSlaveDataIndex];
}
let ids = "";
if (location.pathname.includes("commonList")) {
let { slaveSelectedData } = props;
if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData)) {
slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
}
const slaveSelectedDataNew = deteleObject(slaveSelectedData); // 删除sid重复的数据
if (commonUtils.isNotEmptyArr(slaveSelectedDataNew)) {
slaveSelectedDataNew.forEach(item => {
if (commonUtils.isNotEmptyObject(item)) {
ids += `${item.sId},`;
}
});
ids = commonUtils.isNotEmptyObject(ids) ? ids.substr(0, ids.length - 1) : "";
}
} else {
ids = slaveRow.sId;
}
const beforeInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "1");
const afterInterfaceArr = commonUtils.isNotEmptyArr(interfaceArr) ? interfaceArr.filter(item => item.sInterfaceCallMethod === "2") : [];
if (commonUtils.isNotEmptyArr(beforeInterfaceArr)) {
/* 之前调用 */
let flag = 0;
const asyncFunc = async () => {
for (let i = 0; i < beforeInterfaceArr.length; i++) {
const data = await handleInterfaceCall(beforeInterfaceArr[i], true, btnConfig.sControlName, ids);
if (!data) {
flag += 1;
props.onSaveState({
pageLoading: false,
});
return;
}
}
};
await asyncFunc();
if (flag == 0) {
await handleProcedureCall(props, btnConfig, sProName, JSON.stringify({ params: inParams, changeValue: sValue, sButtonParam: btn }));
}
}
if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
/* 之后调用 */
const result = await handleProcedureCall(
props,
btnConfig,
sProName,
JSON.stringify({ params: inParams, changeValue: sValue, sButtonParam: btn })
);
if (result > 0) {
/* 只有成功 才能调用接口 -5代表失败 */
const asyncFunc = async () => {
for (let i = 0; i < afterInterfaceArr.length; i++) {
await handleInterfaceCall(afterInterfaceArr[i], true, btnConfig.sControlName, ids);
}
};
await asyncFunc();
}
}
}
} else {
const inParamsNew = nextInParams || inParams;
iResult = await handleProcedureCall(props, btnConfig, sProName, JSON.stringify({ params: inParamsNew, changeValue: sValue, sButtonParam: btn }));
}
if (props.app?.currentPane?.title === "工单损耗及无形损跟踪" && btnConfig?.sControlName === "BtnEventAllWork") {
clearInterval(xlyProcessTimer);
xlyProcessPercent = 91;
message.loading({ content: <Progress percent={91} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
xlyProcessTimer = setInterval(() => {
xlyProcessPercent += 1;
message.loading({ content: <Progress percent={xlyProcessPercent} />, key: "xlyProcess", duration: 0, className: styles.xlyProcess });
if (xlyProcessPercent === 100) {
clearInterval(xlyProcessTimer);
setTimeout(() => {
message.destroy();
}, 1000);
}
}, 100);
}
props.onSaveState({
pageLoading: false,
});
return iResult;
};
// 存储过程按钮调用存储过程
const handleProcedureCall = async (props, btnConfig, proName, proInParam, other) => {
const { app, sModelsId } = props;
let iResult = 0;
const sBtnName = btnConfig.sControlName;
const value = { sProName: proName, sProInParam: proInParam, sBtnName };
if (other?.iFlag === 1) {
value.iFlag = 1;
}
const url = `${commonConfig.server_host}procedureCall/doGenericProcedureCall?sModelsId=${sModelsId}`;
// const url = '';
const returnData = (await commonServices.postValueService(app.token, value, url)).data;
if (proName === "Sp_BtnEven_CalcJsHs") {
if (returnData.code === 1) {
message.success(returnData.msg);
} else {
message.warning(returnData.msg);
}
const proInParamJson = commonUtils.convertStrToObj(proInParam);
const sId = proInParamJson.params?.[0]?.value?.[0]?.sId;
const { slave3Data = [] } = props;
const iIndex = slave3Data.findIndex(item => item.sId === sId);
if (iIndex !== -1) {
slave3Data[iIndex].sCalcProDetail = returnData.msg;
props.onSaveState({ slave3Data });
}
} else if (returnData.code === 1) {
message.success(returnData.msg);
props.onRefresh()
} else if (returnData.code === -8) {
Modal.info({
title: "温馨提示:",
content: <div>{handleGetMsg(returnData.msg)}</div>,
okText: "确认",
onOk() { },
});
} else {
props.getServiceError({ ...returnData, fn: () => handleProcedureCall(props, btnConfig, proName, proInParam, { iFlag: 1 }) });
}
iResult = returnData.code;
props.onSaveState({ loading: false });
// 点击返回重排的时候刷新树
if (btnConfig.sControlName === "BtnEventReturn") {
if (props.refreshTreeData) {
props.refreshTreeData();
}
}
return iResult;
};
/* 调用后台配置的接口 */
const handleInterfaceCall = async (props, obj, showTip, key, ids, slaveSelectedRowKeysOld) => {
let bResult = false;
const { app, sModelsId, masterData, slaveData, masterConfig, slaveFilterCondition } = props;
const slaveSelectedRowKeys = slaveSelectedRowKeysOld || props.slaveSelectedRowKeys;
const sInterfaceName = obj.sInterfaceName;
/* 如果key是BtnSendList 传从表的主键集合 */
let idArr = "";
/* 如果有对应字段 则取对应字段 ,否则 取默认值 */
const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === key))
? masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0]
: {};
let sActiveKey = "";
if (commonUtils.isNotEmptyObject(btnConfig)) {
sActiveKey = btnConfig.sActiveKey;
}
if (sActiveKey) {
if (sActiveKey.includes("master.sId")) {
idArr = masterData.sId;
}
} else if (key && (key.includes("BtnSendList") || key.includes("BtnBatchExamine"))) {
if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
slaveSelectedRowKeys.forEach(item => {
if (commonUtils.isNotEmptyObject(item)) {
idArr += `${item},`;
}
});
idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : "";
}
} else if (location.pathname.includes("commonList")) {
const { slaveSelectedRowKeys, slaveData } = props;
let { slaveSelectedData } = props;
if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData)) {
slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
}
const slaveSelectedDataNew = deteleObject(slaveSelectedData); // 删除sid重复的数据
if (commonUtils.isNotEmptyArr(slaveSelectedDataNew)) {
slaveSelectedDataNew.forEach(item => {
if (commonUtils.isNotEmptyObject(item)) {
idArr += `${item.sId},`;
}
});
idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : "";
}
if (commonUtils.isNotEmptyObject(ids)) {
/* 如果是勾选多行 则sId为循环的每一条 */
idArr = ids;
}
} else {
idArr = masterData.sId;
}
const value = {
sId: commonUtils.isNotEmptyObject(idArr) ? idArr : commonUtils.isNotEmptyObject(ids) ? ids : masterData.sId,
sSlaveId: slaveSelectedRowKeys?.toString(),
masterData,
userInfo: app.userinfo,
};
if (location.pathname.includes("commonList") && commonUtils.isNotEmptyArr(slaveFilterCondition)) {
value.bFilter = JSON.stringify(slaveFilterCondition);
}
const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`;
const returnData = (await commonServices.postValueService(app.token, value, url, app)).data;
if (showTip) {
if (!returnData || returnData.code < 0) {
if (commonUtils.isNotEmptyObject(returnData) && returnData.code === -8) {
Modal.info({
title: "温馨提示:",
content: <div>{handleGetMsg(returnData.msg)}</div>,
okText: "确认",
onOk() { },
});
} else {
Modal.info({
title: "温馨提示:",
content: <div>{handleGetMsg(returnData.msg)}</div>,
okText: "确认",
onOk() { },
});
return;
}
// message.error('同步INFOR失败!');
return;
} else {
// message.success('同步INFOR成功!');
}
}
if (!returnData) {
message.error("接口调用失败!");
return false;
}
if (returnData.code === 1) {
bResult = true;
// message.success(returnData.msg);
} else if (returnData.code === 2) {
// Modal.info({
// title: '温馨提示:',
// content: (
// <div>
// {handleGetMsg(returnData.msg)}
// </div>
// ),
// okText: '确认',
// onOk() {},
// });
bResult = true;
} else if (returnData.code === -8) {
Modal.info({
title: "温馨提示:",
content: <div>{handleGetMsg(returnData.msg)}</div>,
okText: "确认",
onOk() { },
});
bResult = false;
} else {
bResult = false;
props.getServiceError(returnData);
}
/* 若配置的是按钮后调用第三方, 则调用成功后 需要重新回刷一次数据 */
if (commonUtils.isNotEmptyObject(obj) && obj.sInterfaceCallMethod === "2") {
if (bResult) {
props.onButtonClick("BtnRefresh");
}
}
return bResult;
};
const handleForceComplete = (props, name, createDate) => {
let sysLogData = {};
const slaveMemoConfigOld = [];
const { slaveSelectedRowKeys, slaveInfoSelectedRowKeys, app, masterConfig, slaveInfoData, masterData, slaveData, gdsformconst } = props;
const btnConfig =
commonUtils.isNotEmptyObject(masterConfig) &&
commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === name))
? masterConfig.gdsconfigformslave.filter(item => item.sControlName === name)[0]
: {}; // sButtonEnabled sButtonParam
const bNoMemo = btnConfig.sDefault === "noMemo";
if (createDate !== "chooseDate") {
let target = "";
if (btnConfig.sActiveKey) {
target = btnConfig.sActiveKey.split(",")[0].split(".")[0];
}
if (target === "slave" && commonUtils.isEmptyArrNew(slaveSelectedRowKeys)) {
message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录
} else if (target === "slaveInfo" && commonUtils.isEmptyArrNew(slaveInfoSelectedRowKeys)) {
message.warn(commonFunc.showMessage(app.commonConst, "pleaseChooseData")); // 请选择记录
} else if (target === "slaveInfo" && !Array.isArray(slaveInfoData)) {
message.warn("请展开详情并选择数据。"); // 请选择记录
} else {
let btnConfigNameArr = [];
let singleConfig = {};
let singleRow = {}; /* 选中行的数据 */
if (name.indexOf("BtnRepair") > -1) {
if (!commonUtils.isEmpty(btnConfig.sActiveKey)) {
btnConfigNameArr = btnConfig.sActiveKey.split(",");
}
if (commonUtils.isNotEmptyArr(btnConfigNameArr)) {
// eslint-disable-next-line array-callback-return
btnConfigNameArr.map(i => {
let sIndex = -1;
if (target === "slaveInfo") {
sIndex = props.slaveInfoConfig.gdsconfigformslave.findIndex(item => item.sName === i.split(".")[1]);
const iSlaveIndex = slaveInfoData.findIndex(item => slaveInfoSelectedRowKeys.includes(item.sSlaveId));
if (iSlaveIndex > -1) {
singleRow = slaveInfoData[iSlaveIndex];
}
} else if (target === "master") {
sIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sName === i.split(".")[1]);
singleRow = masterData;
} else {
if (commonUtils.isNotEmptyObject(props) && commonUtils.isNotEmptyObject(props.slaveConfig)) {
sIndex = props.slaveConfig.gdsconfigformslave.findIndex(item => item.sName === i);
const iSlaveIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sSlaveId));
if (iSlaveIndex > -1) {
singleRow = slaveData[iSlaveIndex];
}
}
}
console.log("singleRow:", singleRow);
if (sIndex > -1) {
if (target === "slaveInfo") {
singleConfig = props.slaveInfoConfig.gdsconfigformslave[sIndex];
} else if (target === "master") {
singleConfig = props.masterConfig.gdsconfigformslave[sIndex];
} else {
singleConfig = props.slaveConfig.gdsconfigformslave[sIndex];
}
if (masterData && commonUtils.isNotEmptyObject(singleRow)) {
masterData[singleConfig.sName] = singleRow[singleConfig.sName];
}
// if (masterData && commonUtils.isNotEmptyObject(singleConfig)) {
// masterData[singleConfig.sName] = undefined;
// }
slaveMemoConfigOld.push(singleConfig);
}
});
}
}
/* 时间格式的字段 若默认值为空 则取当前时间 */
const activeKeyData = commonUtils.isNotEmptyObject(btnConfig.sActiveKey) ? btnConfig.sActiveKey.split(",") : [];
if (activeKeyData.length > 1) {
/* 当多字段时候 若时间格式的字段 若默认值为空 则取当前时间 */
const filterData = activeKeyData.filter(item => item.substring(0, 1) === "t");
if (commonUtils.isNotEmptyArr(filterData)) {
filterData.forEach(item => {
let currentDate = moment().format("YYYY-MM-DD HH:mm:ss");
// 如果默认值为0 则不设置默认时间
const itemConfigIndex = masterConfig.gdsconfigformslave.findIndex(config => config.sName === item);
if (itemConfigIndex !== -1 && masterConfig.gdsconfigformslave[itemConfigIndex].sDefault === "0") {
currentDate = null;
}
if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isEmpty(masterData[item])) {
masterData[item] = currentDate;
}
});
}
} else {
if (commonUtils.isNotEmptyObject(btnConfig.sActiveKey) && btnConfig.sActiveKey.substring(0, 1) === "t") {
if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isEmpty(masterData[btnConfig.sActiveKey])) {
masterData[btnConfig.sActiveKey] = moment().format("YYYY-MM-DD HH:mm:ss");
}
}
}
// if (slaveSelectedRowKeys === undefined || slaveSelectedRowKeys === null) {
// message.warn('请选择数据!');
// return;
// }
sysLogData = commonUtils.isNotEmptyArr(slaveSelectedRowKeys) ? { sId: slaveSelectedRowKeys.toString() } : {};
props.onSaveState({
slaveMemoConfig: slaveMemoConfigOld,
masterData: commonUtils.isNotEmptyObject(masterData)
? lodash.cloneDeep(masterData)
: {} /* 将选中行数据深拷贝 变成两个互不相扰的独立数据源 */,
sCurrMemoProps: {
bVisibleMemo: true,
sMemoField: "sReason",
sRecord: sysLogData,
dataSource: sysLogData,
btnName: name,
bNoMemo,
},
});
}
} else {
/* 从系统常量中找到pChooseDate的sName */
let pChooseDateName = "生成凭证";
if (commonUtils.isNotEmptyArr(gdsformconst)) {
const iIndex = gdsformconst.findIndex(item => item.sName === "pChooseDate");
if (iIndex > -1) {
pChooseDateName = gdsformconst[iIndex].showName;
}
}
const chooseDateConfig = {
sId: commonUtils.createSid(),
sName: "pChooseDate",
sDropDownType: "sql",
bNotEmpty: false,
iVisCount: 1,
dropDownData: [],
showName: pChooseDateName,
sDateFormat: btnConfig && btnConfig.sDateFormat ? btnConfig.sDateFormat : "YYYY-MM-DD",
};
slaveMemoConfigOld.push(chooseDateConfig);
props.onSaveState({
slaveMemoConfig: slaveMemoConfigOld,
sCurrMemoProps: {
bVisibleMemo: true,
sMemoField: "sReason",
sRecord: sysLogData,
dataSource: sysLogData,
btnName: name,
bNoMemo,
},
});
}
};
// 新增
const handleAdd = (props) => {
const { slaveConfig } = props;
const picArrConfig = slaveConfig.gdsconfigformslave.find(item => item.sName === 'picArr');
if (!picArrConfig) {
message.error('请先配置picArr字段');
return;
}
const { sActiveId } = picArrConfig;
if (!sActiveId) {
message.error('请先配置弹窗界面');
}
const { app } = props;
const { managementData } = app;
// const menuList = managementData.reduce((result, item) => {
// // ✅ 安全展开:确保children是数组,否则使用空数组
// result = [...result, ...(Array.isArray(item?.children) ? item.children : [])];
// return result;
// }, []);
// const menu = menuList.find(item => item.sId === sActiveId);
// if (!menu) {
// message.error('弹窗界面不在MES菜单中');
// return;
// }
props.onOpenCommonModal({
type: "commonModal",
sActiveId,
title: props?.btnConfig?.showName,
parentProps: props,
onOk: data => {
window.debugger && console.log("=====onOk", data);
},
onCancel: () => {
window.debugger && console.log("=====onCancel");
}
});
// app.globalFun.onChangeRouter({
// type: "id",
// path: [menu.sParentId, menu.sId],
// sModelType: menu.sName,
// // sParentConditions,
// copyTo: {
// master: { maxBillNo: 'sBillNo' }
// }
// });
}
// 保存
const handleSave = (props) => {
props.onExecInstructSet({
btnConfig: {
showName: "保存",
sInstruct: JSON.stringify([
{
opr: "save",
},
{
opr: "refresh",
},
])
},
inscallback: () => {
props.onSaveState({
currentId: props.masterData.sId, enabled: false
});
}
});
}
// 人脸数据采集
const handleScanFace = (props) => {
const { btnConfig } = props;
const { sButtonParam: sButtonParamStr } = btnConfig;
const sButtonParam = commonUtils.convertStrToObj(sButtonParamStr);
const { addData } = sButtonParam;
props.onExecInstructSet({
btnConfig: {
showName: "保存",
sInstruct: JSON.stringify([
{
opr: "faceauth",
newDataset: "face"
},
{
opr: props?.masterConfig?.sName?.includes("/indexMes/commonModal") ? '' : "refresh",
},
])
},
inscallback: (result) => {
const { faceData = [] } = result;
props.onProcedureCall({
btnConfig,
faceData: { sFaceParentId: faceData[0].sParentId, sFaceEmployeeNo: faceData[0].sEmployeeNo },
onSuccess: (_, dataset) => {
const { proData = [] } = dataset.rows[0].dataSet;
const { [`${addData}Data`]: tableData = [], [`${addData}Config`]: config = {} } = props;
const copyConfig = config?.gdsconfigformslave?.find(item => item.sControlName.toLowerCase().includes('btnscanface'))
proData.forEach(item => {
const data = commonFunc.getAssignFieldValue(copyConfig?.sAssignField, item)
const index = tableData.findIndex(x => x.sEmployeeNo === item.sEmployeeNo)
if (index !== -1) {
message.error('人员重复,请重新添加', 5)
} else {
tableData.push({
...item,
...data,
sId: commonUtils.createSid(),
handleType: "add",
sParentId: props.masterData.sId,
slaveId: props?.slaveData ? props?.slaveData[0].sId : ''
})
}
});
props.onSaveState({
[`${addData}Data`]: tableData,
mesRefresh: true
});
},
onConfirm: () => { },
onError: () => { }
});
},
});
}
export default ToolbarFun;