819527061@qq.com
2024-11-18 34aedd9998b5572488e49db884b2f7966d960a57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
export default {
    setResName:(state,payload)=>{
      //state对象就对应了state.js中的对象
      //payload载荷 对应的 传递的 json对象参数{name:xx,age:12}
      state.resName = payload.resName
    },
    SET_ROLES:(state,payload) =>{
    state.roles = payload;
    },
    SET_ROLELISt:(state,payload)=>{
        console.log('触发')
        //处理左侧菜单栏逻辑
            // type 2 : all admin
            // type 0 :  泊车 id:2
            // type 1 :  执法 id:3
            // state.roles  // 用户权限字段
            // state.resultAsyncRoutes // 用户权限路由
            switch (state.roles) {
                case 0:
                    state.resultAsyncRoutes = state.items2.filter((item)=>item.id == 2);
                    localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
                    console.log(state.resultAsyncRoutes,state.roles,'0泊车')
                  break;
                case 1:
                    state.resultAsyncRoutes =state.items.filter((item)=>item.id == 3);
                    localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
                  console.log(state.resultAsyncRoutes,state.roles,'1执法')
                  break;
                case 2:
                    state.resultAsyncRoutes = state.items;
                    localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
                      console.log(state.resultAsyncRoutes,state.roles,' 全部')//  不用修改
                  break;
                case 3:
                    state.resultAsyncRoutes = state.items3.filter((item)=>item.id == 2);
                    localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
                    console.log(state.resultAsyncRoutes,state.roles,'3APP端')
                  break;
 
                default:
                  break;
            }
 
    },
    CLEAR_ROLELIST:(state,payload)=>{
        state.resultAsyncRoutes =  [];
        localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
 
    }
 
  }