提交 53cb79ed 编写于 作者: D dolymood

feat(form): support submitAlwaysValidate prop

submitAlwaysValidate to control validate always when submit
上级 80a05dc1
...@@ -55,6 +55,10 @@ ...@@ -55,6 +55,10 @@
immediateValidate: { immediateValidate: {
type: Boolean, type: Boolean,
default: false default: false
},
submitAlwaysValidate: {
type: Boolean,
default: false
} }
}, },
data() { data() {
...@@ -85,6 +89,15 @@ ...@@ -85,6 +89,15 @@
} }
return groups return groups
}, },
fieldsData() {
return this.groups.reduce((fields, group) => {
group.fields.reduce((fields, field) => {
fields.push(field)
return fields
}, fields)
return fields
}, [])
},
layout() { layout() {
const options = this.options const options = this.options
const layout = (options && options.layout) || LAYOUTS.STANDARD const layout = (options && options.layout) || LAYOUTS.STANDARD
...@@ -156,7 +169,7 @@ ...@@ -156,7 +169,7 @@
this.$emit(EVENT_INVALID, this.validity) this.$emit(EVENT_INVALID, this.validity)
} }
} }
if (this.valid === undefined) { if (this.submitAlwaysValidate || this.valid === undefined) {
this._submit(submited) this._submit(submited)
if (this.validating || this.pending) { if (this.validating || this.pending) {
// async validate // async validate
...@@ -299,7 +312,8 @@ ...@@ -299,7 +312,8 @@
}) })
}, },
addField(fieldComponent) { addField(fieldComponent) {
this.fields.push(fieldComponent) const i = this.fieldsData.indexOf(fieldComponent.field)
this.fields.splice(i, 0, fieldComponent)
const modelKey = fieldComponent.fieldValue.modelKey const modelKey = fieldComponent.fieldValue.modelKey
modelKey && this.setValidity(modelKey) modelKey && this.setValidity(modelKey)
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册