update Tree selected

This commit is contained in:
梁灏 2017-10-25 22:34:58 +08:00
parent 6ff0e34003
commit af7d72b4cc
2 changed files with 117 additions and 70 deletions

View file

@ -147,9 +147,9 @@
},
handleSelect (nodeKey) {
const node = this.flatState[nodeKey].node;
if (!this.multiple){ // reset selected
if (!this.multiple){ // reset previously selected node
const currentSelectedKey = this.flatState.findIndex(obj => obj.node.selected);
if (currentSelectedKey >= 0) this.$set(this.flatState[currentSelectedKey].node, 'selected', false);
if (currentSelectedKey >= 0 && currentSelectedKey !== nodeKey) this.$set(this.flatState[currentSelectedKey].node, 'selected', false);
}
this.$set(node, 'selected', !node.selected);