1103 lines
42 KiB
TypeScript
1103 lines
42 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ChangeDetectorRef } from '@angular/core';
|
|
|
|
import { ToastService } from '../../components/toast/toast.service';
|
|
import { ToastConfig, ToastType } from '../../components/toast/toast-model';
|
|
|
|
import { HttpClientService } from '../../services/http-client.service';
|
|
import { BasicDataService } from '../basic-data-service';
|
|
import { OperateSpinServiceService } from '../operate-spin-service.service';
|
|
import { WebsocketService } from '../../services/websocket.service';
|
|
|
|
import dateFormatter from '../../utils/data-formatter';
|
|
import timeFormatter from '../../utils/time-formatter';
|
|
|
|
import gctmFormatter from '../../utils/gctm-formatter';
|
|
import botmFormatter from '../../utils/botm-formatter';
|
|
import abdgFormatter from '../../utils/abdg-formatter';
|
|
import aotm_aFormatter from '../../utils/aotm_a-formatter';
|
|
import aotm_dFormatter from '../../utils/aotm_d-formatter';
|
|
import beltFormatter from '../../utils/belt-formatter';
|
|
import chkcFormatter from '../../utils/chkc-formatter';
|
|
import cctmFormatter from '../../utils/cctm-formatter';
|
|
import cotmFormatter from '../../utils/cotm-formatter';
|
|
import chtmOnFormatter from '../../utils/chtm_on-formatter';
|
|
import chtmOffFormatter from '../../utils/chtm_off-formatter';
|
|
import laclFormatter from '../../utils/lacl-formatter';
|
|
import chutFormatter from '../../utils/chut-formatter';
|
|
import acttFormatter from '../../utils/actt-formatter';
|
|
import psstFormatter from '../../utils/psst-formatter';
|
|
import esttFormatter from '../../utils/estt-formatter';
|
|
import mvinFormatter from '../../utils/mvin-formatter';
|
|
import erutFormatter from '../../utils/erut-formatter';
|
|
import flinFormatter from '../../utils/flin-formatter';
|
|
import sodtFormatter from '../../utils/sodt-formatter';
|
|
import gateFormatter from '../../utils/gate-formatter';
|
|
import padtFormatter from '../../utils/padt-formatter';
|
|
|
|
|
|
import * as $ from 'jquery';
|
|
@Component({
|
|
selector: 'app-main',
|
|
templateUrl: './main.component.html',
|
|
styleUrls: ['./main.component.scss']
|
|
})
|
|
export class MainComponent implements OnInit {
|
|
|
|
constructor(
|
|
private basicDataService: BasicDataService,
|
|
// private operateSpinServiceService:OperateSpinServiceService,
|
|
private httpCilent: HttpClientService,
|
|
private changeDetectorRef: ChangeDetectorRef,
|
|
private toastService: ToastService,
|
|
private websocketService: WebsocketService
|
|
) {
|
|
console.log(new Date().getTime())
|
|
}
|
|
public tabClose: boolean = true;
|
|
public isSpinning: boolean = true;
|
|
|
|
//各项基础数据
|
|
public terminals: Array<any>;
|
|
public flightStatus: Array<any>;
|
|
public airports: Array<any>;
|
|
public citys: Array<any>;;
|
|
public airlines: Array<any>;
|
|
|
|
public raw_data: Array<object> = []; //原始数据,即航班计划
|
|
public combined_data: Array<object> = []; //组合数据,即链接航班,显示信息等组合好之后的数据
|
|
public render_data: Array<object> = []; //显示数据,即需要显示的数据
|
|
|
|
public col_lists: Array<object>; //列数据
|
|
public airline_color: Array<object> = [];
|
|
public row_state: any = { renderFlight: {} };
|
|
|
|
|
|
|
|
public checkboxGroup = {
|
|
'related': false,
|
|
'detail': false,
|
|
'vip': false,
|
|
'special': false,
|
|
'guarantee': false
|
|
}
|
|
|
|
public formatter = {
|
|
'GCTM': gctmFormatter,
|
|
'BOTM': botmFormatter,
|
|
'ABDG': abdgFormatter,
|
|
'AOTM_A': aotm_aFormatter,
|
|
'AOTM_D': aotm_dFormatter,
|
|
'BELT': beltFormatter,
|
|
'CHKC': chkcFormatter,
|
|
'CCTM': cctmFormatter,
|
|
'COTM': cotmFormatter,
|
|
'CHTM_ON': chtmOnFormatter,
|
|
'CHTM_OFF': chtmOffFormatter,
|
|
'LACL': laclFormatter,
|
|
'CHUT': chutFormatter,
|
|
'ACTT': acttFormatter,
|
|
'PSST': psstFormatter,
|
|
'ESTT': esttFormatter,
|
|
'MVIN': mvinFormatter,
|
|
'ERUT': erutFormatter,
|
|
'FLIN': flinFormatter,
|
|
'SODT': sodtFormatter,
|
|
'GATE': gateFormatter,
|
|
'PADT': padtFormatter
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.websocketService.dynamicsMessage().subscribe(
|
|
event => {
|
|
console.log(event);
|
|
}
|
|
)
|
|
// this.getBasicData()
|
|
this.changeDetectorRef.detach();
|
|
/* 获取显示列 */
|
|
this.httpCilent.get('/assets/mock-data/airline-col_code.json').subscribe(
|
|
data => {
|
|
data.sort(function (a, b) {
|
|
return (a['COL_ORDER'] - b['COL_ORDER']);
|
|
})
|
|
this.col_lists = data;
|
|
}
|
|
)
|
|
/* 获取航班动态信息 */
|
|
this.httpCilent.get('/assets/mock-data/airline-data.json').subscribe(
|
|
data => {
|
|
//解析数据
|
|
data.forEach(element => {
|
|
this.raw_data.push(JSON.parse(element.value));
|
|
});
|
|
|
|
let combined_linked_data = this.raw_data;
|
|
//查找链接航班并将其组合成一条数据
|
|
for (let i = 0; i < combined_linked_data.length; i++) {
|
|
if (combined_linked_data[i]['MVIN'] === 'D') {
|
|
if (combined_linked_data[i]['TAID']) {
|
|
let index = combined_linked_data.findIndex(val => { return val['FLID'] === combined_linked_data[i]['TAID'] });
|
|
if (index > -1) {
|
|
combined_linked_data[i]['isLinked'] = true;
|
|
combined_linked_data[i]['linkFlight'] = combined_linked_data[index];
|
|
combined_linked_data.splice(index, 1);
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
combined_linked_data.forEach(element => {
|
|
let row_flights = {};
|
|
let render_flight = {};
|
|
let render_pre_flight = {};
|
|
let render_rea_flight = {};
|
|
if (element['MVIN'] === 'A' && !element['isLinked']) {
|
|
row_flights['preFlight'] = element;
|
|
|
|
for (let i = 0; i < this.col_lists.length; i++) {
|
|
let key = this.col_lists[i]['COL_CODE']
|
|
render_flight[key] = this.formatter.hasOwnProperty(key) ? this.formatter[key](row_flights['preFlight']) : row_flights['preFlight'][key];
|
|
}
|
|
row_flights['renderFlight'] = render_flight;
|
|
|
|
} else if (element['MVIN'] === 'D' && !element['isLinked']) {
|
|
row_flights['reaFlight'] = element;
|
|
for (let i = 0; i < this.col_lists.length; i++) {
|
|
let key = this.col_lists[i]['COL_CODE']
|
|
render_flight[key] = this.formatter.hasOwnProperty(key) ? this.formatter[key](row_flights['reaFlight']) : row_flights['reaFlight'][key];
|
|
}
|
|
row_flights['renderFlight'] = render_flight;
|
|
|
|
} else if (element['isLinked']) {
|
|
row_flights['preFlight'] = element['linkFlight'];
|
|
delete element['linkFlight'];
|
|
delete element['isLinked'];
|
|
row_flights['reaFlight'] = element;
|
|
|
|
for (let i = 0; i < this.col_lists.length; i++) {
|
|
let key = this.col_lists[i]['COL_CODE']
|
|
if (this.formatter.hasOwnProperty(key)) {
|
|
let preHasValue = this.formatter[key](row_flights['preFlight']);
|
|
let reaHasValue = this.formatter[key](row_flights['reaFlight']);
|
|
if (preHasValue && !reaHasValue) {
|
|
if (key === 'SODT' || key === 'ESTT' || key === 'ACTT') {
|
|
render_flight[key] = preHasValue + ' / '
|
|
} else {
|
|
render_flight[key] = preHasValue;
|
|
}
|
|
} else if (!preHasValue && reaHasValue) {
|
|
if (key === 'SODT' || key === 'ESTT' || key === 'ACTT') {
|
|
render_flight[key] = ' / ' + reaHasValue
|
|
} else {
|
|
render_flight[key] = reaHasValue;
|
|
}
|
|
// render_flight[key] = reaHasValue;
|
|
} else if (preHasValue && reaHasValue) {
|
|
if (preHasValue === reaHasValue) {
|
|
render_flight[key] = preHasValue
|
|
} else {
|
|
if (key === 'ERUT') {
|
|
render_flight[key] = preHasValue.split(' - ').slice(0, -1).join(' - ') + ' - ' + reaHasValue;
|
|
} else {
|
|
render_flight[key] = preHasValue + ' / ' + reaHasValue;
|
|
}
|
|
// render_flight[key] = preHasValue + ' / ' + reaHasValue;
|
|
}
|
|
} else {
|
|
render_flight[key] = '';
|
|
}
|
|
render_pre_flight[key] = preHasValue;
|
|
render_rea_flight[key] = reaHasValue;
|
|
} else {
|
|
let preHasValue = row_flights['preFlight'][key];
|
|
let reaHasValue = row_flights['reaFlight'][key]
|
|
if (preHasValue && !reaHasValue) {
|
|
if (key === 'SODT' || key === 'ESTT' || key === 'ACTT') {
|
|
render_flight[key] = preHasValue + ' / '
|
|
} else {
|
|
render_flight[key] = preHasValue;
|
|
}
|
|
} else if (!preHasValue && reaHasValue) {
|
|
if (key === 'SODT' || key === 'ESTT' || key === 'ACTT') {
|
|
render_flight[key] = ' / ' + reaHasValue
|
|
} else {
|
|
render_flight[key] = reaHasValue;
|
|
}
|
|
} else if (preHasValue && reaHasValue) {
|
|
if (preHasValue === reaHasValue) {
|
|
render_flight[key] = preHasValue
|
|
} else {
|
|
render_flight[key] = preHasValue + ' / ' + reaHasValue;
|
|
}
|
|
} else {
|
|
render_flight[key] = '';
|
|
}
|
|
// render_flight[key] = (row_flights['preFlight'][key] + '/' + row_flights['reaFlight'][key]);
|
|
render_pre_flight[key] = preHasValue;
|
|
render_rea_flight[key] = reaHasValue;
|
|
}
|
|
}
|
|
row_flights['renderFlight'] = render_flight;
|
|
row_flights['renderPreFlight'] = render_pre_flight;
|
|
row_flights['renderReaFlight'] = render_rea_flight;
|
|
}
|
|
this.combined_data.push(row_flights)
|
|
})
|
|
|
|
//从基础数据服务中拿出部分基础数据
|
|
this.terminals = this.basicDataService.terminal;
|
|
this.flightStatus = this.basicDataService.flightStatus;
|
|
this.airlines = this.basicDataService.airline;
|
|
this.citys = this.basicDataService.city;
|
|
this.airports = this.basicDataService.airport;
|
|
|
|
if (this.airports && this.airports.length > 0) {
|
|
this.basicDataTransHandle();
|
|
} else {
|
|
setTimeout(() => {
|
|
if (this.airports && this.airports.length > 0) {
|
|
|
|
} else {
|
|
const toastCfg = new ToastConfig(ToastType.ERROR, '', '基础数据获取失败!', 3000);
|
|
this.toastService.toast(toastCfg);
|
|
this.doSequence(this.combined_data);
|
|
}
|
|
}, 5000);
|
|
this.basicDataService.terminal_subject.subscribe(
|
|
val => this.terminals = val
|
|
)
|
|
this.basicDataService.flightStatus_subject.subscribe(
|
|
val => this.flightStatus = val
|
|
);
|
|
this.basicDataService.airline_subject.subscribe(
|
|
val => this.airlines = val
|
|
);
|
|
this.basicDataService.city_subject.subscribe(
|
|
val => this.citys = val
|
|
);
|
|
this.basicDataService.airport_subject.subscribe(
|
|
val => {
|
|
this.airports = val;
|
|
this.basicDataTransHandle();
|
|
}
|
|
);
|
|
}
|
|
|
|
}
|
|
)
|
|
|
|
/**
|
|
* 固定表头
|
|
*/
|
|
var tableCont = document.querySelector('#table-container')
|
|
function scrollHandle() {
|
|
var scrollTop = this.scrollTop;
|
|
this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
|
|
}
|
|
tableCont.addEventListener('scroll', scrollHandle)
|
|
}
|
|
|
|
/**
|
|
* 基础数据转换
|
|
*/
|
|
basicDataTransHandle() {
|
|
this.combined_data.forEach(item => {
|
|
if (this.isArriFlight(item) || this.isDeptFlight(item)) {
|
|
//航线处理
|
|
let erutCodeArray = item['renderFlight']['ERUT'].split(' - ');
|
|
let erutChnArray = []
|
|
for (let i = 0; i < erutCodeArray.length; i++) {
|
|
try {
|
|
let airportIndex = this.airports.findIndex(val => val.airportCodeIata === erutCodeArray[i]);
|
|
let cityIndex = this.citys.findIndex(val => this.airports[airportIndex].cityId === val.cityId);
|
|
erutChnArray.push(this.citys[cityIndex].cityNameChn);
|
|
} catch (error) {
|
|
erutChnArray.push(erutCodeArray[i]);
|
|
}
|
|
}
|
|
item['renderFlight']['ERUT'] = erutChnArray.join(' - ');
|
|
//航空公司处理
|
|
let airlineIndex = this.airlines.findIndex(val => val.airlineCode === item['renderFlight']['ALCD']);
|
|
item['renderFlight']['ALCD'] = this.airlines[airlineIndex].airlineName;
|
|
//运营状态处理
|
|
item['renderFlight']['FTSS'] = this.flightStatus.find(val => val.sttc === item['renderFlight']['FTSS']).stdc
|
|
} else {
|
|
//航线处理
|
|
let erutLinkCodeArray = item['renderFlight']['ERUT'].split(' - ');
|
|
let erutLinkChnArray = []
|
|
for (let i = 0; i < erutLinkCodeArray.length; i++) {
|
|
try {
|
|
let airportIndex = this.airports.findIndex(val => val.airportCodeIata === erutLinkCodeArray[i]);
|
|
let cityIndex = this.citys.findIndex(val => this.airports[airportIndex].cityId === val.cityId);
|
|
erutLinkChnArray.push(this.citys[cityIndex].cityNameChn);
|
|
} catch (error) {
|
|
erutLinkChnArray.push(erutLinkCodeArray[i]);
|
|
}
|
|
}
|
|
item['renderFlight']['ERUT'] = erutLinkChnArray.join(' - ');
|
|
//航空公司处理
|
|
let airlineLinkIndex = this.airlines.findIndex(val => val.airlineCode === item['renderFlight']['ALCD']);
|
|
item['renderFlight']['ALCD'] = this.airlines[airlineLinkIndex].airlineName;
|
|
//运营状态处理
|
|
let ftssLinkCodeArray = item['renderFlight']['FTSS'].split(' / ');
|
|
let ftssChnArray = [];
|
|
for (let i = 0; i < ftssLinkCodeArray.length; i++) {
|
|
ftssChnArray.push(this.flightStatus.find(val => val.sttc === ftssLinkCodeArray[i]).stdc)
|
|
}
|
|
item['renderFlight']['FTSS'] = ftssChnArray.join(' / ');
|
|
|
|
//航线处理
|
|
let erutPreCodeArray = item['renderPreFlight']['ERUT'].split(' - ');
|
|
let erutPreChnArray = []
|
|
for (let i = 0; i < erutPreCodeArray.length; i++) {
|
|
try {
|
|
let airportIndex = this.airports.findIndex(val => val.airportCodeIata === erutPreCodeArray[i]);
|
|
let cityIndex = this.citys.findIndex(val => this.airports[airportIndex].cityId === val.cityId);
|
|
erutPreChnArray.push(this.citys[cityIndex].cityNameChn);
|
|
} catch (error) {
|
|
erutPreChnArray.push(erutPreCodeArray[i]);
|
|
}
|
|
}
|
|
item['renderPreFlight']['ERUT'] = erutPreChnArray.join(' - ');
|
|
//航空公司处理
|
|
let airlinePreIndex = this.airlines.findIndex(val => val.airlineCode === item['renderPreFlight']['ALCD']);
|
|
item['renderPreFlight']['ALCD'] = this.airlines[airlinePreIndex].airlineName;
|
|
//运营状态处理
|
|
item['renderPreFlight']['FTSS'] = this.flightStatus.find(val => val.sttc === item['renderPreFlight']['FTSS']).stdc
|
|
|
|
//航线处理
|
|
let erutReaCodeArray = item['renderReaFlight']['ERUT'].split(' - ');
|
|
let erutReaChnArray = []
|
|
for (let i = 0; i < erutReaCodeArray.length; i++) {
|
|
try {
|
|
let airportIndex = this.airports.findIndex(val => val.airportCodeIata === erutReaCodeArray[i]);
|
|
let cityIndex = this.citys.findIndex(val => this.airports[airportIndex].cityId === val.cityId);
|
|
erutReaChnArray.push(this.citys[cityIndex].cityNameChn);
|
|
} catch (error) {
|
|
erutReaChnArray.push(erutReaCodeArray[i]);
|
|
}
|
|
}
|
|
item['renderReaFlight']['ERUT'] = erutReaChnArray.join(' - ');
|
|
//航空公司处理
|
|
let airlineReaIndex = this.airlines.findIndex(val => val.airlineCode === item['renderReaFlight']['ALCD']);
|
|
item['renderReaFlight']['ALCD'] = this.airlines[airlineReaIndex].airlineName;
|
|
//运营状态处理
|
|
item['renderReaFlight']['FTSS'] = this.flightStatus.find(val => val.sttc === item['renderReaFlight']['FTSS']).stdc
|
|
}
|
|
});
|
|
this.doSequence(this.combined_data);
|
|
}
|
|
|
|
|
|
/**
|
|
* 执行排序并渲染
|
|
*/
|
|
doSequence(sequenceData) {
|
|
sequenceData.forEach(element => {
|
|
element['ORDER'] = this.sequence(element);
|
|
})
|
|
|
|
sequenceData.sort(function (a, b) {
|
|
return (a['ORDER'] - b['ORDER']);
|
|
})
|
|
|
|
this.render_data = sequenceData;
|
|
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
|
|
console.log(new Date().getTime() + '---');
|
|
this.changeDetectorRef.detectChanges();
|
|
console.log(new Date().getTime() + '---');
|
|
|
|
}
|
|
|
|
/**
|
|
* 复选框勾选事件
|
|
*/
|
|
checkboxChange() {
|
|
for (const key in this.checkboxGroup) {
|
|
if (this.checkboxGroup.hasOwnProperty(key)) {
|
|
if (this.checkboxGroup[key]) {
|
|
this.tabClose = false;
|
|
break;
|
|
} else {
|
|
this.tabClose = true;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
this.changeDetectorRef.detectChanges()
|
|
}
|
|
|
|
/**
|
|
* tab项切换事件
|
|
*/
|
|
nzClick() {
|
|
this.changeDetectorRef.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* 刷新
|
|
*/
|
|
refresh() {
|
|
this.render_data.reverse();
|
|
console.log('=====');
|
|
this.changeDetectorRef.detectChanges();
|
|
console.log('-----');
|
|
}
|
|
|
|
|
|
/**
|
|
* 过滤及定位
|
|
* @param filterItems
|
|
* @return
|
|
*/
|
|
SEARCH = ''; //手动输入条件
|
|
FLT_POS = 1; //过滤还是定位
|
|
SEL_COL = ''; //选择列名
|
|
public filterItems = {
|
|
ALCD: '', //航空公司
|
|
FLIN: '', //航线类别
|
|
FLTY: '', //航班类别
|
|
MVIN: '', //到达/出发
|
|
FTSS: '',
|
|
TRML: '', //航站楼
|
|
FHAG: '', //机坪代理
|
|
MHAG: '', //维护代理
|
|
PHAG: '', //旅客代理
|
|
}
|
|
|
|
/**
|
|
* 输入框回车事件
|
|
*/
|
|
inputEnter() {
|
|
if (this.FLT_POS === 1) {
|
|
this.selectChange()
|
|
} else {
|
|
// this.selectChange()
|
|
this.inputPosition(this.render_data)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 下拉框选择筛选
|
|
*/
|
|
selectChange() {
|
|
// this.operateSpinServiceService.showSpin()
|
|
let filter_data = [];
|
|
let filterItems = this.filterItems;
|
|
this.combined_data.forEach(item => {
|
|
filter_data.push(Object.assign({}, item));
|
|
})
|
|
//下拉框筛选
|
|
filter_data = filter_data.filter(item => {
|
|
if (this.isArriFlight(item)) {
|
|
let is_satis = true;
|
|
for (const key in filterItems) {
|
|
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
|
|
if (item['preFlight'][key] === filterItems[key]) {
|
|
is_satis = true;
|
|
continue;
|
|
} else {
|
|
is_satis = false;
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
return is_satis;
|
|
} else if (this.isDeptFlight(item)) {
|
|
let is_satis = true;
|
|
for (const key in filterItems) {
|
|
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
|
|
if (item['reaFlight'][key] === filterItems[key]) {
|
|
is_satis = true;
|
|
continue;
|
|
} else {
|
|
is_satis = false;
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
return is_satis;
|
|
} else {
|
|
let pre_satis = true;
|
|
let rea_satis = true;
|
|
for (const key in filterItems) {
|
|
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
|
|
if (item['preFlight'][key] === filterItems[key]) {
|
|
pre_satis = true;
|
|
continue;
|
|
} else {
|
|
pre_satis = false;
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
for (const key in filterItems) {
|
|
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
|
|
if (item['reaFlight'][key] === filterItems[key]) {
|
|
rea_satis = true;
|
|
continue;
|
|
} else {
|
|
rea_satis = false;
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if (pre_satis && !rea_satis) {
|
|
item['renderFlight'] = item['renderPreFlight'];
|
|
return pre_satis;
|
|
} else if (!pre_satis && rea_satis) {
|
|
item['renderFlight'] = item['renderReaFlight'];
|
|
return rea_satis;
|
|
} else if (pre_satis && rea_satis) {
|
|
return pre_satis && rea_satis;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
})
|
|
if (this.FLT_POS === 1) {
|
|
this.inputFilter(filter_data);
|
|
} else {
|
|
this.render_data = filter_data;
|
|
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
|
|
this.changeDetectorRef.detectChanges();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 输入框筛选
|
|
* @param filterData
|
|
*/
|
|
inputFilter(filterData) {
|
|
if (this.SEARCH) {
|
|
if (this.SEL_COL) {
|
|
let sel_col = this.SEL_COL;
|
|
filterData = filterData.filter(item => {
|
|
if (item['renderFlight'][sel_col]) {
|
|
if (item['renderFlight'][sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) {
|
|
return true;
|
|
}
|
|
} else {
|
|
if (this.SEARCH) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
})
|
|
|
|
} else {
|
|
filterData = filterData.filter(item => {
|
|
let is_satis = false;
|
|
for (const key in item['renderFlight']) {
|
|
if (item['renderFlight'].hasOwnProperty(key)) {
|
|
if (item['renderFlight'][key]) {
|
|
if (item['renderFlight'][key].toString().match(new RegExp(this.SEARCH, 'i'))) {
|
|
is_satis = true;
|
|
break;
|
|
} else {
|
|
is_satis = false;
|
|
continue;
|
|
}
|
|
} else {
|
|
if (this.SEARCH) {
|
|
is_satis = false;
|
|
continue;
|
|
} else {
|
|
is_satis = true;
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
continue;
|
|
}
|
|
}
|
|
return is_satis;
|
|
})
|
|
}
|
|
}
|
|
this.render_data = filterData;
|
|
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
|
|
this.changeDetectorRef.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* 输入框定位
|
|
*/
|
|
positionArray: Array<any> = [];
|
|
positionArrayIndex: number = 0;
|
|
|
|
inputPosition(filterData) {
|
|
let transArray = []
|
|
if (this.SEL_COL) {
|
|
let sel_col = this.SEL_COL;
|
|
filterData.forEach(element => {
|
|
if (element['renderFlight'][sel_col]) {
|
|
if (element['renderFlight'][sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) {
|
|
transArray.push(element)
|
|
}
|
|
} else {
|
|
if (!this.SEARCH) {
|
|
transArray.push(element)
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
filterData.forEach(element => {
|
|
for (const key in element['renderFlight']) {
|
|
if (element['renderFlight'].hasOwnProperty(key)) {
|
|
if (element['renderFlight'][key]) {
|
|
if (element['renderFlight'][key].toString().match(new RegExp(this.SEARCH, 'i'))) {
|
|
transArray.push(element)
|
|
break;
|
|
} else {
|
|
continue;
|
|
}
|
|
} else {
|
|
if (this.SEARCH) {
|
|
continue;
|
|
} else {
|
|
transArray.push(element)
|
|
break;
|
|
}
|
|
}
|
|
|
|
} else {
|
|
continue;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
if (transArray.length > 0) {
|
|
if (transArray.toString() == this.positionArray.toString()) {
|
|
this.positionArrayIndex++;
|
|
if (this.positionArrayIndex === this.positionArray.length) {
|
|
this.positionArrayIndex = 0;
|
|
}
|
|
this.row_state = this.positionArray[this.positionArrayIndex];
|
|
} else {
|
|
this.positionArray = transArray;
|
|
this.positionArrayIndex = 0;
|
|
this.row_state = this.positionArray[this.positionArrayIndex];
|
|
}
|
|
} else {
|
|
alert('没有搜索到相关数据');
|
|
}
|
|
|
|
this.changeDetectorRef.detectChanges();
|
|
|
|
let tr = $(".selected");
|
|
let objTr = tr[0];
|
|
$("#table-container").animate({ scrollTop: objTr.offsetTop - 42 }, "slow");
|
|
}
|
|
|
|
/**
|
|
* 行排序规则方法
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public TOP_1 = 1000000000000;
|
|
public TOP_2 = 2000000000000;
|
|
public TOP_3 = 3000000000000;
|
|
public TOP_4 = 4000000000000;
|
|
public TOP_5 = 5000000000000;
|
|
public TOP_6 = 6000000000000;
|
|
public TOP_7 = 7000000000000;
|
|
public TOP_8 = 8000000000000;
|
|
public TOP_9 = 9000000000000;
|
|
public TOP_10 = 10000000000000;
|
|
public TOP_11 = 11000000000000;
|
|
public TOP_12 = 12000000000000;
|
|
public TOP_13 = 13000000000000;
|
|
public TOP_14 = 14000000000000;
|
|
|
|
public sequence(flight) {
|
|
let dateTag: number = 10;
|
|
let dateToCompare = new Date().getTime();
|
|
if (!this.isCancled(flight) && !this.isDone(flight) && this.isDelayed(flight)) {
|
|
if (this.isLinked(flight)) {
|
|
if (this.getActualDatetime(flight['preFlight']) && !this.getActualDatetime(flight['reaFlight'])) {
|
|
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['preFlight']))).getTime();
|
|
dateTag = this.TOP_1;
|
|
}
|
|
else {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
|
dateTag = this.TOP_2;
|
|
}
|
|
}
|
|
else {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
|
dateTag = this.TOP_3;
|
|
}
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (!this.isCancled(flight) && !this.isDone(flight) && this.isBoading(flight)) {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
|
dateTag = this.TOP_4;
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (!this.isCancled(flight) && !this.isDone(flight) && this.isFlying(flight) && !this.getActualDatetime(flight['preFlight'])) {
|
|
if (this.getEstimatedDatetime(flight['preFlight'])) {
|
|
dateToCompare = new Date(dateFormatter(this.getEstimatedDatetime(flight['preFlight']))).getTime();
|
|
} else {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['preFlight']))).getTime();
|
|
}
|
|
dateTag = this.TOP_5;
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (!this.isCancled(flight) && !this.isDone(flight) && this.isLinked(flight) && this.getActualDatetime(flight['preFlight']) && !this.getActualDatetime(flight['reaFlight'])) {
|
|
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['preFlight']))).getTime();
|
|
dateTag = this.TOP_6;
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (!this.isCancled(flight) && !this.isDone(flight) && this.isDeptFlight(flight) && !this.startBoading(flight)) {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
|
dateTag = this.TOP_7;
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (!this.isCancled(flight) && this.isArriFlight(flight) && this.isDone(flight)) {
|
|
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['preFlight']))).getTime();
|
|
dateTag = this.TOP_8;
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (!this.isCancled(flight) && !this.isDone(flight) && this.isOverBoading(flight)) {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
|
dateTag = this.TOP_9;
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (!this.isCancled(flight) && !this.isDone(flight) && !this.isFlying(flight)) {
|
|
if (this.isLinked(flight)) {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
|
dateTag = this.TOP_10;
|
|
} else if (this.isArriFlight(flight)) {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['preFlight']))).getTime();
|
|
dateTag = this.TOP_11;
|
|
}
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (!this.isCancled(flight) && this.isDone(flight) && (this.isLinked(flight) || this.isDeptFlight(flight))) {
|
|
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['reaFlight']))).getTime();
|
|
dateTag = this.TOP_12;
|
|
return dateToCompare + dateTag;
|
|
}
|
|
if (this.isCancled(flight)) {
|
|
if (this.isDeptFlight(flight)) {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
|
} else {
|
|
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['preFlight']))).getTime();
|
|
}
|
|
|
|
dateTag = this.TOP_13;
|
|
return dateToCompare + dateTag;
|
|
}
|
|
return this.TOP_14
|
|
}
|
|
|
|
/**
|
|
* 获取航班实际时间
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public getActualDatetime(flight) {
|
|
return flight['ACTT'];
|
|
}
|
|
|
|
/**
|
|
* 获取航班预计时间
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public getEstimatedDatetime(flight) {
|
|
return flight['ESTT']
|
|
}
|
|
|
|
/**
|
|
* 获取航班计划时间
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public getScheduledDatetime(flight) {
|
|
return flight['SODT']
|
|
}
|
|
|
|
|
|
/**
|
|
* 判断航班是否是链接航班
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isLinked(flight) {
|
|
if (flight['preFlight'] && flight['reaFlight']) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 判断航班是否是纯离港航班
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isDeptFlight(flight) {
|
|
if (!flight['preFlight'] && flight['reaFlight']) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 判断航班是否是纯到港航班
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isArriFlight(flight) {
|
|
if (flight['preFlight'] && !flight['reaFlight']) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 判断航班是否已经前站起飞
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isFlying(flight) {
|
|
if (this.isArriFlight(flight) || this.isLinked(flight)) {
|
|
if (flight['preFlight']['PADT']) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 判断航班是否取消
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isCancled(flight) {
|
|
if (this.isArriFlight(flight)) {
|
|
if (flight['preFlight']['CNCL']) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else if (this.isDeptFlight(flight)) {
|
|
if (flight['reaFlight']['CNCL']) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 判断航班是否延误(只针对纯离港航班或链接航班中的离港航班)
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isDelayed(flight) {
|
|
if (this.isDeptFlight(flight) || this.isLinked(flight)) {
|
|
if (flight['reaFlight']['DELY']) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 判断航班是否已经执行完成
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isDone(flight) {
|
|
if (this.isLinked(flight) || this.isDeptFlight(flight)) {
|
|
if (!this.getActualDatetime(flight['reaFlight'])) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
} else if (this.isArriFlight(flight)) {
|
|
if (!this.getActualDatetime(flight['preFlight'])) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 判断航班是否开始登机
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public startBoading(flight) {
|
|
if (this.isLinked(flight) || this.isDeptFlight(flight)) {
|
|
if (!flight['reaFlight']['BOTM']) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 判断航班是否正在登机中
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isBoading(flight) {
|
|
if (this.isLinked(flight) || this.isDeptFlight(flight)) {
|
|
if (flight['reaFlight']['BOTM'] && !(flight['reaFlight']['GTDT']['GCTM'])) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 判断航班是否登机结束
|
|
* @param flight
|
|
* @return
|
|
*/
|
|
public isOverBoading(flight) {
|
|
if (this.isLinked(flight) || this.isDeptFlight(flight)) {
|
|
if (flight['reaFlight']['GTDT'] && flight['reaFlight']['GTDT']['GCTM']) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 选中某行
|
|
* @param i
|
|
*/
|
|
selectRow(i) {
|
|
this.row_state = i;
|
|
this.changeDetectorRef.detectChanges();
|
|
}
|
|
|
|
/**
|
|
* 获取当前单元格颜色
|
|
* @param col_CODE
|
|
*/
|
|
getColor(col_CODE, flight) {
|
|
if (this.isArriFlight(flight)) {
|
|
if (col_CODE === 'SODT') {
|
|
if (flight['preFlight']['SODT']) {
|
|
if (!flight['preFlight']['ESTT'] && !flight['preFlight']['ACTT']) {
|
|
return 'rgb(0,255,255)';
|
|
} else {
|
|
return null;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
} else if (col_CODE === 'ESTT') {
|
|
if (flight['preFlight']['ESTT']) {
|
|
if (!flight['preFlight']['ACTT']) {
|
|
return 'rgb(255,207,156)';
|
|
} else {
|
|
return null;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
} else if (col_CODE === 'ACTT') {
|
|
if (flight['preFlight']['ACTT']) {
|
|
return 'rgb(148,207,255)';
|
|
} else {
|
|
return null;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
|
|
} else {
|
|
if (col_CODE === 'SODT') {
|
|
if (flight['reaFlight']['SODT']) {
|
|
if (!flight['reaFlight']['ESTT'] && !flight['reaFlight']['ACTT']) {
|
|
return 'rgb(0,255,255)';
|
|
} else {
|
|
return null;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
} else if (col_CODE === 'ESTT') {
|
|
if (flight['reaFlight']['ESTT']) {
|
|
if (!flight['reaFlight']['ACTT']) {
|
|
return 'rgb(255,207,156)';
|
|
} else {
|
|
return null;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
} else if (col_CODE === 'ACTT') {
|
|
if (flight['reaFlight']['ACTT']) {
|
|
return 'rgb(148,207,255)';
|
|
} else {
|
|
return null;
|
|
}
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 单元格内容居左居右
|
|
* @param col_CODE
|
|
* @param flight
|
|
*/
|
|
getPosition(col_CODE, flight) {
|
|
if (this.isDeptFlight(flight)) {
|
|
if (col_CODE === 'FLNO' || col_CODE === 'SODT' || col_CODE === 'ESTT' || col_CODE === 'ACTT') {
|
|
return 'text-right';
|
|
}
|
|
} else if (this.isLinked(flight)) {
|
|
if (col_CODE === 'SODT' || col_CODE === 'ESTT' || col_CODE === 'ACTT') {
|
|
if (!flight['renderPreFlight'][col_CODE] && flight['renderReaFlight'][col_CODE]) {
|
|
return 'text-right';
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
} |