|
@@ -114,16 +114,13 @@ def get_dept_tree2(db: Session, tag_id: int = None) -> Dict:
|
|
|
"deptType": True
|
|
|
}
|
|
|
# print(dept_info.dept_id)
|
|
|
- children = parent_id_get_dept_info(db, dept_info.dept_id)
|
|
|
- if len(children) > 0:
|
|
|
- children_depts = build_dept_tree(children, dept)
|
|
|
- dept["children"] = children_depts
|
|
|
+
|
|
|
users = db.query(SysUser).filter(SysUser.dept_id == dept_info.dept_id).filter(SysUser.del_flag != '2').all()
|
|
|
for user_info in users:
|
|
|
user = {
|
|
|
"uuid": str(uuid.uuid4()).replace('-', ''),
|
|
|
"id": user_info.user_id,
|
|
|
- "label": user_info.user_name,
|
|
|
+ "label": user_info.nick_name,
|
|
|
"deptType": False,
|
|
|
"userTag":get_user_tags(user_info.user_id),
|
|
|
"userDept":dept_info.dept_name,
|
|
@@ -134,14 +131,27 @@ def get_dept_tree2(db: Session, tag_id: int = None) -> Dict:
|
|
|
dept['children'].append(user)
|
|
|
else:
|
|
|
dept['children']=[user]
|
|
|
+
|
|
|
+ children = parent_id_get_dept_info(db, dept_info.dept_id)
|
|
|
+ if len(children) > 0:
|
|
|
+ children_depts = build_dept_tree(children, dept)
|
|
|
+ if "children" in dept:
|
|
|
+ dept['children'] += children_depts
|
|
|
+ else:
|
|
|
+ dept["children"] = children_depts
|
|
|
dept_tree.append(dept)
|
|
|
return dept_tree
|
|
|
if tag_id is None:
|
|
|
- dept_ids = [0]
|
|
|
+ # dept_ids = [0]
|
|
|
+ # for dept_id in dept_ids:
|
|
|
+ dept_tree=build_dept_tree(parent_id_get_dept_info(db, 0), None)
|
|
|
else:
|
|
|
+ dept_infos = []
|
|
|
dept_ids = db.query(SysDeptTag).filter(SysDeptTag.tag_id == tag_id).all()
|
|
|
- for dept_id in dept_ids:
|
|
|
- dept_tree.append( build_dept_tree(parent_id_get_dept_info(db, dept_id), None))
|
|
|
+ for dept_id in dept_ids:
|
|
|
+ c_id = dept_id.dept_id
|
|
|
+ dept_infos.append(dept_id_get_dept_info(db,c_id))
|
|
|
+ dept_tree=build_dept_tree(dept_infos, None)
|
|
|
return dept_tree
|
|
|
@router.get("/alldepts", response_model=Dict)
|
|
|
def read_all_depts(db: Session = Depends(get_db), tag_id: int= Query(None, title="Tag IDs")):
|