MesToolbar.js
6.25 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
/* eslint-disable */
import { message } from "antd";
import * as commonUtils from "@/utils/utils";
import * as commonFunc from "@/components/Common/commonFunc";
const ToolbarFun = async (props) => {
const { btnConfig, bMesBill } = props;
const currentMesPane = commonUtils.getAppData("currentMesPane");
const { sModelType = '' } = currentMesPane;
const { sControlName } = 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;
}
// const { sControlName } = btnConfig;
// const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase();
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')) {
let flag = 0;
let interfaceArr = btnConfig.interface;
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(beforeInterfaceArr[i]);
if (!data) {
flag += 1;
return;
}
}
};
await asyncFunc();
}
let result;
if (flag == 0) {
result = await props.onBtnExamine();
} else {
props.onSaveState({
loading: false,
});
}
if (commonUtils.isNotEmptyArr(afterInterfaceArr)) {
/* 之后调用 */
// const result = await this.props.onBtnExamine();
if (result) {
/* 只有审核成功 才能调用接口 -5代表审核失败 */
const asyncFunc = async () => {
for (let i = 0; i < afterInterfaceArr.length; i++) {
await handleInterfaceCall(afterInterfaceArr[i], true);
}
};
await asyncFunc();
}
}
} else {
console.log(props, 'masterData');
// props.onBtnExamine();
}
}
return true;
}
// 新增
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,
});
}
});
}
// 人脸数据采集
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"
},
])
},
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
});
},
onConfirm: () => { },
onError: () => { }
});
},
});
}
export default ToolbarFun;