Ver Fonte

添加菜单权限控制

lm há 1 mês atrás
pai
commit
e98a30f40d
2 ficheiros alterados com 36 adições e 3 exclusões
  1. 10 1
      src/layout/index.vue
  2. 26 2
      src/store/index.ts

+ 10 - 1
src/layout/index.vue

@@ -19,13 +19,22 @@ import AppMain from './components/AppMain.vue'
 const store = useStore()
 const route = useRoute()
 
+const userInfo = computed(()=>{
+  return  JSON.parse(localStorage.getItem('userInfo') || '{}')
+})
 // 此处要根据登录用户的权限 分条件展示 不同的内容
 const menuList =  computed(()=>{
   if(route.path.startsWith('/main/myCustomerDetail') || 
       route.path.startsWith('/main/highSeasCustomerDetail') ){
     return []
   }
-  return store.state.siderNav
+  console.log('userInfo',userInfo.value)
+  // 管理员
+  if(userInfo.value?.roles?.includes('Admin')){
+    return store.state.managerSiderNav
+  }else{
+    return store.state.siderNav
+  }
 })
 
 

+ 26 - 2
src/store/index.ts

@@ -8,7 +8,8 @@ import {getFieldListExcludeAreaApi,getOpenProvinceCityListApi} from '@/api/param
 interface RootState {
   count: number,
   managerHorizontalMenuItems:any[],
-  siderNav:any[],
+  managerSiderNav:any[],  //管理员导航栏
+  siderNav:any[], // 非管理员导航栏
   positionList:any[],  //职位列表
   productList:any[],   //产品列表
   followUpStatus:any[],  //跟进状态 列表
@@ -25,7 +26,7 @@ const store = createStore<RootState>({
     count: 0,
     // 管理员 评教评学 的访问菜单
     managerHorizontalMenuItems:[],
-    siderNav:[
+    managerSiderNav:[
       {
         title: '预约待办',
         route: '/main',
@@ -57,6 +58,29 @@ const store = createStore<RootState>({
         svgIcon:undefined,
       },
     ],
+    siderNav:[
+      {
+        title: '预约待办',
+        route: '/main',
+        svgIcon:undefined,
+      },
+      {
+        title: '公海客户',
+        route: '/main/highSeasCustomer',
+        svgIcon:undefined,
+      },
+      {
+        title: '我的客户',
+        route: '/main/myCustomer',
+        svgIcon:undefined,
+      },
+      {
+        title: '客户跟进',
+        route: '/main/customerFollowUp',
+        svgIcon:undefined,
+      },
+    ],
+
     positionList:JSON.parse(sessionStorage.getItem('positionList') || '[]'),
     productList:JSON.parse(sessionStorage.getItem('productList') || '[]'),
     followUpStatus:JSON.parse(sessionStorage.getItem('followUpStatus') || '[]'),