瀏覽代碼

登录需要权限

seimin 2 年之前
父節點
當前提交
4574f5ccf0
共有 1 個文件被更改,包括 29 次插入6 次删除
  1. 29 6
      src/views/Login.vue

+ 29 - 6
src/views/Login.vue

@@ -61,7 +61,7 @@ export default {
61 61
               "login_requester",
62 62
               JSON.stringify(res.data.user.requester)
63 63
             );
64
-            that.getConfig();
64
+            that.getConfig(res.data.user.user,res.data.user.requester);
65 65
           }
66 66
         }
67 67
       });
@@ -94,7 +94,7 @@ export default {
94 94
                 "login_requester",
95 95
                 JSON.stringify(res.data.user.requester)
96 96
               );
97
-              that.getConfig();
97
+              that.getConfig(res.data.user.user,res.data.user.requester);
98 98
             }
99 99
           } else if (res.data.state == 501) {
100 100
             that
@@ -137,13 +137,13 @@ export default {
137 137
               "login_requester",
138 138
               JSON.stringify(res.data.data.requester)
139 139
             );
140
-            that.getConfig();
140
+            that.getConfig(res.data.data.user,res.data.data.requester);
141 141
           }
142 142
         });
143 143
     },
144 144
     // 获取版本配置(报修主题:报修人/报修科室)
145 145
     // 获取配置
146
-    getConfig() {
146
+    getConfig(user,requester) {
147 147
       this.$http
148 148
         .post("service/sysinfo/data/fetchDataList/systemConfiguration", {
149 149
           idx: 0,
@@ -185,9 +185,32 @@ export default {
185 185
                 break;
186 186
             }
187 187
           });
188
-          this.$router.push({ path: "/main" });
188
+          this.roleHandler(user,requester);
189 189
         });
190 190
     },
191
+    // 判断角色
192
+    roleHandler(user,requester){
193
+      let userRoles = user.role.map(v=>({id:v.id,rolecode:v.rolecode}));
194
+      if(userRoles.length){
195
+        // this.isService = userRoles.some(v=>(v.rolecode === 'call center' || v.rolecode === 'call center admin'))
196
+        this.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'))
197
+      }else{
198
+        // this.isService = false;
199
+        this.isUser = false;
200
+      }
201
+      // this.isReq = requester ? true : false;
202
+      if(this.isUser){
203
+        this.$router.push({ path: "/main" });
204
+      }else{
205
+        this.$createDialog({
206
+          type: "alert",
207
+          title: "提示",
208
+          content: "没有权限,无法进入!",
209
+          icon: "cubeic-wrong",
210
+          color: "red"
211
+        }).show();
212
+      }
213
+    },
191 214
     // 获取报修人登录方式
192 215
     getLoginType() {
193 216
       this.$http.post("service/wechat/getLoginType", {}).then(result => {
@@ -231,7 +254,7 @@ export default {
231 254
             "login_requester",
232 255
             JSON.stringify(res.data.data.requester)
233 256
           );
234
-          this.getConfig();
257
+          this.getConfig(res.data.data.user,res.data.data.requester);
235 258
         } else {
236 259
           that
237 260
             .$createDialog({