浏览代码

菜单权限BUG修复

seimin 3 年之前
父节点
当前提交
b098184c49
共有 3 个文件被更改,包括 15 次插入10 次删除
  1. 5 3
      src/app/services/tool.service.ts
  2. 5 3
      src/app/views/login/login.component.ts
  3. 5 4
      src/app/views/main/main.component.ts

+ 5 - 3
src/app/services/tool.service.ts

@@ -34,9 +34,11 @@ export class ToolService {
34
     let jurisdiction = []; //当前菜单的权限列表
34
     let jurisdiction = []; //当前菜单的权限列表
35
     let coopBtns: any = {}; // 初始化权限
35
     let coopBtns: any = {}; // 初始化权限
36
     this.menu.forEach((e) => {
36
     this.menu.forEach((e) => {
37
-      e.childrens.forEach((el) => {
38
-        secondMenus.push(el);
39
-      });
37
+      if (e.childrens) {
38
+        e.childrens.forEach((el) => {
39
+          secondMenus.push(el);
40
+        });
41
+      }
40
     });
42
     });
41
     secondMenus.forEach((e) => {
43
     secondMenus.forEach((e) => {
42
       if (e.link == link) {
44
       if (e.link == link) {

+ 5 - 3
src/app/views/login/login.component.ts

@@ -87,9 +87,11 @@ export class LoginComponent implements OnInit {
87
     menuLis.forEach((item) => {
87
     menuLis.forEach((item) => {
88
       item.flag = false;
88
       item.flag = false;
89
       item.flagBg = false;
89
       item.flagBg = false;
90
-      item.childrens.forEach((value) => {
91
-        value.flag = false;
92
-      });
90
+      if (item.childrens) {
91
+        item.childrens.forEach((value) => {
92
+          value.flag = false;
93
+        });
94
+      }
93
     });
95
     });
94
     localStorage.setItem("menu", JSON.stringify(menuLis));
96
     localStorage.setItem("menu", JSON.stringify(menuLis));
95
     localStorage.setItem("index", "true"); //首页默认高亮
97
     localStorage.setItem("index", "true"); //首页默认高亮

+ 5 - 4
src/app/views/main/main.component.ts

@@ -148,10 +148,11 @@ export class MainComponent implements OnInit {
148
       let menus = JSON.parse(localStorage.getItem("menu"));
148
       let menus = JSON.parse(localStorage.getItem("menu"));
149
       menus.forEach((item1) => {
149
       menus.forEach((item1) => {
150
         item1.flagBg = false;
150
         item1.flagBg = false;
151
-        // item1.flag = false;
152
-        item1.childrens.forEach((value) => {
153
-          value.flag = false;
154
-        });
151
+        if (item1.childrens) {
152
+          item1.childrens.forEach((value) => {
153
+            value.flag = false;
154
+          });
155
+        }
155
       });
156
       });
156
       let obj = menus.find((value) => value.id == data.id);
157
       let obj = menus.find((value) => value.id == data.id);
157
       obj.flagBg = true;
158
       obj.flagBg = true;