浏览代码

生成数据开发

maotao 6 天之前
父节点
当前提交
51e4f9b474
共有 2 个文件被更改,包括 27 次插入2 次删除
  1. 5 2
      src/app/app-routing.module.ts
  2. 22 0
      src/app/guard/DataGenerate.guard.ts

+ 5 - 2
src/app/app-routing.module.ts

@@ -23,7 +23,10 @@ import { IncidentConfigGuard } from './guard/IncidentConfig.guard';
23 23
 import { OtherConfigGuard } from './guard/OtherConfig.guard';
24 24
 //业务页面控制查看权限
25 25
 import { PageConfigGuard } from './guard/PageConfig.guard';
26
+// 护士端控制查看权限
26 27
 import { NurseConfigGuard } from './guard/nurseConfig.guard';
28
+// 数据生成查看权限
29
+import { DataGenerateGuard } from './guard/DataGenerate.guard';
27 30
 //系统配置查看权限
28 31
 import { SystemConfigGuard } from './guard/SystemConfig.guard';
29 32
 // 故障实时播报权限
@@ -149,11 +152,11 @@ const routes: Routes = [
149 152
     loadChildren: () => import('./views/nurse-config/nurse-config.module').then(m => m.NurseConfigModule),
150 153
     canActivate: [NurseConfigGuard]
151 154
   },
152
-	// 数据生查看
155
+	// 数据生查看
153 156
 	{
154 157
 	  path: 'dataGenerate',
155 158
 	  loadChildren: () => import('./views/data-generate/data-generate.module').then(m => m.DataGenerateModule),
156
-	  canActivate: [NurseConfigGuard]
159
+	  canActivate: [DataGenerateGuard]
157 160
 	},
158 161
   // 问卷预览
159 162
   {

+ 22 - 0
src/app/guard/DataGenerate.guard.ts

@@ -0,0 +1,22 @@
1
+import { Injectable } from '@angular/core';
2
+import { CanActivate, Router } from '@angular/router';
3
+
4
+@Injectable({
5
+  providedIn: 'root'
6
+})
7
+export class DataGenerateGuard implements CanActivate  {
8
+  constructor(public router: Router) { }
9
+
10
+  canActivate(): boolean {
11
+    const menus = JSON.parse(localStorage.getItem('menu'));
12
+    let can = false;
13
+    if (menus) {
14
+      can = menus.some(e => e.link == 'dataGenerate');
15
+    }
16
+    if (!can) {
17
+      this.router.navigate(['login']);
18
+      return false
19
+    }
20
+    return true;
21
+  }
22
+}