Przeglądaj źródła

fix: 手工发放员工范围受制度适用范围限制 & status过滤修正

alphah 1 tydzień temu
rodzic
commit
00c3dd041b

BIN
frontend/dist.zip


+ 39 - 2
frontend/src/views/module_payment/quota/components/IssueBatchForm.vue

@@ -146,6 +146,7 @@ import { reactive, ref, onMounted } from "vue";
 import { ElMessage } from "element-plus";
 import type { IssueTargetInfo } from "@/api/module_payment/quota";
 import EmployeeAPI from "@/api/module_payment/employee";
+import InstitutionAPI from "@/api/module_payment/institution";
 import { useEnterpriseStore } from "@/store/modules/enterprise.store";
 
 const OWNER_TYPE_LABEL: Record<string, string> = {
@@ -206,10 +207,46 @@ async function loadEmployees() {
       eid = store.getCurrentEnterprise?.enterprise_id;
     }
     if (!eid) return;
+
+    const institutionId = props.institutionId || formData.institution_id;
+
+    // 1. 获取制度适用范围
+    let scopeType = "all";
+    let scopeEmployeeIds: string[] = [];
+
+    if (institutionId) {
+      try {
+        const instRes = await InstitutionAPI.detailInstitution(institutionId, eid);
+        scopeType = instRes?.data?.data?.applicable_scope || "all";
+
+        if (scopeType === "employee") {
+          const scopeRes = await InstitutionAPI.listScope(institutionId, {
+            enterprise_id: eid, page_size: 500,
+          });
+          const scopeList = scopeRes?.data?.data?.scope_info_list || [];
+          scopeEmployeeIds = scopeList.flatMap((s: any) => s.owner_id_list || []);
+        }
+      } catch {
+        // 获取适用范围失败时回退为不限制
+      }
+    }
+
+    // 2. 加载员工列表
     const res = await EmployeeAPI.listEmployee({ enterprise_id: eid, page_no: 1, page_size: 500 });
-    // 仅展示已签约的员工
     const allItems = res?.data?.data?.items || [];
-    employeeList.value = allItems.filter((emp: any) => emp.status === "ACTIVATED");
+
+    // 3. 过滤:状态 + 适用范围
+    let filtered = allItems.filter((emp: any) => emp.status === "EMPLOYEE_ACTIVATED");
+
+    if (scopeType === "employee" && scopeEmployeeIds.length > 0) {
+      const scopeIdSet = new Set(scopeEmployeeIds);
+      filtered = filtered.filter((emp: any) => scopeIdSet.has(emp.employee_id));
+    } else if (scopeType === "none") {
+      filtered = [];
+    }
+    // scopeType === "all" → 不额外过滤
+
+    employeeList.value = filtered;
   } catch (e) {
     console.error("加载员工列表失败", e);
   }