From 00553e6895234ae94b91a4edab7724e00722dda2 Mon Sep 17 00:00:00 2001 From: pengm <674192343@qq.com> Date: Wed, 7 Jan 2026 14:11:08 +0800 Subject: [PATCH] 1.保存的时候,删除的时候,传入sOldData --- src/components/Common/CommonBase.js | 2 ++ src/components/Common/CommonBillEvent.js | 7 ++++++- src/components/IndexCenter/IndexCenter.js | 1 - src/utils/utils.js | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/components/Common/CommonBase.js b/src/components/Common/CommonBase.js index 27d18da..47719b6 100644 --- a/src/components/Common/CommonBase.js +++ b/src/components/Common/CommonBase.js @@ -763,6 +763,7 @@ export default (ChildComponent) => { } } addState[`${name}Data`] = returnData; + addState[`${name}DataOld`] = returnData; if(commonUtils.isNotEmptyObject(returnData.customConfig) && commonUtils.isJSON(returnData.customConfig) && commonUtils.isNotEmptyObject(slaveConfig)) { const columnConfig = JSON.parse(returnData.customConfig); const newConfig =JSON.parse(JSON.stringify(slaveConfig)); @@ -1048,6 +1049,7 @@ export default (ChildComponent) => { const filterConditionNew = commonUtils.isNotEmptyObject(filterCondition) ? filterCondition.filter(item => item.bFilterType !== 'tree') : ''; let addState = { [`${name}Data`]: returnData, + [`${name}DataOld`]: returnData, [`${name}Pagination`]: returnPagination, [`${name}FilterCondition`]: filterConditionNew, [`${name}OrderBy`]: orderBy, diff --git a/src/components/Common/CommonBillEvent.js b/src/components/Common/CommonBillEvent.js index a926e9a..a2e7342 100644 --- a/src/components/Common/CommonBillEvent.js +++ b/src/components/Common/CommonBillEvent.js @@ -2603,8 +2603,10 @@ export default (ChildComponent) => { } }); } + const sOldData = commonUtils.getOldDataFromProps(this.props); + console.log('组装后的原始数据', sOldData); - this.handleSaveData({ data, sClientType: '1', sSysLogSrcId: masterData.sId }); + this.handleSaveData({ data, sClientType: '1', sSysLogSrcId: masterData.sId, sOldData }); } }); }; @@ -3115,12 +3117,15 @@ export default (ChildComponent) => { } } } + const sOldData = commonUtils.getOldDataFromProps(this.props); + console.log('删除的原始数据', sOldData); const value = { sClientType: '1', data: { sMasterTable: masterConfig.sTbName, sId: [masterData.sId], }, + sOldData }; const sSlaveTable = []; if (commonUtils.isNotEmptyObject(slaveConfig)) { diff --git a/src/components/IndexCenter/IndexCenter.js b/src/components/IndexCenter/IndexCenter.js index e7f1554..2cbc598 100644 --- a/src/components/IndexCenter/IndexCenter.js +++ b/src/components/IndexCenter/IndexCenter.js @@ -105,7 +105,6 @@ class IndexCenter extends Component { componentWillReceiveProps(nextProps) { const { dispatch } = nextProps; const { modelCenter, comParameter:comParameterAll = [], dataCode, kpiData, logoImageInfo, userinfo, token } = nextProps.app; - console.log('1-comParameterAll', comParameterAll); const comParameter = comParameterAll.filter(item => item.sDisplayType ? item.sDisplayType !== 'LargeScreen' : !item.sFormUrl?.includes('http')); const commonThirdApp = comParameterAll.filter(item => item.sDisplayType ? item.sDisplayType === 'LargeScreen' : item.sFormUrl?.includes('http')); const { modelCenter: modelCenterOld } = this.props; diff --git a/src/utils/utils.js b/src/utils/utils.js index 8cac108..2a7ecf5 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -641,6 +641,39 @@ export function genSlaveNewId(arr, tableName, idName, oldName, baseObj) { } +/** + * 从props中提取带DataOld后缀的字段,组装成以表名为key的原始数据对象 + * @param {Object} props - 组件的props对象 + * @returns {Object} - 组装后的sOldData,格式:{ 表名: 对应的数据数组 } + */ +export function getOldDataFromProps(props) { + // 初始化返回的空对象 + const sOldData = {}; + + // 2. 遍历props的所有key + for (const key of Object.keys(props)) { + if (key.includes('DataOld')) { + // 提取去掉DataOld后的表名前缀 + const tablename = key.replace('DataOld', '').trim(); + + // 获取对应的配置对象(tablename + Config) + const tableConfig = props[tablename + 'Config']; + // 获取对应的原始数据(tablename + DataOld),默认空数组 + const tableData = props[tablename + 'DataOld'] || []; + + // 3. 校验配置对象是否有效,避免无配置时赋值 + if (isNotEmptyObject(tableConfig) && tableConfig.sTbName) { + // 以配置中的真实表名为key,存入数据 + const sTbName = tableConfig.sTbName; + sOldData[sTbName] = tableData; + } + } + } + + return sOldData; +} + + export const myContext = createContext(null); export function reducer(state, action) { -- libgit2 0.22.2