[update] 修改扩展表格提交时,未展开过校验必填,都不必填校验通过
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user