Browse Source

页签调整

seimin 3 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
    * @param {ActivatedRouteSnapshot} route - 要检查分离的路由快照。
42
    * @param {ActivatedRouteSnapshot} route - 要检查分离的路由快照。
43
    * @return {boolean} 如果应该分离路由则返回true,否则返回 false。
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
   styleUrls: ['./custom-tabs.component.less']
9
   styleUrls: ['./custom-tabs.component.less']
10
 })
10
 })
11
 export class CustomTabsComponent implements OnInit {
11
 export class CustomTabsComponent implements OnInit {
12
-  @Output() selectTabEmit = new EventEmitter();
13
   constructor(
12
   constructor(
14
     public tabService: TabService,
13
     public tabService: TabService,
15
     public router: Router,
14
     public router: Router,
@@ -23,15 +22,13 @@ export class CustomTabsComponent implements OnInit {
23
 
22
 
24
   closeTab(path: string, event: MouseEvent): void {
23
   closeTab(path: string, event: MouseEvent): void {
25
     event.stopPropagation();
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
   selectTab(path: string): void {
28
   selectTab(path: string): void {
31
     const [routePath, params] = this.tabService.getFullPath(path);
29
     const [routePath, params] = this.tabService.getFullPath(path);
32
     // console.log('params:', params)
30
     // console.log('params:', params)
33
     // console.log('routePath:', routePath)
31
     // console.log('routePath:', routePath)
34
-    this.selectTabEmit.emit(routePath.split('/').reverse()[0])
35
     this.router.navigate([routePath], {
32
     this.router.navigate([routePath], {
36
       replaceUrl: true
33
       replaceUrl: true
37
     }).catch(err => {
34
     }).catch(err => {
@@ -70,7 +67,6 @@ export class CustomTabsComponent implements OnInit {
70
     this.rightClickedTab.active = true;
67
     this.rightClickedTab.active = true;
71
 
68
 
72
     this.tabService.closeOtherTabs(this.rightClickedTab);
69
     this.tabService.closeOtherTabs(this.rightClickedTab);
73
-    this.selectTabEmit.emit(this.rightClickedTab.path.split('/').reverse()[0])
74
 
70
 
75
     this.showContextMenu = false;
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
 <!-- content -->
1
 <!-- content -->
2
 <div class="content">
2
 <div class="content">
3
   <virtual-scroller #osComponentRef1 [items]="secondMenuList" class="secondMenu">
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
   </virtual-scroller>
5
   </virtual-scroller>
6
   <div class="main">
6
   <div class="main">
7
-    <app-custom-tabs (selectTabEmit)="selectTabEmit($event)"></app-custom-tabs>
7
+    <app-custom-tabs></app-custom-tabs>
8
     <router-outlet></router-outlet>
8
     <router-outlet></router-outlet>
9
   </div>
9
   </div>
10
 </div>
10
 </div>

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

@@ -41,6 +41,8 @@
41
         padding: 0 36px;
41
         padding: 0 36px;
42
         border-bottom: 1px solid #E9E9E9;
42
         border-bottom: 1px solid #E9E9E9;
43
         cursor: pointer;
43
         cursor: pointer;
44
+        display: block;
45
+        color: rgba(0,0,0,0.65);
44
         &.active{
46
         &.active{
45
           background-color: #E9F7E9;
47
           background-color: #E9F7E9;
46
           border-color: #E9F7E9;
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
   initSecondMenu(){
26
   initSecondMenu(){
27
     this.secondMenuList = this.menuList.find(v => v.link == this.route.parent.routeConfig.path).childrens || [];
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
     this.initSecondMenu();
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
 <!-- content -->
1
 <!-- content -->
2
 <div class="content">
2
 <div class="content">
3
   <virtual-scroller #osComponentRef1 [items]="secondMenuList" class="secondMenu">
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
   </virtual-scroller>
5
   </virtual-scroller>
6
   <div class="main">
6
   <div class="main">
7
-    <app-custom-tabs (selectTabEmit)="selectTabEmit($event)"></app-custom-tabs>
7
+    <app-custom-tabs></app-custom-tabs>
8
     <router-outlet></router-outlet>
8
     <router-outlet></router-outlet>
9
   </div>
9
   </div>
10
 </div>
10
 </div>

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

@@ -41,6 +41,8 @@
41
         padding: 0 36px;
41
         padding: 0 36px;
42
         border-bottom: 1px solid #E9E9E9;
42
         border-bottom: 1px solid #E9E9E9;
43
         cursor: pointer;
43
         cursor: pointer;
44
+        display: block;
45
+        color: rgba(0,0,0,0.65);
44
         &.active{
46
         &.active{
45
           background-color: #E9F7E9;
47
           background-color: #E9F7E9;
46
           border-color: #E9F7E9;
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
   initSecondMenu(){
26
   initSecondMenu(){
27
     this.secondMenuList = this.menuList.find(v => v.link == this.route.parent.routeConfig.path).childrens || [];
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
     this.initSecondMenu();
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
 <div class="header">
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
   <div class="hospital" (click)="queryRangeClick()">
3
   <div class="hospital" (click)="queryRangeClick()">
4
     <ng-container *ngIf="queryType == 1">查询范围:全院查询</ng-container>
4
     <ng-container *ngIf="queryType == 1">查询范围:全院查询</ng-container>
5
     <ng-container *ngIf="queryType == 2">查询范围:{{hospital.hosName}}</ng-container>
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
     .title{
13
     .title{
14
       margin-right: 16px;
14
       margin-right: 16px;
15
       cursor: pointer;
15
       cursor: pointer;
16
+      color: rgba(0,0,0,0.65);
16
       &:last-of-type{
17
       &:last-of-type{
17
         margin-right: 0;
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
   getMenuList(){
30
   getMenuList(){
31
     this.menuList = this.tool.getMenuAutoType();
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
   // 全院查询-1|院区查询-2|责任部门查询-3|部门垂直查询-4
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
     const title = this.getTitleFromUrl(url);
65
     const title = this.getTitleFromUrl(url);
66
+    if(title === ''){
67
+      return;
68
+    }
66
     this.tabs.forEach(t => t.active = false);
69
     this.tabs.forEach(t => t.active = false);
67
 
70
 
68
     const newTab: Tab = {
71
     const newTab: Tab = {
@@ -122,12 +125,11 @@ export class TabService {
122
         replaceUrl: true
125
         replaceUrl: true
123
       });
126
       });
124
     }
127
     }
125
-    return newActiveTab.path;
126
   }
128
   }
127
 
129
 
128
   private getTitleFromRoute(route: ActivatedRouteSnapshot): string {
130
   private getTitleFromRoute(route: ActivatedRouteSnapshot): string {
129
     while (route.firstChild) route = route.firstChild;
131
     while (route.firstChild) route = route.firstChild;
130
-    return route.data.title || '未命名标签';
132
+    return route.data.title || '';
131
   }
133
   }
132
 
134
 
133
   private getTitleFromUrl(url: string): string {
135
   private getTitleFromUrl(url: string): string {