diff --git a/src/app/pages/main/main.component.html b/src/app/pages/main/main.component.html index 6e1011e..6279839 100644 --- a/src/app/pages/main/main.component.html +++ b/src/app/pages/main/main.component.html @@ -210,7 +210,7 @@
- + diff --git a/src/app/pages/main/related-tab/related-tab.component.html b/src/app/pages/main/related-tab/related-tab.component.html index b2e66a4..25bc545 100644 --- a/src/app/pages/main/related-tab/related-tab.component.html +++ b/src/app/pages/main/related-tab/related-tab.component.html @@ -38,34 +38,50 @@
航班状态记录 -
+

到达航班:{{lines['preFlight']['FLNO']}}

-
- +
+

延误类别:{{predelay.CODE}}

+

延误信息:{{predelay.VALUE}}

+

原定时间:{{predelay.STRT|date:'yyyy-MM-dd HH:mm'}}

+

延误时间:{{predelay.DURA==predelay.STRT?'待定':predelay.DURA|date:'yyyy-MM-dd HH:mm'}}

-
- +
+

取消:(取消时间:{{precancle|date:'yyyy-MM-dd HH:mm'}})

-
- +
+

备降:(备降机场:{{prefdiv.DDES}} 备降原因:{{prefdiv.VALUE}})

-
- +
+

+ 空返:(空返时间:{{xxx}} 空返原因:{{prefret.VALUE}}) +

+

+ 地返:(地返时间:{{xxx}} 地返原因:{{prefret.VALUE}}) +

出发航班:{{lines['reaFlight']['FLNO']}}

-
- +
+

延误类别:{{readelay.CODE||''}}

+

延误信息:{{readelay.VALUE}}

+

原定时间:{{readelay.STRT|date:'yyyy-MM-dd HH:mm'}}

+

延误时间:{{readelay.DURA==readelay.STRT?'待定':readelay.DURA|date:'yyyy-MM-dd HH:mm'}}

-
- +
+

取消:(取消时间:{{reacancle|date:'yyyy-MM-dd HH:mm'}})

-
- +
+

备降:(备降机场:{{reafdiv.DDES}} 备降原因:{{reafdiv.VALUE}})

-
- +
+

+ 空返:(空返时间:{{xxx}} 空返原因:{{reafret.VALUE}}) +

+

+ 地返:(地返时间:{{xxx}} 地返原因:{{reafret.VALUE}}) +

