support Checkbox
support Checkbox
This commit is contained in:
parent
06322514c6
commit
cbe03a12b2
10 changed files with 146 additions and 29 deletions
|
@ -9,42 +9,49 @@
|
|||
export default {
|
||||
name: 'checkboxGroup',
|
||||
props: {
|
||||
model: {
|
||||
value: {
|
||||
type: Array,
|
||||
default () {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
currentValue: this.value
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
return `${prefixCls}`;
|
||||
}
|
||||
},
|
||||
compiled () {
|
||||
mounted () {
|
||||
this.updateModel(true);
|
||||
},
|
||||
methods: {
|
||||
updateModel (update) {
|
||||
const model = this.model;
|
||||
const value = this.value;
|
||||
|
||||
this.$children.forEach((child) => {
|
||||
child.model = model;
|
||||
child.model = value;
|
||||
|
||||
if (update) {
|
||||
child.selected = model.indexOf(child.value) >= 0;
|
||||
child.currentValue = value.indexOf(child.label) >= 0;
|
||||
child.group = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
change (data) {
|
||||
this.model = data;
|
||||
this.currentValue = data;
|
||||
this.$emit('input', data);
|
||||
this.$emit('on-change', data);
|
||||
this.$dispatch('on-form-change', data);
|
||||
// todo 事件
|
||||
// this.$dispatch('on-form-change', data);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
model () {
|
||||
value () {
|
||||
this.updateModel(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue