Procházet zdrojové kódy

[Fix 0000] 修复了部门下单矿井、单单位等情况下菜单结构不正确的问题

houzekong před 3 měsíci
rodič
revize
5f53397ece

+ 3 - 2
public/js/global.js

@@ -145,7 +145,7 @@ const __STATIC_ROUTES__ = [
   {
   {
     redirect: undefined,
     redirect: undefined,
     path: '/sealed',
     path: '/sealed',
-    component: 'LAYOUT',
+    component: '/monitor/sealedMonitor/index',
     children: [
     children: [
       {
       {
         path: '/sealed/${rawid}',
         path: '/sealed/${rawid}',
@@ -156,7 +156,8 @@ const __STATIC_ROUTES__ = [
           icon: '',
           icon: '',
           componentName: 'index',
           componentName: 'index',
           title: '${departName}',
           title: '${departName}',
-          hideMenu: true
+          hideMenu: true,
+          generation: false,
           // orderNo: '${departOrder}',
           // orderNo: '${departOrder}',
         },
         },
         name: 'sealed-${rawid}',
         name: 'sealed-${rawid}',

+ 9 - 6
src/api/sys/menu.ts

@@ -20,7 +20,11 @@ enum Api {
 }
 }
 
 
 const generateStaticSealedMonitorRoute = (route: AppRouteRecordRaw, items: MineDepartment[]) => {
 const generateStaticSealedMonitorRoute = (route: AppRouteRecordRaw, items: MineDepartment[]) => {
-  return items.map((item) => {
+  return items.reduce((arr: AppRouteRecordRaw[], item) => {
+    const [__, ___, LEAF_LEVEL_ORG] = item.memoDesc;
+
+    if (item.orgType === LEAF_LEVEL_ORG) return arr;
+
     const res: AppRouteRecordRaw = {
     const res: AppRouteRecordRaw = {
       component: route.component,
       component: route.component,
       path: getFormattedText(item, route.path),
       path: getFormattedText(item, route.path),
@@ -31,14 +35,14 @@ const generateStaticSealedMonitorRoute = (route: AppRouteRecordRaw, items: MineD
         hideMenu: false,
         hideMenu: false,
       },
       },
     };
     };
-    const [__, LEAF_LEVEL_ORG, ___] = item.memoDesc;
 
 
-    if (item.orgType !== LEAF_LEVEL_ORG && item.childDepart.length) {
+    if (item.childDepart.length) {
       res.children = generateStaticSealedMonitorRoute(route, item.childDepart);
       res.children = generateStaticSealedMonitorRoute(route, item.childDepart);
     }
     }
 
 
-    return res;
-  });
+    arr.push(res);
+    return arr;
+  }, []);
 };
 };
 
 
 /**
 /**
@@ -60,7 +64,6 @@ export const getMenuList: () => Promise<getMenuListResultModel> = () => {
 
 
           ele.children = routes;
           ele.children = routes;
         }
         }
-
         return ele;
         return ele;
       }),
       }),
     };
     };

+ 2 - 1
src/store/modules/mine.ts

@@ -106,7 +106,8 @@ export const useMineDepartmentStore = defineStore('mine-department-store', () =>
 
 
       const r1 = r2.reduce((arr: MineDepartment[], node) => {
       const r1 = r2.reduce((arr: MineDepartment[], node) => {
         const isRoot = node.orgType === TOP_LEVEL_ORG;
         const isRoot = node.orgType === TOP_LEVEL_ORG;
-        if (isRoot) return arr; // 根节点不处理
+        // 根节点不处理,放在这里return是因为有时请求返回的是单矿,也需要走上面的数据处理流程
+        if (isRoot && node.orgType !== LEAF_LEVEL_ORG) return arr;
 
 
         const ele: MineDepartment = {
         const ele: MineDepartment = {
           ...node,
           ...node,

+ 1 - 1
src/views/monitor/sealedMonitor/hooks/form.ts

@@ -7,7 +7,7 @@ import { useMineDepartmentStore } from '/@/store/modules/mine';
 export function useInitForm() {
 export function useInitForm() {
   const mineStore = useMineDepartmentStore();
   const mineStore = useMineDepartmentStore();
   const route = useRoute();
   const route = useRoute();
-  const departId = last(route.path.split('/')) as string;
+  const departId = route.meta.generation ? undefined : (last(route.path.split('/')) as string);
   const dep = mineStore.findDepartById(departId, mineStore.departTree);
   const dep = mineStore.findDepartById(departId, mineStore.departTree);
   const rawcode = route.query.mineCode as string;
   const rawcode = route.query.mineCode as string;
   // 给历史数据默认填充的矿码
   // 给历史数据默认填充的矿码