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) }}
+
@@ -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)" /> @@ -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 @@