index.js
9.86 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
import { useState, useEffect } from "react";
import { Image, Badge, Modal } from "antd";
import termClass from "classnames/bind";
import { DoubleRightOutlined } from "@ant-design/icons";
import styles from "./index.less";
// 通用方法
import * as commonUtils from "@/utils/utils";
// 菜单图标
const getNavIcon = (bActive, iconName = 2) => {
const picName = bActive ? `${iconName}_1.png` : `${iconName}.png`;
return require(`@/assets/btnComponentIcon/${picName}`);
};
const ButtonComponent = props => {
const { app, sModelsId, currentContent, menuMap } = props;
const { managementData, userinfo = {} } = app;
const { iTeamType, sWorkshopId } = userinfo;
if ([3, 4, 5, 6].includes(iTeamType)) {
const scheduledTasks = managementData.find(
item => item.sMenuName === "计划任务"
);
if (scheduledTasks && scheduledTasks.children) {
const iIndex = scheduledTasks.children.findIndex(
child => child.sMenuName === "生产返工"
);
if (iIndex !== -1) {
scheduledTasks.children.splice(iIndex, 1);
}
}
const restArr = [];
if (iTeamType === 3) {
restArr.push("研发工艺参数");
} else if ([4, 5].includes(iTeamType)) {
restArr.push("研发工艺参数(烫金)");
restArr.push("研发工艺参数(模切)");
} else if (iTeamType === 6) {
restArr.push("研发工艺参数(丝印)");
}
const productionExecMain = managementData.find(
item => item.sMenuName === "生产执行"
);
if (productionExecMain && productionExecMain.children) {
const forLength = productionExecMain.children.length;
for (let i = 0; i < forLength; i++) {
const iIndex = productionExecMain.children.findIndex(
child =>
!["生产执行", "质量巡检", "研发改版记录", ...restArr].includes(
child.sMenuName
)
);
if (iIndex !== -1) {
productionExecMain.children.splice(iIndex, 1);
}
}
}
} else {
const productionExecMain = managementData.find(
item => item.sMenuName === "生产执行"
);
if (productionExecMain && productionExecMain.children) {
for (let i = 0; i < 4; i++) {
const iIndex = productionExecMain.children.findIndex(child =>
child.sMenuName.includes("研发工艺参数")
);
if (iIndex !== -1) {
productionExecMain.children.splice(iIndex, 1);
}
}
}
}
if (sWorkshopId !== "20240511102738376607209385783909") {
const productionExecMain = managementData.find(
item => item.sMenuName === "生产执行"
);
if (productionExecMain && productionExecMain.children) {
const iIndex = productionExecMain.children.findIndex(child =>
child.sMenuName.includes("研发改版记录")
);
if (iIndex !== -1) {
productionExecMain.children.splice(iIndex, 1);
}
}
}
const [expand, setExpand] = useState(true);
const [processReport, setProcessReport] = useState(false);
const [dataList, setDataList] = useState([]);
useEffect(
() => {
if (managementData.length) {
const sParentId = menuMap[currentContent];
if (!sParentId) return;
const parent = managementData.find(item => item.sId === sParentId);
if (!parent || !commonUtils.isNotEmptyArr(parent.children)) return;
const btnList = parent.children;
const newList = btnList
.filter(
item =>
item.sName &&
!item.sName.includes("Modal") &&
item.sMenuName !== "工单物料信息"
)
.map(item => {
const { sId, sMenuName, sName } = item;
return {
name: sMenuName,
id: sId,
sName,
badeg: 0,
// badeg: index === 0 ? 1 : index === 4 ? 10 : index === 8 ? 999 : 0,
icon: getNavIcon(false),
activeIcon: getNavIcon(true),
disabled: false
};
});
setDataList(newList);
}
// 是否为维修保养模块和查询追踪模块
setProcessReport(
props.currentContent === 'queryTracking' ||
props.currentContent === "serviceUpkeep" ||
(props.currentContent === "productionExec" && [3, 4, 5, 6].includes(iTeamType))
);
},
[JSON.stringify(managementData)]
);
const menuOrderList1 = [
["机台任务", 1],
null,
["标签补打", 2],
null,
["工单信息", 2],
["产品质量档案", 3],
["工艺作业指导书", 4],
["相关文档", 5],
["历史任务", 6],
["生产返工", 2],
null,
null,
// ["工单物料信息", 7],
["产前提醒信息", 7],
["工单在制品清单", 8],
null,
null
];
const menuOrderList2 = [
["生产执行", 10],
["首签样通知", 11],
["异常/协助提报", 12],
["完工清场/确认单据", 13],
["拆合版", 14],
null,
null,
["质量巡检", 15],
["班组报工", 16],
["签样/完成", 17],
["班组交接", 18],
["工单变更信息", 19],
["其它机台日报", 16],
null,
null,
["工艺巡检", 20]
];
const menuOrderList3 = [
["设备保养", 21],
["设备点检", 22],
["设备维修", 23],
["设备资料", 24]
];
const menuList = [];
new Array(16).fill("").forEach((_, index) => {
const itemName = [
menuOrderList1[index]?.[0],
menuOrderList2[index]?.[0],
menuOrderList3[index]?.[0]
];
const icon = [
menuOrderList1[index]?.[1],
menuOrderList2[index]?.[1],
menuOrderList3[index]?.[1]
];
const item = dataList.find(item => itemName.includes(item.name));
let result = "";
if (item) {
const iIndex = itemName.findIndex(item1 => item1 === item.name);
const iconName = icon[iIndex];
item.icon = getNavIcon(false, iconName);
item.activeIcon = getNavIcon(true, iconName);
result = item;
}
menuList.push(result);
});
dataList.forEach(item => {
if (!menuList.some(item1 => item1.name === item.name)) {
const iIndex = menuList.findIndex(item1 => !item1);
menuList[iIndex] = item;
}
});
// 点击
const itemClick = e => {
const { id, disabled, sName } = e;
if (id == sModelsId || disabled) return;
if (e.name !== "首签样通知") {
props.onChangeRouter({
routerPath: [currentContent],
sModelsId: id,
sModelType: sName
});
} else {
props.openFirstNotice(e);
}
};
const counterInfo = props.app.counterInfo || {};
const { table0 = 0, table1 = 0, table2 = 0, table3 = 0 } = counterInfo;
// 每个item
const renderItem = (e, index) => {
// (取消)延迟加班按钮
const userinfo = props.app.userinfo;
if (!e) return <div />;
const currentWorkOrderInfo =
commonUtils.convertStrToObj(localStorage.xlybusinessglobalData)
.currentWorkOrderInfo || {};
const iInterface = currentWorkOrderInfo.iInterface || userinfo.iInterface;
let bHideTab = false;
// 【踢废,拼接,倒卷,读码】完工清场记录不可点击
if ([5, 6, 7, 8].includes(iInterface) && e.name === "完工清场/确认") {
bHideTab = true;
}
// 生产执行+未上班+不是生产执行或者班组报工 点击给提示
let bStartWorkLimit = false;
const bStartWork = commonUtils.getAppData("userinfo", "bStartWork");
if (
props.currentContent === "productionExec" &&
!bStartWork &&
!["生产执行", "班组报工", "其它机台日报"].includes(e.name)
) {
bStartWorkLimit = true;
}
// iInterface除了0-3的都不允许拆合板
let bChaihebanLimit = false;
if (iInterface > 3 && ["拆合板"].includes(e.name)) {
bChaihebanLimit = true;
}
let count = e.disabled ? 0 : e.badeg;
if (e.name === "机台任务") {
count = table0;
} else if (e.name === "历史任务") {
count = table1;
} else if (e.name === "工序任务") {
count = table2;
} else if (e.name === "其它机台日报") {
count = table3;
}
return (
<div
key={e.id}
onClick={() => {
if (bStartWorkLimit) {
Modal.warning({
title: "温馨提示:",
content: <div>请先上班后再操作!</div>,
okText: "确认"
});
return;
}
if (bChaihebanLimit) {
Modal.warning({
title: "温馨提示:",
content: <div>当前工序不允许拆合板!</div>,
okText: "确认"
});
return;
}
if (bHideTab) return;
itemClick(e);
}}
className={termClass({
btnsBoxItem: true,
active: e.id == sModelsId,
disabled: e.disabled || bHideTab
})}
>
<Badge className="itemBadge" count={count} offset={[0, -1]}>
<Image
src={e.id == sModelsId ? e.activeIcon : e.icon}
preview={false}
style={{ width: 30 }}
/>
<div
className="itemName"
title={e.name}
style={{ "-webkit-box-orient": "vertical" }}
>
{e.name}
</div>
</Badge>
</div>
);
};
return (
<div
className={`${styles.buttonComponent} ${
expand ? styles.expand : styles.packup
} ${processReport ? styles.specialBtns : ""}`}
>
<div className={`btns`}>
<div className={styles.btnsBox}>
{menuList.map((e, index) => renderItem(e, index))}
</div>
</div>
<div className="arrow">
<div className="expandCut">
<DoubleRightOutlined
rotate={expand ? -90 : 90}
onClick={() => setExpand(!expand)}
/>
</div>
</div>
</div>
);
};
export default ButtonComponent;