// const authoritiesStatus = (arr: any[]) => {
// arr.forEach((item: any) => {
// item.disabled = true;
// if (item.children && item.children.length !== 0) {
// let newChildren = [];
// newChildren = authoritiesStatus(item.children);
// item.children = newChildren;
// }
// });
// return arr;
// };
// 处理返回数据,给id等于pid的添加disabled=true属性 显示父节点 但是不允许选择
// const addDisabledForStatus = (arr: any, pid: any) => {
// arr.forEach((item: { id: any; disabled: boolean; children: string | any[] }) => {
// if (item.id == pid) {
// if (item.children && item.children.length !== 0) {
// let superiorslist = [];
// superiorslist = authoritiesStatus(item.children);
// item.children = superiorslist;
// }
// item.disabled = true;
// }
// // 有无children项
// if (item.children && item.children.length !== 0) {
// let newChildren = [];
// newChildren = addDisabledForStatus(item.children, pid);
// item.children = newChildren;
// }
// });
// return arr;
// };
树形结构 根据id 给父节点及子节点 添加disabled =true
最新推荐文章于 2024-07-15 22:27:12 发布