fanghuisheng преди 3 години
родител
ревизия
55d98f6c1a
променени са 3 файла, в които са добавени 52 реда и са изтрити 40 реда
  1. 47 35
      src/layout/vab-menu/index.vue
  2. 4 4
      src/router/index.js
  3. 1 1
      src/views/monthReport/tables/deviationTable.vue

+ 47 - 35
src/layout/vab-menu/index.vue

@@ -10,51 +10,63 @@
         v-for="route in item.children"
         :key="route.path"
         :item="route"
+        :default-active="activeMenu"
       ></vab-menu>
     </template>
   </component>
 </template>
 
 <script>
-  import MenuItem from './components/MenuItem'
-  import Submenu from './components/Submenu'
-  export default {
-    name: 'VabMenu',
-    components: { MenuItem, Submenu },
-    props: {
-      item: {
-        type: Object,
-        required: true,
-      },
-    },
-    data() {
-      return {
-        routeChildren: {},
-        menuComponent: '',
+import MenuItem from './components/MenuItem'
+import Submenu from './components/Submenu'
+export default {
+  name: 'VabMenu',
+  components: { MenuItem, Submenu },
+  computed: {
+    activeMenu() {
+      const route = this.$route
+      const { meta, path } = route
+      // if set path, the sidebar will highlight the path you set
+      if (meta.activeMenu) {
+        return meta.activeMenu
       }
+      return path
     },
-    created() {
-      const showChildren = this.handleChildren(this.item.children)
-      if (showChildren.length === 0) {
-        this.menuComponent = 'MenuItem'
-        this.routeChildren = this.item
-      } else if (showChildren.length === 1 && this.item.alwaysShow !== true) {
-        this.menuComponent = 'MenuItem'
-        this.routeChildren = showChildren[0]
-      } else {
-        this.menuComponent = 'Submenu'
-      }
+  },
+  props: {
+    item: {
+      type: Object,
+      required: true,
     },
-    methods: {
-      handleChildren(children = []) {
-        if (children === null) return []
-        return children.filter((item) => item.hidden !== true)
-      },
+  },
+  data() {
+    return {
+      routeChildren: {},
+      menuComponent: '',
+    }
+  },
+  created() {
+    const showChildren = this.handleChildren(this.item.children)
+    if (showChildren.length === 0) {
+      this.menuComponent = 'MenuItem'
+      this.routeChildren = this.item
+    } else if (showChildren.length === 1 && this.item.alwaysShow !== true) {
+      this.menuComponent = 'MenuItem'
+      this.routeChildren = showChildren[0]
+    } else {
+      this.menuComponent = 'Submenu'
+    }
+  },
+  methods: {
+    handleChildren(children = []) {
+      if (children === null) return []
+      return children.filter((item) => item.hidden !== true)
     },
-  }
+  },
+}
 </script>
 <style lang="less">
-  .anticon {
-    margin-right: 3px !important;
-  }
+.anticon {
+  margin-right: 3px !important;
+}
 </style>

+ 4 - 4
src/router/index.js

@@ -111,23 +111,23 @@ export const asyncRoutes = [
       meta: {
         icon: 'stationManage',
         title: '站点列表',
+        activeMenu: '/stationManage/index'
       },
       path: 'siteList',
       component: () =>
         import('@/views/stationManage/siteList.vue'),
-      selectLeftMenu: '/stationManage',
-      hidden: true
+      hidden: true,
     },
     {
       meta: {
         icon: 'stationManage',
         title: '所有台区',
+        activeMenu: '/stationManage/index'
       },
       path: 'index',
       component: () =>
         import('@/views/stationManage/index.vue'),
-      selectLeftMenu: '/stationManage',
-      hidden: true
+      hidden: true,
     }
     ]
   },

+ 1 - 1
src/views/monthReport/tables/deviationTable.vue

@@ -36,7 +36,7 @@
           label="当前状态"
           width=""
         ></el-table-column>
-        <el-table-column  label="操作" width="100">
+        <el-table-column label="操作" width="100">
           <template #default="scope">
             <el-button
               type="text"