路由复用优化

This commit is contained in:
zhouyuejun
2018-12-19 13:40:46 +08:00
parent 1e735059f8
commit cdb09eefa2
15 changed files with 155 additions and 116 deletions
+14 -17
View File
@@ -81,26 +81,23 @@
</div>
<div class="input-container mr-4">
<label for="">机坪代理:&nbsp;&nbsp;</label>
<select [(ngModel)]="filterItems.FHAG" class="form-control">
<select [(ngModel)]="filterItems.FHAG" (ngModelChange)="selectChange()" class="form-control">
<option value=""></option>
<option value="GH">国航代理</option>
<option value="CH">川航代理</option>
<option *ngFor="let anget of flightAgents" [value]="anget.oGId">{{anget.flightAgentName}}</option>
</select>
</div>
<div class="input-container mr-4">
<label for="">旅客代理:&nbsp;&nbsp;</label>
<select [(ngModel)]="filterItems.PHAG" class="form-control">
<select [(ngModel)]="filterItems.PHAG" (ngModelChange)="selectChange()" class="form-control">
<option value=""></option>
<option value="GH">国航代理</option>
<option value="CH">川航代理</option>
<option *ngFor="let anget of flightAgents" [value]="anget.oGId">{{anget.flightAgentName}}</option>
</select>
</div>
<div class="input-container mr-4">
<label for="">维护代理:&nbsp;&nbsp;</label>
<select [(ngModel)]="filterItems.MHAG" class="form-control">
<select [(ngModel)]="filterItems.MHAG" (ngModelChange)="selectChange()" class="form-control">
<option value=""></option>
<option value="GH">国航代理</option>
<option value="CH">川航代理</option>
<option *ngFor="let anget of flightAgents" [value]="anget.oGId">{{anget.flightAgentName}}</option>
</select>
</div>
</div>
@@ -143,14 +140,14 @@
[ngClass]="{'selected':row_state['renderFlight']['FLNO']===airline_row['renderFlight']['FLNO']}">
<td>{{i+1}}</td>
<td>
<img class="mr-2" *ngIf="getVipNotes(airline_row)" src="/assets/images/important-notes/vip.png" alt="">
<img class="mr-2" *ngIf="getOutplanNotes(airline_row)" src="/assets/images/important-notes/out_plan.png" alt="">
<img class="mr-2" *ngIf="getAlternateNotes(airline_row)" src="/assets/images/important-notes/alternate.png" alt="">
<img class="mr-2" *ngIf="getDelay30Notes(airline_row)" src="/assets/images/important-notes/delay_30.png" alt="">
<img class="mr-2" *ngIf="getDelayNotes(airline_row)" src="/assets/images/important-notes/delay.png" alt="">
<img class="mr-2" *ngIf="getReturnNotes(airline_row)" src="/assets/images/important-notes/return.png" alt="">
<img class="mr-2" *ngIf="getCancleNotes(airline_row)" src="/assets/images/important-notes/cancle.png" alt="">
<img class="mr-2" *ngIf="getStopoverNotes(airline_row)" src="/assets/images/important-notes/stopover.png" alt="">
<img class="mr-2" *ngIf="getVipNotes(airline_row)" src="/adminweb/assets/images/important-notes/vip.png" alt="">
<img class="mr-2" *ngIf="getOutplanNotes(airline_row)" src="/adminweb/assets/images/important-notes/out_plan.png" alt="">
<img class="mr-2" *ngIf="getAlternateNotes(airline_row)" src="/adminweb/assets/images/important-notes/alternate.png" alt="">
<img class="mr-2" *ngIf="getDelay30Notes(airline_row)" src="/adminweb/assets/images/important-notes/delay_30.png" alt="">
<img class="mr-2" *ngIf="getDelayNotes(airline_row)" src="/adminweb/assets/images/important-notes/delay.png" alt="">
<img class="mr-2" *ngIf="getReturnNotes(airline_row)" src="/adminweb/assets/images/important-notes/return.png" alt="">
<img class="mr-2" *ngIf="getCancleNotes(airline_row)" src="/adminweb/assets/images/important-notes/cancle.png" alt="">
<img class="mr-2" *ngIf="getStopoverNotes(airline_row)" src="/adminweb/assets/images/important-notes/stopover.png" alt="">
</td>
<td *ngFor="let airline_col of render_col_lists" [ngClass]="getPosition(airline_col.COL_CODE,airline_row)"
[ngStyle]="getColor(airline_col.COL_CODE,airline_row)">{{airline_row['renderFlight'][airline_col.COL_CODE]}}</td>
+33 -15
View File
@@ -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<any> = [];
//各项基础数据
public flightAgents: Array<any>;
public flightTypes: Array<any>;
public terminals: Array<any>;
public flightStatus: Array<any>;
@@ -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
)