Merge pull request #4214 from myvueyyyy/2.0

when rule change ,form-item rule not refresh
This commit is contained in:
Aresn 2018-08-08 10:29:28 +08:00 committed by GitHub
commit ab719ff2be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 52 deletions

View file

@ -90,6 +90,9 @@
},
validateStatus (val) {
this.validateState = val;
},
rules (){
this.setRules();
}
},
inject: ['form'],
@ -143,6 +146,18 @@
}
},
methods: {
setRules() {
let rules = this.getRules();
if (rules.length) {
rules.every((rule) => {
this.isRequired = rule.required;
});
this.$off('on-form-blur', this.onFieldBlur);
this.$off('on-form-change', this.onFieldChange);
this.$on('on-form-blur', this.onFieldBlur);
this.$on('on-form-change', this.onFieldChange);
}
},
getRules () {
let formRules = this.form.rules;
const selfRules = this.rules;
@ -229,18 +244,7 @@
value: this.fieldValue
});
let rules = this.getRules();
if (rules.length) {
rules.every(rule => {
if (rule.required) {
this.isRequired = true;
return false;
}
});
this.$on('on-form-blur', this.onFieldBlur);
this.$on('on-form-change', this.onFieldChange);
}
this.setRules();
}
},
beforeDestroy () {