mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-03 12:48:45 +08:00
support dynamic form item rule required
This commit is contained in:
parent
a54b5e626e
commit
9756a3c33a
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user