mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 优化 部门树多基点展示问题 支持相同名称节点并排展示
This commit is contained in:
@ -102,11 +102,22 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
if (CollUtil.isEmpty(depts)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
return TreeBuildUtils.build(depts, (dept, tree) ->
|
||||
tree.setId(dept.getDeptId())
|
||||
.setParentId(dept.getParentId())
|
||||
.setName(dept.getDeptName())
|
||||
.setWeight(dept.getOrderNum()));
|
||||
// 获取当前列表中每一个节点的parentId,然后在列表中查找是否有id与其parentId对应,若无对应,则表明此时节点列表中,该节点在当前列表中属于顶级节点
|
||||
List<Tree<Long>> treeList = CollUtil.newArrayList();
|
||||
for (SysDeptVo d : depts) {
|
||||
Long parentId = d.getParentId();
|
||||
SysDeptVo sysDeptVo = depts.stream().filter(it -> it.getDeptId().longValue() == parentId).findFirst().orElse(null);
|
||||
if (sysDeptVo == null) {
|
||||
List<Tree<Long>> trees = TreeBuildUtils.build(depts, parentId, (dept, tree) ->
|
||||
tree.setId(dept.getDeptId())
|
||||
.setParentId(dept.getParentId())
|
||||
.setName(dept.getDeptName())
|
||||
.setWeight(dept.getOrderNum()));
|
||||
Tree<Long> tree = trees.stream().filter(it -> it.getId().longValue() == d.getDeptId()).findFirst().get();
|
||||
treeList.add(tree);
|
||||
}
|
||||
}
|
||||
return treeList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user