diff --git a/src/components/Template/CustomTable.vue b/src/components/Template/CustomTable.vue index 31b77e6..83026c2 100644 --- a/src/components/Template/CustomTable.vue +++ b/src/components/Template/CustomTable.vue @@ -111,15 +111,13 @@ @@ -324,15 +322,11 @@ export default { onDeleteCheckboxTag(rowIndex, col, tagIndex) { this.localDataSource[rowIndex][col.prop].splice(tagIndex, 1); this.$emit("onDeleteTag", rowIndex, col, tagIndex); - const params = { - type: "fieldChanged", - newRecord: null, - resourceList: null, - } - EventBus.$emit('onModifyRecord', params,) + this.justUpdateFilledFormData(); }, - onCheckboxTagChange(rowIndex, col, tagIndex, value) { + onCheckboxTagChange(rowIndex, colIndex, col, tagIndex, value) { this.localDataSource[rowIndex][col.prop][tagIndex] = value; + this.onErrorUpdate(rowIndex, colIndex, col.prop, value?false:true); this.$emit("onCheckboxTagChange", rowIndex, col, tagIndex, value) }, handleClickButton(e, data, key, rowIndex, colIndex) { @@ -487,10 +481,35 @@ export default { // 检查主字段 const mainValue = row[col.prop]; if (col.bodyType === "checkboxTag") { - if(this.templateFillType === "actFill"){ - - }else if(this.templateFillType === "preFill"){ - + // checkboxTag类型的校验逻辑 + if (this.templateFillType === "actFill") { + // actFill时,检查是否有checked为true的项 + const hasChecked = mainValue && mainValue.some(tag => tag.checked === true); + if (!hasChecked && !col.bodyDisabled) { + const errorItem = { + rowIndex, + colIndex, + field: col.prop, + label: this.$t(col.label), + error: `请勾选${this.$t(col.label)}` + }; + errors.push(errorItem); + this.formErrors.push(errorItem); + } + } else if (this.templateFillType === "preFill") { + // preFill时,检查所有tagValue是否不为空 + const allTagValuesFilled = mainValue && mainValue.every(tag => tag.tagValue && tag.tagValue.trim() !== ''); + if (!allTagValuesFilled && !col.bodyDisabled) { + const errorItem = { + rowIndex, + colIndex, + field: col.prop, + label: this.$t(col.label), + error: `请填写${this.$t(col.label)}` + }; + errors.push(errorItem); + this.formErrors.push(errorItem); + } } } else { if (this.isValueEmpty(mainValue) && !col.bodyDisabled && col.bodyType !== 'span' && col.bodyType !== 'button') { @@ -761,6 +780,15 @@ export default { return true; }, + // 只是更新已填写的表单数据,不触发校验 + justUpdateFilledFormData(){ + const params = { + type: "fieldChanged", + newRecord: null, + resourceList: null, + } + EventBus.$emit('onModifyRecord', params,) + }, onAddRow() { if (this.$listeners && this.$listeners['onAddRow']) { this.$emit('onAddRow'); @@ -772,6 +800,7 @@ export default { targetDiluentVolumePrecision: 3,//小数点精度默认为3 targetStartSolutionVolumePrecision: 3,//小数点精度默认为3 }); + this.justUpdateFilledFormData() }, // 添加行 @@ -1055,13 +1084,13 @@ export default { .flex-wrap { flex-wrap: wrap; + gap:10px; } -.error-border { - border-color: #ff5d5d; +.row-error-border { box-shadow: 0 0 6px #ffc3c3; padding: 8px; border-radius: 4px; - border: 1px solid; + border: 1px solid #ff5d5d; } \ No newline at end of file diff --git a/src/components/Template/HandleFormItem.vue b/src/components/Template/HandleFormItem.vue index df49189..a42a2f4 100644 --- a/src/components/Template/HandleFormItem.vue +++ b/src/components/Template/HandleFormItem.vue @@ -820,6 +820,7 @@ export default { // checkboxTag的checkbox变化处理 onCheckboxTagChange() { this.emitCheckboxTagValue(); + this.onCommonHandleSaveRecord(); }, // tag输入框失去焦点 @@ -827,10 +828,7 @@ export default { const value = e.target.value; this.tagValue = value; this.emitCheckboxTagValue(); - // 触发保存记录 - if (this.tagValue) { - this.onCommonHandleSaveRecord(this.tagValue); - } + this.onCommonHandleSaveRecord(this.tagValue); }, // 删除tag onDeleteTag() { @@ -961,7 +959,9 @@ export default { //处理更新记录 handleUpdateRecord(data,recordData) { const baseInfo = this.getCommonRecordInfo(); - if (!this.oldValue && !this.inputValue) return; + if (!this.oldValue && !this.inputValue){ + return + } if(recordData){ this.oldValue = recordData.oldValue; this.inputValue = recordData.inputValue; @@ -1647,8 +1647,8 @@ export default { .checkbox-tag-container { border-radius: 4px; // transition: all 0.3s; - margin-bottom: 10px; - margin-right: 10px; + // margin-bottom: 10px; + // margin-right: 10px; &.error-border { border-color: #ff5d5d !important; diff --git a/src/components/Template/operation/TableOpertaion.vue b/src/components/Template/operation/TableOpertaion.vue index 1483bad..7cdc64b 100644 --- a/src/components/Template/operation/TableOpertaion.vue +++ b/src/components/Template/operation/TableOpertaion.vue @@ -162,7 +162,15 @@ export default { }, // 删除行 deleteRow(index) { - this.$emit("deleteRow", index) + this.$emit("deleteRow", index); + setTimeout(() => { + const params = { + type: "fieldChanged", + newRecord: null, + resourceList: null, + } + EventBus.$emit('onModifyRecord', params,) + }, 30); } } } diff --git a/src/components/Template/operation/TableOpertaionDelete.vue b/src/components/Template/operation/TableOpertaionDelete.vue index c9f6562..54b3401 100644 --- a/src/components/Template/operation/TableOpertaionDelete.vue +++ b/src/components/Template/operation/TableOpertaionDelete.vue @@ -10,6 +10,8 @@