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