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 commonFunc from "@/components/Common/commonFunc"; // 通用方法 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; console.log('3managementData3', managementData); const { iTeamType, sWorkshopId } = userinfo; if ([3, 4, 5, 6].includes(iTeamType)) { const scheduledTasks = managementData.find( item => (item.sMenuName === "计划任务" || item.sMenuName?.trim() === "Scheduled Tasks") ); if (scheduledTasks && scheduledTasks.children) { const iIndex = scheduledTasks.children.findIndex( child => (child.sMenuName === "生产返工" || child.sMenuName?.trim() === "Production Rework") ); if (iIndex !== -1) { scheduledTasks.children.splice(iIndex, 1); } } const restArr = []; if(userinfo?.sLanguage ==='sEnglish') { if (iTeamType === 3) { restArr.push("研发工艺参数"); } else if ([4, 5].includes(iTeamType)) { restArr.push("研发工艺参数(烫金)"); restArr.push("研发工艺参数(模切)"); } else if (iTeamType === 6) { restArr.push("研发工艺参数(丝印)"); } } else{ if (iTeamType === 3) { restArr.push("R&D Process Parameters"); } else if ([4, 5].includes(iTeamType)) { restArr.push("R&D Process Parameters (Hot Stampinging)"); restArr.push("R&D Process Parameters (Die-Cutting)"); } else if (iTeamType === 6) { restArr.push("R&D Process Parameters (Screen Printing)"); } } const productionExecMain = managementData.find( item => (item.sMenuName === "生产执行" || item.sMenuName === "Production Execution") ); console.log('productionExecMain', productionExecMain); if ( productionExecMain && productionExecMain.children) { const forLength = productionExecMain.children.length; for (let i = 0; i < forLength; i++) { const iIndex = productionExecMain.children.findIndex( child => !["生产执行", "质量巡检", "研发改版记录", "Production Execution", "Quality Inspection", "R&D Revision Records", ...restArr].includes( child.sMenuName ) ); if (iIndex !== -1) { productionExecMain.children.splice(iIndex, 1); } } } } else { const productionExecMain = managementData.find( item => (item.sMenuName === "生产执行" || item.sMenuName === "Production Execution") ); if (productionExecMain && productionExecMain.children) { for (let i = 0; i < 4; i++) { const iIndex = productionExecMain.children.findIndex(child => child.sMenuName.includes("研发工艺参数") || child.sMenuName.includes("R&D Process Parameters") ); if (iIndex !== -1) { productionExecMain.children.splice(iIndex, 1); } } } } if (sWorkshopId !== "20240511102738376607209385783909") { const productionExecMain = managementData.find( item => (item.sMenuName === "生产执行" || item.sMenuName === "Production Execution") ); if (productionExecMain && productionExecMain.children) { const iIndex = productionExecMain.children.findIndex(child => (child.sMenuName.includes("研发改版记录") || child.sMenuName.includes("R&D Revision Records")) ); 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?.trim() && !item.sName.includes("Modal") && ( item.sMenuName !== "工单物料信息" || item.sMenuName !== "Work Order Material Information") ) .map(item => { const { sId, sMenuName, sName } = item; return { name: sMenuName?.trim(), 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 language = props.app.userinfo?.sLanguage; const menuOrderListEnglish1 = [ ["Machine Task", 1], null, ["Label Reprint", 2], null, ["Work Order Information", 2, 'Label Reprint'], ["Product Quality Record", 3, 'Label Reprint'], ["Process Work Instructions", 4, 'Label Reprint'], ["Related Documents", 5, 'Label Reprint'], ["Historical Tasks", 6, 'Label Reprint'], ["Production Rework", 2, 'Label Reprint'], null, null, // ["工单物料信息", 7], ["Pre-production Reminder Information", 7, 'Label Reprint'], ["Work Order WIP List", 8, 'Label Reprint'], null, null ]; 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 menuOrderListEnglish2 = [ ["Production Execution", 10], ["First Approval Sample Notice", 11], ["Exception/Assistance Reporting", 12], ["Post-Completion Clearance/Confirmation", 13], ["Plate Splitting/Combining", 14], null, null, ["Quality Patrol Inspection List", 15], ["Team Production Reporting", 16], ["Sign-off/Completion", 17], ["Team Handover", 18], ["Work Order Change Information", 19], ["Other Machine Daily Report", 16], null, null, ["Process Inspection", 20] ]; const menuOrderList3 = [ ["设备保养", 21], // ["设备点检", 22], ["设备维修", 23], ["设备资料", 24] ]; const menuOrderListEnglish3 = [ ["Equipment Maintenance", 21], // ["Equipment Check", 22], ["Equipment Repair", 23], ["Equipment Documentation", 24] ]; const menuOrderListLocal1 = language === 'sEnglish' ? menuOrderListEnglish1 : menuOrderList1; const menuOrderListLocal2 = language === 'sEnglish' ? menuOrderListEnglish2 : menuOrderList2; const menuOrderListLocal3 = language === 'sEnglish' ? menuOrderListEnglish3 : menuOrderList3; const menuList = []; new Array(16).fill("").forEach((_, index) => { const itemName = [ menuOrderListLocal1[index]?.[0], menuOrderListLocal2[index]?.[0], menuOrderListLocal3[index]?.[0] ]; const icon = [ menuOrderListLocal1[index]?.[1], menuOrderListLocal2[index]?.[1], menuOrderListLocal3[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); }); console.log('menuList:', menuList); dataList.forEach(item => { if (!menuList.some(item1 => item1.name === item.name)) { const iIndex = menuList.findIndex(item1 => !item1); menuList[iIndex] = item; } }); console.log('dataList:', dataList); // 点击 const itemClick = e => { const { id, disabled, sName } = e; if (id == sModelsId || disabled) return; if (e.name !== "首签样通知" && e.name?.trim() !== "First Approval Sample Notice") { 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
; 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 === "完工清场/确认" || e.name ==='Post-Completion Clearance/Confirmation' )) { bHideTab = true; } // 生产执行+未上班+不是生产执行或者班组报工 点击给提示 let bStartWorkLimit = false; const bStartWork = commonUtils.getAppData("userinfo", "bStartWork"); if ( props.currentContent === "productionExec" && !bStartWork && ( !["生产执行", "班组报工", "其它机台日报"].includes(e.name) || !["Production Execution", "Team Production Reporting ", "Other Machine Daily Report"].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 === "机台任务" || e.name ==='Machine Task') { count = table0; } else if (e.name === "历史任务" || e.name ==='Historical Tasks') { count = table1; } else if (e.name === "工序任务" || e.name ==='Process Task') { count = table2; } else if (e.name === "其它机台日报" || e.name === "Other Machine Daily Report") { count = table3; } const workFirst = commonFunc.showLocalMessage(props, 'workFirst', '请先上班后再操作'); const FriendlyReminder = commonFunc.showLocalMessage(props, 'FriendlyReminder', '温馨提示'); const BtnSure = commonFunc.showLocalMessage(props, 'BtnSure', '确认'); const NotAllowedBoards = commonFunc.showLocalMessage(props, 'NotAllowedBoards', '当前工序不允许拆合板!'); return (
{ if (bStartWorkLimit) { Modal.warning({ title: FriendlyReminder, content:
{workFirst}
, okText: BtnSure }); return; } if (bChaihebanLimit) { Modal.warning({ title: FriendlyReminder, content:
{NotAllowedBoards}
, okText: BtnSure }); return; } if (bHideTab) return; itemClick(e); }} className={termClass({ btnsBoxItem: true, active: e.id == sModelsId, disabled: e.disabled || bHideTab })} >
{e.name}
); }; console.log(menuList, '1menuLis111t '); return (
{menuList.map((e, index) => renderItem(e, index))}
setExpand(!expand)} />
); }; export default ButtonComponent;