Browse Source

页签调整

seimin 2 months ago
parent
commit
1c33b75f23

+ 1 - 1
src/app/SimpleReuseStrategy.ts

@@ -37,7 +37,7 @@ export class SimpleReuseStrategy implements RouteReuseStrategy {
37 37
 
38 38
   /**
39 39
    * 基于路由数据确定路由是否应该分离。
40
-   * 表示对所有路由允许复用 如果有路由不想利用可以在这加一些业务逻辑判断,这里判断路由是否有 keepAlive 数据判断是否复用。
40
+   * 表示对所有路由允许复用 如果有路由不想利用可以在这加一些业务逻辑判断,这里判断路由是否有 reuse 数据判断是否复用。
41 41
    *
42 42
    * @param {ActivatedRouteSnapshot} route - 要检查分离的路由快照。
43 43
    * @return {boolean} 如果应该分离路由则返回true,否则返回 false。

+ 1 - 5
src/app/views/new-statistics/components/custom-tabs/custom-tabs.component.ts

@@ -9,7 +9,6 @@ import { Router } from '@angular/router';
9 9
   styleUrls: ['./custom-tabs.component.less']
10 10
 })
11 11
 export class CustomTabsComponent implements OnInit {
12
-  @Output() selectTabEmit = new EventEmitter();
13 12
   constructor(
14 13
     public tabService: TabService,
15 14
     public router: Router,
@@ -23,15 +22,13 @@ export class CustomTabsComponent implements OnInit {
23 22
 
24 23
   closeTab(path: string, event: MouseEvent): void {
25 24
     event.stopPropagation();
26
-    let newPath:any = this.tabService.closeTab(path);
27
-    this.selectTabEmit.emit(newPath.split('/').reverse()[0])
25
+    this.tabService.closeTab(path);
28 26
   }
29 27
 
30 28
   selectTab(path: string): void {
31 29
     const [routePath, params] = this.tabService.getFullPath(path);
32 30
     // console.log('params:', params)
33 31
     // console.log('routePath:', routePath)
34
-    this.selectTabEmit.emit(routePath.split('/').reverse()[0])
35 32
     this.router.navigate([routePath], {
36 33
       replaceUrl: true
37 34
     }).catch(err => {
@@ -70,7 +67,6 @@ export class CustomTabsComponent implements OnInit {
70 67
     this.rightClickedTab.active = true;
71 68
 
72 69
     this.tabService.closeOtherTabs(this.rightClickedTab);
73
-    this.selectTabEmit.emit(this.rightClickedTab.path.split('/').reverse()[0])
74 70
 
75 71
     this.showContextMenu = false;
76 72
   }

+ 2 - 2
src/app/views/new-statistics/distribution-inspection-statistics/distribution-inspection-statistics.component.html

@@ -1,10 +1,10 @@
1 1
 <!-- content -->
2 2
 <div class="content">
3 3
   <virtual-scroller #osComponentRef1 [items]="secondMenuList" class="secondMenu">
4
-    <div class="secondMenuItem ellipsis-oneline" [ngClass]="{ active: activeSecondMenuLink == data.link }" [title]="data.title" *ngFor="let data of osComponentRef1.viewPortItems" (click)="clickSecondMenu(data)">{{data.title}}</div>
4
+    <a replaceUrl [routerLink]="'/newStatistics/' + route.parent.snapshot.routeConfig.path + '/' + data.link" class="secondMenuItem ellipsis-oneline" routerLinkActive="active" [title]="data.title" *ngFor="let data of osComponentRef1.viewPortItems">{{data.title}}</a>
5 5
   </virtual-scroller>
6 6
   <div class="main">
7
-    <app-custom-tabs (selectTabEmit)="selectTabEmit($event)"></app-custom-tabs>
7
+    <app-custom-tabs></app-custom-tabs>
8 8
     <router-outlet></router-outlet>
9 9
   </div>
10 10
 </div>

+ 2 - 0
src/app/views/new-statistics/distribution-inspection-statistics/distribution-inspection-statistics.component.less

@@ -41,6 +41,8 @@
41 41
         padding: 0 36px;
42 42
         border-bottom: 1px solid #E9E9E9;
43 43
         cursor: pointer;
44
+        display: block;
45
+        color: rgba(0,0,0,0.65);
44 46
         &.active{
45 47
           background-color: #E9F7E9;
46 48
           border-color: #E9F7E9;

+ 5 - 19
src/app/views/new-statistics/distribution-inspection-statistics/distribution-inspection-statistics.component.ts

@@ -25,14 +25,11 @@ export class DistributionInspectionStatisticsComponent implements OnInit {
25 25
 
26 26
   initSecondMenu(){
27 27
     this.secondMenuList = this.menuList.find(v => v.link == this.route.parent.routeConfig.path).childrens || [];
28
-    console.log(this.tabService.tabs)
29
-    let activeTab = this.tabService.tabs.find(v => v.active);
30
-    if(this.secondMenuList.length){
31
-      if(activeTab.path === `/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.secondMenuList[0].link}`){
32
-        this.clickSecondMenu(this.secondMenuList[0]);
33
-      }else{
34
-        this.activeSecondMenuLink = activeTab.path.split('/').reverse()[0];
35
-      }
28
+    if(location.hash == '#/newStatistics/distributionInspectionStatistics'){
29
+      this.router.navigate([`/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.secondMenuList[0].link}`], { replaceUrl: true });
30
+    }else{
31
+      let tab = this.tabService.tabs.find(v => v.active);
32
+      this.router.navigate([tab.path], { replaceUrl: true });
36 33
     }
37 34
   }
38 35
 
@@ -41,15 +38,4 @@ export class DistributionInspectionStatisticsComponent implements OnInit {
41 38
     this.initSecondMenu();
42 39
   }
43 40
 
44
-  // 点击二级菜单
45
-  activeSecondMenuLink:string;
46
-  clickSecondMenu(data){
47
-    this.activeSecondMenuLink = data.link;
48
-    this.router.navigate([`/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.activeSecondMenuLink}`], { replaceUrl: true });
49
-  }
50
-
51
-  // 回显二级菜单
52
-  selectTabEmit(link){
53
-    this.activeSecondMenuLink = link;
54
-  }
55 41
 }

+ 2 - 2
src/app/views/new-statistics/maintenance-statistics/maintenance-statistics.component.html

@@ -1,10 +1,10 @@
1 1
 <!-- content -->
2 2
 <div class="content">
3 3
   <virtual-scroller #osComponentRef1 [items]="secondMenuList" class="secondMenu">
4
-    <div class="secondMenuItem ellipsis-oneline" [ngClass]="{ active: activeSecondMenuLink == data.link }" [title]="data.title" *ngFor="let data of osComponentRef1.viewPortItems" (click)="clickSecondMenu(data)">{{data.title}}</div>
4
+    <a replaceUrl [routerLink]="'/newStatistics/' + route.parent.snapshot.routeConfig.path + '/' + data.link" class="secondMenuItem ellipsis-oneline" routerLinkActive="active" [title]="data.title" *ngFor="let data of osComponentRef1.viewPortItems">{{data.title}}</a>
5 5
   </virtual-scroller>
6 6
   <div class="main">
7
-    <app-custom-tabs (selectTabEmit)="selectTabEmit($event)"></app-custom-tabs>
7
+    <app-custom-tabs></app-custom-tabs>
8 8
     <router-outlet></router-outlet>
9 9
   </div>
10 10
 </div>

+ 2 - 0
src/app/views/new-statistics/maintenance-statistics/maintenance-statistics.component.less

@@ -41,6 +41,8 @@
41 41
         padding: 0 36px;
42 42
         border-bottom: 1px solid #E9E9E9;
43 43
         cursor: pointer;
44
+        display: block;
45
+        color: rgba(0,0,0,0.65);
44 46
         &.active{
45 47
           background-color: #E9F7E9;
46 48
           border-color: #E9F7E9;

+ 5 - 19
src/app/views/new-statistics/maintenance-statistics/maintenance-statistics.component.ts

@@ -25,14 +25,11 @@ export class MaintenanceStatisticsComponent implements OnInit {
25 25
 
26 26
   initSecondMenu(){
27 27
     this.secondMenuList = this.menuList.find(v => v.link == this.route.parent.routeConfig.path).childrens || [];
28
-    console.log(this.tabService.tabs)
29
-    let activeTab = this.tabService.tabs.find(v => v.active);
30
-    if(this.secondMenuList.length){
31
-      if(activeTab.path === `/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.secondMenuList[0].link}`){
32
-        this.clickSecondMenu(this.secondMenuList[0]);
33
-      }else{
34
-        this.activeSecondMenuLink = activeTab.path.split('/').reverse()[0];
35
-      }
28
+    if(location.hash == '#/newStatistics/maintenanceStatistics'){
29
+      this.router.navigate([`/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.secondMenuList[0].link}`], { replaceUrl: true });
30
+    }else{
31
+      let tab = this.tabService.tabs.find(v => v.active);
32
+      this.router.navigate([tab.path], { replaceUrl: true });
36 33
     }
37 34
   }
38 35
 
@@ -41,15 +38,4 @@ export class MaintenanceStatisticsComponent implements OnInit {
41 38
     this.initSecondMenu();
42 39
   }
43 40
 
44
-  // 点击二级菜单
45
-  activeSecondMenuLink:string;
46
-  clickSecondMenu(data){
47
-    this.activeSecondMenuLink = data.link;
48
-    this.router.navigate([`/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.activeSecondMenuLink}`], { replaceUrl: true });
49
-  }
50
-
51
-  // 回显二级菜单
52
-  selectTabEmit(link){
53
-    this.activeSecondMenuLink = link;
54
-  }
55 41
 }

+ 1 - 1
src/app/views/new-statistics/new-statistics.component.html

@@ -1,5 +1,5 @@
1 1
 <div class="header">
2
-  <span class="title" *ngFor="let data of menuList" [ngClass]="{ active: activeMenuId == data.id }" (click)="clickMenu(data)">{{data.title}}</span>
2
+  <a replaceUrl routerLinkActive="active" [routerLink]="'/newStatistics/' + data.link" class="title" *ngFor="let data of menuList">{{data.title}}</a>
3 3
   <div class="hospital" (click)="queryRangeClick()">
4 4
     <ng-container *ngIf="queryType == 1">查询范围:全院查询</ng-container>
5 5
     <ng-container *ngIf="queryType == 2">查询范围:{{hospital.hosName}}</ng-container>

+ 1 - 0
src/app/views/new-statistics/new-statistics.component.less

@@ -13,6 +13,7 @@
13 13
     .title{
14 14
       margin-right: 16px;
15 15
       cursor: pointer;
16
+      color: rgba(0,0,0,0.65);
16 17
       &:last-of-type{
17 18
         margin-right: 0;
18 19
       }

+ 0 - 9
src/app/views/new-statistics/new-statistics.component.ts

@@ -29,15 +29,6 @@ export class NewStatisticsComponent implements OnInit, OnDestroy {
29 29
 
30 30
   getMenuList(){
31 31
     this.menuList = this.tool.getMenuAutoType();
32
-    this.menuList.length && this.clickMenu(this.menuList[0]);
33
-  }
34
-
35
-  // 点击一级菜单
36
-  activeMenuId:number;
37
-  clickMenu(data){
38
-    this.activeMenuId = data.id;
39
-    console.log(`/newStatistics/${data.link}/${data.childrens[0].link}`);
40
-    this.router.navigate([`/newStatistics/${data.link}/${data.childrens[0].link}`], { replaceUrl: true });
41 32
   }
42 33
 
43 34
   // 全院查询-1|院区查询-2|责任部门查询-3|部门垂直查询-4

+ 4 - 2
src/app/views/new-statistics/services/tab.service.ts

@@ -63,6 +63,9 @@ export class TabService {
63 63
     }
64 64
 
65 65
     const title = this.getTitleFromUrl(url);
66
+    if(title === ''){
67
+      return;
68
+    }
66 69
     this.tabs.forEach(t => t.active = false);
67 70
 
68 71
     const newTab: Tab = {
@@ -122,12 +125,11 @@ export class TabService {
122 125
         replaceUrl: true
123 126
       });
124 127
     }
125
-    return newActiveTab.path;
126 128
   }
127 129
 
128 130
   private getTitleFromRoute(route: ActivatedRouteSnapshot): string {
129 131
     while (route.firstChild) route = route.firstChild;
130
-    return route.data.title || '未命名标签';
132
+    return route.data.title || '';
131 133
   }
132 134
 
133 135
   private getTitleFromUrl(url: string): string {