MesToolbar.js
3.99 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
/* eslint-disable */
import { message } from "antd";
import * as commonUtils from "@/utils/utils";
const ToolbarFun = (props) => {
const { btnConfig, bMesBill } = props;
const currentMesPane = commonUtils.getAppData("currentMesPane");
const { sModelType } = currentMesPane;
if (!["/indexPage/commonList", "/indexPage/commonBill"].includes(sModelType) && !bMesBill) {
return false;
}
const { sControlName } = btnConfig;
const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase();
console.log("🚀 ~ ToolbarFun ~ btnName:", btnName)
if (btnName === 'btnadd') {
handleAdd(props);
} else if (btnName === 'btnsave') {
handleSave(props);
} else if (btnName === 'btnupd') {
props.onSaveState({ enabled: true });
} else if (btnName === 'btnscanface') {
handleScanFace(props);
} else if (btnName === 'btncancel') {
props.onCancel()
} else if (btnName === 'btndel') {
props.onDel(props)
}
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: () => {
console.log(1111, 'footer');
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"
},
])
},
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 = [] } = props;
proData.forEach(item => {
tableData.push({
...item,
sId: commonUtils.createSid(),
handleType: "add",
sParentId: props.masterData.sId,
})
});
props.onSaveState({
[`${addData}Data`]: tableData
});
},
onConfirm: () => { },
onError: () => { }
});
},
});
}
export default ToolbarFun;