From 71a442ddbb24ce8d8f5947406830dc4bc1c9540d Mon Sep 17 00:00:00 2001 From: chenxt <10125295+chen-xintao97@user.noreply.gitee.com> Date: Wed, 24 Dec 2025 16:49:02 +0800 Subject: [PATCH] 计算价格离开后计算 --- src/components/Common/CommonHooks/useCommonBase.js | 127 +++++++++++++++++++------------------------------------------------------------------------------------------------------------ src/components/Common/CommonInstructSet.js | 2 +- src/mes/common/commonModelComponent/index.js | 7 +++++-- src/mes/common/commonOperationBarComponent/MesToolbar.js | 2 +- src/mes/common/commonOperationBarComponent/index.js | 4 +++- 5 files changed, 29 insertions(+), 113 deletions(-) diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js index 044807e..aaeb70a 100644 --- a/src/components/Common/CommonHooks/useCommonBase.js +++ b/src/components/Common/CommonHooks/useCommonBase.js @@ -1928,8 +1928,23 @@ const useCommonBase = props => { const { masterData } = state const { app } = props const { token } = app || {} - tableDataRow = await handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models); - console.log(tableDataRow, 'tableDataRow'); + // tableDataRow = await handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models); + /* 找到sFieldName对应的配置,判断是否是离开调用逻辑,若是离开调用, 则走离开调用逻辑,否则走原来的 */ + let bMoveSql = false; + if (commonUtils.isNotEmptyObject(tableConfig)) { + const iConfigIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === sFieldName); + if (iConfigIndex > -1) { + const sDropDownType = tableConfig.gdsconfigformslave[iConfigIndex].sDropDownType; + if (sDropDownType === 'movesql') { + bMoveSql = true; + } + } + } + + if (!bMoveSql) { + tableDataRow = await handleMaterialsChange(tableDataRow, sModelsId, masterData, changeValue, sFieldName, app, token, models); + } + if (isWait) { return tableDataRow; } else { @@ -1953,112 +1968,7 @@ 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 @@ -3758,6 +3668,7 @@ const useCommonBase = props => { handleSqlDropDownNewRecord, onChange: handleMasterChange, // 主表数据变化 onDataChange: handleTableChange, // 表格数据变化 + onMaterialsChange: handleMaterialsChange, onGetDataSet: handleGetDataSet, onGetTreeDataSet: handleGetTreeDataSet, // 获取树型数据 onSaveState: handleSaveState, diff --git a/src/components/Common/CommonInstructSet.js b/src/components/Common/CommonInstructSet.js index fe32045..b781f98 100644 --- a/src/components/Common/CommonInstructSet.js +++ b/src/components/Common/CommonInstructSet.js @@ -2395,7 +2395,7 @@ const utils = { } if (returnData.code === 1) { props.onSaveState({ - enabled: true, + enabled: false, currentId: masterData.sId, loading: false, isRefresh: true diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js index 02f6c66..4a37913 100644 --- a/src/mes/common/commonModelComponent/index.js +++ b/src/mes/common/commonModelComponent/index.js @@ -338,12 +338,15 @@ const useCommonModelEvent = props => { }, [ formData.length, - ['production/productionReport', 'commonBill'].includes(sModelType) ? isRefresh : refreshCount, + refreshCount, noGetData, JSON.stringify(sFilterConditions) ] ); - + useEffect(() => { + if (!isRefresh) return + handleRefresh() + }, [isRefresh]) // 初始化后执行一次指令集 useEffect( diff --git a/src/mes/common/commonOperationBarComponent/MesToolbar.js b/src/mes/common/commonOperationBarComponent/MesToolbar.js index 3beaaed..3ad827c 100644 --- a/src/mes/common/commonOperationBarComponent/MesToolbar.js +++ b/src/mes/common/commonOperationBarComponent/MesToolbar.js @@ -1019,7 +1019,7 @@ const handleSave = (props) => { }, inscallback: () => { props.onSaveState({ - currentId: props.masterData.sId,enabled:true + currentId: props.masterData.sId,enabled:false }); } }); diff --git a/src/mes/common/commonOperationBarComponent/index.js b/src/mes/common/commonOperationBarComponent/index.js index e3a46bd..26ff3f9 100644 --- a/src/mes/common/commonOperationBarComponent/index.js +++ b/src/mes/common/commonOperationBarComponent/index.js @@ -737,12 +737,14 @@ const useCommonOperationBarComponentEvent = props => { console.log("=====err", { tempData, str: sDefault, strNew, error }); } } else if (props.bMesBill) { + const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase(); + console.log(btnName,props, 'btnName'); + if (props.enabled) { if (["btnupd", 'btnevent', 'btnsubmit', 'btnsubmitcancel', 'btnexamine', 'btncancelexamine'].includes(btnName)) { defaultProps.disabled = true; } - console.log(btnName, 'btnName'); } else { if (["btnsave", "btnscanface"].includes(btnName)) { -- libgit2 0.22.2