From 8e749bb778fe1abbc5480749d35f9e02b6b92030 Mon Sep 17 00:00:00 2001 From: zhangzhen <525765282@qq.com> Date: Fri, 17 Oct 2025 15:15:15 +0800 Subject: [PATCH] 新增commonNewBill的sBmRule功能; --- src/components/Common/CommonNewBill.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/components/Common/commonBusiness.js | 3 +++ 2 files changed, 56 insertions(+), 0 deletions(-) diff --git a/src/components/Common/CommonNewBill.js b/src/components/Common/CommonNewBill.js index df6d4e5..802389a 100644 --- a/src/components/Common/CommonNewBill.js +++ b/src/components/Common/CommonNewBill.js @@ -3369,12 +3369,65 @@ const BillComponent = Form.create({ + ); }); +// 函数式组件 +const CommonEffectEvent = props => { + const { masterData = {} } = props; + const { sBmRule } = masterData; + + const [watchFields, setWatchFields] = useState([]); + const preValue = useRef(""); + + useEffect(() => { + if (!sBmRule) { + setWatchFields([]); + preValue.current = ""; + return; + } + + const sBmRuleObj = commonUtils.convertStrToObj(sBmRule); + const { showName = "" } = sBmRuleObj; + setWatchFields(showName.split(",")); + }, [sBmRule]); + + useEffect(() => { + if (!watchFields.length) return; + const newValue = watchFields.map(key => masterData[key] || "").join(""); + if (preValue.current === newValue) return; + preValue.current = newValue; + + const sBmRuleObj = commonUtils.convertStrToObj(sBmRule); + const addState = Object.keys(sBmRuleObj).filter(key => key !== "showName").reduce((result, key) => { + const list = sBmRuleObj[key]?.split("+") || []; + result[key] = list.map(item => item.trim().replace(/\'/g, '')).map(item => { + if (item !== '.' && item?.includes('.')) { + const [tableName, sFieldName] = item.split('.'); + return props[`${tableName}Data`]?.[sFieldName] || ""; + } + return item; + }).join(''); + return result; + }, {}); + + props.onSaveState({ + masterData: { + ...masterData, + ...addState, + handleType: masterData.handleType || 'update', + } + }); + + }, [watchFields, masterData]); + + return null; +} + // 工艺参数弹窗 const ModalComponent = props => { if (!props.sParamsModalVisible && !props.sParamsNewModalVisible) return ""; diff --git a/src/components/Common/commonBusiness.js b/src/components/Common/commonBusiness.js index b6b4c2a..74db2d9 100644 --- a/src/components/Common/commonBusiness.js +++ b/src/components/Common/commonBusiness.js @@ -1004,6 +1004,9 @@ export function getKeyUpEvent(name, sFieldName, tableConfig, masterData, tableDa tableDataRowNew = tableDataRow; newCopyTo.slave = tableDataRow; } + if (tableDataRowNew.sBmRule) { + return tableDataRowNew; + } if (commonUtils.isNotEmptyObject(tableConfig) && commonUtils.isNotEmptyArr(tableConfig.gdsconfigformslave)) { const iConfigIndex = tableConfig.gdsconfigformslave.findIndex(item => item.sName === sFieldName); if (iConfigIndex > -1) { -- libgit2 0.22.2