parent
3c145e6ffe
commit
53754a3185
3 changed files with 11 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<Tree :data="baseData" @on-select-change="handleSelectChange" show-checkbox></Tree>
|
||||
<Tree :data="baseData" @on-check-change="handleSelectChange" show-checkbox></Tree>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
|
|
|
@ -58,8 +58,7 @@
|
|||
data () {
|
||||
return {
|
||||
prefixCls: prefixCls,
|
||||
indeterminate: false,
|
||||
checked: false
|
||||
indeterminate: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
@ -120,6 +119,7 @@
|
|||
}
|
||||
this.data.checked = checked;
|
||||
this.dispatch('Tree', 'checked');
|
||||
this.dispatch('Tree', 'on-checked');
|
||||
},
|
||||
setIndeterminate () {
|
||||
this.indeterminate = this.data.checked ? false : findComponentsDownward(this, 'TreeNode').some(node => node.data.checked);
|
||||
|
@ -131,6 +131,7 @@
|
|||
},
|
||||
mounted () {
|
||||
this.$on('indeterminate', () => {
|
||||
this.broadcast('TreeNode', 'indeterminate');
|
||||
this.setIndeterminate();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -54,6 +54,10 @@
|
|||
const nodes = findComponentsDownward(this, 'TreeNode');
|
||||
return nodes.filter(node => node.data.selected).map(node => node.data);
|
||||
},
|
||||
getCheckedNodes () {
|
||||
const nodes = findComponentsDownward(this, 'TreeNode');
|
||||
return nodes.filter(node => node.data.checked).map(node => node.data);
|
||||
},
|
||||
updateData (isInit = true) {
|
||||
// init checked status
|
||||
function reverseChecked(data) {
|
||||
|
@ -105,6 +109,9 @@
|
|||
this.$on('checked', () => {
|
||||
this.updateData(false);
|
||||
});
|
||||
this.$on('on-checked', () => {
|
||||
this.$emit('on-check-change', this.getCheckedNodes());
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Reference in a new issue