Parcourir la source

fix: 新增安全文化活动责任人筛选

xiaweibo il y a 1 mois
Parent
commit
1da62b7c46

+ 27 - 1
src/views/production-safety/safety-culture/safetyCultureActivityManagement/components/safetyCultureActivityManagementDetail.vue

@@ -21,6 +21,7 @@
           placeholder="请选择责任部门"
           style="width: 100%"
           :disabled="isViewMode"
+          @change="handleResponsibleDeptChange"
         />
       </template>
       <template #cooperateDeptIds>
@@ -143,6 +144,8 @@
     ACADEMY_FILE_FORM_RULES,
   );
 
+  const responsibleDeptName = ref('');
+
   const viewFormConfig = ref([
     // 原有的表单配置
     ...ACADEMY_FILE_FORM_CONFIG.map((item) => ({
@@ -218,7 +221,9 @@
     const result = await queryAvailableUserList({
       pageNumber: 1,
       pageSize: 1000,
-      queryParam: {},
+      queryParam: {
+        deptName: responsibleDeptName.value || '',
+      },
     });
     responsiblePersonOptions.value = (result.records || []).map((item) => ({
       label: item.realname || item.staffNo,
@@ -328,6 +333,27 @@
     }
   };
 
+  const handleResponsibleDeptChange = (val: number | undefined) => {
+    if (val) {
+      ruleFormData.responsiblePersonId = 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(deptTree.value, val);
+      responsibleDeptName.value = deptName;
+      loadResponsiblePersonOptions();
+    }
+  };
+
   onMounted(() => {
     cloneRuleFormData();
     loadDeptTreeData();