From edd37f0b261c27c5c1fe752d891bab63957a9c34 Mon Sep 17 00:00:00 2001 From: chenxt <10125295+chen-xintao97@user.noreply.gitee.com> Date: Tue, 23 Dec 2025 16:57:03 +0800 Subject: [PATCH] 放大镜弹窗选择后强制赋值sParentId --- src/components/Common/CommonHooks/useCommonBase.js | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/components/Common/CommonTable/index.js | 6 +----- src/mes/common/commonModelComponent/index.js | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/mes/common/commonOperationBarComponent/MesToolbar.js | 6 ++++-- 4 files changed, 301 insertions(+), 9 deletions(-) diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js index f389048..3b3d4b3 100644 --- a/src/components/Common/CommonHooks/useCommonBase.js +++ b/src/components/Common/CommonHooks/useCommonBase.js @@ -116,6 +116,7 @@ const useCommonBase = props => { * @param {Function} callback - 回调函数 */ const handleSaveState = (values, callback) => { + console.log("🚀 ~ handleSaveState ~ values:", values) if (commonUtils.isNotEmptyObject(values.masterConfig) && values.masterConfig.bMerged) { delete values.masterConfig; } @@ -1950,8 +1951,115 @@ const useCommonBase = props => { ); } }; + // const handleMaterialsChange = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models) => { + // const { sComputeId, sConversionComputeId, sReConversionComputeId } = tableDataRow; + // const sFormulaIdType = tableDataRow.bInverse ? 'sReComputeId' : 'sComputeId'; /* 正算、反算类型 */ + // if (sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName' || sFieldName === 'dAuxiliaryQty' || sFieldName === 'dReelAuxiliaryQty' || sFieldName === 'dConversionQty' || sFieldName === 'sMaterialsStyle' || sFieldName === 'dProductQty') { + // if (sFieldName === 'dReelAuxiliaryQty') { + // if (tableDataRow.sMaterialsUnit === '吨' && tableDataRow.bReel && tableDataRow.dGramWeight > 0) { + // tableDataRow = commonBusiness.getMaterialsQty(app, { ...tableDataRow, sMaterialsStyle: tableDataRow.sReelMaterialsStyle }, 'dReelAuxiliaryQty', 'dMaterialsQty'); + // tableDataRow.dAuxiliaryQty = tableDataRow.dMaterialsQty; + // tableDataRow.sMaterialsStyle = tableDataRow.sMaterialsStyle !== undefined && tableDataRow.sMaterialsStyle.split('*').length > 1 ? tableDataRow.sMaterialsStyle.split('*')[0] : tableDataRow.sMaterialsStyle; + // tableDataRow.sAuxiliaryUnit = tableDataRow.sMaterialsUnit; + // } else if (tableDataRow.sMaterialsUnit.toUpper() === 'M2' && tableDataRow.bReel) { + // tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dReelAuxiliaryQty', 'dMaterialsQty'); + // tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty; + // } else { + // tableDataRow.dAuxiliaryQty = tableDataRow.dReelAuxiliaryQty; + // } + // } + // if (commonUtils.isEmpty(sComputeId) && sFieldName !== 'dConversionQty') { + // if (sFieldName === 'dProductQty') { + // tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dProductQty', 'dMaterialsQty'); + // } else if (app.currentPane.sModelsType && app.currentPane.sModelsType.includes('outside/')) { + // tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, 'dAuxiliaryQty', 'dMaterialsQty'); + // } else { + // tableDataRow.dMaterialsQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow, sComputeId, sFormulaIdType, + // }); + // } + // } else if (!commonUtils.isEmpty(sComputeId)) { + // tableDataRow.dMaterialsQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow, sComputeId, + // }); + // } + // if (sFieldName !== 'dConversionQty' && !commonUtils.isEmpty(sConversionComputeId)) { + // tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow, sComputeId: sConversionComputeId, + // }); + // } + // } else if (sFieldName === 'dMaterialsQty') { + // const { sReComputeId } = tableDataRow; + // if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) { + // if (app.currentPane.sModelsType && app.currentPane.sModelsType.includes('outside/')) { + // tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryQty'); + // } else { + // tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow, sReComputeId, sFormulaIdType, + // }); + // } + // } else if (tableDataRow.bInverse) { + // tableDataRow.dAuxiliaryQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow, sComputeId: sReComputeId, + // }); + // if (commonUtils.isNotEmptyArr(tableDataRow.dAuxiliaryQty) && tableDataRow.dAuxiliaryQty !== 0) { + // tableDataRow.dProductQty = tableDataRow.dAuxiliaryQty; + // } + // } + // if (!commonUtils.isEmpty(sReConversionComputeId)) { + // tableDataRow.dConversionQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow, sComputeId: sReConversionComputeId, + // }); + // } + // } else if (sFieldName === 'dAuxiliaryLossQty') { + // const tableDataRowNew = { ...tableDataRow, dAuxiliaryQty: tableDataRow.dAuxiliaryLossQty }; + // if (commonUtils.isEmpty(sComputeId)) { + // // tableDataRow = commonBusiness.getMaterialsQty(app, tableDataRow, sFieldName, 'dLossQty'); + // tableDataRow.dLossQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow: tableDataRowNew, sComputeId, sFormulaIdType, + // }); + // } else { + // tableDataRow.dLossQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow: tableDataRowNew, sComputeId, + // }); + // } + // if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) { + // tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty; + // tableDataRow.dMaterialsQty = commonUtils.convertFixNum(tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty, 6); + // } + // } else if (sFieldName === 'dLossQty') { + // const { sReComputeId } = tableDataRow; + // const tableDataRowNew = { ...tableDataRow, dMaterialsQty: tableDataRow.dLossQty }; + // if (commonUtils.isEmpty(sReComputeId) && tableDataRow.bInverse) { + // // tableDataRow = commonBusiness.getAuxiliaryQty(app, tableDataRow, sFieldName, 'dAuxiliaryLossQty'); + // tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow: tableDataRowNew, sReComputeId, sFormulaIdType, + // }); + // } else { + // tableDataRow.dAuxiliaryLossQty = await commonBusiness.getFormulaValue({ + // token, sModelsId, masterData, tableDataRow: tableDataRowNew, sComputeId: sReComputeId, + // }); + // } + // if (!commonUtils.isEmpty(tableDataRow.dSrcSurplusAuxiliaryQty)) { + // tableDataRow.dAuxiliaryQty = tableDataRow.dSrcSurplusAuxiliaryQty - tableDataRow.dAuxiliaryLossQty; + // tableDataRow.dMaterialsQty = tableDataRow.dSrcSurplusQty - tableDataRow.dLossQty; + // } + // } else if (sFieldName === 'sProcessId' || sFieldName === 'sProcessNo' || sFieldName === 'sProcessName') { + // const sProcessId = changeValue.sProcessId; + // const url = `${commonConfig.server_host}process/outsideprocess?sModelsId=${sModelsId}&sProcessId=${sProcessId}`; + // const dataReturn = (await commonServices.getService(token, url)).data; + // if (dataReturn.code === 1) { + // if (commonUtils.isNotEmptyArr(dataReturn.dataset.rows)) { + // tableDataRow.dMaterialsPrice = dataReturn.dataset.rows[0].dMaterialsPrice; + // } + // tableDataRow = commonBusiness.getCalculateAllMoney(app, models, 'dMaterialsPrice', masterData, tableDataRow); + // } + // } + // return tableDataRow; + // } const handleMaterialsChange = async (tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models) => { const { sComputeId, sConversionComputeId, sReConversionComputeId } = tableDataRow; + // dAuxiliaryQty const sFormulaIdType = tableDataRow.bInverse ? 'sReComputeId' : 'sComputeId'; /* 正算、反算类型 */ if (sFieldName === 'sMaterialsNo' || sFieldName === 'sMaterialsName' || sFieldName === 'dAuxiliaryQty' || sFieldName === 'dReelAuxiliaryQty' || sFieldName === 'dConversionQty' || sFieldName === 'sMaterialsStyle' || sFieldName === 'dProductQty') { if (sFieldName === 'dReelAuxiliaryQty') { @@ -3298,6 +3406,7 @@ const useCommonBase = props => { const newCopyTo = {}; newCopyTo.master = masterData; const sName = selectConfig.sKeyUpFilter; /* 将后台配置筛选字段作为 列字段 */ + console.log("🚀 ~ handleSelectCommonPopupNew ~ sName:", sName) let sValue = ''; if (iIndex > -1) { newCopyTo.slave = tableData[iIndex]; @@ -3364,6 +3473,10 @@ const useCommonBase = props => { if (tbName === 'master') { const result = handleMasterChange(tbName, selectConfig.sName, {}, null, null, true, tableData); tableData = result.masterData; + } else if (tbName.includes('slave')){ + tableData.forEach(item=>{ + item.sParentId = state?.masterData?.sId + }) } const addState = { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination }; @@ -3452,6 +3565,7 @@ const useCommonBase = props => { }; /** toolbar审核(消审) */ const handleAudit = async (flag) => { + console.log("🚀 ~ handleAudit ~ flag:", flag) /* 待用数据声明 */ let bResult = true; const { masterData, gdsformconst } = props; diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js index d258322..a4bd21f 100644 --- a/src/components/Common/CommonTable/index.js +++ b/src/components/Common/CommonTable/index.js @@ -4864,8 +4864,6 @@ class CommonTableRc extends React.Component { const { selectedRowKeys = [] } = props; if (sControlName.includes('BtnTableCopyTo.ActProduceReport')) { const copyToConfig = props?.config?.gdsconfigformslave.filter(x=>x.sControlName.includes('BtnTableCopyTo.ActProduceReport')) - console.log(props, 'record'); - props.onCopyTo(props.name, config.sActiveId, config, copyToConfig, record) return } @@ -6984,7 +6982,7 @@ class CommonTableRc extends React.Component { this.props.onSelectCommonPopup(name, selectConfig, selectData, tb?.name, tb?.config, { index: this.rowClickRef.current }); return; } - + this.props.onSelectCommonPopup(name, selectConfig, selectData, tb?.name, commonPopupShowConfig); } }; @@ -8243,8 +8241,6 @@ class CommonTableRc extends React.Component { controlConfig[0].sDropDownType === "popup" ) { btnPupopConfig = controlConfig[0]; - console.log(btnPupopConfig, 'btnPupopConfig'); - this.setState({ commonPopupVisible: true, commonPopupTbName: name, diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js index 06ee3d8..4ff4806 100644 --- a/src/mes/common/commonModelComponent/index.js +++ b/src/mes/common/commonModelComponent/index.js @@ -1079,7 +1079,186 @@ const useCommonModelEvent = props => { [props[`${name}Data`], props[`${name}SelectedRowKeys`]] ); - + // 审核 + /** toolbar审核(消审) */ + const handleAudit = async (flag) => { + console.log("🚀 ~ handleAudit ~ flag:", flag) + /* 待用数据声明 */ + let bResult = true; + const { masterData, gdsformconst } = props; + if (!commonUtils.isEmpty(masterData)) { + /* 作废订单不能审核 */ + if (masterData.bInvalid) { + message.warning(commonFunc.showMessage(app.commonConst, 'sToVoid')); + handleSaveState({ + loading: false, + }); + return ''; + } + /** 数据审核 */ + bResult = await dataAudit(flag); + } else { + handleSaveState({ + loading: false, + }); + } + return bResult; + }; + /** 数据审核 */ + const dataAudit = async (flag, tmpCheck, isWait) => { + message.destroy(); + /* 待用数据声明 */ + const { + sModelsId, masterData, app, masterConfig, slaveConfig, checkConfig, token, sModelsType = '', controlConfig, materialsConfig, processConfig, colorConfig, packConfig, slaveData, orderDetailConfig, + } = props; + + const FriendlyReminder = commonFunc.showLocalMessage(props, 'FriendlyReminder', '温馨提示'); + const sSlaveIdArray = []; + if (commonUtils.isNotEmptyArr(slaveData)) { + slaveData.forEach((item) => { + sSlaveIdArray.push(commonUtils.isNotEmptyObject(item.sId) ? item.sId : item.sSlaveId); + }); + } + const slaveId = sSlaveIdArray.toString(); + /* 数据参数 */ + const value = { + sClientType: '1', + paramsMap: { + iFlag: flag, + iTmpCheck: commonUtils.isEmptyNumber(tmpCheck) ? 0 : tmpCheck, + sFormGuid: sModelsId, + sGuid: masterData.sId, + sSlaveId: slaveId, + sBillNo: commonUtils.isNotEmptyObject(masterData.sBillNo) ? masterData.sBillNo : '', + }, + }; + let clearFlag = false; + if (sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder')) { + if (commonUtils.isNotEmptyArr(slaveData)) { + for (const item of slaveData) { + if (commonUtils.isNotEmptyStr(item.sProductInfo)) { + clearFlag = true; + break; + } + } + } else { + handleSaveState({ + loading: false, + }); + return; + } + } + /* 数据审核 */ + const url = `${commonConfig.server_host}business/doExamine?sModelsId=${sModelsId}`; + const returnData = (await commonServices.postValueService(app.token, value, url)).data; + if (isWait) { + return returnData; + } else { + /* 接收返回值 */ + const check = commonFunc.showMessage(app.commonConst, 'BtnExamine');/* 审核 */ + const BtnCancelExamine = commonFunc.showMessage(app.commonConst, 'BtnCancelExamine');/* 销审 */ + if (returnData.code === 1) { /* 成功 */ + handleSaveState({ + loading: false, + }); + if (flag === 1) { + /* 审核 */ + if (clearFlag && (sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder'))) { + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductId', []); + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductNo', []); + commonUtils.setStoreDropDownData(sModelsId, 'master', 'sProductName', []); + } + let outData; + if (commonUtils.isNotEmptyObject(returnData.dataset)) { + outData = returnData.dataset.rows[0].dataSet.outData; + } + if (false && commonUtils.isNotEmptyStr(outData[0].sReturn)) { + const sReturnArray = outData[0].sReturn.split('|'); + if (outData[0].sReturn.split('-').length < 2) { + // 正常业务提示,非审核模板 + // if (this.props.app.currentPane.refresh !== undefined) { + // this.props.app.currentPane.refresh(); + // } + message.error(check + outData[0].sReturn); + return; + } + const checkConditions = []; + let checkPersonData = {}; + sReturnArray.forEach((item) => { + const checkCondition = item.split('-')[2]; + const iIndex = checkConditions.findIndex(itemCondition => itemCondition.condition === checkCondition); + if (iIndex <= -1) { + checkConditions.push({ + key: commonUtils.createSid(), + condition: checkCondition, + }); + } + }); + const sCheckModelId = sReturnArray[0].split('-')[1]; + if (commonUtils.isNotEmptyStr(sCheckModelId)) { + const urlCheck = `${commonConfig.server_host}checkModel/getUserListByModelId/${sCheckModelId}?sModelsId=${sModelsId}`; + const dataReturn = (await commonServices.getService(token, urlCheck)).data; + if (dataReturn.code === 1) { + checkPersonData = dataReturn.dataset.rows; + checkPersonData.forEach((item) => { + item.key = commonUtils.createSid(); + }); + this.props.onSaveState({ + checkConditions, checkPersonData, sCheckModelId, visible: true, + }); + return true; + } else { /* 失败 */ + this.props.getServiceError({ msg: check + dataReturn }); + } + } + } else { + message.success(check + returnData.msg); + } + } else { + /* 消审 */ + const { outData } = returnData.dataset.rows[0].dataSet; + if (commonUtils.isNotEmptyStr(outData[0].sReturn)) { + message.error(outData[0].sReturn); + } else { + // if (this.props.app.currentPane.refresh !== undefined) { + // this.props.app.currentPane.refresh(); + // } + message.success(BtnCancelExamine + returnData.msg); + } + } + await handleGetData(masterConfig, slaveConfig, checkConfig); + if ((sModelsType.includes('sales/salesOrder') || sModelsType.includes('manufacture/workOrder')) && !commonUtils.isEmpty(controlConfig)) { + await handleGetMemoData(controlConfig, materialsConfig, processConfig, colorConfig, packConfig); + } else if (commonUtils.isNotEmptyObject(orderDetailConfig)) { + await handleGetOneMemoData('orderDetail', orderDetailConfig); + } + // if (props.app.currentPane.refresh !== undefined) { + // this.props.app.currentPane.refresh(); + // } + } else if (returnData.code === -8) { + Modal.info({ + title: FriendlyReminder, + content: ( +
+ {handleGetMsg(returnData.msg)} +
+ ), + onOk() { }, + }); + handleSaveState({ + loading: false, + }); + return false; + } else { /* 失败 */ + props.getServiceError(returnData); + handleSaveState({ + loading: false, + }); + return false; + } + return true; + } + }; return { ...props, onGetColumnData: handleGetColumnData, @@ -1087,7 +1266,8 @@ const useCommonModelEvent = props => { onTableBtnClick: handleTableBtnClick, // 表格按钮事件 handleUpdateProductionplan, handleStartWork, - onViewChoose: handleViewChoose + onViewChoose: handleViewChoose, + onBtnExamine: handleAudit, }; }; diff --git a/src/mes/common/commonOperationBarComponent/MesToolbar.js b/src/mes/common/commonOperationBarComponent/MesToolbar.js index cba5e3a..bbca07e 100644 --- a/src/mes/common/commonOperationBarComponent/MesToolbar.js +++ b/src/mes/common/commonOperationBarComponent/MesToolbar.js @@ -17,6 +17,8 @@ const ToolbarFun = async (props) => { // const { sControlName } = btnConfig; // const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase(); + console.log(btnName, 'btnName'); + if (btnName === 'btnadd') { handleAdd(props); } else if (btnName === 'btnsave') { @@ -73,8 +75,8 @@ const ToolbarFun = async (props) => { } } } else { - console.log(props, 'masterData'); - // props.onBtnExamine(); + // console.log(props, 'masterData'); + props.onBtnExamine(); } } -- libgit2 0.22.2