Browse Source

登录权限

seimin 2 years ago
parent
commit
cf71fd0a5b
1 changed files with 29 additions and 5 deletions
  1. 29 5
      src/views/Login.vue

+ 29 - 5
src/views/Login.vue

@@ -44,8 +44,32 @@ export default {
44 44
     LoadIng
45 45
   },
46 46
   methods: {
47
+    // 判断角色
48
+    roleHandler(user,requester){
49
+      let userRoles = user.role.map(v=>({id:v.id,rolecode:v.rolecode}));
50
+      let isService = false;
51
+      if(userRoles.length){
52
+        isService = userRoles.some(v=>(v.rolecode === 'call center' || v.rolecode === 'call center admin'))
53
+        // isUser = userRoles.some(v=>(v.rolecode === 'first-line support' || v.rolecode === 'second-line support' || v.rolecode === 'incident manager' || v.rolecode === 'inspectman' || v.rolecode === 'incident-category-manager'))
54
+      }else{
55
+        isService = false;
56
+        // isUser = false;
57
+      }
58
+      // this.isReq = requester ? true : false;
59
+      if(isService){
60
+        this.$router.push({ path: "/main" });
61
+      }else{
62
+        this.$createDialog({
63
+          type: "alert",
64
+          title: "提示",
65
+          content: "没有权限,无法进入!",
66
+          icon: "cubeic-wrong",
67
+          color: "red"
68
+        }).show();
69
+      }
70
+    },
47 71
     // 获取版本配置(报修主题:报修人/报修科室)
48
-    getConfig() {
72
+    getConfig(user,requester) {
49 73
       this.$http
50 74
         .post("/service/sysinfo/data/fetchDataList/systemConfiguration", {
51 75
           idx: 0,
@@ -75,7 +99,7 @@ export default {
75 99
                 break;
76 100
             }
77 101
           });
78
-          this.$router.push({ path: "/main" });
102
+          this.roleHandler(user,requester);
79 103
         });
80 104
     },
81 105
     // 获取报修人登录方式
@@ -120,7 +144,7 @@ export default {
120 144
             "login_requester",
121 145
             JSON.stringify(res.data.data.requester)
122 146
           );
123
-          this.getConfig();
147
+          this.getConfig(res.data.data.user,res.data.data.requester);
124 148
         } else {
125 149
           that
126 150
             .$createDialog({
@@ -150,7 +174,7 @@ export default {
150 174
               "login_requester",
151 175
               JSON.stringify(res.data.user.requester)
152 176
             );
153
-            that.getConfig();
177
+            that.getConfig(res.data.user.user,res.data.user.requester);
154 178
           }
155 179
         }
156 180
       });
@@ -176,7 +200,7 @@ export default {
176 200
                 "login_requester",
177 201
                 JSON.stringify(res.data.user.requester)
178 202
               );
179
-              that.getConfig();
203
+              that.getConfig(res.data.user.user,res.data.user.requester);
180 204
             }
181 205
           } else if (res.data.state == 501) {
182 206
             that