From 52459b3a1f5365dbe7667f2e1d901cc835ba12b0 Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Mon, 5 Jan 2026 20:36:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=8A=BD=E7=A6=BBing]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/CustomTable.vue | 3 ++ .../comps/template/mixins/templateMixin.js | 39 ++++++++++++++-------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index 4465a80..bcf6762 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -280,6 +280,9 @@ export default { // 深拷贝数据以避免直接修改原始数据 this.localDataSource = JSON.parse(JSON.stringify(dataSource || [])); }, + getDataSource(){ + return this.localDataSource; + }, // 根据行索引更新数据 updateDataSourceByRowIndex(rowIndex,data){ this.localDataSource[rowIndex] = {...this.localDataSource[rowIndex],...data}; diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index 32a383f..eefdae6 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -13,7 +13,7 @@ export default { if(v){ let n = {...v}; if(v.bdnr){ - this.formData = JSON.parse(v.bdnr); + this.formData = {...n,...JSON.parse(v.bdnr)}; } this.templateDetail = n; this.setTemplateData(n); @@ -64,7 +64,7 @@ export default { }, //统一处理blur事件,因为有效周期和过期日期是相关的,所以需要在有效周期失焦时更新过期日期 onHandleBlur(fields){ - const {key ,effectivePeriodUnit,effectivePeriod,codeSTD} = fields; + const {key ,effectivePeriodUnit,effectivePeriod,codeSTD,targetStartSolution} = fields; const {createTime} = this.formData; if(key ==="effectivePeriod"){//统一处理有效周期失焦,计算失效事件,保证字段名不能变 const start = moment(createTime); @@ -78,28 +78,39 @@ export default { targetStartSolutionVolumePrecision:3,//小数点精度默认为3 targetSolutionCode:`STD${Number(codeSTD)-index}` })); - console.log(arr, "arr") this.$refs.stepTableRef.updateDataSource(arr); + }else if(key === "targetStartSolution"){//起始溶液体积失焦时,更新目标溶液预计浓度 + const arr = this.$refs.stepTableRef.getDataSource(); + arr.forEach((item,rowIndex) => { + this.updateTargetStartSolutionVolume(rowIndex,item,targetStartSolution); + }) } }, + //统一处理table失焦事件 onHandleTableBlur(params){ const {rowIndex, colKey, value,item} = params; console.log(rowIndex, colKey, value,item, "params") - if(colKey === "targetSolutionVolume" || colKey === "targetSolutionConcentration" || colKey === "targetStartSolutionVolumePrecision" || colKey === "targetDiluentVolumePrecision"){//预设起始溶液体积:(目标溶液预计浓度 乘以 目标溶液预计体积)除以 起始溶液浓度 + if(colKey === "targetSolutionVolume" || colKey === "targetSolutionConcentration" || colKey === "targetStartSolutionVolumePrecision" || colKey === "targetDiluentVolumePrecision"){ const volume = this.$refs.stepFormPackageRef.getFormDataByKey("targetStartSolution") || 0; - const precision = item.targetStartSolutionVolumePrecision || 0; if(volume){ - const concentration = item.targetSolutionConcentration || 0; - const targetVolume = item.targetSolutionVolume || 0; - const result = ((concentration * targetVolume) / volume).toFixed(precision); - this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex,{targetStartSolutionVolume:result}); - if(targetVolume){//预设稀释液体积:目标溶液预计体积 减去 源溶液预计体积; - const precision1 = item.targetDiluentVolumePrecision || 0; - const result1 = (targetVolume - result).toFixed(precision1); - this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex,{targetDiluentVolume:result1}); - } + this.updateTargetStartSolutionVolume(rowIndex,item,volume); } } + }, + //更新起始溶液体积时,更新目标溶液预计浓度 + updateTargetStartSolutionVolume(rowIndex,item,volume){ + const precision = item.targetStartSolutionVolumePrecision || 0; + const concentration = item.targetSolutionConcentration || 0; + const targetVolume = item.targetSolutionVolume || 0; + //目标溶液预计浓度:(目标溶液预计体积 乘以 起始溶液浓度)除以 起始溶液体积 + const result = ((concentration * targetVolume) / volume).toFixed(precision); + this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex,{targetStartSolutionVolume:result}); + if(targetVolume){ + //预设稀释液体积:目标溶液预计体积 减去 源溶液预计体积; + const precision1 = item.targetDiluentVolumePrecision || 0; + const result1 = (targetVolume - result).toFixed(precision1); + this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex,{targetDiluentVolume:result1}); + } } },