fix 修复树形结果转换函数
This commit is contained in:
parent
de14eaf7b5
commit
232e578a6b
@ -29,7 +29,7 @@ export function getUpFileUrl(url:string){
|
|||||||
* @param {*} children 孩子节点字段 默认 'children'
|
* @param {*} children 孩子节点字段 默认 'children'
|
||||||
* @param {*} rootId 根Id 默认 0
|
* @param {*} rootId 根Id 默认 0
|
||||||
*/
|
*/
|
||||||
export function handleTree(data:any[], id:string, parentId:string, children:string, rootId:number):any[] {
|
export function handleTree(data:any[], id:string, parentId:string, children:string, rootId:any):any[] {
|
||||||
id = id || 'id'
|
id = id || 'id'
|
||||||
parentId = parentId || 'parentId'
|
parentId = parentId || 'parentId'
|
||||||
children = children || 'children'
|
children = children || 'children'
|
||||||
@ -44,7 +44,16 @@ export function handleTree(data:any[], id:string, parentId:string, children:stri
|
|||||||
});
|
});
|
||||||
branchArr.length > 0 ? father[children] = branchArr : '';
|
branchArr.length > 0 ? father[children] = branchArr : '';
|
||||||
//返回第一层
|
//返回第一层
|
||||||
return father[parentId] === rootId;
|
switch (typeof father[parentId]){
|
||||||
|
case 'string':
|
||||||
|
if(father[parentId]===''&&rootId===0){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return father[parentId]===rootId.toString();
|
||||||
|
case 'number':
|
||||||
|
return father[parentId] === rootId;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
return treeData != '' ? treeData : data;
|
return treeData != '' ? treeData : data;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user