Commit 3f78182792eccda6e91b90c6fb091e78cc213f31

Authored by zhangzzzz
1 parent 2e6b9e9f

菜单根据接口返回顺序展示;

src/mes/common/buttonComponent/index.js
... ... @@ -16,64 +16,8 @@ const ButtonComponent = props => {
16 16 const { app, sModelsId, currentContent, menuMap } = props;
17 17 const { managementData, userinfo = {} } = app;
18 18 const { iTeamType } = userinfo;
19   - console.log('managementData', managementData);
20   - if ([3, 4, 5, 6].includes(iTeamType)) {
21   - const scheduledTasks = managementData.find(
22   - item => item.sMenuName === "计划任务"
23   - );
24   - if (scheduledTasks && scheduledTasks.children) {
25   - const iIndex = scheduledTasks.children.findIndex(
26   - child => child.sMenuName === "生产返工"
27   - );
28   - if (iIndex !== -1) {
29   - scheduledTasks.children.splice(iIndex, 1);
30   - }
31   - }
32   -
33   - const restArr = [];
34   - if (iTeamType === 3) {
35   - restArr.push("研发工艺参数");
36   - } else if ([4, 5].includes(iTeamType)) {
37   - restArr.push("研发工艺参数(烫金)");
38   - restArr.push("研发工艺参数(模切)");
39   - } else if (iTeamType === 6) {
40   - restArr.push("研发工艺参数(丝印)");
41   - }
42   - const productionExecMain = managementData.find(
43   - item => item.sMenuName === "生产执行"
44   - );
45   - if (productionExecMain && productionExecMain.children) {
46   - const forLength = productionExecMain.children.length;
47   - for (let i = 0; i < forLength; i++) {
48   - const iIndex = productionExecMain.children.findIndex(
49   - child =>
50   - !["生产执行", "质量巡检", ...restArr].includes(child.sMenuName)
51   - );
52   - if (iIndex !== -1) {
53   - productionExecMain.children.splice(iIndex, 1);
54   - }
55   - }
56   - }
57   - } else {
58   - console.log('managementData', managementData);
59   - const productionExecMain = managementData.find(
60   - item => item.sMenuName === "生产执行"
61   - );
62   - if (productionExecMain && productionExecMain.children) {
63   - for (let i = 0; i < 4; i++) {
64   - const iIndex = productionExecMain.children.findIndex(child =>
65   - child.sMenuName.includes("研发工艺参数")
66   - );
67   - if (iIndex !== -1) {
68   - productionExecMain.children.splice(iIndex, 1);
69   - }
70   - }
71   - }
72   - }
73 19  
74 20 const [expand, setExpand] = useState(true);
75   - const [processReport, setProcessReport] = useState(false);
76   -
77 21 const [dataList, setDataList] = useState([]);
78 22  
79 23 useEffect(
... ... @@ -89,8 +33,7 @@ const ButtonComponent = props =&gt; {
89 33 .filter(
90 34 item =>
91 35 item.sName &&
92   - !item.sName.includes("Modal") &&
93   - item.sMenuName !== "工单物料信息"
  36 + !item.sName.includes("Modal")
94 37 )
95 38 .map(item => {
96 39 const { sId, sMenuName, sName } = item;
... ... @@ -99,7 +42,6 @@ const ButtonComponent = props =&gt; {
99 42 id: sId,
100 43 sName,
101 44 badeg: 0,
102   - // badeg: index === 0 ? 1 : index === 4 ? 10 : index === 8 ? 999 : 0,
103 45 icon: getNavIcon(false),
104 46 activeIcon: getNavIcon(true),
105 47 disabled: false
... ... @@ -108,93 +50,46 @@ const ButtonComponent = props =&gt; {
108 50  
109 51 setDataList(newList);
110 52 }
111   -
112   - // 是否为维修保养模块
113   - setProcessReport(
114   - props.currentContent === "serviceUpkeep" ||
115   - (props.currentContent === "productionExec" &&
116   - [3, 4, 5, 6].includes(iTeamType))
117   - );
118 53 },
119 54 [JSON.stringify(managementData)]
120 55 );
121 56  
122   - const menuOrderList1 = [
123   - ["机台任务", 1],
124   - null,
125   - ["标签补打", 2],
126   - null,
127   - ["工单信息", 2],
128   - ["产品质量档案", 3],
129   - ["工艺作业指导书", 4],
130   - ["相关文档", 5],
131   - ["历史任务", 6],
132   - ["生产返工", 2],
133   - null,
134   - null,
135   - // ["产前提醒信息", 7],
136   - null,
137   - ["工单在制品清单", 8],
138   - ["产前提醒信息", 7],
139   - null
140   - ];
141   -
142   - const menuOrderList2 = [
143   - ["生产执行", 10],
144   - ["首签样通知", 11],
145   - ["异常/协助提报", 12],
146   - ["完工清场/确认单据", 13],
147   - ["拆合版", 14],
148   - null,
149   - null,
150   - ["质量巡检", 15],
151   - ["班组报工", 16],
152   - ["签样/完成", 17],
153   - ["班组交接", 18],
154   - ["工单变更信息", 19],
155   - ["其它机台日报", 16],
156   - ["印刷出版任务", 2],
157   - null,
158   - ["工艺巡检", 20]
159   - ];
160   -
161   - const menuOrderList3 = [
162   - ["设备保养", 21],
163   - ["设备点检", 22],
164   - ["设备维修", 23],
165   - ["设备资料", 24]
166   - ];
167   -
168   - const menuList = [];
169   - new Array(16).fill("").forEach((_, index) => {
170   - const itemName = [
171   - menuOrderList1[index]?.[0],
172   - menuOrderList2[index]?.[0],
173   - menuOrderList3[index]?.[0]
174   - ];
175   - const icon = [
176   - menuOrderList1[index]?.[1],
177   - menuOrderList2[index]?.[1],
178   - menuOrderList3[index]?.[1]
179   - ];
180   - const item = dataList.find(item => itemName.includes(item.name));
181   - let result = "";
182   - if (item) {
183   - const iIndex = itemName.findIndex(item1 => item1 === item.name);
184   - const iconName = icon[iIndex];
185   - item.icon = getNavIcon(false, iconName);
186   - item.activeIcon = getNavIcon(true, iconName);
187   - result = item;
188   - }
189   - menuList.push(result);
190   - });
  57 + const iconJson = {
  58 + "机台任务": 1,
  59 + "标签补打": 2,
  60 + "工单信息": 2,
  61 + "产品质量档案": 3,
  62 + "工艺作业指导书": 4,
  63 + "相关文档": 5,
  64 + "历史任务": 6,
  65 + "生产返工": 2,
  66 + "产前提醒信息": 7,
  67 + "工单在制品清单": 8,
  68 + "生产执行": 10,
  69 + "首签样通知": 11,
  70 + "异常/协助提报": 12,
  71 + "完工清场/确认单据": 13,
  72 + "拆合版": 14,
  73 + "质量巡检": 15,
  74 + "班组报工": 16,
  75 + "签样/完成": 17,
  76 + "班组交接": 18,
  77 + "工单变更信息": 19,
  78 + "其它机台日报": 16,
  79 + "印刷出版任务": 2,
  80 + "工艺巡检": 20,
  81 + "设备保养": 21,
  82 + "设备点检": 22,
  83 + "设备维修": 23,
  84 + "设备资料": 24
  85 + }
191 86  
192   - dataList.forEach(item => {
193   - if (!menuList.some(item1 => item1.name === item.name)) {
194   - const iIndex = menuList.findIndex(item1 => !item1);
195   - menuList[iIndex] = item;
196   - }
197   - });
  87 + const menuList = dataList.map(item => {
  88 + const iconName = iconJson[item.name];
  89 + item.icon = getNavIcon(false, iconName);
  90 + item.activeIcon = getNavIcon(true, iconName);
  91 + return item;
  92 + })
198 93  
199 94 // 点击
200 95 const itemClick = e => {
... ... @@ -311,9 +206,8 @@ const ButtonComponent = props =&gt; {
311 206  
312 207 return (
313 208 <div
314   - className={`${styles.buttonComponent} ${
315   - expand ? styles.expand : styles.packup
316   - } ${processReport ? styles.specialBtns : ""}`}
  209 + className={`${styles.buttonComponent} ${expand ? styles.expand : styles.packup
  210 + } ${dataList.length && dataList.length <= 8 ? styles.specialBtns : ""}`}
317 211 >
318 212 <div className={`btns`}>
319 213 <div className={styles.btnsBox}>
... ...