// 勾选全选反勾选等实现setChecked(data) {for (let i = 0; i < data.length; i++) {const node = data[i];if (node.isCheck) {// 如果当前节点被勾选,将其子节点全部设置为选中状态if(node.children) {for (let j = 0; j < node.children.length; j++) {const childNode = node.children[j];childNode.isCheck = true;if (childNode.children){this.setChecked(childNode.children); // 递归地设置子节点的子节点为选中状态}}}else {this.deptList.forEach(item => {if (item.id === node.parentId) {if (item.children && item.children.every(child => child.isCheck === true)) {item.isCheck = true;}}
});}} else {// 如果当前节点未被勾选,将其子节点全部设置为未选中状态if(node.children) {for (let j = 0; j < node.children.length; j++) {const childNode = node.children[j];childNode.isCheck = false;if (childNode.children){this.setChecked(childNode.children); // 递归地设置子节点的子节点为未选中状态}}}else{this.deptList.forEach(item => {if (item.id === node.parentId) {if (item.children && item.children.every(child => child.isCheck === false)) {item.isCheck = false;}}
});
console.log(this.deptList,'最后的数据')}}}
},