Browse Source

登录菜单bug修改1862

zhouna 6 years ago
parent
commit
341feb970d

+ 4 - 4
src/components/admin/Console.vue

@@ -1,7 +1,7 @@
 <template>
     <div>
         <crumbs title="控制台"></crumbs>
-        <div class="console" v-if="hasConcole">
+        <div class="console">
             <h2>平台数据</h2>
             <el-row :gutter="20">
                 <el-col :span="6">
@@ -36,7 +36,7 @@
 
   export default {
     name: 'admin-console',
-    props:['hasConcole'],
+   /* props:['hasConcole'],*/
     data: function () {
       return {
         orderCount: '...',
@@ -45,10 +45,10 @@
     },
     beforeRouteEnter(to,form,next){
       next(vm=>{
-        if(!vm.hasConcole){
+        /*if(!vm.hasConcole){
           vm.$emit('redirect-page');
           return;
-        }
+        }*/
         //获取控制台默认显示数字
         api.getOrderNum().then((res) => {
           const result = res.data;

+ 35 - 19
src/components/common/HomePage.vue

@@ -23,7 +23,7 @@
                 </div>
             </el-header>
             <el-main>
-              <router-view v-if="ok" v-on:status-change="changeStatus" v-on:redirect-page="redirectPage" :hasConcole="hasConcole"></router-view>
+              <router-view v-if="ok" v-on:status-change="changeStatus"></router-view>
             </el-main>
         </el-container>
     </el-container>
@@ -51,7 +51,6 @@
         authStatus: null,
         authStatusName:'',
         ok:false,           //是否已获取到菜单
-        hasConcole:true         //是否有控制台权限,登录后跳转用
       }
     },
     computed: {
@@ -61,28 +60,45 @@
     },
     created () {
       //获取菜单
-      api.getAccessdMenu().then((res) => {
-        if (res.data.code == '0') {
-          const data = res.data.data;
-            this.ok = true;
-            const hasConcole=data.menuWrappers.findIndex((it)=>{
-              return it.code == 'LT-KZT'
-            });
-          this.hasConcole = hasConcole!=-1;
-          this.menuWrappers = data.menuWrappers;
-          this.organization = data.organization;
-          this.userLoginDTO = data.userLoginDTO;
-          data.userLoginDTO && data.userLoginDTO.type == '0' && this.getAuthStatus();
+      this.getMenuList();
+    },
+    watch:{
+      '$route': function(to,from){
+            if(from.name=='login'){
+              this.getMenuList();
+            }
+            if(to.path=='/'){       // 退出时清空菜单
+              this.menuWrappers=[];
+            }
         }
-      }).catch((error) => {
-        console.log(error);
-      });
     },
     methods: {
-      redirectPage(){
+      getMenuList(){
+        api.getAccessdMenu().then((res) => {
+          if (res.data.code == '0') {
+            const data = res.data.data;
+            this.ok = true;
+            const hasConcole=data.menuWrappers.find((it)=>{
+              return it.code.indexOf('-KZT')>-1;
+            });
+            //this.hasConcole = hasConcole!=-1;
+            this.menuWrappers = data.menuWrappers;
+            this.organization = data.organization;
+            this.userLoginDTO = data.userLoginDTO;
+            this.getRole=='user' && this.getAuthStatus();
+            if(hasConcole){
+              const url = this.getRole=='user'?'/user/YH-KZT':'/admin/LT-KZT';
+              this.$router.push({path:url});
+            }
+          }
+        }).catch((error) => {
+          console.log(error);
+        });
+      },
+      /*redirectPage(){
         const url = this.getRole=='user'?'/user':'/admin';
         this.$router.push({path:url});
-      },
+      },*/
       changeStatus(text){       //账号信息中提交认证后修改状态
         this.authStatus = 2;
         this.authStatusName = text;

+ 2 - 2
src/components/login/Login.vue

@@ -175,11 +175,11 @@
                       const type = res.data.data.type;
                       if (type == 0) {
                         this.$router.push({
-                          path: '/user/YH-KZT'
+                          path: '/user'
                         });
                       } else if (type == 1) {
                         this.$router.push({
-                          path: '/admin/LT-KZT'
+                          path: '/admin'
                         });
                       }
                     }.bind(this)