From 75ff33ad6b5246a5665264a0f657b2f84beb57a0 Mon Sep 17 00:00:00 2001
From: cpf <1105965053@qq.com>
Date: Thu, 14 Jul 2022 12:12:24 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B2=B9=E7=AB=99=E9=AB=98=E4=BA=AE=E4=BB=A5?=
 =?UTF-8?q?=E5=8F=8A=E7=99=BB=E5=BD=95=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/app/pages/home/home.component.ts          | 37 ++++++++++++++++++-
 .../records-nav/records-nav.component.ts      |  4 +-
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts
index 9155ef7..4ac735b 100644
--- a/src/app/pages/home/home.component.ts
+++ b/src/app/pages/home/home.component.ts
@@ -17,6 +17,7 @@ import * as moment from 'moment';
 import { FormBuilder, FormGroup, Validators } from '@angular/forms';
 import { DisposeequipmentComponent } from '../records/warning-statistics-list/disposeequipment/disposeequipment.component';
 import { SelectedMenu } from 'src/app/service/selectedMenu.service';
+import {Location} from "@angular/common";
 @Component({
   selector: 'app-home',
   templateUrl: './home.component.html',
@@ -26,12 +27,14 @@ export class HomeComponent implements OnInit {
   @ViewChild('warning', { static: false }) template?: TemplateRef<{}>;
   passwordValidateForm!: FormGroup;
   constructor(private listRefreshService: listRefreshService, private http: HttpClient, private router: Router, private navChangeService: NavChangeService, public token: CacheTokenService,
-    private message: NzMessageService, private notificationService: NzNotificationService, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private fb: FormBuilder, private selectedMenu: SelectedMenu) {
+    private message: NzMessageService, private notificationService: NzNotificationService, private modal: NzModalService, private viewContainerRef: ViewContainerRef, private fb: FormBuilder, private selectedMenu: SelectedMenu,private location: Location) {
     const { password } = MyValidators;
+    
     this.passwordValidateForm = this.fb.group({
       oldpassword: [null, [Validators.required]],
       newpassword: [null, [Validators.required, password]],
       affirmpassword: [null, [Validators.required, password]]
+      
     });
   }
 
@@ -93,6 +96,38 @@ export class HomeComponent implements OnInit {
   }
 
   ngOnInit(): void {
+    this.location.subscribe(event => {
+      
+      if(event.url=="/homepage"){
+        sessionStorage.setItem('selectedMenu', "首页")
+        this.selectedItem = "首页"
+      }else if(event.url=="/plan"||event.url=="/plan/petrolStation"){
+        sessionStorage.setItem('selectedMenu', "数字油站")
+        this.selectedItem = "数字油站"
+      }else if(event.url=="/todaywarning"||event.url=="/todaywarning/petrolStation"){
+        sessionStorage.setItem('selectedMenu', "今日预警")
+        this.selectedItem = "今日预警"
+      }else if(event.url.indexOf("/records_nav")!=-1){
+        if(event.url=="/records_nav"){
+          console.log(1);
+          
+          this.router.navigate(['/records_nav/all'])
+          
+        }else if(event.url=="/records_nav/petrolStation"){
+          console.log(4963);
+          
+          this.router.navigate(['/records_nav/petrolStation/all'])
+          
+        }
+        sessionStorage.setItem('selectedMenu', "预警记录")
+        this.selectedItem = "预警记录"
+      }else if(event.url=="/license"||event.url=="/license/petrolStation"){
+        sessionStorage.setItem('selectedMenu', "证照管理")
+        this.selectedItem = "证照管理"
+      }
+      
+});
+    
     let a = sessionStorage.getItem('userdata')
     this.userMenu = JSON.parse(a).menus
     for (let index = 0; index < this.userMenu.length; index++) {
diff --git a/src/app/pages/records/records-nav/records-nav.component.ts b/src/app/pages/records/records-nav/records-nav.component.ts
index ba04503..fb9cd4b 100644
--- a/src/app/pages/records/records-nav/records-nav.component.ts
+++ b/src/app/pages/records/records-nav/records-nav.component.ts
@@ -1,7 +1,7 @@
 import { Component, OnInit } from '@angular/core';
 import { Router } from '@angular/router';
 import { IsShowEchartsService } from 'src/app/service/isShowEcharts.service';
-
+import {Location} from "@angular/common";
 @Component({
   selector: 'app-records-nav',
   templateUrl: './records-nav.component.html',
@@ -9,7 +9,7 @@ import { IsShowEchartsService } from 'src/app/service/isShowEcharts.service';
 })
 export class RecordsNavComponent implements OnInit {
 
-  constructor(private router: Router, private isShowEcharts: IsShowEchartsService) { }
+  constructor(private router: Router, private isShowEcharts: IsShowEchartsService,private location: Location) { }
 
   isEcharts = true
   menuList = ['预警类型统计', '卸油统计', '证照预警统计']