support dynamic form item rule required

This commit is contained in:
baiyaaaaa 2017-06-15 19:34:45 +08:00 committed by 杨奕
parent a54b5e626e
commit 9756a3c33a

View File

@ -112,6 +112,21 @@
return getPropByPath(model, path).v;
}
},
isRequired() {
let rules = this.getRules();
let isRequired = false;
if (rules && rules.length) {
rules.every(rule => {
if (rule.required) {
isRequired = true;
return false;
}
return true;
});
}
return isRequired;
}
},
data() {
@ -119,8 +134,7 @@
validateState: '',
validateMessage: '',
validateDisabled: false,
validator: {},
isRequired: false
validator: {}
};
},
methods: {
@ -211,12 +225,6 @@
let rules = this.getRules();
if (rules.length) {
rules.every(rule => {
if (rule.required) {
this.isRequired = true;
return false;
}
});
this.$on('el.form.blur', this.onFieldBlur);
this.$on('el.form.change', this.onFieldChange);
}