Przeglądaj źródła

fix: 修改考核管理处人员的转换函数

username 3 miesięcy temu
rodzic
commit
b15aaa6629

+ 15 - 7
src/views/evaluate/children/change/components/settingIndexDrawer.vue

@@ -835,16 +835,24 @@ const countNoConditionFormulaInnerScore = (item, index, indexList) => {
 // 转换函数 --- 人员
 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
     };
   });
 };