Jelajahi Sumber

fix: 首页菜单

zh 2 tahun lalu
induk
melakukan
652ef7ff28
2 mengubah file dengan 64 tambahan dan 25 penghapusan
  1. 52 0
      src/components/MenuRouter/index.vue
  2. 12 25
      src/views/dashboard.vue

+ 52 - 0
src/components/MenuRouter/index.vue

@@ -0,0 +1,52 @@
+<template>
+  <div>
+    <div v-for="item in list" :key="item.path">
+      <template v-if="!item.hidden">
+        <template v-if="!item.children || !item.children.length" style="display: block">
+          <el-link class="title" :underline="false" @click="clickMenu(item.path)">{{ item.meta.title }}</el-link>
+        </template>
+        <template v-else>
+          <h5 class="title">{{ item.meta.title }}</h5>
+          <MenuRouter :list="item.children" class="menu"/>
+        </template>
+      </template>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'MenuRouter',
+  props: {
+    list: {
+      type: Array,
+      default: () => []
+    }
+  },
+  methods: {
+    // 点击菜单
+    clickMenu(path) {
+      const curlArr = ['/notice', '/issue']
+      // if (curlArr.includes(path)) {
+      //   path += '/index'
+      // }
+      this.$router.push({
+        path
+      })
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.menu {
+  display: flex;
+    flex-direction: row;
+    flex-wrap: wrap;
+}
+
+.title {
+  padding: 3px 10px;
+  margin-top: 16px;
+}
+</style>

+ 12 - 25
src/views/dashboard.vue

@@ -16,31 +16,13 @@
                 :span="4"
                 style="margin-top: 16px; padding: 3px 20px"
               >
-                <el-link class="link" :underline="false" @click="clickMenu(it.fullUrl)">{{ it.moduleName }}</el-link>
+                <el-link class="link" :underline="false" @click="clickMenu(it.path)">{{ it.moduleName }}</el-link>
               </el-col>
             </el-row>
           </div>
         </div>
-        <div v-for="(item, index) in menuList" :key="index" class="group">
-          <div v-if="item.moduleName != '首页'">
-            <div class="main-title">
-              <div class="title">{{ item.moduleName }}</div>
-            </div>
-            <div v-if="item.children && item.children.length" class="child">
-              <el-row :gutter="20">
-                <el-col v-for="(it, idx) in item.children" :key="idx" class="item" :span="4">
-                  <el-link class="link" :underline="false" @click="clickMenu(it.fullUrl)">{{ it.moduleName }}</el-link>
-                </el-col>
-              </el-row>
-            </div>
-            <div v-else class="child">
-              <div class="item">
-                <el-link class="link" :underline="false" @click="clickMenu(item.fullUrl)">{{
-                  item.moduleName
-                }}</el-link>
-              </div>
-            </div>
-          </div>
+        <div class="group">
+          <MenuRouter v-if="routes && routes.length" :list="routes" :flag="true" />
         </div>
       </div>
       <!-- 弹窗 -->
@@ -89,7 +71,7 @@ import {
   getListInvoiceOrder
 } from '@/api/dashboard'
 import { getArrivalNotice } from '@/api/stock'
-
+import MenuRouter from '@/components/MenuRouter'
 import { getListOrderTrack } from '@/api/supply/pickup'
 import { getFileUrl } from '@/api/common'
 import { mapGetters } from 'vuex'
@@ -97,7 +79,8 @@ import popu from '@/components/template/popu.vue'
 export default {
   name: 'Dashboard',
   components: {
-    popu
+    popu,
+    MenuRouter
   },
   created() {
     getRouter({
@@ -105,12 +88,16 @@ export default {
       adminUserId: this.userid
     }).then(res => {
       this.menuList = res.data
-      console.log(res.data)
     })
     this.getMenuList()
   },
   computed: {
-    ...mapGetters(['showMessages', 'userid', 'isCustomer'])
+    ...mapGetters(['showMessages', 'userid', 'isCustomer']),
+    routes() {
+      // return this.$router.options.routes
+      // this.$router.options.routes.concat(global.antRouter)
+      return global.antRouter // 把路由concat进去
+    }
   },
   data() {
     return {