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 {