Skip to content

Commit 6b8bb0d

Browse files
committed
fix: 修复修改根部门时获取部门树数据异常的bug
1 parent e2b76a6 commit 6b8bb0d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

dash-fastapi-backend/module_admin/dao/dept_dao.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ def get_dept_info_for_edit_option(cls, db: Session, dept_info: DeptModel, data_s
8686
SysDept.parent_id != dept_info.dept_id,
8787
SysDept.del_flag == 0, SysDept.status == 0,
8888
eval(data_scope_sql)) \
89-
.all()
89+
.order_by(SysDept.order_num) \
90+
.distinct().all()
9091
dept = cls.get_dept_by_id(db, dept_info.dept_id)
9192
parent = cls.get_dept_by_id(db, dept.parent_id)
92-
dept_result.insert(0, parent)
93+
if parent:
94+
dept_result.insert(-1, parent)
9395

94-
return list_format_datetime(list(set(dept_result)))
96+
return list_format_datetime(sorted(set(dept_result), key=dept_result.index))
9597

9698
@classmethod
9799
def get_children_dept(cls, db: Session, dept_id: int):

0 commit comments

Comments
 (0)