diff --git a/src/app/pages/main/related-tab/related-tab.component.ts b/src/app/pages/main/related-tab/related-tab.component.ts index e0131e7..1b4dd82 100644 --- a/src/app/pages/main/related-tab/related-tab.component.ts +++ b/src/app/pages/main/related-tab/related-tab.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit, Input } from '@angular/core'; import timeFormatter from '../../../utils/time-formatter'; +import dateFormatter from '../../../utils/date-formatter'; @Component({ selector: 'app-related-tab', @@ -8,8 +9,29 @@ import timeFormatter from '../../../utils/time-formatter'; }) export class RelatedTabComponent implements OnInit { public lines; - public airports; + public airports; + public predelay; + public precancle; + public prefdiv; + public prefret; + + public readelay; + public reacancle; + public reafdiv; + public reafret; + + @Input() allAirports; @Input() set flight(flight) { + this.predelay = ''; + this.precancle = ''; + this.prefdiv = ''; + this.prefret = ''; + + this.readelay = ''; + this.reacancle = ''; + this.reafdiv = ''; + this.reafret = ''; + this.lines = Object.assign({}, flight); if (this.lines.preFlight && !this.lines.reaFlight) { this.airports = this.lines.renderFlight.ERUT.split(' - '); @@ -23,7 +45,7 @@ export class RelatedTabComponent implements OnInit { } } else { this.lines.preFlight.ERUT[this.lines.preFlight.ERUT.length - 1]['SCDT'] = this.lines.reaFlight.ERUT[0]['SCDT']; - let concatArray = this.lines.reaFlight.ERUT.slice(1); + let concatArray = this.lines.reaFlight.ERUT.slice(1); let linkAirport = this.lines.preFlight.ERUT.concat(concatArray) this.airports = this.lines.renderFlight.ERUT.split(' - '); for (let i = 0; i < this.airports.length; i++) { @@ -31,6 +53,58 @@ export class RelatedTabComponent implements OnInit { } } + if (this.lines.preFlight && this.lines.preFlight['ABN'] && this.lines.preFlight['ABN'].length > 0) { + let delyIndex = this.lines.preFlight['ABN'].findIndex(ele => ele.TYPE === 'DLY'); + let cancleIndex = this.lines.preFlight['ABN'].findIndex(ele => ele.TYPE === 'CAN'); + let fdivIndex = this.lines.preFlight['ABN'].findIndex(ele => ele.TYPE === 'ALT'); + let fretIndex = this.lines.preFlight['ABN'].findIndex(ele => ele.TYPE === 'RTN'); + + if (delyIndex > -1) { + this.predelay = this.lines.preFlight['ABN'][delyIndex].BODY; + this.predelay['STRT'] = new Date(dateFormatter(this.predelay['STRT'])).getTime(); + this.predelay['DURA'] = parseInt(this.predelay['DURA'].substr(0, 2)) * 3600000 + parseInt(this.predelay['DURA'].substr(2, 3)) * 60000 + this.predelay['STRT'] + } + if (cancleIndex > -1) { + this.precancle = this.lines.preFlight['ABN'][cancleIndex].BODY; + this.precancle = new Date(dateFormatter(this.precancle)).getTime(); + } + if (fdivIndex > -1) { + this.prefdiv = this.lines.preFlight['ABN'][fdivIndex].BODY; + let airportIndex = this.allAirports.findIndex(val => val.airportCodeIata === this.prefdiv.DDES); + if (airportIndex > -1) { + this.prefdiv.DDES = this.allAirports[airportIndex].briefNameChn + } + } + if (fretIndex > -1) { + this.prefret = this.lines.preFlight['ABN'][fretIndex].BODY; + } + } + if (this.lines.reaFlight && this.lines.reaFlight['ABN'] && this.lines.reaFlight['ABN'].length > 0) { + let delyIndex = this.lines.reaFlight['ABN'].findIndex(ele => ele.TYPE === 'DLY'); + let cancleIndex = this.lines.reaFlight['ABN'].findIndex(ele => ele.TYPE === 'CAN'); + let fdivIndex = this.lines.reaFlight['ABN'].findIndex(ele => ele.TYPE === 'ALT'); + let fretIndex = this.lines.reaFlight['ABN'].findIndex(ele => ele.TYPE === 'RTN'); + + if (delyIndex > -1) { + this.readelay = this.lines.reaFlight['ABN'][delyIndex].BODY; + this.readelay['STRT'] = new Date(dateFormatter(this.readelay['STRT'])).getTime(); + this.readelay['DURA'] = parseInt(this.readelay['DURA'].substr(0, 2)) * 3600000 + parseInt(this.readelay['DURA'].substr(2, 3)) * 60000 + this.readelay['STRT']; + } + if (cancleIndex > -1) { + this.reacancle = this.lines.reaFlight['ABN'][cancleIndex].BODY; + this.reacancle = new Date(dateFormatter(this.reacancle)).getTime(); + } + if (fdivIndex > -1) { + this.reafdiv = this.lines.reaFlight['ABN'][fdivIndex].BODY; + let airportIndex = this.allAirports.findIndex(val => val.airportCodeIata === this.reafdiv.DDES); + if (airportIndex > -1) { + this.reafdiv.DDES = this.allAirports[airportIndex].briefNameChn + } + } + if (fretIndex > -1) { + this.reafret = this.lines.reaFlight['ABN'][fretIndex].BODY; + } + } }; constructor() { }