Browse Source

权限修改

renmy 3 years ago
parent
commit
90c1d893f5
2 changed files with 29 additions and 12 deletions
  1. 28 12
      src/layout/components/Sidebar/index.vue
  2. 1 0
      src/views/sys/role/index.vue

+ 28 - 12
src/layout/components/Sidebar/index.vue

@@ -33,19 +33,35 @@ export default {
     
     ...mapState("user", ['role']),
     routes() {
-      let role = this.role
-      let regx = /\//g
-      let roles = role.filter(res => res.match(regx).length ===  1)
-      let rolesChild = role.filter(res => res.match(regx).length !== 1)
-      console.log(rolesChild,"rolesChildrolesChildrolesChildrolesChild");
-      console.log(this.$router.options.routes,"rolesrolesrolesroles");
-      let parent = [...this.$router.options.routes].filter(element => roles.includes(element.path));
-      parent.forEach(element => {
-        element.children = element.children.filter(res => rolesChild.includes(element.path+'/'+res.path))
-      });
+      // let role = this.role
+      // let regx = /\//g
+      // let roles = role.filter(res => res.match(regx).length ===  1)
+      // let rolesChild = role.filter(res => res.match(regx).length !== 1)
+      // console.log(rolesChild,"rolesChildrolesChildrolesChildrolesChild");
+      // console.log(this.$router.options.routes,"rolesrolesrolesroles");
+      // let parent = [...this.$router.options.routes].filter(element => roles.includes(element.path));
+      // parent.forEach(element => {
+      //   element.children = element.children.filter(res => rolesChild.includes(element.path+'/'+res.path))
+      // });
       
-      console.log(parent,"asdsadsa");
-      return this.$router.options.routes
+      // console.log(parent,"asdsadsa");
+
+
+      let routes = this.$router.options.routes.copyWithin(0, 0)
+      let role = this.role
+      let regx = /\//g
+      let roles = role.filter(res => res.match(regx).length ===  1)
+      let rolesChild = role.filter(res => res.match(regx).length !== 1)
+      let parent = routes.filter(element => roles.includes(element.path));
+      parent.forEach(element => {
+        element.children = element.children.filter(res => rolesChild.includes(element.path+'/'+res.path))
+      });
+      
+      console.log(parent, this.$router.options.routes);
+      return parent
+
+
+      // return this.$router.options.routes
     },
     activeMenu() {
       const route = this.$route

+ 1 - 0
src/views/sys/role/index.vue

@@ -280,6 +280,7 @@ export default {
         if (response.code === 200) {
           this.tree.loading = false
           this.$message({ type: 'success', message: '保存成功' })
+          this.grant_visible = false
         }
       })