lrf402788946 5 rokov pred
rodič
commit
64d5c2a789
2 zmenil súbory, kde vykonal 36 pridanie a 5 odobranie
  1. 31 3
      src/layout/index/native.vue
  2. 5 2
      src/layout/list/mainLeft.vue

+ 31 - 3
src/layout/index/native.vue

@@ -39,7 +39,7 @@
 </template>
 
 <script>
-import { mapActions, mapState } from 'vuex';
+import { mapActions, mapState,mapMutations } from 'vuex';
 export default {
   name: 'native',
   props: {},
@@ -52,8 +52,36 @@ export default {
     ...mapState(['menu']),
   },
   methods: {
-    handleSelect(key, keyPath) {
-      console.log(key, keyPath);
+    ...mapMutations(['setSubMenu']),
+    handleSelect(path, arr) {
+      let res = this.menu.filter(fil => {
+          let is_this = this.checkChildrens(fil, path);
+          return is_this;
+        });
+        if (res.length > 0) {
+          let this_menu = res[0];
+          if (this_menu.children.length > 0) {
+            this_menu = this_menu.children;
+          }
+          this.setSubMenu(this_menu);
+        }
+    },
+    checkChildrens(fil, path){
+      let is_this = false;
+      if (fil.children) {
+        for (const item of fil.children) {
+          if (item.path === path) {
+            is_this = true;
+            break;
+          } else {
+            let res = this.checkChildrens(item, path);
+            if(res) {
+              is_this = true;
+              break;
+            }
+          }
+        }
+      }return is_this;
     },
     turnTo(url) {
       window.open(url);

+ 5 - 2
src/layout/list/mainLeft.vue

@@ -20,6 +20,7 @@
 </template>
 
 <script>
+import { mapActions, mapState } from 'vuex';
 export default {
   name: 'mainLeft',
   props: {
@@ -27,8 +28,10 @@ export default {
   },
   components: {},
   data: () => ({}),
-  created() { },
-  computed: {},
+  created() {},
+  computed: {
+    ...mapState(['subMenu']),
+  },
   methods: {},
 };
 </script>