From 96afaf25ea235015e138fa3ab40ec8bc9895da15 Mon Sep 17 00:00:00 2001 From: pengm <674192343@qq.com> Date: Tue, 12 May 2026 14:45:51 +0800 Subject: [PATCH] 1.放大镜支持若数据根据条件已存在则修改,不存在插入 --- src/components/Common/CommonBase.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/components/Common/CommonNewBill.js | 2 +- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/components/Common/CommonBase.js b/src/components/Common/CommonBase.js index 5ab4477..f5c57d2 100644 --- a/src/components/Common/CommonBase.js +++ b/src/components/Common/CommonBase.js @@ -2651,8 +2651,54 @@ export default (ChildComponent) => { if (iControlIndex > -1) { newCopyTo.control = controlData[iControlIndex]; } - /* 第一条数据若字段值为空或者只有一条数据时 则添加到该行 否则新增一行 */ - if (selectData.length === 1 || (index === 0 && commonUtils.isEmptyObject(sValue))) { + if (selectConfig?.sControlName?.toLowerCase().includes('_edit')) { + const sActiveKey = selectConfig.sDefault; + // 检查当前 item 的 sActiveKey 是否已经在 tableData 中存在 + const existRowIndex = tableData.findIndex(row => row?.[sActiveKey] === item?.[sActiveKey]); + console.log('existRowInd1ex', sActiveKey, existRowIndex); + if ( sActiveKey && existRowIndex !== -1 ) { + let tableDataRow = { ...tableData[existRowIndex] }; + if (tbName === 'slave') { + tableDataRow.sSqlConditionId = tableDataRow.sId; + } + // 赋值字段 + tableDataRow = {...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo), ...tableDataRow }; + tableData[existRowIndex] = tableDataRow; + tableData[existRowIndex].handleType = 'update'; + // 异步价格处理 + tableData[existRowIndex] = await setProductPrice(tableData[existRowIndex], item, this.props); + + // 指令执行 + if (instructType) { + this.handleExecInstructSet({ + type, + sInstruct: instructType, + showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`, + }); + } + + // 分页 & 状态保存 + pagination.total = tableData.length; + const addState = { [`${tbName}Data`]: tableData, [`${tbName}Pagination`]: pagination }; + if (typeof isWait !== 'boolean') this.handleSaveState(addState); + return; // 直接结束本次循环,不走下面原有逻辑 + } else{ + let tableDataRowAdd = this.handleTableAdd(tbName, true); + if (tbName === 'slave') { + tableDataRowAdd.sSqlConditionId = tableDataRowAdd.sId; + } + tableDataRowAdd = { ...tableDataRowAdd, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 + tableDataRowAdd = await setProductPrice(tableDataRowAdd, item, this.props); + if (instructType) { + this.handleExecInstructSet({ + type, + sInstruct: instructType, + showName: `${showName}-${type === 'blur' ? '离焦' : '变化'}`, + }); + } + tableData.push(tableDataRowAdd); + } + } else if (selectData.length === 1 || (index === 0 && commonUtils.isEmptyObject(sValue))) { let tableDataRow = {}; // 取默认值 if (tbName === 'master') { tableDataRow = { ...tableData, ...commonFunc.getAssignFieldValue(selectConfig.sAssignField, item, newCopyTo) }; // 取赋值字段 diff --git a/src/components/Common/CommonNewBill.js b/src/components/Common/CommonNewBill.js index a366572..67945a0 100644 --- a/src/components/Common/CommonNewBill.js +++ b/src/components/Common/CommonNewBill.js @@ -2685,7 +2685,7 @@ const BillComponent = Form.create({ separateTabName10 = separateTabConfig.showName; } } - console.log('333props', props); + const flexRowStyle = bFlow ? { display: "flex", flexDirection: "row" } : {}; const flexContentStyle = bFlow ? { width: "75%" } : {}; -- libgit2 0.22.2