guhongwei 4 年之前
父節點
當前提交
0f89a80e2d
共有 2 個文件被更改,包括 22 次插入10 次删除
  1. 2 1
      src/views/superAdminCenter/index.vue
  2. 20 9
      src/views/superAdminCenter/menuInfo.vue

+ 2 - 1
src/views/superAdminCenter/index.vue

@@ -11,7 +11,7 @@
               <menus @setRight="setRight"></menus>
             </el-col>
             <el-col :span="19" class="mainMess">
-              <top :title="topTitle"></top>
+              <top :title="topTitle" v-if="cpt && cpt != ''"></top>
               <div style="padding:10px">
                 <component :is="cpt"></component>
               </div>
@@ -76,6 +76,7 @@ export default {
   methods: {
     setRight(menu) {
       let { name, cpt } = menu;
+      console.log(menu);
       this.$set(this, `topTitle`, name);
       this.$set(this, `cpt`, cpt);
     },

+ 20 - 9
src/views/superAdminCenter/menuInfo.vue

@@ -24,6 +24,7 @@
 </template>
 
 <script>
+import _ from 'lodash';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('role');
 export default {
@@ -45,16 +46,26 @@ export default {
   methods: {
     ...mapActions(['query', 'create', 'update', 'delete']),
     async search() {
-      const res = await this.query();
-      if (this.$checkRes(res)) {
-        let data = res.data.reverse();
-        data = data.map(i => {
-          let { role_name: name, url: cpt } = i;
-          return { name, cpt };
-        });
-        this.$set(this, `menuList`, data);
-        this.setRight(this.active);
+      let data;
+      if (this.user.role == '0' && !_.get(this.user, 'pid')) {
+        const res = await this.query();
+        if (this.$checkRes(res)) {
+          data = res.data.reverse();
+          data = this.dataChange(data);
+        }
+      } else {
+        let menus = _.get(this.user, 'menus');
+        data = this.dataChange(JSON.parse(menus));
       }
+      this.$set(this, `menuList`, data);
+      this.setRight(this.active);
+    },
+    dataChange(data) {
+      data = data.map(i => {
+        let { role_name: name, url: cpt } = i;
+        return { name, cpt };
+      });
+      return data;
     },
     // 菜单跳转
     setRight(index) {