Browse Source

fix: scope.modify 补 enterprise_id + 过滤空 owner_id

alphah 2 weeks ago
parent
commit
a0493fddda

+ 7 - 2
backend/app/plugin/module_payment/expense/institution/controller.py

@@ -281,13 +281,18 @@ async def modify_institution_controller(
     applicable_scope = data.get("applicable_scope", "")
     applicable_scope = data.get("applicable_scope", "")
     scope_info = None
     scope_info = None
     if applicable_scope and applicable_scope not in ("NONE", "none"):
     if applicable_scope and applicable_scope not in ("NONE", "none"):
+        enterprise_id = data.get("enterprise_id", "")
         ADAPTER_MAP = {"all": "EMPLOYEE_ALL", "employee": "EMPLOYEE_SELECT", "department": "DEPARTMENT_SELECT"}
         ADAPTER_MAP = {"all": "EMPLOYEE_ALL", "employee": "EMPLOYEE_SELECT", "department": "DEPARTMENT_SELECT"}
         scope_info = {
         scope_info = {
+            "enterprise_id": enterprise_id,
             "adapter_type": ADAPTER_MAP.get(applicable_scope, applicable_scope),
             "adapter_type": ADAPTER_MAP.get(applicable_scope, applicable_scope),
             "owner_type": "ENTERPRISE_PAY_UID",
             "owner_type": "ENTERPRISE_PAY_UID",
         }
         }
-        if applicable_scope in ("employee", "department") and data.get("scope_owner_id_list"):
-            scope_info["add_owner_id_list"] = data["scope_owner_id_list"]
+        if applicable_scope in ("employee", "department"):
+            owner_ids = data.get("scope_owner_id_list") or []
+            valid_ids = [str(i) for i in owner_ids if i is not None and str(i).strip()]
+            if valid_ids:
+                scope_info["add_owner_id_list"] = valid_ids
         # 从请求中移除 scope 数据,避免与基础修改冲突
         # 从请求中移除 scope 数据,避免与基础修改冲突
         data.pop("modify_scope_info", None)
         data.pop("modify_scope_info", None)