Explorar el Código

fix: 安全文化活动下发具体负责人选择联动

xiaweibo hace 1 mes
padre
commit
e9050f4f4a

+ 23 - 4
src/views/production-safety/safety-culture/safetyCultureActivityManagement/safetyCultureActivityManagement.vue

@@ -239,6 +239,7 @@
   };
   const issueDeptTree = ref<DeptTree[]>([]);
   const issueUserList = ref<Array<{ id: number; realname?: string; username?: string }>>([]);
+  const rectificationResponsibleDeptName = ref('');
 
   // 表格
   const basicTableRef = ref<InstanceType<typeof BasicTable>>();
@@ -536,7 +537,9 @@
     try {
       const [deptRes, userRes] = await Promise.all([
         getAllDepartments(),
-        queryAvailableUserList({ pageNumber: 1, pageSize: 9999, queryParam: {} }),
+        queryAvailableUserList({ pageNumber: 1, pageSize: 9999, queryParam: {
+          deptName: rectificationResponsibleDeptName.value,
+        } }),
       ]);
       const fullTree = (deptRes as DeptTree[]) ?? [];
       issueDeptTree.value = Array.isArray(fullTree) && fullTree[0]?.children ? fullTree[0].children : [];
@@ -549,9 +552,25 @@
     }
   };
 
-  const onIssueDeptChange = () => {
-    issueForm.value.rectificationResponsibleUserId = undefined;
-    issueForm.value.rectificationResponsiblePersonName = '';
+  const onIssueDeptChange = (val: number | undefined) => {
+    if (val) {
+      issueForm.value.rectificationResponsibleUserId = undefined;
+      const findDeptName = (tree: any[], id: number): string => {
+        for (const node of tree) {
+          if (node.id === id) {
+            return node.deptName || node.label || '';
+          }
+          if (node.children) {
+            const found = findDeptName(node.children, id);
+            if (found) return found;
+          }
+        }
+        return '';
+      };
+      const deptName = findDeptName(issueDeptTree.value, val);
+      rectificationResponsibleDeptName.value = deptName;
+      onIssueDialogOpen();
+    }
   };
 
   const handleDispatch = (id: number) => {