|
@@ -322,16 +322,24 @@ const convertDepartmentDataRecursive = data => {
|
|
|
// 转换函数 --- 人员
|
|
|
const convertDepartmentDataRecursive_Person = data => {
|
|
|
return data.map(department => {
|
|
|
- const { userNameNew, userCodeNew, children } = department;
|
|
|
+ const { userNameNew, userCodeNew, children, type } = department;
|
|
|
+ // 递归处理子节点
|
|
|
+ const processedChildren =
|
|
|
+ children.length > 0
|
|
|
+ ? convertDepartmentDataRecursive_Person(children)
|
|
|
+ : [];
|
|
|
+ // 检查子节点是否有 type 为 "user" 的节点
|
|
|
+ const hasUserInChildren = processedChildren.some(child => !child.disabled);
|
|
|
+ // 当前节点是否为 user 类型
|
|
|
+ const isUser = type === "user";
|
|
|
+ // 判断当前节点是否需要禁用
|
|
|
+ const shouldDisable = !isUser && !hasUserInChildren;
|
|
|
+
|
|
|
return {
|
|
|
value: userCodeNew,
|
|
|
label: userNameNew,
|
|
|
- children:
|
|
|
- children.length > 0
|
|
|
- ? children.map(
|
|
|
- child => convertDepartmentDataRecursive_Person([child])[0]
|
|
|
- )
|
|
|
- : []
|
|
|
+ children: processedChildren,
|
|
|
+ disabled: shouldDisable
|
|
|
};
|
|
|
});
|
|
|
};
|