Commit 00553e6895234ae94b91a4edab7724e00722dda2

Authored by Min
1 parent c1b44e46

1.保存的时候,删除的时候,传入sOldData

src/components/Common/CommonBase.js
@@ -763,6 +763,7 @@ export default (ChildComponent) => { @@ -763,6 +763,7 @@ export default (ChildComponent) => {
763 } 763 }
764 } 764 }
765 addState[`${name}Data`] = returnData; 765 addState[`${name}Data`] = returnData;
  766 + addState[`${name}DataOld`] = returnData;
766 if(commonUtils.isNotEmptyObject(returnData.customConfig) && commonUtils.isJSON(returnData.customConfig) && commonUtils.isNotEmptyObject(slaveConfig)) { 767 if(commonUtils.isNotEmptyObject(returnData.customConfig) && commonUtils.isJSON(returnData.customConfig) && commonUtils.isNotEmptyObject(slaveConfig)) {
767 const columnConfig = JSON.parse(returnData.customConfig); 768 const columnConfig = JSON.parse(returnData.customConfig);
768 const newConfig =JSON.parse(JSON.stringify(slaveConfig)); 769 const newConfig =JSON.parse(JSON.stringify(slaveConfig));
@@ -1048,6 +1049,7 @@ export default (ChildComponent) => { @@ -1048,6 +1049,7 @@ export default (ChildComponent) => {
1048 const filterConditionNew = commonUtils.isNotEmptyObject(filterCondition) ? filterCondition.filter(item => item.bFilterType !== 'tree') : ''; 1049 const filterConditionNew = commonUtils.isNotEmptyObject(filterCondition) ? filterCondition.filter(item => item.bFilterType !== 'tree') : '';
1049 let addState = { 1050 let addState = {
1050 [`${name}Data`]: returnData, 1051 [`${name}Data`]: returnData,
  1052 + [`${name}DataOld`]: returnData,
1051 [`${name}Pagination`]: returnPagination, 1053 [`${name}Pagination`]: returnPagination,
1052 [`${name}FilterCondition`]: filterConditionNew, 1054 [`${name}FilterCondition`]: filterConditionNew,
1053 [`${name}OrderBy`]: orderBy, 1055 [`${name}OrderBy`]: orderBy,
src/components/Common/CommonBillEvent.js
@@ -2603,8 +2603,10 @@ export default (ChildComponent) => { @@ -2603,8 +2603,10 @@ export default (ChildComponent) => {
2603 } 2603 }
2604 }); 2604 });
2605 } 2605 }
  2606 + const sOldData = commonUtils.getOldDataFromProps(this.props);
  2607 + console.log('组装后的原始数据', sOldData);
2606 2608
2607 - this.handleSaveData({ data, sClientType: '1', sSysLogSrcId: masterData.sId }); 2609 + this.handleSaveData({ data, sClientType: '1', sSysLogSrcId: masterData.sId, sOldData });
2608 } 2610 }
2609 }); 2611 });
2610 }; 2612 };
@@ -3115,12 +3117,15 @@ export default (ChildComponent) => { @@ -3115,12 +3117,15 @@ export default (ChildComponent) => {
3115 } 3117 }
3116 } 3118 }
3117 } 3119 }
  3120 + const sOldData = commonUtils.getOldDataFromProps(this.props);
  3121 + console.log('删除的原始数据', sOldData);
3118 const value = { 3122 const value = {
3119 sClientType: '1', 3123 sClientType: '1',
3120 data: { 3124 data: {
3121 sMasterTable: masterConfig.sTbName, 3125 sMasterTable: masterConfig.sTbName,
3122 sId: [masterData.sId], 3126 sId: [masterData.sId],
3123 }, 3127 },
  3128 + sOldData
3124 }; 3129 };
3125 const sSlaveTable = []; 3130 const sSlaveTable = [];
3126 if (commonUtils.isNotEmptyObject(slaveConfig)) { 3131 if (commonUtils.isNotEmptyObject(slaveConfig)) {
src/components/IndexCenter/IndexCenter.js
@@ -105,7 +105,6 @@ class IndexCenter extends Component { @@ -105,7 +105,6 @@ class IndexCenter extends Component {
105 componentWillReceiveProps(nextProps) { 105 componentWillReceiveProps(nextProps) {
106 const { dispatch } = nextProps; 106 const { dispatch } = nextProps;
107 const { modelCenter, comParameter:comParameterAll = [], dataCode, kpiData, logoImageInfo, userinfo, token } = nextProps.app; 107 const { modelCenter, comParameter:comParameterAll = [], dataCode, kpiData, logoImageInfo, userinfo, token } = nextProps.app;
108 - console.log('1-comParameterAll', comParameterAll);  
109 const comParameter = comParameterAll.filter(item => item.sDisplayType ? item.sDisplayType !== 'LargeScreen' : !item.sFormUrl?.includes('http')); 108 const comParameter = comParameterAll.filter(item => item.sDisplayType ? item.sDisplayType !== 'LargeScreen' : !item.sFormUrl?.includes('http'));
110 const commonThirdApp = comParameterAll.filter(item => item.sDisplayType ? item.sDisplayType === 'LargeScreen' : item.sFormUrl?.includes('http')); 109 const commonThirdApp = comParameterAll.filter(item => item.sDisplayType ? item.sDisplayType === 'LargeScreen' : item.sFormUrl?.includes('http'));
111 const { modelCenter: modelCenterOld } = this.props; 110 const { modelCenter: modelCenterOld } = this.props;
src/utils/utils.js
@@ -641,6 +641,39 @@ export function genSlaveNewId(arr, tableName, idName, oldName, baseObj) { @@ -641,6 +641,39 @@ export function genSlaveNewId(arr, tableName, idName, oldName, baseObj) {
641 } 641 }
642 642
643 643
  644 +/**
  645 + * 从props中提取带DataOld后缀的字段,组装成以表名为key的原始数据对象
  646 + * @param {Object} props - 组件的props对象
  647 + * @returns {Object} - 组装后的sOldData,格式:{ 表名: 对应的数据数组 }
  648 + */
  649 +export function getOldDataFromProps(props) {
  650 + // 初始化返回的空对象
  651 + const sOldData = {};
  652 +
  653 + // 2. 遍历props的所有key
  654 + for (const key of Object.keys(props)) {
  655 + if (key.includes('DataOld')) {
  656 + // 提取去掉DataOld后的表名前缀
  657 + const tablename = key.replace('DataOld', '').trim();
  658 +
  659 + // 获取对应的配置对象(tablename + Config)
  660 + const tableConfig = props[tablename + 'Config'];
  661 + // 获取对应的原始数据(tablename + DataOld),默认空数组
  662 + const tableData = props[tablename + 'DataOld'] || [];
  663 +
  664 + // 3. 校验配置对象是否有效,避免无配置时赋值
  665 + if (isNotEmptyObject(tableConfig) && tableConfig.sTbName) {
  666 + // 以配置中的真实表名为key,存入数据
  667 + const sTbName = tableConfig.sTbName;
  668 + sOldData[sTbName] = tableData;
  669 + }
  670 + }
  671 + }
  672 +
  673 + return sOldData;
  674 +}
  675 +
  676 +
644 export const myContext = createContext(null); 677 export const myContext = createContext(null);
645 678
646 export function reducer(state, action) { 679 export function reducer(state, action) {