|
@@ -199,19 +199,19 @@ export default {
|
|
} else {
|
|
} else {
|
|
this.checkedKeys = this.checkedKeys.filter(id0 => id0 !== id);
|
|
this.checkedKeys = this.checkedKeys.filter(id0 => id0 !== id);
|
|
}
|
|
}
|
|
- // 选中状态下对子节点的影响:递归选中所有子孙节点
|
|
|
|
|
|
+ // 选中状态下对子节点的影响:递归选中所有子孙节点
|
|
if (checked && children) {
|
|
if (checked && children) {
|
|
this.checkedKeys = [...this.checkedKeys, ...children.map(v => v.id)];
|
|
this.checkedKeys = [...this.checkedKeys, ...children.map(v => v.id)];
|
|
for (const child of children) {
|
|
for (const child of children) {
|
|
this.checkedKeys = [...this.checkedKeys, child.id];
|
|
this.checkedKeys = [...this.checkedKeys, child.id];
|
|
for (const child of child.children || []) {
|
|
for (const child of child.children || []) {
|
|
- // 树最多只有三个层级,这里就不写递归了
|
|
|
|
|
|
+ // 树最多只有三个层级,这里就不写递归了
|
|
this.checkedKeys = [...this.checkedKeys, child.id];
|
|
this.checkedKeys = [...this.checkedKeys, child.id];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 选中状态下对父节点的影响:递归选中所有父辈节点
|
|
|
|
|
|
+ // 选中状态下对父节点的影响:递归选中所有父辈节点
|
|
if (checked && parentId) {
|
|
if (checked && parentId) {
|
|
this.checkedKeys = [...this.checkedKeys, parentId];
|
|
this.checkedKeys = [...this.checkedKeys, parentId];
|
|
const parent1 = this.$refs.tree.getNode(parentId).data;
|
|
const parent1 = this.$refs.tree.getNode(parentId).data;
|
|
@@ -223,7 +223,7 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 取消选中状态下对子节点的影响:递归取消选中所有子孙节点
|
|
|
|
|
|
+ // 取消选中状态下对子节点的影响:递归取消选中所有子孙节点
|
|
if (!checked && children) {
|
|
if (!checked && children) {
|
|
this.checkedKeys = this.checkedKeys.filter(id0 => id0 !== id);
|
|
this.checkedKeys = this.checkedKeys.filter(id0 => id0 !== id);
|
|
// console.log(this.checkedKeys);
|
|
// console.log(this.checkedKeys);
|
|
@@ -231,7 +231,7 @@ export default {
|
|
this.checkedKeys = this.checkedKeys.filter(id => id !== child.id);
|
|
this.checkedKeys = this.checkedKeys.filter(id => id !== child.id);
|
|
// console.log(this.checkedKeys);
|
|
// console.log(this.checkedKeys);
|
|
for (const child of child.children || []) {
|
|
for (const child of child.children || []) {
|
|
- // 树最多只有三个层级,这里就不写递归了
|
|
|
|
|
|
+ // 树最多只有三个层级,这里就不写递归了
|
|
this.checkedKeys = this.checkedKeys.filter(id => id !== child.id);
|
|
this.checkedKeys = this.checkedKeys.filter(id => id !== child.id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -240,7 +240,7 @@ export default {
|
|
this.checkedKeys = [...new Set(this.checkedKeys)];
|
|
this.checkedKeys = [...new Set(this.checkedKeys)];
|
|
this.$refs.tree.setCheckedKeys(this.checkedKeys);
|
|
this.$refs.tree.setCheckedKeys(this.checkedKeys);
|
|
|
|
|
|
- // 取消选中状态下对父节点的影响:无影响
|
|
|
|
|
|
+ // 取消选中状态下对父节点的影响:无影响
|
|
|
|
|
|
// if (checked && !this.checkedKeys.includes(node.id)) {
|
|
// if (checked && !this.checkedKeys.includes(node.id)) {
|
|
// this.checkedKeys.push(node.id);
|
|
// this.checkedKeys.push(node.id);
|