From c4f223f362a2369464528f12240807cd75a0938f Mon Sep 17 00:00:00 2001
From: luojie <125330818@qq.com>
Date: Thu, 12 Feb 2026 11:23:13 +0800
Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][?=
=?UTF-8?q?=E7=83=A6=E4=BA=BA=E7=9A=84=E6=B5=93=E5=BA=A6=E8=AE=A1=E7=AE=97?=
=?UTF-8?q?=E5=92=8C=E5=8D=95=E4=BD=8D=E6=8D=A2=E7=AE=97]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Template/BaseInfoFormPackage.vue | 11 ++++-
src/components/Template/CustomTable.vue | 5 +++
src/components/Template/HandleFormItem.vue | 31 +++++++++++++
.../business/comps/template/comps/sp/SP003.vue | 10 ++++-
.../business/comps/template/comps/sp/SP00456.vue | 2 +-
.../comps/template/mixins/templateMixin.js | 51 ++++++++++++----------
6 files changed, 84 insertions(+), 26 deletions(-)
diff --git a/src/components/Template/BaseInfoFormPackage.vue b/src/components/Template/BaseInfoFormPackage.vue
index a22e75d..0b93b28 100644
--- a/src/components/Template/BaseInfoFormPackage.vue
+++ b/src/components/Template/BaseInfoFormPackage.vue
@@ -86,10 +86,11 @@
:error="errors[key]" @update:error="errors[key] = false"
:orange-bg="orangeBgFields[key]" />
-
+
+ {{ $t( sItem.text) }}
onRegentSubmit(data,key,sItem)"
:item="sItem" :value="formFields[key]" />
+
@@ -420,4 +422,11 @@ export default {
color: #606266;
font-size: 14px;
}
+.item-center{
+ display: flex;
+ align-items: center;
+}
+.ml-5{
+ margin-left: 5px;
+}
\ No newline at end of file
diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue
index 3ac969c..d7b621a 100644
--- a/src/components/Template/CustomTable.vue
+++ b/src/components/Template/CustomTable.vue
@@ -54,6 +54,7 @@
@change="onBodyValueChange(rowIndex, colIndex, $event)"
:error="hasError(rowIndex, colIndex, col.prop)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)"
+ @beforeSaveRecord = "(data,callback)=>beforeSaveRecord(data,callback,rowIndex, col,row)"
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" />
@@ -64,6 +65,7 @@
@blur="onBlur(rowIndex, col.prop, $event)"
@change="onBodyValueChange(rowIndex, colIndex, $event)"
:error="hasError(rowIndex, colIndex, col.prop)"
+ @beforeSaveRecord = "(data,callback)=>beforeSaveRecord(data,callback,rowIndex, col,row)"
@update:error="onErrorUpdate(rowIndex, colIndex, col.prop, $event)"
:orange-bg="hasOrangeBg(rowIndex, colIndex, col.prop)" />
@@ -287,6 +289,9 @@ export default {
this.oldLocalDataSource = [];
},
methods: {
+ beforeSaveRecord(data,callback,rowIndex, col,row){
+ this.$emit("beforeSaveRecord", {inputData:data, callback,rowIndex, key:col.prop, rowData:row,dataSource:this.localDataSource})
+ },
getCellWidth(col){
const {templateFillType} = this;
let width = col.width ? col.width + 'px' : 'auto';
diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue
index 279f3c8..6041d3e 100644
--- a/src/components/Template/HandleFormItem.vue
+++ b/src/components/Template/HandleFormItem.vue
@@ -628,12 +628,43 @@ export default {
}
},
async onCommonHandleSaveRecord(val) {
+
const isEmpty = this.isValueEmpty(this.inputValue);
if (this.error && !isEmpty) {
this.$emit('update:error', false);
} else if (!this.error && isEmpty) {
this.$emit('update:error', true);
}
+
+ // 创建验证控制器,让父组件可以在保存前进行验证
+ const validationController = {
+ isPrevented: false,
+ errorMsg: '',
+ prevent(msg) {
+ this.isPrevented = true;
+ if (msg) this.errorMsg = msg;
+ }
+ };
+
+ // 触发beforeSaveRecord事件,让父组件进行验证
+ this.$emit('beforeSaveRecord', {
+ value: this.inputValue,
+ oldValue: this.oldValue,
+ fieldKey: this.fieldKey
+ }, validationController);
+
+ // 检查是否被阻止
+ if (validationController.isPrevented) {
+ // 验证不通过,显示错误信息
+ if (validationController.errorMsg) {
+ this.$message.error(validationController.errorMsg);
+ }
+ // 回退到旧值
+ this.inputValue = this.oldValue;
+ this.$emit('input', this.inputValue);
+ return;
+ }
+
if (!this.isFieldsRecord) {//是否需要记录修改记录
this.$emit("blur", this.inputValue);
this.$emit('input', this.inputValue);
diff --git a/src/views/business/comps/template/comps/sp/SP003.vue b/src/views/business/comps/template/comps/sp/SP003.vue
index cdb2e56..c4dbd54 100644
--- a/src/views/business/comps/template/comps/sp/SP003.vue
+++ b/src/views/business/comps/template/comps/sp/SP003.vue
@@ -24,6 +24,7 @@
@@ -56,7 +57,7 @@ import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue";
import { EventBus } from "@/utils/eventBus";
import { addTj, uniqeResource, uniqeResourceOne, addDecimals } from "@/utils/calUnitTools";
import { isCommonUnit } from "@/utils/conTools";
-import { convertConcentration } from "@/utils/conConverter";
+import { isValueEmpty } from "@/utils/index";
export default {
name: "SP003",
components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, SelectReagentDialog, TableOpertaion },
@@ -220,6 +221,8 @@ export default {
disabled: true,
maxlength: 10,
compareTo: "targetStartSolution",
+ subKey: "subTargetAcSolutionUnit",
+ subType:"span"
},
solution: {
label: "template.sp.sp003.xsy",
@@ -438,6 +441,10 @@ export default {
// const re = convertConcentration.convert('100mg/mL',"ng/mL")
},
methods: {
+ beforeSaveRecord(data){
+ const formFields = this.$refs.stepFormPackageRef?.getFilledFormData();
+ this.onCommonVerifyNdException(formFields,data);
+ },
onFormSelect(fields){
this.onHandleBlur(fields)
},
@@ -465,6 +472,7 @@ export default {
const { row } = selectInfo;
if (key === "subStartSolution") {//选择起始源溶液需要同步更新table的变更记录。
this.$refs.stepFormPackageRef.updateFormData("targetAcSolution", row.nd);
+ this.$refs.stepFormPackageRef.updateFormData("subTargetAcSolutionUnit", row.nddw);
this.updateStepTableData(row);
}
},
diff --git a/src/views/business/comps/template/comps/sp/SP00456.vue b/src/views/business/comps/template/comps/sp/SP00456.vue
index 1ccc71e..d59b113 100644
--- a/src/views/business/comps/template/comps/sp/SP00456.vue
+++ b/src/views/business/comps/template/comps/sp/SP00456.vue
@@ -553,7 +553,7 @@ export default {
item.startSolutionCode = row.bh;
} else {
item.startSolutionCode = newData[index - 1].targetSolutionCode + newData[index - 1].subTargetSolutionCode;
- initNd = newData[i - 1].actSolutionConcentration;
+ initNd = newData[index - 1].actSolutionConcentration;
}
const volResult = this.updateSjmbrynd(item, initNd);
if (!volResult) {
diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js
index 1396b26..a55d8e8 100644
--- a/src/views/business/comps/template/mixins/templateMixin.js
+++ b/src/views/business/comps/template/mixins/templateMixin.js
@@ -332,6 +332,30 @@ export default {
this.$refs.stepTableRef.deleteRow(index)
},
+ //统一处理浓度校验异常
+ onCommonVerifyNdException(formFields,data){
+ const {callback,rowIndex, key,dataSource} = data;
+ const keys = [
+ 'actStartSolutionVolume',
+ 'actDiluentVolume',
+ ]
+ if(keys.includes(key)){
+ const {targetAcSolution} = formFields;
+ if (rowIndex === 0) {//第一行的浓度取选择的溶液,
+ if (isValueEmpty(targetAcSolution)) {
+ callback.prevent("请先选择起始源溶液")
+ }
+ } else {
+ //非第一行的浓度取上一行的浓度
+ const prevItem = dataSource[rowIndex - 1]
+ const prevConcentration = prevItem.actSolutionConcentration;
+ if (!prevConcentration) {
+ callback.prevent("请先计算上一行的实际目标溶液浓度")
+ }
+ }
+ }
+
+ },
//统一处理blur事件,因为有效周期和过期日期是相关的,所以需要在有效周期失焦时更新过期日期
onHandleBlur(fields) {
const {
@@ -410,13 +434,13 @@ export default {
colKey === 'actDiluentVolume'
) {
//实际起始溶液体积和实际目标溶液体积
- const targetAcSolution =
- this.$refs.stepFormPackageRef?.getFormDataByKey('targetAcSolution') //获取实际起始溶液浓度
+ const {targetAcSolution} =
+ this.$refs.stepFormPackageRef?.getFilledFormData() //获取实际起始溶液浓度
if (isValueEmpty(targetAcSolution)) {
this.$message.error('请先选择起始源溶液')
return
} else {
- const volResult = this.updateSjmbrynd(item, targetAcSolution, rowIndex, dataSource, "ladder")
+ const volResult = this.updateSjmbrynd(item, targetAcSolution)
if (!volResult) {
return
}
@@ -457,26 +481,7 @@ export default {
},
//计算并更新实际目标溶液浓度 先计算实际目标溶液体积再计算实际目标溶液浓度
- updateSjmbrynd(item, targetAcSolution, rowIndex, dataSource, type) {
- //如果是阶梯配置的就需要传rowIndex,dataSource,type字段
- if (type === "ladder") {
- if (rowIndex === 0) {//第一行的浓度取选择的溶液,
- if (isValueEmpty(targetAcSolution)) {
- this.$message.error('请先选择起始源溶液')
- return
- }
- return this.calcNd(item, targetAcSolution)
- } else {
- //非第一行的浓度取上一行的浓度
- const prevItem = dataSource[rowIndex - 1]
- const prevConcentration = prevItem.actSolutionConcentration;
- if (!prevConcentration) {
- this.$message.error('请先计算上一行的实际目标溶液浓度')
- return false
- }
- return this.updateSjmbrynd(item, prevConcentration);
- }
- }
+ updateSjmbrynd(item, targetAcSolution) {
return this.calcNd(item, targetAcSolution)
},
//更新起始溶液体积时,计算预设起始溶液体积和预设稀释液体积