mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-04 21:27:52 +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;
|
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() {
|
data() {
|
||||||
@ -119,8 +134,7 @@
|
|||||||
validateState: '',
|
validateState: '',
|
||||||
validateMessage: '',
|
validateMessage: '',
|
||||||
validateDisabled: false,
|
validateDisabled: false,
|
||||||
validator: {},
|
validator: {}
|
||||||
isRequired: false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -211,12 +225,6 @@
|
|||||||
let rules = this.getRules();
|
let rules = this.getRules();
|
||||||
|
|
||||||
if (rules.length) {
|
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.blur', this.onFieldBlur);
|
||||||
this.$on('el.form.change', this.onFieldChange);
|
this.$on('el.form.change', this.onFieldChange);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user