ソースを参照

修改门店装修重复显示的bug

lxr 5 日 前
コミット
5296e4e957

+ 1 - 1
src/assets/json/authMenuList.json

@@ -1100,7 +1100,7 @@
           "component": "/storeDecoration/decorationCompany",
           "meta": {
             "icon": "OfficeBuilding",
-            "title": "门店装修",
+            "title": "装修公司",
             "isLink": "",
             "isHide": false,
             "isFull": false,

+ 2 - 1
src/layouts/components/Menu/SubMenu.vue

@@ -1,6 +1,7 @@
 <template>
   <template v-for="subItem in menuList" :key="subItem.path">
-    <el-sub-menu v-if="subItem.children?.length" :index="subItem.path">
+    <SubMenu v-if="subItem.meta?.flattenSingleChild && subItem.children?.length === 1" :menu-list="subItem.children" />
+    <el-sub-menu v-else-if="subItem.children?.length" :index="subItem.path">
       <template #title>
         <el-icon v-if="subItem.meta.icon">
           <component :is="subItem.meta.icon" />

+ 16 - 2
src/stores/modules/auth.ts

@@ -43,7 +43,7 @@ export const useAuthStore = defineStore({
       const businessSection = Number(userInfo.businessSection || localGet("businessSection") || 0);
       const mealsFlag = Number(userInfo.mealsFlag || localGet("mealsFlag") || 0);
       const storeId = userInfo.storeId ?? localGet("createdId");
-      const storeTickets = Number(userInfo.storeTickets ?? localGet("storeTickets") ?? 0);
+      const storeTickets = Number(localGet("storeTickets") || 0);
 
       // 递归处理菜单的显示/隐藏状态
       const processMenus = (menuList: any[]) => {
@@ -116,7 +116,10 @@ export const useAuthStore = defineStore({
                 menu.meta.isHide = !storeId || businessSection !== 2;
                 break;
               case "门店装修":
-                menu.meta.isHide = !storeId;
+                // 仅父级:子项 decorationManagement 同 title,若在此处理会覆盖 storeTickets 下的 isHide
+                if (menu.name === "storeDecorationManagement") {
+                  menu.meta.isHide = !storeId;
+                }
                 break;
             }
           }
@@ -125,6 +128,7 @@ export const useAuthStore = defineStore({
           if (menu.name === "storeDecorationManagement" && menu.children?.length) {
             if (storeTickets != 0 && storeTickets != 1) {
               menu.meta.isHide = true;
+              menu.meta.flattenSingleChild = false;
             } else {
               menu.children.forEach((child: any) => {
                 if (child.name === "decorationManagement") {
@@ -133,6 +137,16 @@ export const useAuthStore = defineStore({
                   child.meta.isHide = storeTickets !== 1;
                 }
               });
+              // 仅装修公司模式:侧栏只出现一项「装修公司」,并重定向到装修公司页
+              if (storeTickets === 1) {
+                menu.meta.title = "装修公司";
+                menu.meta.flattenSingleChild = true;
+                menu.redirect = "/storeDecorationManagement/decorationCompany";
+              } else if (storeTickets === 0) {
+                menu.meta.title = "门店装修";
+                menu.meta.flattenSingleChild = false;
+                menu.redirect = "/storeDecorationManagement/decorationManagement";
+              }
             }
           }
 

+ 2 - 0
src/typings/global.d.ts

@@ -17,6 +17,8 @@ declare namespace Menu {
     isFull: boolean;
     isAffix: boolean;
     isKeepAlive: boolean;
+    /** 仅一个可见子菜单时不在侧栏渲染父级分组,直接展示子项 */
+    flattenSingleChild?: boolean;
   }
 }