el-table 表格里面有tree 层级 进行勾选和反勾选

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

// 勾选全选反勾选等实现
   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,'最后的数据')

      }
    
    }
  }
},

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6