From 0e6afb51fd63bd78bcf2ebb645ae11e6ef467c3d Mon Sep 17 00:00:00 2001 From: wuteng <419274783@qq.com> Date: Wed, 15 Oct 2025 15:53:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=82=B9=E8=B4=B9=E7=94=A8=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=AD=90=E8=A1=A8=E5=8D=95=E6=A0=A1=E9=AA=8C=E6=8B=A6?= =?UTF-8?q?=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../emisWaybillAjustApply/adjustPanel.vue | 21 ++++++++- .../emisWaybillAjustApplyForm.vue | 43 +++++++++++-------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/views/emis/emisWaybillAjustApply/adjustPanel.vue b/src/views/emis/emisWaybillAjustApply/adjustPanel.vue index 6ac5bf7b..aaba533f 100644 --- a/src/views/emis/emisWaybillAjustApply/adjustPanel.vue +++ b/src/views/emis/emisWaybillAjustApply/adjustPanel.vue @@ -2490,7 +2490,26 @@ export default { } }); return true; - } + }, + // 暴露校验方法给父组件调用 + validateForm(cb) { + this.$refs.form.validate((valid) => { + // 获取所有错误信息 + const errors = this.getFormErrors() + cb(valid, errors) // 给父组件传递:校验结果 + 错误信息 + }) + }, + getFormErrors() { + const form = this.$refs.form + if (!form) return [] + // Element UI 的 fields 数组存储了所有字段的校验状态 + return form.fields + .filter(field => field.validateMessage) // 筛选出有错误的字段 + .map(field => ({ + prop: field.prop, // 字段名(如 'name'、'age') + message: field.validateMessage // 错误提示信息 + })) + } } }; diff --git a/src/views/emis/emisWaybillAjustApply/emisWaybillAjustApplyForm.vue b/src/views/emis/emisWaybillAjustApply/emisWaybillAjustApplyForm.vue index 79dad601..f4582d18 100644 --- a/src/views/emis/emisWaybillAjustApply/emisWaybillAjustApplyForm.vue +++ b/src/views/emis/emisWaybillAjustApply/emisWaybillAjustApplyForm.vue @@ -259,25 +259,34 @@ export default { }, /** 提交按钮 */ submitForm() { - this.$refs["form"].validate(valid => { - if (valid) { - let jsonData=this.$refs.refAdjustDetail.getJsonData(); - console.log("====>jsonData==>",jsonData); - const params={ - "applyManCode":this.form.applyManCode, - "applyMemo":this.form.applyMemo, - "applySiteCode":this.form.applySiteCode, - "applyType":this.form.applyType, - "billCode":this.form.billCode, - "destConfirmSiteCode":this.form.destConfirmSiteCode, - "jsonData":JSON.stringify(jsonData), - } - addEmisWaybillAjustApply(params).then(response => { - this.$modal.msgSuccess("申请成功"); - this.$emit("on-changed"); - }); + // 校验子表单 + this.$refs["refAdjustDetail"].validateForm((valid, errors) => { + if (!valid) { + // this.$modal.msgError(errors[0].message); + return + } else { + this.$refs["form"].validate(valid => { + if (valid) { + let jsonData = this.$refs.refAdjustDetail.getJsonData(); + console.log("====>jsonData==>", jsonData); + const params = { + "applyManCode": this.form.applyManCode, + "applyMemo": this.form.applyMemo, + "applySiteCode": this.form.applySiteCode, + "applyType": this.form.applyType, + "billCode": this.form.billCode, + "destConfirmSiteCode": this.form.destConfirmSiteCode, + "jsonData": JSON.stringify(jsonData), + } + addEmisWaybillAjustApply(params).then(response => { + this.$modal.msgSuccess("申请成功"); + this.$emit("on-changed"); + }); + } + }); } }); + }, }