Explorar el Código

fix:举一反三责任部门只能选择一级部门

sunqijun hace 1 mes
padre
commit
28d5b8c427

+ 9 - 16
src/views/production-safety/hiddenTroubleInvestigationAndGovernance/oneByOneManagement/components/oneByOneManagementDetail.vue

@@ -206,28 +206,21 @@
     }
   }
 
-  /** 责任部门:与新增隐患台账的举一反三责任部门同源(getAllDepartments 扁平化) */
+  /** 责任部门:仅取 deptTree.value[0].children,不递归 */
   const deptTree = ref<DeptTree[]>([]);
-  function flattenDeptTree(nodes: DeptTree[] | undefined): Array<{ id: number; deptName: string }> {
-    if (!nodes?.length) return [];
-    const list: Array<{ id: number; deptName: string }> = [];
-    const walk = (items: DeptTree[]) => {
-      items.forEach((n) => {
-        if (n.id != null) list.push({ id: n.id, deptName: n.deptName });
-        if (n.children?.length) walk(n.children);
-      });
-    };
-    walk(nodes);
-    return list;
-  }
-  const deptOptions = computed(() => flattenDeptTree(deptTree.value));
+  const deptOptions = computed(() => {
+    const firstChildren = deptTree.value?.[0]?.children ?? [];
+    return firstChildren
+      .filter((n) => n.id != null)
+      .map((n) => ({ id: Number(n.id), deptName: n.deptName }));
+  });
+  
   const associationOtObligationDeptIdsArray = ref<number[]>([]);
 
   const loadDeptOptions = async () => {
     try {
       const deptRes = await getAllDepartments();
-      const fullTree = (deptRes as DeptTree[]) ?? [];
-      deptTree.value = Array.isArray(fullTree) && fullTree[0]?.children ? fullTree[0].children : [];
+      deptTree.value = (deptRes as DeptTree[]) ?? [];
     } catch (e) {
       console.error('获取部门列表失败:', e);
       deptTree.value = [];

+ 2 - 12
src/views/production-safety/risk-identification-and-control/labor-products-purchase-apply-manage-admin/components/detail.vue

@@ -746,17 +746,7 @@
 
   /** 底部主按钮:新增时弹出选择审核人,编辑时直接保存 */
   async function onPrimaryClick() {
-    if (isCreateMode.value) {
-      await openApproverDialog();
-    } else {
-      const valid = await formRef.value?.validate().catch(() => false);
-      if (!valid) return;
-      if (!form.itemList.length || form.itemList.every((it) => !it.ppeName && !it.equipmentName)) {
-        ElMessage.warning('请至少填写一条劳防用品明细');
-        return;
-      }
-      await doSubmit(buildSubmitPayload());
-    }
+    await openApproverDialog();
   }
 
   async function handleAuditPass() {
@@ -812,7 +802,7 @@
   const handleSubmitApproval = () => {
     approvalFormRef.value.validate(async (valid: boolean) => {
       if (valid) {
-        const approvalInfoList: ApprovalInfoItem[] = approvalNodeList.value.map((node) => {
+          const approvalInfoList: ApprovalInfoItem[] = approvalNodeList.value.map((node) => {
           let approverIds: number[] = [];
           if (node.approverType === APPROVER_TYPE.FIX) {
             approverIds = node.approverInfoList.map((info) => info.approverId);

+ 1 - 1
src/views/production-safety/risk-identification-and-control/labor-products-purchase-apply-manage-admin/configs/tablesTow.ts

@@ -41,7 +41,7 @@ const PURCHASE_APPLY_TABLE_COLUMNS: TableColumnProps[] = [
   },
   {
     label: '当前流程节点',
-    prop: 'nodeDescription',
+    prop: 'ppeDescription',
     align: 'left',
     minWidth: '140px',
   },