From c107d09c0220ea815069d99a26eb7b98b7deafeb Mon Sep 17 00:00:00 2001 From: zhangz Date: Thu, 11 Dec 2025 14:13:14 +0800 Subject: [PATCH] commonbill功能v1; --- src/components/Common/CommonHooks/useCommonBase.js | 70 ++++++++++++++++++++++++++++++++++++++++++++-------------------------- src/components/Common/CommonViewTable/index.js | 2 +- src/mes/common/commonModelComponent/index.js | 61 ++++++++++++++++++++++++++++++++++++++++++------------------- src/mes/common/commonOperationBarComponent/MesToolbar.js | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mes/common/commonOperationBarComponent/index.js | 19 ++++++++++++++++++- src/mes/indexMes/index.js | 14 +++++++++----- src/mes/scheduledTasks/machineTasks/index.js | 57 +++++++++++++-------------------------------------------- 7 files changed, 212 insertions(+), 96 deletions(-) create mode 100644 src/mes/common/commonOperationBarComponent/MesToolbar.js diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js index 8fe1235..cc5778e 100644 --- a/src/components/Common/CommonHooks/useCommonBase.js +++ b/src/components/Common/CommonHooks/useCommonBase.js @@ -56,33 +56,51 @@ const useCommonBase = props => { } const { sModelsId, app } = state; const formData = await handleGetModelConfig({ sModelsId }); + + const addState = {}; + let pageRoute = props.sModelType; + // 如果是弹窗且没有pageLayout,则认为是commonBill + if (commonUtils.isNotEmptyObject(props.parentProps) && formData.length && !formData[0].gdsconfigformslave.some(item => item.sControlName === 'pageLayout')) { + pageRoute = '/indexPage/commonBill'; + } + + if (formData.length && !props.currentContent && ['/indexPage/commonList', '/indexPage/commonBill'].includes(pageRoute) && !formData[0].gdsconfigformslave.some(item => item.sControlName === 'pageLayout')) { + if (pageRoute === '/indexPage/commonList') { + formData[0].sGrd = 'slave'; + formData[0].gdsconfigformslave.push({ + sId: commonUtils.createSid(), + sControlName: 'pageLayout', + sDefault: JSON.stringify([["slave"],[{"configList":[{"sName":"slave","sTabName":"","sEnglishTabName":"","sBig5TabName":"","showType":"table","bHideTitle":true,"tableBtnsConfig":[]}],"mode":"advanced","height":"100%","width":"100%"}]]) + }) + } else if (pageRoute === '/indexPage/commonBill') { + const { sLanguage } = app.userinfo; + const [tableList, tabConfig] = [[], []]; + formData.forEach((item, index) => { + if (index === 0) { + item.sGrd = 'master'; + tableList.push('master'); + tabConfig.push({"configList":[{"sName":"master","showType":"form","bHideTitle":true,"defaultEnabled":true}],"mode":"advanced","height":"auto","width":"100%"}); + } else { + const tablename = `slave${index - 2 < 0 ? '' : index - 2}`; + item.sGrd = tablename; + tableList.push(tablename); + if (!tabConfig[1]) { + tabConfig.push({"configList":[],"mode":"advanced"}); + } + tabConfig[1].configList.push({"sName":tablename,"sTabName":item[sLanguage],"showType":"table","defaultEnabled":true,"bHideTitle":true}); + } + }); + formData[0].gdsconfigformslave.push({ + sId: commonUtils.createSid(), + sControlName: 'pageLayout', + sDefault: JSON.stringify([tableList, tabConfig]) + }) + addState.bMesBill = true; + addState.copyTo = { master: { maxBillNo: 'sBillNo' } }; + } + } - // 班组报工特殊处理 - // if (state.sModelsId === "12710101117087404588200") { - // const { userinfo = {} } = app; - // const globalData = commonUtils.convertStrToObj( - // localStorage.xlybusinessglobalData - // ); - // const iInterface = - // globalData.currentWorkOrderInfo?.iInterface || userinfo.iInterface; - // const iIndex = formData.findIndex(item => item.sGrd === "table1"); - // if (iIndex !== -1) { - // const iIndex1 = formData[iIndex].gdsconfigformslave.findIndex( - // item => item.sName === "sBoardNo" - // ); - // if (iIndex1 !== -1) { - // if (iInterface === 10) { - // // 包装的托盘计数信息托盘板号改为包装板号 - // formData[iIndex].gdsconfigformslave[iIndex1].showName = "包装板号"; - // } else if (iInterface === 9) { - // // 品检的托盘计数信息托盘板号改为质检板号 - // formData[iIndex].gdsconfigformslave[iIndex1].showName = "质检板号"; - // } - // } - // } - // } - - handleSaveState({ formData }); + handleSaveState({ formData, ...addState }); }, []); const { callbackRefresh, callback } = state; diff --git a/src/components/Common/CommonViewTable/index.js b/src/components/Common/CommonViewTable/index.js index 9784790..8ab0bbd 100644 --- a/src/components/Common/CommonViewTable/index.js +++ b/src/components/Common/CommonViewTable/index.js @@ -487,7 +487,7 @@ class CommonViewTableRc extends Component { enabledNew = true; } - if (this.props.enabledNew !== undefined) { + if (!this.props.bMesBill && this.props.enabledNew !== undefined) { enabledNew = this.props.enabledNew; } diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js index 2822360..f7168e3 100644 --- a/src/mes/common/commonModelComponent/index.js +++ b/src/mes/common/commonModelComponent/index.js @@ -29,7 +29,8 @@ const useCommonModelEvent = props => { enabled, copyTo, sFilterConditions, // 父页面过滤条件 - noGetData // 不要加载数据,根据另一张表选中行加载时用 + noGetData, // 不要加载数据,根据另一张表选中行加载时用 + currentId, } = props; let formData = @@ -279,24 +280,31 @@ const useCommonModelEvent = props => { pageLayout = handleGetFilterPageLayout(pageLayout); const [tableList, tabConfig] = pageLayout; const colunmData = handleGetColumnData(tableList, true); - const result = !noGetData - ? await handleGetData(tableList, true, true) - : await handleGetData( - tableList.filter( - item => - item === "workerOrderBatchMaterial" || item === "plateInfo" - ), - true, - true - ); + let result = {}; + if (!commonUtils.isEmptyObject(copyTo) && !refreshCount) { + + } else if (noGetData) { + result = await await handleGetData( + tableList.filter( + item => + item === "workerOrderBatchMaterial" || item === "plateInfo" + ), + true, + true + ); + } else { + result = await handleGetData(tableList, true, true); + } + if (!currentId) { + addState.bFinish = props.bFinish ? props.bFinish + 1 : 1; + } addState = { ...addState, tableList, tabConfig, ...colunmData, ...result, - firstTableName: tableList[0], - bFinish: props.bFinish ? props.bFinish + 1 : 1 + firstTableName: tableList[0] }; // 读码时,点下料不需要选中,使用指令集 clearrowkey, 发现与这个是异步的,导致还是选中状态。 // addState["salveWydm1SelectedRowKeys"] = []; // 0806解决生成检验标示后选中状态消失 @@ -327,7 +335,7 @@ const useCommonModelEvent = props => { [ formData.length, refreshCount, - enabled, + // enabled, noGetData, JSON.stringify(sFilterConditions) ] @@ -567,6 +575,14 @@ const useCommonModelEvent = props => { conditonValues.sSReserve1 = props.sSReserve1; } + if (currentId) { + if (tableName === 'master') { + conditonValues.sId = currentId; + } else { + conditonValues.sParentId = currentId; + } + } + const result = (await props.onGetDataSet({ name: tableName, @@ -1138,7 +1154,7 @@ const useGetSelectedDataGroup = props => { [`${tableName}SelectedRowKeys`]: selectedRowKeys = [] } = props; - if (selectedRowKeys.length) { + if (tableName !== 'master' && selectedRowKeys.length) { const rowData = tableData.find( item => selectedRowKeys.includes(item.sId) || @@ -1185,7 +1201,7 @@ const CommonModel = baseProps => { }; const CommonModelComponent = props => { - const { tabConfig = [], level, modelStyle, app } = props; + const { tabConfig = [], level, modelStyle, app, bMesBill, enabled } = props; const { userinfo } = app; const sLanguage = userinfo.sLanguage; const getComponent = (config, index = 0) => { @@ -1220,7 +1236,7 @@ const CommonModelComponent = props => { const componentProps = { ...props, showType, // 展示类型(表单/表格) - enabled: defaultEnabled, // 是否可编辑 + enabled: !bMesBill ? defaultEnabled: enabled, // 是否可编辑 sTabName, // 标题名称 sName, // 配置对应的sGrd bHideTitle, //隐藏标题 @@ -1242,9 +1258,16 @@ const CommonModelComponent = props => { } }; + const extraStyle = {}; + if (bMesBill) { + extraStyle.display = 'flex'; + extraStyle.flexDirection = 'column'; + extraStyle.paddingTop = 5; + } + return ( <> -
+
{tabConfig.map(item => { const { configList = [], @@ -1427,7 +1450,7 @@ const TabTitleComponent = props => { // 表单组件 const CommonViewTableComponent = props => { - const { sTabName, showType, sName } = props; + const { sTabName = "", showType, sName } = props; if (showType !== "form") return ""; const { diff --git a/src/mes/common/commonOperationBarComponent/MesToolbar.js b/src/mes/common/commonOperationBarComponent/MesToolbar.js new file mode 100644 index 0000000..f307efa --- /dev/null +++ b/src/mes/common/commonOperationBarComponent/MesToolbar.js @@ -0,0 +1,85 @@ +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(); + if (btnName === 'btnadd') { + handleAdd(props); + } else if (btnName === 'btnsave') { + handleSave(props); + } else if (btnName === 'btnupd') { + props.onSaveState({ enabled: true }); + } + + + 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) => { + result = [...result, ...item.children]; + return result; + }, []); + + const menu = menuList.find(item => item.sId === sActiveId); + if (!menu) { + message.error('弹窗界面不在MES菜单中'); + return; + } + + 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, enabled: false + }); + } + }); +} + +export default ToolbarFun; \ No newline at end of file diff --git a/src/mes/common/commonOperationBarComponent/index.js b/src/mes/common/commonOperationBarComponent/index.js index 04d0f50..22ddc14 100644 --- a/src/mes/common/commonOperationBarComponent/index.js +++ b/src/mes/common/commonOperationBarComponent/index.js @@ -8,6 +8,7 @@ import * as commonBusiness from "@/components/Common/commonBusiness"; import StaticEditTable from "@/components/Common/CommonTable"; import costomPageFun from "@/mes/costomPageFun"; import * as commonConfig from "@/utils/config"; +import MesToolbar from "./MesToolbar"; import styles from "./index.less"; import { Button, Space, Input, Modal, Dropdown, Popconfirm } from "antd"; @@ -92,6 +93,11 @@ const useCommonOperationBarComponentEvent = props => { const delayedOvertime = commonFunc.showLocalMessage(props, 'delayedOvertime', '延迟加班'); const cancelDelayedOvertime = commonFunc.showLocalMessage(props, 'cancelDelayedOvertime', '取消延迟加班'); + // 走工具栏功能逻辑 + if (MesToolbar({ ...props, btnConfig: config })) { + return; + } + // 自定义按钮事件 if ( costomPageFun({ @@ -472,7 +478,7 @@ const useCommonOperationBarComponentEvent = props => { onClick: handleBtnClick.bind(this, config, searchField) }; - const { sDefault } = config; + const { sDefault, sControlName } = config; const delayedOvertime = commonFunc.showLocalMessage(props, 'delayedOvertime', '延迟加班'); const cancelDelayedOvertime = commonFunc.showLocalMessage(props, 'cancelDelayedOvertime', '取消延迟加班'); @@ -589,6 +595,17 @@ const useCommonOperationBarComponentEvent = props => { } catch (error) { console.log("=====err", { tempData, str: sDefault, strNew, error }); } + } else if (props.bMesBill) { + const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase(); + if (props.enabled) { + if (["btnupd"].includes(btnName)) { + defaultProps.disabled = true; + } + } else { + if (["btnsave"].includes(btnName)) { + defaultProps.disabled = true; + } + } } const { sColor } = config; diff --git a/src/mes/indexMes/index.js b/src/mes/indexMes/index.js index 2099b44..30eaa9e 100644 --- a/src/mes/indexMes/index.js +++ b/src/mes/indexMes/index.js @@ -242,6 +242,7 @@ const useIndexMesEvent = props => { sModelType, type, path = [], + copyTo, sParentConditions = {} // 上层页面带过来的查询条件 } = params; const { managementData = [] } = props.app; @@ -261,7 +262,8 @@ const useIndexMesEvent = props => { routerPath: [menuMapOpposite[currentContent]], sModelsId, sModelType, - sParentConditions + sParentConditions, + copyTo }); } else if (type === "id") { // 未上班不能进维修保养 @@ -282,7 +284,8 @@ const useIndexMesEvent = props => { routerPath: [menuMapOpposite[lv1]], sModelsId: lv2, sModelType, - sParentConditions + sParentConditions, + copyTo } ]); } else { @@ -293,7 +296,8 @@ const useIndexMesEvent = props => { routerPath, sModelsId, sModelType, - sParentConditions + sParentConditions, + copyTo } ]); } @@ -323,12 +327,12 @@ const useIndexMesEvent = props => { }, []); // 监听菜单变化 - const { currentContent, sModelsId, sModelType, sParentConditions } = state; + const { currentContent, sModelsId, sModelType, sParentConditions, copyTo } = state; useEffect( () => { props.dispatch({ type: "app/saveCurrentMesPane", - payload: { currentContent, sModelsId, sModelType, sParentConditions } + payload: { currentContent, sModelsId, sModelType, sParentConditions, copyTo } }); }, [currentContent, sModelsId, sModelType] diff --git a/src/mes/scheduledTasks/machineTasks/index.js b/src/mes/scheduledTasks/machineTasks/index.js index 1cea01a..ea64072 100644 --- a/src/mes/scheduledTasks/machineTasks/index.js +++ b/src/mes/scheduledTasks/machineTasks/index.js @@ -343,7 +343,12 @@ const useInfoEvent = props => { // 开工、暂停事件 const handleTableBtnClick = async item => { const { tableName, index, record, tableData, config, iFlag } = item; - const { showName } = config; + const { showName, sControlName } = config; + + if (sControlName === 'BtnProductionReporting') { + props.onTableBtnClick(item); + return; + } if (showName === "完工") { Modal.confirm({ title: "温馨提示:", @@ -356,7 +361,6 @@ const useInfoEvent = props => { }); return; } - // const iStar = index === 0 ? 1 : 2; const { iStar } = record; if (iStar === 1) { @@ -511,9 +515,13 @@ const MachineTasks = baseProps => { // 表格业务 const [sSrcNo, setSSrcNo] = useState(""); + const tableBtnsConfig = slave0Config?.gdsconfigformslave?.filter( + item => item.sControlName === "BtnProductionReporting" + ) || []; // 顶部表格配置 const tableProps = { ...commonBusiness.getTableTypes("slave0", props), + data: [{ sId: "123" }], tableProps: { onChange: () => {}, loading: isTableLoading @@ -521,15 +529,6 @@ const MachineTasks = baseProps => { tableBtnsConfig: params => { const { record, index } = params; const { iStar } = record; - // const iStar = index === 0 ? 1 : 2; - - // const bStart = iStar === 1; - // const bPause = iStar === 2; - - // 1 :开工状态(显示暂停) 2: 暂停状态(显示开工) 3: 完工状态(显示完工,灰色) - // 开工:开工接口(现在)1:正常, -7:有开工,要有提示, -1: 错误提示 - // -7 :完工: iFlag:3 (完工上一条) 暂停:iFlag:2 (暂停上一条) - // 暂停:新接口 let showName, btnBgColor, sDefault; if (iStar === 1) { @@ -550,44 +549,14 @@ const MachineTasks = baseProps => { return [ { showName, btnBgColor, sDefault, startWorkConfig, pauseWorkConfig }, - { showName: "完工", btnBgColor: "#1890FF", sDefault } + { showName: "完工", btnBgColor: "#1890FF", sDefault }, + ...tableBtnsConfig ]; - - // return [ - // { - // ...startWorkConfig, - // showName: "开工", - // btnBgColor: bStart ? "#1890FF" : "#AAA" - // }, - // { - // ...pauseWorkConfig, - // showName: "暂停", - // btnBgColor: bPause ? "#FAAD14" : "#AAA" - // } - // ]; }, onTableBtnClick: item => { props.onTableBtnClick(item); - return; - // 通用按钮操作 - // props.onTableBtnClick(item); - const { tableName, index, record, tableData, config } = item; - const { iStar } = record; - const { showName } = config; - if (iStar === 1 && showName === "开工") { - setTableLoading(true); - props.onStartWork(item).finally(() => { - setTableLoading(false); - }); - } else if (iStar === 2 && showName === "暂停") { - setTableLoading(true); - handlePause({ item, props }).finally(() => { - setTableLoading(false); - props.onRefresh(); - }); - } }, - tableBtnsWidth: "190px", + tableBtnsWidth: "280px", fixedHeight: "335px" }; // 全部按钮事件 -- libgit2 0.22.2