Browse Source

菜单选中状态,刷新时也保持选中状态

mork 2 weeks ago
parent
commit
2d3a2e7539

+ 14 - 4
public/static/config/config.js

@@ -6,11 +6,21 @@ let systemConfig = {
     touristUserId: "191",//默认游客用户(user002)id,Oauth中配置
     adminRoleId: "1",//默认管理员角色id,Oauth中配置“系统管理员”角色
     /*
-     * 模型id:1667(应用中心模型id)、1690(用户登录模型id)
-     * 栏目id:1657(应用中心栏目id(示范应用))、1659(应用中心栏目id)、1666(门户都示范栏目id)、1676(用户登录栏目id)
+     * 模型id如下
+        1667(应用中心模型id)
+        1690(用户登录模型id)
+        1677(微功能服务模型id)
+     * 栏目id如下
+        1657(应用中心栏目id(示范应用))
+        1659(应用中心栏目id)
+        1666(门户都示范栏目id)
+        1676(用户登录栏目id)
+        1665(微功能服务栏目id)
+        1651(微功能搜索服务栏目id)
+     * 
     */
-    modelIds: [1667,1690],
-    columnIds: [1657,1659,1666,1676],
+    modelIds: [1667,1690,1677],
+    columnIds: [1657,1659,1666,1676,1665,1651],
 
     baseServicerPath: "/oneMap",
     // oauth和DMS环境

+ 9 - 3
src/components/AppVue/Header.vue

@@ -9,8 +9,8 @@
         <template v-for="item in $store.state.menuList" :key="item.path">
           <li
             v-if="item.path != '/taskManger' || $getUserType() != 1"
-            :class="{ active: $route.path == item.path }"
-            @click="$router.push(item.path)"
+            :class="{ active: $store.state.activeMenu == item.id }"
+            @click="handleClick(item)"
           >
             <!-- 任务管理仅对非游客可见 -->
             {{ item.label }}
@@ -31,7 +31,13 @@ export default {
     return {};
   },
   mounted() {},
-  methods: {},
+  methods: {
+    handleClick(item) {
+      this.$store.commit('setActiveMenu', item.id);
+      sessionStorage.setItem('activeMenu', item.id);
+      this.$router.push(item.path);
+    }
+  },
 };
 </script>
 

+ 10 - 1
src/router/index.js

@@ -61,7 +61,16 @@ const routes = [
         path: 'yygl',
         component: function () {
           return import('../views/yygl/index.vue')
-        }
+        },
+        children: [ // 子路由配置开始
+          {
+            path: 'appCenter',
+            component: function () {
+              return import('../views/yygl/appCenter.vue')
+            }
+          }
+        ]
+
       },
       //应用中心
       {

+ 15 - 8
src/store/index.js

@@ -11,15 +11,16 @@ export default createStore({
     DMSTypes: ["appstatus","applevel"],
     // appstatus: 应用状态
     DmsTypesMap: localStorage.getItem("DmsTypesMap") ? JSON.parse(localStorage.getItem("DmsTypesMap")) : {},
+    activeMenu: sessionStorage.getItem('activeMenu') ? parseInt(sessionStorage.getItem('activeMenu')) : 1, // 初始化为1或具体的菜单项ID
     menuList: [
-      { path: "/", label: "首页" },
-      { path: "/sksjgl", label: "时空数据管理" },
-      // { path: "/skmh/scene", label: "二维GIS引擎"},
-      { path: "/skmh", label: "时空门户" },
-      { path: "/wgn", label: "微功能" },
-      { path: "/yygl", label: "应用管理" },
-      { path: "/yxgl", label: "运行管理" },
-      { path: "/taskManger", label: "任务管理" }
+      { id:1,path: "/", label: "首页" },
+      { id:2,path: "/sksjgl", label: "时空数据管理" },
+      // { id:3,path: "/skmh/scene", label: "二维GIS引擎"},
+      { id:4,path: "/skmh", label: "时空门户" },
+      { id:5,path: "/wgn", label: "微功能" },
+      { id:6,path: "/yygl", label: "应用管理" },
+      { id:7,path: "/yxgl", label: "运行管理" },
+      { id:8,path: "/taskManger", label: "任务管理" }
     ],
     sksjgl: {},
     skmh: {},
@@ -37,6 +38,9 @@ export default createStore({
     getUserInfo: function (state) {
       return JSON.parse(localStorage.getItem("userInfo"))
     },
+    getActiveMenu: function (state) {
+      return state.activeMenu
+    },
   },
   mutations: {
     setDmsTypesMap(state, obj) {
@@ -55,6 +59,9 @@ export default createStore({
       state.userInfo = obj;
       localStorage.setItem("userInfo", JSON.stringify(obj))
     },
+    setActiveMenu(state, id) {
+      state.activeMenu = id;
+    },
   },
   actions: {
   },

+ 3 - 3
src/views/Wgn.vue

@@ -176,8 +176,8 @@ export default {
       },
       // 申请使用微功能服务的表单数据
       column: {
-        columnId: 1665,
-        modelId: 1677,
+        columnId: systemConfig.columnIds[4],
+        modelId: systemConfig.modelIds[2],
         from: {
           // 备注:申请使用微功能服务的详细信息,非必填
           content: "",
@@ -212,7 +212,7 @@ export default {
       }
       this.searchTimeout = setTimeout(() => {
         let requestParams = {
-          columnId: 1651,
+          columnId: systemConfig.columnIds[5],
           states: 0,
           pageSize: 999,
           page: 0,

+ 1 - 0
src/views/wgn/sksj/index.vue

@@ -448,6 +448,7 @@ export default {
 
 .container {
     width: 100%;
+    height: calc(100vh - 120px);
     padding: 0px;
     margin: 0 auto;
     overflow: hidden;