From a5bd8e79103b4434629b9fa786b72796743d9ee6 Mon Sep 17 00:00:00 2001 From: lideqin <694785430@qq.com> Date: Tue, 28 Nov 2023 19:19:41 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20=E4=BF=AE=E6=94=B9=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E6=8F=90=E4=BA=A4=E6=97=B6=EF=BC=8C=E6=9C=AA?= =?UTF-8?q?=E5=B1=95=E5=BC=80=E8=BF=87=E6=A0=A1=E9=AA=8C=E5=BF=85=E5=A1=AB?= =?UTF-8?q?=EF=BC=8C=E9=83=BD=E4=B8=8D=E5=BF=85=E5=A1=AB=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/JExpandTable.vue | 40 ++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/components/JExpandTable.vue b/src/components/JExpandTable.vue index 6c0f3342..ff32f5ff 100644 --- a/src/components/JExpandTable.vue +++ b/src/components/JExpandTable.vue @@ -232,10 +232,48 @@ export default { arr[i] = valid }) } else { + // arr[i] = false // 表单都没有渲染,说明没有展开过,也就是未填状态 - arr[i] = false + if (this.formIsDepend) { + if (this.dataSource[i][this.formIsDepend]) { + // 需要依赖某个字段,获取当前行该字段时,扩展表单是否有必填项 + const currRowExtraFormRules = this.extraForm[this.dataSource[i][this.formIsDepend]].rules + let isHaveRequired = false + for (const item in currRowExtraFormRules) { + if (currRowExtraFormRules[item].required === true) { + // 有任意一个字段有必填 + isHaveRequired = true + } + } + if (isHaveRequired) { + // 任意一个字段有必填,她又没展开过,校验不通过 + arr[i] = false + } else { + arr[i] = true + } + } else { + // 依赖的字段都没有填 + arr[i] = false + } + } else { + // 没有依赖的字段 + let isHaveRequired = false + for (const item in this.extraForm.rules) { + if (this.extraForm.rules[item].required === true) { + // 有任意一个字段有必填 + isHaveRequired = true + } + } + if (isHaveRequired) { + // 任意一个字段有必填,她又没展开过,校验不通过 + arr[i] = false + } else { + arr[i] = true + } + } } } + console.log(arr) if (arr.includes(false)) { return false } else {