|
@@ -1,6 +1,8 @@
|
1
|
1
|
import { ActivatedRoute, Router } from '@angular/router';
|
2
|
2
|
import { Component, OnInit, OnDestroy } from "@angular/core";
|
3
|
3
|
import { ToolService } from 'src/app/services/tool.service';
|
|
4
|
+import { SimpleReuseStrategy } from '../../../SimpleReuseStrategy';
|
|
5
|
+import { TabService } from '../services/tab.service';
|
4
|
6
|
@Component({
|
5
|
7
|
selector: "app-maintenance-statistics",
|
6
|
8
|
templateUrl: "./maintenance-statistics.component.html",
|
|
@@ -11,6 +13,7 @@ export class MaintenanceStatisticsComponent implements OnInit, OnDestroy {
|
11
|
13
|
public tool: ToolService,
|
12
|
14
|
public route: ActivatedRoute,
|
13
|
15
|
public router: Router,
|
|
16
|
+ public tabService: TabService,
|
14
|
17
|
) {}
|
15
|
18
|
|
16
|
19
|
menuList: any[] = [];
|
|
@@ -24,6 +27,8 @@ export class MaintenanceStatisticsComponent implements OnInit, OnDestroy {
|
24
|
27
|
|
25
|
28
|
ngOnDestroy(){
|
26
|
29
|
this.sessionRemove();
|
|
30
|
+ this.tabService.tabs = [];
|
|
31
|
+ SimpleReuseStrategy.deleteAllRouteCache();
|
27
|
32
|
}
|
28
|
33
|
|
29
|
34
|
getMenuList(){
|
|
@@ -36,6 +41,8 @@ export class MaintenanceStatisticsComponent implements OnInit, OnDestroy {
|
36
|
41
|
clickMenu(data){
|
37
|
42
|
this.activeMenuId = data.id;
|
38
|
43
|
this.secondMenuList = this.menuList.find(v => v.id == this.activeMenuId).childrens || [];
|
|
44
|
+ this.tabService.tabs = [];
|
|
45
|
+ SimpleReuseStrategy.deleteAllRouteCache();
|
39
|
46
|
this.secondMenuList.length && this.clickSecondMenu(this.secondMenuList[0]);
|
40
|
47
|
}
|
41
|
48
|
|
|
@@ -43,8 +50,12 @@ export class MaintenanceStatisticsComponent implements OnInit, OnDestroy {
|
43
|
50
|
activeSecondMenuLink:string;
|
44
|
51
|
clickSecondMenu(data){
|
45
|
52
|
this.activeSecondMenuLink = data.link;
|
46
|
|
- // this.router.navigateByUrl(`newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.activeSecondMenuLink}`).finally();
|
47
|
|
- this.router.navigate([`newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.activeSecondMenuLink}`], { replaceUrl: true });
|
|
53
|
+ let hasCache = SimpleReuseStrategy.cacheRouters.has(`/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.activeSecondMenuLink}`);
|
|
54
|
+ console.log('tabs', this.tabService.tabs);
|
|
55
|
+ console.log('cacheRouters', SimpleReuseStrategy.cacheRouters);
|
|
56
|
+ console.log('cacheRouters', hasCache);
|
|
57
|
+ !hasCache && SimpleReuseStrategy.deleteRouteCache(`/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.activeSecondMenuLink}`);
|
|
58
|
+ this.router.navigate([`/newStatistics/${this.route.parent.snapshot.routeConfig.path}/${this.activeSecondMenuLink}`], { replaceUrl: true });
|
48
|
59
|
}
|
49
|
60
|
|
50
|
61
|
// 回显二级菜单
|