From 7b91b0392497c29c46111d9b2197f097f951b310 Mon Sep 17 00:00:00 2001 From: luojie <125330818@qq.com> Date: Tue, 31 Mar 2026 10:37:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86][upd?= =?UTF-8?q?ate]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Template/StepComponents/JcbComp.vue | 27 ++++++++++++---------- src/components/Template/StepFormPackage.vue | 7 ++---- src/components/Template/mixins/stepMixins.js | 2 +- .../comps/template/mixins/templateMixin.js | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/Template/StepComponents/JcbComp.vue b/src/components/Template/StepComponents/JcbComp.vue index ecc2e73..8b9bad8 100644 --- a/src/components/Template/StepComponents/JcbComp.vue +++ b/src/components/Template/StepComponents/JcbComp.vue @@ -67,19 +67,22 @@ export default { tableRef.deleteRow(rowIndex); } }, - getFilledFormData() { - const tableData = this.$refs.tableRef?.getFilledFormData(); - return { - jcbInfo:tableData, + // 实现validateFormData方法,用于表单验证 + validateFormData() { + + // 调用CustomTable的同步验证方法 + const validateResult = this.$refs.tableRef.validateFormData(); + + // 如果验证通过,还需要检查是否有数据行 + if (validateResult.valid) { + const filledData = this.$refs.tableRef.getFilledFormData(); + const { stepTableFormData = [] } = filledData; + if (stepTableFormData.length === 0) { + return { valid: false, error: '请添加取板数据' }; + } } - }, - // 实现getFormData方法,用于表单验证 - async getFormData() { - const result = await this.$refs.tableRef?.getFormData() - if(result){ - result.jcbInfo = result.jcbInfo || [] - } - return result; + console.log("validateResult",validateResult); + return validateResult; }, // 点击按钮事件 handleClickButton(key, rowIndex, row) { diff --git a/src/components/Template/StepFormPackage.vue b/src/components/Template/StepFormPackage.vue index 30cbc41..d85bfa3 100644 --- a/src/components/Template/StepFormPackage.vue +++ b/src/components/Template/StepFormPackage.vue @@ -161,7 +161,7 @@ export default { }, // 重写子组件校验钩子方法,检查ZLSubPackage的表单验证 validateSubComponents() { - const refs = [],qbRefs = []; + const refs = []; // 遍历formConfig,找到所有type为zlfz的项 for (const item of this.formConfig) { if (item.config) { @@ -179,10 +179,9 @@ export default { }else if(sItem.type === 'qb'){ const refName = `jcbComp_${key}`; const jcbCompRef = this.$refs[refName]; - console.log(jcbCompRef,"jcbCompRef") // 检查ZLSubPackage组件的表单验证 if (jcbCompRef) { - qbRefs.push(jcbCompRef); + refs.push(jcbCompRef); } } } @@ -190,8 +189,6 @@ export default { } if(refs.length === 0){ return {valid: true, error: ''}; - }else if(qbRefs.length > 0){ - return qbRefs[0][0].getFormData(); }else{//目前一个步骤只会有一个质量分装,所以不考虑多个的情况 return refs[0][0].validateFormData(); } diff --git a/src/components/Template/mixins/stepMixins.js b/src/components/Template/mixins/stepMixins.js index 3ca8672..7f61469 100644 --- a/src/components/Template/mixins/stepMixins.js +++ b/src/components/Template/mixins/stepMixins.js @@ -115,7 +115,7 @@ export default { const fzInfo = stepFormData.fzInfo || this.formData.fzInfo; let fields = [],options = [] let maxVolume, maxVolumeUnit; - if (this.getMybh) { + if (this.getMybh && this.getMybh()) { const { mybh,mybhOptions=[], maxVolume:max, maxVolumeUnit:unit } = this.getMybh() if((!mybh &&!mybhOptions.length) || !max || !unit){ this.$message.warning('请先填写分装数据') diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js index 1e3d518..ee08113 100644 --- a/src/views/business/comps/template/mixins/templateMixin.js +++ b/src/views/business/comps/template/mixins/templateMixin.js @@ -430,7 +430,7 @@ export default { }) const validFormData = await Promise.all(refs).catch((err) => { // this.$message.error(err); - if (err.errorType && err.errorType === 'step') { + if (err &&err.errorType && err.errorType === 'step') { this.$message.error('请添加步骤') return }