Files
airport-chengdu-web/src/app/pages/main/main.component.ts
T

1556 lines
65 KiB
TypeScript

import { Component, OnInit, ViewChild, Renderer2 } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
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 '../../services/basic-data-service';
import { OperateSpinServiceService } from '../../services/operate-spin-service.service';
import { WebsocketService } from '../../services/websocket.service';
import { FlightOrder } from '../../utils/flight-order';
import { FlightsDataHandle } from '../../utils/flights-data-handle';
import { CellColorHandle } from '../../utils/cell-color-handle';
import { AlertMessageHandle } from '../../utils/alert-message-handle';
import { Utils } from '../../utils/utils';
import * as $ from 'jquery';
import { filter } from 'rxjs/operators';
@Component({
selector: 'app-main',
templateUrl: './main.component.html',
styleUrls: ['./main.component.scss']
})
export class MainComponent implements OnInit {
private toastConfigs: Array<ToastConfig> = [];
constructor(
private router: Router,
private renderer2: Renderer2,
private basicDataService: BasicDataService,
private operateSpinServiceService: OperateSpinServiceService,
private httpCilent: HttpClientService,
private toastService: ToastService,
private websocketService: WebsocketService
) {
this.toastService.getToasts().forEach((config: ToastConfig) => {
console.log(config);
this.toastConfigs.unshift(config);
});
this.toastService.removeToastMainSubject.subscribe((config?: ToastConfig) => {
if (config) {
this.remove(config);
} else {
this.toastConfigs = [];
}
})
this.operateSpinServiceService.showSpin();
this.router.events.pipe(
filter((event => event instanceof NavigationEnd))
).subscribe(
(event: NavigationEnd) => {
if (event.urlAfterRedirects != '/app/main') {
if (this.websocketService.websocket.readyState === 1) {
this.websocketService.websocket.close();
}
}
}
)
}
public orderHandle = new FlightOrder();
public dataHandle = new FlightsDataHandle();
public cellColorHandle = new CellColorHandle();
public alertMessageHandle = new AlertMessageHandle();
public utils = new Utils();
public tabClose: boolean = true;
public canHandleDynamicMessage: boolean = false;
public dynamicMessageArray: Array<any> = [];
public canHandleDynamicAlert: boolean = false;
public dynamicAlertArray: Array<any> = [];
//各项基础数据
public flightStatusDefinitions: Array<any>;
public flightAgents: Array<any>;
public flightTypes: Array<any>;
public terminals: Array<any>;
public flightStatus: Array<any>;
public airports: Array<any>;
public citys: Array<any>;
public airlines: Array<any>;
public airlinesSelections: Array<any> = [];
public flightTypeSelections: Array<any> = [];
public raw_data: Array<object> = []; //原始数据,未经过任何转换和组合
public combined_data: Array<object> = []; //组合数据,即链接航班,显示信息等组合好之后的数据
public wait_render_data: Array<object> = []; //待显示的数据,实际显示从中截取可视区域高度可容纳的数据条数
public render_data: Array<object> = []; //显示数据,即需要显示的数据
public selectedFilterData: Array<object> = [];
public commonCol: Array<object>;
public col_lists: Array<object>; //列数据
public render_col_lists: Array<object>;
public airline_color: Array<object> = [];
public airline_message_alert: Array<object> = [];
public row_state: any = {};
public checkboxGroup = {
'related': false,
'detail': false,
'vip': false,
'special': false,
'guarantee': false
}
@ViewChild('pageContent') pageContent;
@ViewChild('searchFilter') searchFilter;
@ViewChild('tableContainer') tableContainer;
@ViewChild('tabContainer') tabContainer;
@ViewChild('tableHead') tableHead;
@ViewChild('tableBody') tableBody;
@ViewChild('tableContent') tableContent;
trItemHeight: number = 42;
start: number = 0;
end: number = 0;
visibleCount: number = 0;
scrollTop: number = 0;
data = [
'Racing car sprays burning fuel into crowd.',
'Japanese princess to wed commoner.',
'Australian walks 100km after outback crash.',
'Man charged over missing wedding girl.',
'Los Angeles battles huge wildfires.'
];
ngOnInit() {
window.onresize = function () {
this.calcVisibleCount();
}.bind(this)
//订阅航班更新
this.websocketService.dynamicsMessage().subscribe(
event => {
setInterval(() => {
let msg = { "topic": "heart-beat", "message": "" };
this.websocketService.websocket.send(JSON.stringify(msg));
}, 30000);
let data = JSON.parse(event as string);
if (data.topic === 'schd') {
let message = JSON.parse(data.message);
// console.log(message);
//是否可以开始处理动态消息
if (this.canHandleDynamicMessage) {
this.dynamicMessageHandle(message);
} else {
this.dynamicMessageArray.push(message);
}
} else if (data.topic === 'msg') {
let message = JSON.parse(data.message);
// console.log(message);
if (this.canHandleDynamicAlert) {
this.dynamicAlertHandle(message);
} else {
this.dynamicAlertArray.push(message);
}
}
}
)
this.httpCilent.get('/adminapi/settings/uisettings').subscribe(
data => {
this.commonCol = [
{ "COL_CODE": "NO", "COL_CN": "序号", "COL_WIDTH": "55px" },
{ "COL_CODE": "IMPT", "COL_CN": "重要提示", "COL_WIDTH": "120px" },
{ "COL_CODE": "FLID", "COL_CN": "航班ID", "COL_WIDTH": "165px" }
]
data.body.forEach(element => {
if (element.groupCode === 'userSettingCol') {
this.col_lists = JSON.parse(element.settingContent).defaultData;
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 => {
this.raw_data = data.body;
//查找链接航班并将其组合成一条数据
let combined_linked_data = this.dataHandle.findLinkFlights(this.raw_data);
combined_linked_data.forEach(element => {
let flights_item = this.dataHandle.flightsRenderTransfer(element, this.col_lists);
this.combined_data.push(flights_item);
});
//从基础数据服务中拿出部分基础数据
this.flightStatusDefinitions = this.basicDataService.flightStatusDefinitions;
this.flightAgents = this.basicDataService.flightAgents;
this.flightTypes = this.basicDataService.flightTypes;
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) {
let combined_data = []
this.combined_data.forEach(item => {
combined_data.push(this.dataHandle.basicDataTransHandle(item, this.airports, this.citys, this.airlines, this.flightStatus, this.flightTypes));
})
this.combined_data = combined_data;
this.doSequence(this.combined_data);
} else {
this.basicDataService.flightStatusDefinitions_subject.subscribe(
val => this.flightStatusDefinitions = val
)
this.basicDataService.flightAgents_subject.subscribe(
val => this.flightAgents = val
)
this.basicDataService.flightTypes_subject.subscribe(
val => this.flightTypes = val
)
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;
let combined_data = []
this.combined_data.forEach(item => {
combined_data.push(this.dataHandle.basicDataTransHandle(item, this.airports, this.citys, this.airlines, this.flightStatus, this.flightTypes));
})
this.combined_data = combined_data;
this.doSequence(this.combined_data);
}
);
}
}
)
}
)
}
/**
* 数据组合完毕,执行排序、渲染以及动态信息处理
* @param combined_data
*/
doSequence(combined_data) {
this.raw_data.forEach(element => {
if (this.airlinesSelections.findIndex(airline => airline.airlineCodeIata === element['ALCD']) === -1) {
let index = this.airlines.findIndex(val => val.airlineCodeIata === element['ALCD']);
this.airlinesSelections.push(this.airlines[index]);
}
if (this.flightTypeSelections.findIndex(flightType => flightType.flightTypeCode === element['FLTY']) === -1) {
let index = this.flightTypes.findIndex(val => val.flightTypeCode === element['FLTY']);
this.flightTypeSelections.push(this.flightTypes[index]);
}
})
combined_data.forEach(element => {
element['ORDER'] = this.orderHandle.sequence(element);
})
combined_data.sort(function (a, b) {
return (a['ORDER'] - b['ORDER']);
})
//计算可视区域高度,渲染数据
this.wait_render_data = combined_data;
this.selectedFilterData = combined_data;
this.calcVisibleCount()
//默认选中第一条
if (this.render_data.length > 0) {
this.row_state = this.render_data[0];
}
this.operateSpinServiceService.hideSpin();
//开始处理动态消息
this.canHandleDynamicMessage = true;
this.dynamicMessageArray.forEach(message => {
this.dynamicMessageHandle(message);
})
this.dynamicMessageArray = [];
this.canHandleDynamicAlert = true;
this.dynamicAlertArray.forEach(message => {
this.dynamicAlertHandle(message);
})
this.dynamicAlertArray = [];
}
/**
* 设置动态设置单元格的宽度
* @param isLast
*/
setWidth(isLast) {
if (isLast) {
$(".table-body tbody>tr").eq(0).find('td').each((index, element) => {
$(".table-head table thead tr").eq(0).find('th').eq(index).attr('width', $(element).outerWidth() + 'px');
})
if (this.tableBody.nativeElement.scrollHeight <= (this.tableBody.nativeElement.innerHeight || this.tableBody.nativeElement.clientHeight)) {
this.tableHead.nativeElement.style.overflowY = 'auto';
} else {
this.tableHead.nativeElement.style.overflowY = 'scroll';
}
}
return true;
}
/**
* 纵向滚动条滚动渲染数据
*/
handleScroll() {
const scrollTop = this.tableBody.nativeElement.scrollTop;
$(".table-head").scrollLeft($('.table-body').scrollLeft());
const fixedScrollTop = scrollTop - scrollTop % this.trItemHeight;
this.tableContent.nativeElement.style.webkitTransform = `translateY(${fixedScrollTop}px)`;
this.start = Math.floor(scrollTop / this.trItemHeight);
this.end = this.start + this.visibleCount;
this.render_data = this.wait_render_data.slice(this.start, this.end);
}
/**
* 计算可视区域数据的渲染
*/
calcVisibleCount() {
this.renderer2.setStyle(this.tableContainer.nativeElement, 'height', this.pageContent.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 35 + 'px');
this.renderer2.setStyle(this.tableBody.nativeElement, 'height', this.tableContainer.nativeElement.offsetHeight - this.tableHead.nativeElement.offsetHeight + 'px');
if (!this.tabClose) {
this.renderer2.setStyle(this.tabContainer.nativeElement, 'height', this.pageContent.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 35 + 'px');
}
this.visibleCount = Math.ceil(this.tableBody.nativeElement.clientHeight / this.trItemHeight);
const scrollTop = this.tableBody.nativeElement.scrollTop;
const fixedScrollTop = scrollTop - scrollTop % this.trItemHeight;
this.tableContent.nativeElement.style.transform = `translateY(${fixedScrollTop}px)`;
this.start = Math.floor(scrollTop / this.trItemHeight);
this.end = this.start + this.visibleCount;
this.render_data = this.wait_render_data.slice(this.start, this.end);
}
/**
* 展开/关闭过滤条件
*/
public filterClose: boolean = true;
toggleFilter() {
this.filterClose = !this.filterClose;
setTimeout(() => {
this.calcVisibleCount();
}, 10)
}
/**
* 刷新
*/
refresh() {
this.operateSpinServiceService.showSpin();
this.positionedArray = []; //定位数组为清空
this.positionArrayIndex = 0; //定位元素Index归零
this.canHandleDynamicMessage = false;
this.canHandleDynamicAlert = false;
this.SEARCH = ''; //手动输入条件
this.LASTSEARCH = '';
this.FLT_POS = 1; //过滤还是定位
this.SEL_COL = ''; //选择列名
this.LAST_SEL_COL = '';
this.filterItems = {
ALCD: '', //航空公司
FLIN: '', //航线类别
FLTY: '', //航班类别
MVIN: '', //到达/出发
FTSS: '', //运营状态
TRML: '', //航站楼
Abnormal_state: '', //异常状态
FHAG: '', //机坪代理
MHAG: '', //维护代理
PHAG: '', //旅客代理
}
/** 用户设置 */
this.httpCilent.get('/adminapi/settings/uisettings').subscribe(
data => {
data.body.forEach(element => {
if (element.groupCode === 'userSettingCol') {
this.col_lists = JSON.parse(element.settingContent).defaultData;
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 => {
this.raw_data = data.body;
//查找链接航班并将其组合成一条数据
this.combined_data = [];
let combined_linked_data = this.dataHandle.findLinkFlights(this.raw_data);
combined_linked_data.forEach(element => {
let flights_item = this.dataHandle.flightsRenderTransfer(element, this.col_lists);
this.combined_data.push(flights_item);
});
let combined_data = []
this.combined_data.forEach(item => {
combined_data.push(this.dataHandle.basicDataTransHandle(item, this.airports, this.citys, this.airlines, this.flightStatus, this.flightTypes));
})
this.combined_data = combined_data;
this.doSequence(this.combined_data);
}
)
}
/**
* 导出
* @param
*/
export() {
let exportArray = [];
this.wait_render_data.forEach(item => {
let exportItem = Object.assign({}, item)
if (this.orderHandle.isLinked(exportItem) || this.orderHandle.isArriFlight(exportItem)) {
exportItem['renderFlight']['orderBy'] = new Date(this.utils.dateFormatter(exportItem['preFlight']['SODT'])).getTime();
} else {
exportItem['renderFlight']['orderBy'] = new Date(this.utils.dateFormatter(exportItem['reaFlight']['SODT'])).getTime()
}
exportArray.push(exportItem['renderFlight']);
})
exportArray.sort(function (a, b) {
return (a['orderBy'] - b['orderBy']);
})
let colArray = [];
this.render_col_lists.forEach(element => {
let column = { 'key': element['COL_CODE'], "name": element['COL_CN'] }
colArray.push(column);
})
var postData = new Object();
postData['columns'] = colArray;
postData['data'] = exportArray;
this.httpCilent.post('/adminapi/fltrs/toExcel', postData, { responseType: 'blob' }).subscribe(
data => {
let blob = new Blob();
blob = data;
let downloadFileName = '航班动态.xlsx';
if ('msSaveOrOpenBlob' in navigator) {
window.navigator.msSaveOrOpenBlob(blob, downloadFileName);
}
else {
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
downloadElement.download = downloadFileName; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
window.URL.revokeObjectURL(href); //释放掉blob对象
}
}
)
}
/**
* 动态消息处理方法
* @param message
*/
dynamicMessageHandle(message) {
this.creatWorkers(message);
}
/**
* 创建线程并执行
*/
public promise: Worker = new Worker('/adminweb/assets/web-worker-handle.js');
creatWorkers(message?) {
let dynamicData = {
message: message,
airlinesSelections: this.airlinesSelections,
flightTypeSelections: this.flightTypeSelections,
raw_data: this.raw_data,
col_lists: this.col_lists,
airports: this.airports,
citys: this.citys,
airlines: this.airlines,
flightStatus: this.flightStatus,
flightTypes: this.flightTypes
}
this.promise.postMessage(dynamicData);
this.promise.onmessage = function (e) {
this.combined_data = e.data.combined_data;
this.raw_data = e.data.raw_data;
this.airlinesSelections = e.data.airlinesSelections;
this.flightTypeSelections = e.data.flightTypeSelections;
this.selectChange('dynamic');
}.bind(this);
}
/**
* 动态警示处理方法
* @param message
*/
public alertMessage = {
'FLOP-CNCL': this.alertMessageHandle.flopCncl.bind(this.alertMessageHandle),
'FLOP-FRET': this.alertMessageHandle.flopFret.bind(this.alertMessageHandle),
'FLOP-FDIV': this.alertMessageHandle.flopFdiv.bind(this.alertMessageHandle),
'FLOP-FDEL': this.alertMessageHandle.flopFdel.bind(this.alertMessageHandle),
'FLOP-DELY': this.alertMessageHandle.flopDely.bind(this.alertMessageHandle),
'FLOP-ACTT': this.alertMessageHandle.flopActt.bind(this.alertMessageHandle),
'FLOP-GTDT': this.alertMessageHandle.flopGtdt.bind(this.alertMessageHandle),
'FLOP-PSDT': this.alertMessageHandle.flopPsdt.bind(this.alertMessageHandle),
'FLOP-ESTT': this.alertMessageHandle.flopEstt.bind(this.alertMessageHandle),
'FLOP-PADT': this.alertMessageHandle.flopPadt.bind(this.alertMessageHandle),
'FLOP-CKDT': this.alertMessageHandle.flopCkdt.bind(this.alertMessageHandle),
'FLOP-BOTM': this.alertMessageHandle.flopBotm.bind(this.alertMessageHandle),
'FLOP-CLDT': this.alertMessageHandle.flopCldt.bind(this.alertMessageHandle),
'FLOP-ROUT': this.alertMessageHandle.flopRout.bind(this.alertMessageHandle),
'FLOP-VIPP': this.alertMessageHandle.flopVipp.bind(this.alertMessageHandle),
'FLOP-HNAG': this.alertMessageHandle.flopHnag.bind(this.alertMessageHandle),
'FLOP-FLBG': this.alertMessageHandle.flopFlbg.bind(this.alertMessageHandle),
'FLOP-RENO': this.alertMessageHandle.flopReno.bind(this.alertMessageHandle),
'FLOP-ABTM': this.alertMessageHandle.flopAbtm.bind(this.alertMessageHandle),
'FLOP-CHOT': this.alertMessageHandle.flopChot.bind(this.alertMessageHandle),
'FLOP-TRML': this.alertMessageHandle.flopTrml.bind(this.alertMessageHandle),
'SCHD-DNLD': this.alertMessageHandle.schdDnld.bind(this.alertMessageHandle)
}
dynamicAlertHandle(message) {
let alertType = message.META.TYPE + '-' + message.META.STYP;
let index = this.airline_message_alert.findIndex(val => val['COL_CODE'] === alertType);
if (index > -1) {
if (alertType === 'FLOP-FDEL') {
let index = this.raw_data.findIndex(element => element['FLID'] === message.FLOP.FLID);
if (index > -1) {
this.raw_data.splice(index, 1);
this.creatWorkers();
}
} else if (alertType === 'SCHD-DNLD') {
this.canHandleDynamicMessage = false;
this.canHandleDynamicAlert = false;
this.httpCilent.get('/msgexchangeapi/all/flights').subscribe(
data => {
this.raw_data = data.body;
this.creatWorkers();
this.canHandleDynamicMessage = true;
this.dynamicMessageArray.forEach(message => {
this.dynamicMessageHandle(message);
})
this.canHandleDynamicAlert = true;
this.dynamicAlertArray.forEach(message => {
this.dynamicAlertHandle(message);
})
})
}
let alertText = this.alertMessage[alertType](message, this.airports, this.flightStatusDefinitions, this.flightAgents);
const toastCfg = new ToastConfig(ToastType.SUCCESS, '', alertText, 600000);
this.toastService.toast(toastCfg);
}
}
/**
* 过滤及定位
* @param filterItems
* @return
*/
SEARCH = ''; //手动输入条件
LASTSEARCH = '';
FLT_POS = 1; //过滤还是定位
SEL_COL = ''; //选择列名
LAST_SEL_COL = '';
public filterItems = {
ALCD: '', //航空公司
FLIN: '', //航线类别
FLTY: '', //航班类别
MVIN: '', //到达/出发
FTSS: '', //运营状态
TRML: '', //航站楼
Abnormal_state: '', //异常状态
FHAG: '', //机坪代理
MHAG: '', //维护代理
PHAG: '', //旅客代理
}
dateSelect: Date = null;
dateFilterItem: string = '';
/**
* 输入框回车事件
*/
inputEnter() {
if (this.FLT_POS === 1) {
this.LAST_SEL_COL = this.SEL_COL;
this.LASTSEARCH = this.SEARCH;
// this.selectChange('filter');
this.operateSpinServiceService.showSpin();
this.inputFilter(this.selectedFilterData);
} else {
this.inputPosition(this.wait_render_data)
}
}
onChangeDate(date) {
if (date) {
this.dateFilterItem = this.changeDate(date);
} else {
this.dateFilterItem = '';
}
this.selectChange('filter');
}
/**
* 下拉框选择筛选
*/
selectChange(type) {
if (type === 'filter') {
this.positionedArray = [];
this.positionArrayIndex = 0;
this.operateSpinServiceService.showSpin();
}
let filter_data = [];
let filterItems = this.filterItems;
this.combined_data.forEach(item => {
filter_data.push(Object.assign({}, item));
})
//下拉框筛选
if (this.dateFilterItem) {
filter_data = filter_data.filter(item => {
if (this.orderHandle.isArriFlight(item)) {
let is_satis = true;
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['preFlight'][filterItems[key]] && item['preFlight'][filterItems[key]].length > 0) {
is_satis = true;
continue;
} else {
is_satis = false;
break;
}
}
else {
if (item['preFlight'][key] == filterItems[key]) {
is_satis = true;
continue;
} else {
is_satis = false;
break;
}
}
}
}
if (is_satis) {
if (item['renderFlight']['FLDT']) {
if (item['renderFlight']['FLDT'] === this.dateFilterItem) {
is_satis = true;
} else {
is_satis = false;
}
} else {
is_satis = false;
}
}
return is_satis;
} else if (this.orderHandle.isDeptFlight(item)) {
let is_satis = true;
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['reaFlight'][filterItems[key]] && item['reaFlight'][filterItems[key]].length > 0) {
is_satis = true;
continue;
} else {
is_satis = false;
break;
}
}
else {
if (item['reaFlight'][key] == filterItems[key]) {
is_satis = true;
continue;
} else {
is_satis = false;
break;
}
}
}
}
if (is_satis) {
if (item['renderFlight']['FLDT']) {
if (item['renderFlight']['FLDT'] === this.dateFilterItem) {
is_satis = true;
} else {
is_satis = false;
}
} else {
is_satis = false;
}
}
return is_satis;
} else {
let pre_satis = true;
let rea_satis = true;
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['preFlight'][filterItems[key]] && item['preFlight'][filterItems[key]].length > 0) {
pre_satis = true;
continue;
} else {
pre_satis = false;
break;
}
}
else {
if (item['preFlight'][key] == filterItems[key]) {
pre_satis = true;
continue;
} else {
pre_satis = false;
break;
}
}
}
}
if (pre_satis) {
if (item['renderPreFlight']['FLDT']) {
if (item['renderPreFlight']['FLDT'] === this.dateFilterItem) {
pre_satis = true;
} else {
pre_satis = false;
}
} else {
pre_satis = false;
}
}
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['reaFlight'][filterItems[key]] && item['reaFlight'][filterItems[key]].length > 0) {
rea_satis = true;
continue;
} else {
rea_satis = false;
break;
}
}
else {
if (item['reaFlight'][key] == filterItems[key]) {
rea_satis = true;
continue;
} else {
rea_satis = false;
break;
}
}
}
}
if (rea_satis) {
if (item['renderReaFlight']['FLDT']) {
if (item['renderReaFlight']['FLDT'] === this.dateFilterItem) {
rea_satis = true;
} else {
rea_satis = false;
}
} else {
rea_satis = false;
}
}
if (pre_satis && !rea_satis) {
item['renderFlight'] = item['renderPreFlight'];
delete item['reaFlight'];
delete item['renderReaFlight'];
return pre_satis;
} else if (!pre_satis && rea_satis) {
item['renderFlight'] = item['renderReaFlight'];
delete item['preFlight'];
delete item['renderPreFlight'];
return rea_satis;
} else if (pre_satis && rea_satis) {
return pre_satis && rea_satis;
} else {
return false;
}
}
})
} else {
filter_data = filter_data.filter(item => {
if (this.orderHandle.isArriFlight(item)) {
let is_satis = true;
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['preFlight'][filterItems[key]] && item['preFlight'][filterItems[key]].length > 0) {
is_satis = true;
continue;
} else {
is_satis = false;
break;
}
}
else {
if (item['preFlight'][key] == filterItems[key]) {
is_satis = true;
continue;
} else {
is_satis = false;
break;
}
}
}
}
return is_satis;
} else if (this.orderHandle.isDeptFlight(item)) {
let is_satis = true;
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['reaFlight'][filterItems[key]] && item['reaFlight'][filterItems[key]].length > 0) {
is_satis = true;
continue;
} else {
is_satis = false;
break;
}
}
else {
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 (key === 'Abnormal_state') {
if (item['preFlight'][filterItems[key]] && item['preFlight'][filterItems[key]].length > 0) {
pre_satis = true;
continue;
} else {
pre_satis = false;
break;
}
}
else {
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 (key === 'Abnormal_state') {
if (item['reaFlight'][filterItems[key]] && item['reaFlight'][filterItems[key]].length > 0) {
rea_satis = true;
continue;
} else {
rea_satis = false;
break;
}
}
else {
if (item['reaFlight'][key] == filterItems[key]) {
rea_satis = true;
continue;
} else {
rea_satis = false;
break;
}
}
}
}
if (pre_satis && !rea_satis) {
item['renderFlight'] = item['renderPreFlight'];
delete item['reaFlight'];
delete item['renderReaFlight'];
return pre_satis;
} else if (!pre_satis && rea_satis) {
item['renderFlight'] = item['renderReaFlight'];
delete item['preFlight'];
delete item['renderPreFlight'];
return rea_satis;
} else if (pre_satis && rea_satis) {
return pre_satis && rea_satis;
} else {
return false;
}
}
})
}
this.selectedFilterData = filter_data;
if (this.FLT_POS === 1) {
this.inputFilter(filter_data);
} else {
this.wait_render_data = filter_data;
this.render_data = this.wait_render_data.slice(this.start, this.end);
let hasSelectedRow: boolean = false;
for (let i = 0; i < this.wait_render_data.length; i++) {
let flight = this.wait_render_data[i];
if (flight['preFlight'] && !flight['reaFlight']) {
if (this.row_state['preFlight'] && !this.row_state['reaFlight']) {
if (flight['preFlight']['FLID'] === this.row_state['preFlight']['FLID']) {
this.row_state = flight;
hasSelectedRow = true;
break;
}
}
} else if (!flight['preFlight'] && flight['reaFlight']) {
if (!this.row_state['preFlight'] && this.row_state['reaFlight']) {
if (flight['reaFlight']['FLID'] === this.row_state['reaFlight']['FLID']) {
this.row_state = flight;
hasSelectedRow = true;
break;
}
}
} else {
if (this.row_state['preFlight'] && this.row_state['reaFlight']) {
if ((flight['preFlight']['FLID'] === this.row_state['preFlight']['FLID']) && (flight['reaFlight']['FLID'] === this.row_state['reaFlight']['FLID'])) {
this.row_state = flight;
hasSelectedRow = true;
break;
}
}
}
}
if (!hasSelectedRow) {
if (this.render_data.length > 0) {
this.row_state = this.render_data[0];
}
}
this.operateSpinServiceService.hideSpin();
}
}
/**
* 输入框筛选
* @param filterData
*/
inputFilter(filterData) {
if (this.LASTSEARCH) {
if (this.LAST_SEL_COL) {
let sel_col = this.LAST_SEL_COL;
filterData = filterData.filter(item => {
if (item['renderFlight'][sel_col]) {
if (item['renderFlight'][sel_col].toString().match(new RegExp(this.LASTSEARCH, 'i'))) {
return true;
}
} else {
return false;
}
})
} else {
filterData = filterData.filter(item => {
let is_satis = false;
let cols = this.col_lists;
for (let i = 0; i < cols.length; i++) {
if (item['renderFlight'][cols[i]['COL_CODE']]) {
if (item['renderFlight'][cols[i]['COL_CODE']].toString().match(new RegExp(this.LASTSEARCH, 'i'))) {
is_satis = true;
break;
} else {
is_satis = false;
continue;
}
} else {
is_satis = false;
continue;
}
}
return is_satis;
})
}
}
this.wait_render_data = filterData;
this.render_data = this.wait_render_data.slice(this.start, this.end);
let hasSelectedRow: boolean = false;
for (let i = 0; i < this.wait_render_data.length; i++) {
let flight = this.wait_render_data[i];
if (flight['preFlight'] && !flight['reaFlight']) {
if (this.row_state['preFlight'] && !this.row_state['reaFlight']) {
if (flight['preFlight']['FLID'] === this.row_state['preFlight']['FLID']) {
this.row_state = flight;
hasSelectedRow = true;
break;
}
}
} else if (!flight['preFlight'] && flight['reaFlight']) {
if (!this.row_state['preFlight'] && this.row_state['reaFlight']) {
if (flight['reaFlight']['FLID'] === this.row_state['reaFlight']['FLID']) {
this.row_state = flight;
hasSelectedRow = true;
break;
}
}
} else {
if (this.row_state['preFlight'] && this.row_state['reaFlight']) {
if ((flight['preFlight']['FLID'] === this.row_state['preFlight']['FLID']) && (flight['reaFlight']['FLID'] === this.row_state['reaFlight']['FLID'])) {
this.row_state = flight;
hasSelectedRow = true;
break;
}
}
}
}
if (!hasSelectedRow) {
if (this.render_data.length > 0) {
this.row_state = this.render_data[0];
}
}
this.operateSpinServiceService.hideSpin();
}
/**
* 输入框定位
*/
positionedArray: Array<any> = [];
positionArrayIndex: number = 0;
inputPosition(filterData) {
let hasSearchData: boolean = false;
let hasPositionedEle: boolean = false;
if (this.SEL_COL) {
let sel_col = this.SEL_COL;
for (let i = 0; i < filterData.length; i++) {
if (i === filterData.length - 1) {
this.positionedArray = [];
this.positionArrayIndex = 0;
}
let fliterElement = filterData[i];
if (fliterElement['renderFlight'][sel_col]) {
if (fliterElement['renderFlight'][sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) {
let hasThisEle: boolean = false;
hasSearchData = true;
for (let k = 0; k < this.positionedArray.length; k++) {
let positionedElement = this.positionedArray[k];
let diffResult = this.utils.diff(positionedElement, fliterElement);
if (diffResult) {
hasThisEle = true;
break;
} else {
continue;
}
};
if (!hasThisEle) {
hasPositionedEle = true;
this.row_state = fliterElement;
this.positionArrayIndex = i;
this.positionedArray.push(fliterElement);
break;
}
} else {
continue;
}
} else {
if (!this.SEARCH) {
let hasThisEle: boolean = false;
hasSearchData = true;
for (let k = 0; k < this.positionedArray.length; k++) {
let positionedElement = this.positionedArray[k];
let diffResult = this.utils.diff(positionedElement, fliterElement);
if (diffResult) {
hasThisEle = true;
break;
} else {
continue;
}
};
if (!hasThisEle) {
hasPositionedEle = true;
this.row_state = fliterElement;
this.positionArrayIndex = i;
this.positionedArray.push(fliterElement);
break;
}
} else {
continue;
}
}
}
} else {
let cols = this.render_col_lists;
for (let i = 0; i < filterData.length; i++) {
if (i === filterData.length - 1) {
this.positionedArray = [];
this.positionArrayIndex = 0;
}
let positionIsOk: boolean = false;
let filterElement = filterData[i];
for (let j = 0; j < cols.length; j++) {
let elementCol = cols[j];
if (filterElement['renderFlight'][elementCol['COL_CODE']]) {
if (filterElement['renderFlight'][elementCol['COL_CODE']].toString().match(new RegExp(this.SEARCH, 'i'))) {
let hasThisEle: boolean = false;
hasSearchData = true;
for (let k = 0; k < this.positionedArray.length; k++) {
let positionedElement = this.positionedArray[k];
let diffResult = this.utils.diff(positionedElement, filterElement);
if (diffResult) {
hasThisEle = true;
break;
} else {
continue;
}
};
if (!hasThisEle) {
hasPositionedEle = true;
positionIsOk = true;
this.row_state = filterElement;
this.positionArrayIndex = i;
this.positionedArray.push(filterElement);
}
break;
} else {
continue;
}
} else {
if (!this.SEARCH) {
let hasThisEle: boolean = false;
hasSearchData = true;
for (let k = 0; k < this.positionedArray.length; k++) {
let positionedElement = this.positionedArray[k];
let diffResult = this.utils.diff(positionedElement, filterElement);
if (diffResult) {
hasThisEle = true;
break;
} else {
continue;
}
};
if (!hasThisEle) {
hasPositionedEle = true;
positionIsOk = true;
this.row_state = filterElement;
this.positionArrayIndex = i;
this.positionedArray.push(filterElement);
}
break;
} else {
continue;
}
}
}
if (positionIsOk) {
break;
}
}
}
if (!hasSearchData) {
alert("没有搜索到相关数据");
}
if (hasPositionedEle) {
const scrollTop = this.positionArrayIndex * this.trItemHeight
this.tableBody.nativeElement.scrollTop = scrollTop;
}
}
/**
* 重置定位数组
*/
resetPositionArray() {
this.positionedArray = [];
this.positionArrayIndex = 0;
}
/**
* 选中某行
* @param i
*/
selectRow(i) {
this.row_state = i;
}
/**
* 判断当前行是否是选中的行,是则高亮
*/
getSelectedRow(flight) {
if (flight['preFlight'] && !flight['reaFlight']) {
if (this.row_state['preFlight'] && !this.row_state['reaFlight']) {
if (flight['preFlight']['FLID'] === this.row_state['preFlight']['FLID']) {
return true;
} else {
return false;
}
} else {
return false;
}
} else if (!flight['preFlight'] && flight['reaFlight']) {
if (!this.row_state['preFlight'] && this.row_state['reaFlight']) {
if (flight['reaFlight']['FLID'] === this.row_state['reaFlight']['FLID']) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
if (this.row_state['preFlight'] && this.row_state['reaFlight']) {
if ((flight['preFlight']['FLID'] === this.row_state['preFlight']['FLID']) && (flight['reaFlight']['FLID'] === this.row_state['reaFlight']['FLID'])) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}
/**
* 获取当前单元格颜色
* @param col_CODE
*/
public colorFormatter = {
'RENO': this.cellColorHandle.reno.bind(this.cellColorHandle),
'ACTT': this.cellColorHandle.actt.bind(this.cellColorHandle),
'ESTT': this.cellColorHandle.estt.bind(this.cellColorHandle),
'SODT': this.cellColorHandle.sodt.bind(this.cellColorHandle),
'PADT': this.cellColorHandle.padt.bind(this.cellColorHandle),
'PSST': this.cellColorHandle.psst.bind(this.cellColorHandle),
}
getColor(col_CODE, flight, col_WIDTH) {
let index = this.airline_color.findIndex(color => color['COL_CODE'] === col_CODE)
if (index > -1) {
let styles = this.colorFormatter[col_CODE](flight, this.airline_color[index]);
styles['min-width'] = col_WIDTH;
return styles;
} else {
return { 'min-width': col_WIDTH };
}
}
/**
* 单元格内容居左居右
* @param col_CODE
* @param flight
*/
getPosition(col_CODE, flight) {
if (this.orderHandle.isDeptFlight(flight)) {
if (col_CODE === 'FLNO' || col_CODE === 'SODT' || col_CODE === 'ESTT' || col_CODE === 'ACTT') {
return 'text-right';
}
} else if (this.orderHandle.isLinked(flight)) {
if (col_CODE === 'SODT' || col_CODE === 'ESTT' || col_CODE === 'ACTT') {
if (!flight['renderPreFlight'][col_CODE] && flight['renderReaFlight'][col_CODE]) {
return 'text-right';
} else if (flight['renderPreFlight'][col_CODE] && !flight['renderReaFlight'][col_CODE]) {
return 'text-left';
}
}
} else {
if (col_CODE === 'FLNO' || col_CODE === 'SODT' || col_CODE === 'ESTT' || col_CODE === 'ACTT') {
return 'text-left';
}
}
}
getVipNotes(flight) {
if (this.orderHandle.isArriFlight(flight)) {
if (flight['preFlight']['VIPP'] && flight['preFlight']['VIPP'] > 0 && flight['preFlight']['VIPR'] && flight['preFlight']['VIPR'] > 0) {
return true;
} else {
return false;
}
} else if (this.orderHandle.isDeptFlight(flight)) {
if (flight['reaFlight']['VIPP'] && flight['reaFlight']['VIPP'] > 0 && flight['reaFlight']['VIPR'] && flight['reaFlight']['VIPR'] > 0) {
return true;
} else {
return false;
}
} else {
if ((flight['preFlight']['VIPP'] && flight['preFlight']['VIPP'] > 0 && flight['reaFlight']['VIPR'] && flight['reaFlight']['VIPR'] > 0) || (flight['reaFlight']['VIPP'] && flight['reaFlight']['VIPP'] > 0 && flight['reaFlight']['VIPR'] && flight['reaFlight']['VIPR'] > 0)) {
return true;
} else {
return false;
}
}
}
getOutplanNotes(flight) {
if (this.orderHandle.isArriFlight(flight)) {
if (flight['preFlight']['UPTP'] && flight['preFlight']['UPTP'] === 'SCHD-ADFT') {
return true;
} else {
return false;
}
} else if (this.orderHandle.isDeptFlight(flight)) {
if (flight['reaFlight']['UPTP'] && flight['reaFlight']['UPTP'] === 'SCHD-ADFT') {
return true;
} else {
return false;
}
} else {
if ((flight['preFlight']['UPTP'] && flight['preFlight']['UPTP'] === 'SCHD-ADFT') || (flight['reaFlight']['UPTP'] && flight['reaFlight']['UPTP'] === 'SCHD-ADFT')) {
return true;
} else {
return false;
}
}
}
getAlternateNotes(flight) {
if (this.orderHandle.isArriFlight(flight)) {
let preFdiv = flight['preFlight']['FDIV'];
if (preFdiv && preFdiv.DDES) {
return true;
} else {
return false;
}
} else if (this.orderHandle.isDeptFlight(flight)) {
let reaFdiv = flight['reaFlight']['FDIV'];
if (reaFdiv && reaFdiv.DDES) {
return true;
} else {
return false;
}
} else {
let preFdiv = flight['preFlight']['FDIV'];
let reaFdiv = flight['reaFlight']['FDIV'];
if ((preFdiv && preFdiv.DDES) || (reaFdiv && reaFdiv.DDES)) {
return true;
} else {
return false;
}
}
}
getDelay30Notes(flight) {
// return false;
if (this.orderHandle.isArriFlight(flight)) {
return false;
} else {
let reaDelay = flight['reaFlight']['DELY'];
try {
if (reaDelay && Array.isArray(reaDelay) && reaDelay.length > 0) {
if (parseInt(reaDelay[reaDelay.length - 1]['DURA']) - 30 > 0) {
return true;
} else {
return false;
}
} else {
return false;
}
} catch (error) {
return false;
}
}
}
getDelayNotes(flight) {
if (this.orderHandle.isArriFlight(flight)) {
if (flight['preFlight']['DELY'] && Array.isArray(flight['preFlight']['DELY']) && flight['preFlight']['DELY'].length > 0) {
return true;
} else {
return false;
}
} else if (this.orderHandle.isDeptFlight(flight)) {
if (flight['reaFlight']['DELY'] && Array.isArray(flight['reaFlight']['DELY']) && flight['reaFlight']['DELY'].length > 0) {
return true;
} else {
return false;
}
} else {
if ((flight['preFlight']['DELY'] && Array.isArray(flight['preFlight']['DELY']) && flight['preFlight']['DELY'].length > 0) || (flight['reaFlight']['DELY'] && Array.isArray(flight['reaFlight']['DELY']) && flight['reaFlight']['DELY'].length > 0)) {
return true;
} else {
return false;
}
}
}
getReturnNotes(flight) {
if (this.orderHandle.isArriFlight(flight)) {
let preFret = flight['preFlight']['FRET'];
if (preFret && preFret.VALUE && preFret.REID) {
return true;
} else {
return false;
}
} else if (this.orderHandle.isDeptFlight(flight)) {
let reaFret = flight['reaFlight']['FRET'];
if (reaFret && reaFret.VALUE && reaFret.REID) {
return true;
} else {
return false;
}
} else {
let preFret = flight['preFlight']['FRET'];
let reaFret = flight['reaFlight']['FRET'];
if ((preFret && preFret.VALUE && preFret.REID) || (reaFret && reaFret.VALUE && reaFret.REID)) {
return true;
} else {
return false;
}
}
}
getCancleNotes(flight) {
if (this.orderHandle.isArriFlight(flight)) {
if (flight['preFlight']['CNCL']) {
return true;
} else {
return false;
}
} else if (this.orderHandle.isDeptFlight(flight)) {
if (flight['reaFlight']['CNCL']) {
return true;
} else {
return false;
}
} else {
if ((flight['preFlight']['CNCL']) || (flight['reaFlight']['CNCL'])) {
return true;
} else {
return false;
}
}
}
getStopoverNotes(flight) {
if (this.orderHandle.isLinked(flight)) {
if (flight['preFlight']['ACTT'] && flight['reaFlight']['ESTT']) {
if (new Date(this.utils.dateFormatter(flight['reaFlight']['ESTT'])).getTime() - new Date(this.utils.dateFormatter(flight['preFlight']['ACTT'])).getTime() > 3600000) {
return false;
} else {
return true;
}
} else if (flight['preFlight']['ACTT'] && flight['reaFlight']['SODT']) {
if (new Date(this.utils.dateFormatter(flight['reaFlight']['SODT'])).getTime() - new Date(this.utils.dateFormatter(flight['preFlight']['ACTT'])).getTime() > 3600000) {
return false;
} else {
return true;
}
} else if (flight['preFlight']['ESTT'] && flight['reaFlight']['ESTT']) {
if (new Date(this.utils.dateFormatter(flight['reaFlight']['ESTT'])).getTime() - new Date(this.utils.dateFormatter(flight['preFlight']['ESTT'])).getTime() > 3600000) {
return false;
} else {
return true;
}
} else if (flight['preFlight']['ESTT'] && flight['reaFlight']['SODT']) {
if (new Date(this.utils.dateFormatter(flight['reaFlight']['SODT'])).getTime() - new Date(this.utils.dateFormatter(flight['preFlight']['ESTT'])).getTime() > 3600000) {
return false;
} else {
return true;
}
} else if (flight['preFlight']['SODT'] && flight['reaFlight']['ESTT']) {
if (new Date(this.utils.dateFormatter(flight['reaFlight']['ESTT'])).getTime() - new Date(this.utils.dateFormatter(flight['preFlight']['SODT'])).getTime() > 3600000) {
return false;
} else {
return true;
}
} else if (flight['preFlight']['SODT'] && flight['reaFlight']['SODT']) {
if (new Date(this.utils.dateFormatter(flight['reaFlight']['SODT'])).getTime() - new Date(this.utils.dateFormatter(flight['preFlight']['SODT'])).getTime() > 3600000) {
return false;
} else {
return true;
}
} else {
return false;
}
} else {
return false;
}
}
/**
* 复选框勾选事件
*/
checkboxChange() {
let tabClose = true
for (const key in this.checkboxGroup) {
if (this.checkboxGroup.hasOwnProperty(key)) {
if (this.checkboxGroup[key]) {
tabClose = false;
break;
} else {
tabClose = true;
continue;
}
}
}
this.tabClose = tabClose;
if (!this.tabClose) {
setTimeout(() => {
this.renderer2.setStyle(this.tabContainer.nativeElement, 'height', this.pageContent.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 35 + 'px');
}, 10)
}
}
//日期时间处理
changeDate(time) {
var date = new Date(time);
var Y = date.getFullYear() + '';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '';
var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '';
return Y + '-' + M + '-' + D;
}
/**
* 移除消息提示框
* @param toastCfg
*/
remove(toastCfg: ToastConfig) {
if (this.toastConfigs.indexOf(toastCfg) >= 0) {
this.toastConfigs.splice(this.toastConfigs.indexOf(toastCfg), 1);
this.toastService.removeToastBoxSubject.next(toastCfg);
}
}
/**
* 清除所有消息弹出框
*/
clearAllNotify() {
this.toastConfigs = [];
this.toastService.removeToastBox();
}
}