
/** * 公共表单校验依次校验传入的 form 实例列表校验失败时弹出错误提示 * param {Array} formRefs - 表单 ref 实例数组 * param {Function} notifyError - 错误提示函数 (如 proxy.$modal.notifyError) * returns {Promiseboolean} */ export const validateForms async (formRefs, notifyError) { try { for (const ref of formRefs) { if (ref) await ref.validate() } return true } catch (error) { if (error typeof error object) { const messages Object.values(error).flat().map(e e.message).join() if (messages notifyError) { notifyError(messages) } } return false } }使用const step1FormEle ref(null) const refs [step1FormEle.value] const valid await validateForms(refs, ElMessage.success) if (!valid) { return }