Skip to content

Commit

Permalink
fix 解决部门树状数据时重复问题 (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
onekb authored Jun 8, 2024
1 parent 1abf182 commit 4b64fe1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/System/Mapper/SystemDeptMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public function getSelectTree(): array
->orderBy('parent_id')->orderBy('sort', 'desc')
->get()->toArray();

return (new MineCollection())->toTree(array_merge($treeData, $deptTree), $treeData[0]['parent_id'] ?? 0);
// 去除重复部门
$deptTree = array_merge($treeData, $deptTree);
$deptTree = array_values(array_column($deptTree, null, 'id'));

return (new MineCollection())->toTree($deptTree, $treeData[0]['parent_id'] ?? 0);
}
return $deptTree;
}
Expand Down

0 comments on commit 4b64fe1

Please sign in to comment.