|
|
@@ -42,7 +42,9 @@ export default function DepartmentManagement() {
|
|
|
setLoading(true);
|
|
|
try {
|
|
|
const data = await deptApi.getDeptPage(queryParams);
|
|
|
- const treeData = handleTree(data || []);
|
|
|
+ // 过滤掉没有 id 的项,并确保 id 存在
|
|
|
+ const validDeptList = (data || []).filter((dept): dept is DeptVO & { id: number } => !!dept.id);
|
|
|
+ const treeData = handleTree(validDeptList);
|
|
|
setList(treeData);
|
|
|
} catch (error: any) {
|
|
|
console.error('获取部门列表失败:', error);
|
|
|
@@ -80,7 +82,9 @@ export default function DepartmentManagement() {
|
|
|
setLoading(true);
|
|
|
deptApi.getDeptPage(resetParams)
|
|
|
.then((data) => {
|
|
|
- const treeData = handleTree(data || []);
|
|
|
+ // 过滤掉没有 id 的项,并确保 id 存在
|
|
|
+ const validDeptList = (data || []).filter((dept): dept is DeptVO & { id: number } => !!dept.id);
|
|
|
+ const treeData = handleTree(validDeptList);
|
|
|
setList(treeData);
|
|
|
})
|
|
|
.catch((error: any) => {
|