From cdb09eefa2a640c9d971714b752b80b44b3451f6 Mon Sep 17 00:00:00 2001 From: zhouyuejun <505127606@qq.com> Date: Wed, 19 Dec 2018 13:40:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=A4=8D=E7=94=A8=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app-routing.module.ts | 2 +- src/app/login/login.component.html | 4 +- src/app/login/login.component.ts | 18 ++-- .../basic-data/basic-data-routing.module.ts | 89 ++++++++++--------- .../historical-data-routing.module.ts | 2 +- .../historical-data.component.html | 17 ++-- .../historical-data.component.ts | 7 +- src/app/pages/main/main.component.html | 31 +++---- src/app/pages/main/main.component.ts | 48 ++++++---- src/app/pages/pages-routing.module.ts | 4 +- src/app/pages/pages.component.html | 12 +-- src/app/pages/pages.component.ts | 7 +- .../seasonal-plan-routing.module.ts | 2 +- src/app/router-reuse-strategy.ts | 21 +++-- src/app/services/basic-data-service.ts | 7 ++ 15 files changed, 155 insertions(+), 116 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index f6284ca..b20e58d 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -27,7 +27,7 @@ const appRoutes: Routes = [ path: 'app', loadChildren: './pages/pages.module#PagesModule', canActivate: [LoginAuthService], - data: { preload: false, reuse: true } + data: { preload: false, reuse: false } } ] diff --git a/src/app/login/login.component.html b/src/app/login/login.component.html index 10a1708..5a4ca4f 100644 --- a/src/app/login/login.component.html +++ b/src/app/login/login.component.html @@ -2,8 +2,8 @@
diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index caf6e01..36c5c26 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -35,11 +35,19 @@ export class LoginComponent implements OnInit { _submit() { this.httpClient.post('/login', this.loginForm.value).subscribe( data => { - if(data.is_success){ - const toastCfg = new ToastConfig(ToastType.SUCCESS, '', '登录成功!', 3000); - this.toastService.toast(toastCfg); - this.router.navigate(['../app'], { relativeTo: this.route }) - }else{ + if (data.is_success) { + this.httpClient.get('/sysapi/setting/user/currentUser/detail').subscribe( + xhr => { + console.log(xhr); + if (xhr.is_success) { + sessionStorage.setItem('userInfo', JSON.stringify(xhr.body)); + const toastCfg = new ToastConfig(ToastType.SUCCESS, '', '登录成功!', 3000); + this.toastService.toast(toastCfg); + this.router.navigate(['../app/main'], { relativeTo: this.route }) + } + } + ) + } else { const toastCfg = new ToastConfig(ToastType.ERROR, '', '登录失败!', 3000); this.toastService.toast(toastCfg); } diff --git a/src/app/pages/basic-data/basic-data-routing.module.ts b/src/app/pages/basic-data/basic-data-routing.module.ts index 2d7bf98..4597cfe 100644 --- a/src/app/pages/basic-data/basic-data-routing.module.ts +++ b/src/app/pages/basic-data/basic-data-routing.module.ts @@ -20,78 +20,79 @@ const basicDataRoutes: Routes = [ { path: '', component: BasicDataComponent, - children:[ + children: [ { - path:'', - redirectTo:'chekingroup', - pathMatch:'full' + path: '', + redirectTo: 'chekingroup', + pathMatch: 'full' }, { - path:'checkingroup', - component:CheckinGroupComponent, - data: { preload: true, reuse: false } + path: 'checkingroup', + component: CheckinGroupComponent, + data: { preload: true, reuse: true } }, { - path:'gate', - component:GateComponent, - data: { preload: true, reuse: false } + path: 'gate', + component: GateComponent, + data: { preload: true, reuse: true } }, { - path:'terminal', - component:TerminalComponent, - data: { preload: true, reuse: false } + path: 'terminal', + component: TerminalComponent, + data: { preload: true, reuse: true } }, { - path:'chut', - component:ChutComponent, - data: { preload: true, reuse: false } + path: 'chut', + component: ChutComponent, + data: { preload: true, reuse: true } }, { - path:'stand', - component:StandComponent, - data: { preload: true, reuse: false } + path: 'stand', + component: StandComponent, + data: { preload: true, reuse: true } }, { - path:'carousel', - component:CarouselComponent, - data: { preload: true, reuse: false } + path: 'carousel', + component: CarouselComponent, + data: { preload: true, reuse: true } }, { - path:'checkindesk', - component:CheckinDeskComponent, - data: { preload: true, reuse: false } + path: 'checkindesk', + component: CheckinDeskComponent, + data: { preload: true, reuse: true } }, { - path:'airport', - component:AirportComponent, - data: { preload: true, reuse: false } + path: 'airport', + component: AirportComponent, + data: { preload: true, reuse: true } }, { - path:'city', - component:CityComponent, - data: { preload: true, reuse: false } + path: 'city', + component: CityComponent, + data: { preload: true, reuse: true } }, { - path:'aircrafttype', - component:AircraftTypeComponent, - data: { preload: true, reuse: false } + path: 'aircrafttype', + component: AircraftTypeComponent, + data: { preload: true, reuse: true } }, { - path:'aircraft', - component:AircraftComponent, - data: { preload: true, reuse: false } + path: 'aircraft', + component: AircraftComponent, + data: { preload: true, reuse: true } }, { - path:'terminalarea', - component:TerminalAreaComponent, - data: { preload: true, reuse: false } + path: 'terminalarea', + component: TerminalAreaComponent, + data: { preload: true, reuse: true } }, { - path:'airline', - component:AirlineComponent, - data: { preload: true, reuse: false } + path: 'airline', + component: AirlineComponent, + data: { preload: true, reuse: true } } - ] + ], + // data: { preload: false, reuse: true } } ] diff --git a/src/app/pages/historical-data/historical-data-routing.module.ts b/src/app/pages/historical-data/historical-data-routing.module.ts index 4014ea0..341bf3c 100644 --- a/src/app/pages/historical-data/historical-data-routing.module.ts +++ b/src/app/pages/historical-data/historical-data-routing.module.ts @@ -7,7 +7,7 @@ const historicalDataRoutes: Routes = [ { path: '', component: HistoricalDataComponent, - data: { preload: true, reuse: false } + data: { preload: true, reuse: true } } ] diff --git a/src/app/pages/historical-data/historical-data.component.html b/src/app/pages/historical-data/historical-data.component.html index 61d14f1..ff5e6ed 100644 --- a/src/app/pages/historical-data/historical-data.component.html +++ b/src/app/pages/historical-data/historical-data.component.html @@ -52,31 +52,28 @@
- - - +
- - - +
- - - +
diff --git a/src/app/pages/historical-data/historical-data.component.ts b/src/app/pages/historical-data/historical-data.component.ts index 4527055..442d16f 100644 --- a/src/app/pages/historical-data/historical-data.component.ts +++ b/src/app/pages/historical-data/historical-data.component.ts @@ -36,6 +36,7 @@ export class HistoricalDataComponent implements OnInit { public tabClose: boolean = true; //各项基础数据 + public flightAgents: Array; public flightTypes: Array; public terminals: Array; public flightStatus: Array; @@ -77,7 +78,7 @@ export class HistoricalDataComponent implements OnInit { } ) //获取航班动态信息 - this.httpCilent.post('/adminapi/hitFlightData/list', { searchDate: new Date().getTime() }).subscribe( + this.httpCilent.post('/adminapi/hitFlightData/list', { hstFLightTime: "2018-11-22" }).subscribe( data => { this.raw_data = data.body; @@ -89,6 +90,7 @@ export class HistoricalDataComponent implements OnInit { }); //从基础数据服务中拿出部分基础数据 + this.flightAgents = this.basicDataService.flightAgents; this.flightTypes = this.basicDataService.flightTypes; this.terminals = this.basicDataService.terminal; this.flightStatus = this.basicDataService.flightStatus; @@ -104,6 +106,9 @@ export class HistoricalDataComponent implements OnInit { this.combined_data = combined_data; this.doSequence(this.combined_data); } else { + this.basicDataService.flightAgents_subject.subscribe( + val => this.flightAgents = val + ) this.basicDataService.flightTypes_subject.subscribe( val => this.flightTypes = val ) diff --git a/src/app/pages/main/main.component.html b/src/app/pages/main/main.component.html index ae72459..4b18be7 100644 --- a/src/app/pages/main/main.component.html +++ b/src/app/pages/main/main.component.html @@ -81,26 +81,23 @@
- - - +
- - - +
- - - +
@@ -143,14 +140,14 @@ [ngClass]="{'selected':row_state['renderFlight']['FLNO']===airline_row['renderFlight']['FLNO']}"> {{i+1}} - - - - - - - - + + + + + + + + {{airline_row['renderFlight'][airline_col.COL_CODE]}} diff --git a/src/app/pages/main/main.component.ts b/src/app/pages/main/main.component.ts index 59b9c82..5fde696 100644 --- a/src/app/pages/main/main.component.ts +++ b/src/app/pages/main/main.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { ChangeDetectorRef } from '@angular/core'; +import { NavigationEnd, Router } from '@angular/router'; import { ToastService } from '../../components/toast/toast.service'; import { ToastConfig, ToastType } from '../../components/toast/toast-model'; @@ -16,7 +17,9 @@ import { AlertMessageHandle } from '../../utils/alert-message-handle'; import dateFormatter from '../../utils/date-formatter'; +import { filter } from 'rxjs/operators'; import * as $ from 'jquery'; + @Component({ selector: 'app-main', templateUrl: './main.component.html', @@ -24,6 +27,7 @@ import * as $ from 'jquery'; }) export class MainComponent implements OnInit { constructor( + private router: Router, private basicDataService: BasicDataService, private operateSpinServiceService: OperateSpinServiceService, private httpCilent: HttpClientService, @@ -33,6 +37,30 @@ export class MainComponent implements OnInit { ) { this.operateSpinServiceService.showSpin(); this.changeDetectorRef.detach(); + this.router.events.pipe( + filter((event => event instanceof NavigationEnd)) + ).subscribe( + (event: NavigationEnd) => { + console.log(event); + if (event.urlAfterRedirects === '/app/main') { + this.httpCilent.get('/adminapi/settings/uisettings').subscribe( + data => { + data.body.forEach(element => { + if (element.groupCode === 'userSettingCol') { + this.col_lists = JSON.parse(element.settingContent).allCols; + this.render_col_lists = JSON.parse(element.settingContent).targetList; + } else if (element.groupCode === 'userSettingColor') { + this.airline_color = JSON.parse(element.settingContent); + } else if (element.groupCode === 'userSettingMsgAlert') { + this.airline_message_alert = JSON.parse(element.settingContent).targetList; + } + }); + this.changeDetectorRef.detectChanges(); + } + ) + } + } + ) } public orderHandle = new DynamicFlightOrder(); public dataHandle = new FlightsDataHandle(); @@ -48,6 +76,7 @@ export class MainComponent implements OnInit { public dynamicAlertArray: Array = []; //各项基础数据 + public flightAgents: Array; public flightTypes: Array; public terminals: Array; public flightStatus: Array; @@ -104,21 +133,6 @@ export class MainComponent implements OnInit { } ) - /* 获取用户设置 */ - this.httpCilent.get('/adminapi/settings/uisettings').subscribe( - data => { - data.body.forEach(element => { - if (element.groupCode === 'userSettingCol') { - this.col_lists = JSON.parse(element.settingContent).allCols; - this.render_col_lists = JSON.parse(element.settingContent).targetList; - } else if (element.groupCode === 'userSettingColor') { - this.airline_color = JSON.parse(element.settingContent); - } else if (element.groupCode === 'userSettingMsgAlert') { - this.airline_message_alert = JSON.parse(element.settingContent).targetList; - } - }) - } - ) //获取航班动态信息 this.httpCilent.get('/msgexchangeapi/all/flights').subscribe( data => { @@ -132,6 +146,7 @@ export class MainComponent implements OnInit { }); //从基础数据服务中拿出部分基础数据 + this.flightAgents = this.basicDataService.flightAgents; this.flightTypes = this.basicDataService.flightTypes; this.terminals = this.basicDataService.terminal; this.flightStatus = this.basicDataService.flightStatus; @@ -147,6 +162,9 @@ export class MainComponent implements OnInit { this.combined_data = combined_data; this.doSequence(this.combined_data); } else { + this.basicDataService.flightAgents_subject.subscribe( + val => this.flightAgents = val + ) this.basicDataService.flightTypes_subject.subscribe( val => this.flightTypes = val ) diff --git a/src/app/pages/pages-routing.module.ts b/src/app/pages/pages-routing.module.ts index 58cfe3f..a5da6eb 100644 --- a/src/app/pages/pages-routing.module.ts +++ b/src/app/pages/pages-routing.module.ts @@ -21,12 +21,12 @@ const pagesRoutes: Routes = [ { path:'season', loadChildren:'./seasonal-plan/seasonal-plan.module#SeasonalPlanModule', - data: { preload: true, reuse: false } + data: { preload: true, reuse: true } }, { path:'history', loadChildren:'./historical-data/historical-data.module#HistoricalDataModule', - data: { preload: true, reuse: false } + data: { preload: true, reuse: true } }, { path:'basic', diff --git a/src/app/pages/pages.component.html b/src/app/pages/pages.component.html index d8c1c2a..1913136 100644 --- a/src/app/pages/pages.component.html +++ b/src/app/pages/pages.component.html @@ -13,14 +13,14 @@