工具类抽取及历史数据处理
This commit is contained in:
@@ -1,337 +1,381 @@
|
||||
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 dateFormatter from '../../utils/data-formatter';
|
||||
import { HttpParams } from '@angular/common/http';
|
||||
import { BasicDataService } from '../../services/basic-data-service';
|
||||
import { OperateSpinServiceService } from '../../services/operate-spin-service.service';
|
||||
|
||||
import { DynamicFlightOrder } from '../../utils/dynamic-flight-order';
|
||||
import { FlightsDataHandle } from '../../utils/flights-data-handle';
|
||||
|
||||
import * as $ from 'jquery';
|
||||
|
||||
@Component({
|
||||
selector: 'app-historical-data',
|
||||
templateUrl: './historical-data.component.html',
|
||||
styleUrls: ['./historical-data.component.scss']
|
||||
selector: 'app-historical-data',
|
||||
templateUrl: './historical-data.component.html',
|
||||
styleUrls: ['./historical-data.component.scss']
|
||||
})
|
||||
export class HistoricalDataComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private httpCilent: HttpClientService,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
) { }
|
||||
|
||||
public raw_data: Array<object> = []; //原始数据,即航班计划
|
||||
|
||||
public combined_data: Array<object> = []; //组合数据,即链接航班,显示信息等组合好之后的数据
|
||||
|
||||
public render_data: Array<object> = []; //显示数据,即需要显示的数据
|
||||
|
||||
public historical_lists: Array<object>; //列数据
|
||||
|
||||
public row_state: any = { renderFlight: {} };
|
||||
|
||||
// 搜索条件
|
||||
SEARCH = ''; //手动输入条件
|
||||
FLT_POS = 1; //过滤还是定位
|
||||
SEL_COL = ''; //选择列名
|
||||
|
||||
public filterItems = {
|
||||
TT: '',//航线类别
|
||||
flightTask:'',//航班任务
|
||||
arriOrDept:'',//到达/出发
|
||||
flightTypeCode:''//航班代理
|
||||
}
|
||||
|
||||
public formatter = {
|
||||
'TT': {
|
||||
'D': '国内'
|
||||
},
|
||||
'flightTask': {
|
||||
'S': '正班'
|
||||
},
|
||||
'arriOrDept': {
|
||||
'A': '到达'
|
||||
},
|
||||
'flightTypeCode': {
|
||||
'T': '国航代理'
|
||||
},
|
||||
'SODT': dateFormatter,
|
||||
'ESTT': dateFormatter,
|
||||
'ACTT': dateFormatter
|
||||
}
|
||||
|
||||
selectRow(i) {
|
||||
this.row_state = i;
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
|
||||
getColor(col_CODE) {
|
||||
if (col_CODE === 'SODT') {
|
||||
return 'skyblue'
|
||||
} else {
|
||||
return null
|
||||
constructor(
|
||||
private basicDataService: BasicDataService,
|
||||
private operateSpinServiceService: OperateSpinServiceService,
|
||||
private httpCilent: HttpClientService,
|
||||
private toastService: ToastService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
) {
|
||||
this.operateSpinServiceService.showSpin();
|
||||
this.changeDetectorRef.detach();
|
||||
}
|
||||
}
|
||||
public orderHandle = new DynamicFlightOrder();
|
||||
public dataHandle = new FlightsDataHandle();
|
||||
|
||||
ngOnInit() {
|
||||
this.changeDetectorRef.detach();
|
||||
/* 获取显示列 */
|
||||
this.httpCilent.get('/assets/mock-data/historical-code.json').subscribe(
|
||||
data => {
|
||||
data.sort(function (a, b) {
|
||||
return (a['COL_ORDER'] - b['COL_ORDER']);
|
||||
})
|
||||
this.historical_lists = data;
|
||||
}
|
||||
)
|
||||
/* 获取历史数据信息 */
|
||||
this.httpCilent.get('/assets/mock-data/historical-data.json').subscribe(
|
||||
data => {
|
||||
//解析数据
|
||||
data.forEach(element => {
|
||||
this.raw_data.push(JSON.parse(element.value));
|
||||
});
|
||||
public tabClose: boolean = true;
|
||||
|
||||
let combined_linked_data = this.raw_data;
|
||||
//各项基础数据
|
||||
public flightTypes: Array<any>;
|
||||
public terminals: Array<any>;
|
||||
public flightStatus: Array<any>;
|
||||
public airports: Array<any>;
|
||||
public citys: Array<any>;
|
||||
public airlines: Array<any>;
|
||||
|
||||
combined_linked_data.forEach(element => {
|
||||
let row_flights = {};
|
||||
let render_flight = {};
|
||||
let render_pre_flight = {};
|
||||
let render_rea_flight = {};
|
||||
row_flights['preFlight'] = element;
|
||||
public airlinesSelections: Array<any> = [];
|
||||
public flightTypeSelections: Array<any> = [];
|
||||
|
||||
for (let i = 0; i < this.historical_lists.length; i++) {
|
||||
let key = this.historical_lists[i]['COL_CODE']
|
||||
render_flight[key] = typeof (this.formatter[key]) === 'function' ? this.formatter[key](row_flights['preFlight'][key], 1) : this.formatter[key] ? this.formatter[key][row_flights['preFlight'][key]] : row_flights['preFlight'][key];
|
||||
public raw_data: Array<object> = []; //原始数据,未经过任何转换和组合
|
||||
public combined_data: Array<object> = []; //组合数据,即链接航班,显示信息等组合好之后的数据
|
||||
public render_data: Array<object> = []; //显示数据,即需要显示的数据
|
||||
|
||||
public col_lists: Array<object>; //列数据
|
||||
public render_col_lists: Array<object>;
|
||||
|
||||
public row_state: any = { renderFlight: {} };
|
||||
|
||||
public checkboxGroup = {
|
||||
'related': false,
|
||||
'detail': false,
|
||||
'vip': false,
|
||||
'special': false,
|
||||
'guarantee': false
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
/* 获取用户设置 */
|
||||
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;
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
//获取航班动态信息
|
||||
this.httpCilent.post('/adminapi/hitFlightData/list', { searchDate: new Date().getTime() }).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.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.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);
|
||||
}
|
||||
);
|
||||
}
|
||||
row_flights['renderFlight'] = render_flight;
|
||||
if (element['isLinked']) {
|
||||
row_flights['preFlight'] = element['linkFlight'];
|
||||
delete element['linkFlight'];
|
||||
delete element['isLinked'];
|
||||
row_flights['reaFlight'] = element;
|
||||
}
|
||||
)
|
||||
|
||||
for (let i = 0; i < this.historical_lists.length; i++) {
|
||||
let key = this.historical_lists[i]['COL_CODE']
|
||||
if (this.formatter.hasOwnProperty(key)) {
|
||||
if (typeof (this.formatter[key]) === 'function') {
|
||||
render_flight[key] = (row_flights['preFlight'][key] === row_flights['reaFlight'][key]) ? (this.formatter[key](row_flights['preFlight'][key], 1)) : (this.formatter[key](row_flights['preFlight'][key], 1) + '/' + this.formatter[key](row_flights['reaFlight'][key], 1));
|
||||
render_pre_flight[key] = this.formatter[key](row_flights['preFlight'][key], 1);
|
||||
render_rea_flight[key] = this.formatter[key](row_flights['reaFlight'][key], 1);
|
||||
//固定表头
|
||||
var tableCont = document.querySelector('#table-container')
|
||||
function scrollHandle() {
|
||||
var scrollTop = this.scrollTop;
|
||||
this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
|
||||
}
|
||||
tableCont.addEventListener('scroll', scrollHandle)
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据组合完毕,执行排序、渲染以及动态信息处理
|
||||
* @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.render_data = combined_data;
|
||||
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
|
||||
this.changeDetectorRef.detectChanges();
|
||||
this.operateSpinServiceService.hideSpin()
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新
|
||||
*/
|
||||
refresh() {
|
||||
const toastCfg = new ToastConfig(ToastType.SUCCESS, '', '刷新成功!', 3000);
|
||||
this.toastService.toast(toastCfg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 过滤及定位
|
||||
* @param filterItems
|
||||
* @return
|
||||
*/
|
||||
SEARCH = ''; //手动输入条件
|
||||
FLT_POS = 1; //过滤还是定位
|
||||
SEL_COL = ''; //选择列名
|
||||
public filterItems = {
|
||||
ALCD: '', //航空公司
|
||||
FLIN: '', //航线类别
|
||||
FLTY: '', //航班类别
|
||||
MVIN: '', //到达/出发
|
||||
FHAG: '', //机坪代理
|
||||
MHAG: '', //维护代理
|
||||
PHAG: '', //旅客代理
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入框回车事件
|
||||
*/
|
||||
inputEnter() {
|
||||
if (this.FLT_POS === 1) {
|
||||
this.selectChange()
|
||||
} else {
|
||||
this.inputPosition(this.render_data)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框选择筛选
|
||||
*/
|
||||
selectChange() {
|
||||
this.operateSpinServiceService.showSpin();
|
||||
setTimeout(() => {
|
||||
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.orderHandle.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 {
|
||||
render_flight[key] = (row_flights['preFlight'][key] === row_flights['reaFlight'][key]) ? (this.formatter[key][row_flights['preFlight'][key]]) : (this.formatter[key][row_flights['preFlight'][key]] + '/' + this.formatter[key][row_flights['reaFlight'][key]]);
|
||||
render_pre_flight[key] = this.formatter[key][row_flights['preFlight'][key]];
|
||||
render_rea_flight[key] = this.formatter[key][row_flights['reaFlight'][key]];
|
||||
is_satis = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
render_flight[key] = (row_flights['preFlight'][key] === row_flights['reaFlight'][key]) ? (row_flights['preFlight'][key]) : (row_flights['preFlight'][key] + '/' + row_flights['reaFlight'][key]);
|
||||
render_pre_flight[key] = row_flights['preFlight'][key];
|
||||
render_rea_flight[key] = row_flights['reaFlight'][key];
|
||||
}
|
||||
}
|
||||
row_flights['renderFlight'] = render_flight;
|
||||
row_flights['renderPreFlight'] = render_pre_flight;
|
||||
row_flights['renderReaFlight'] = render_rea_flight;
|
||||
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 (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'];
|
||||
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.combined_data.push(row_flights);
|
||||
})
|
||||
//this.doSequence(this.combined_data);
|
||||
this.render_data = this.combined_data
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
)
|
||||
/**
|
||||
* 固定表头
|
||||
*/
|
||||
var tableCont = document.querySelector('#table-container');
|
||||
function scrollHandle (){
|
||||
var scrollTop = this.scrollTop;
|
||||
this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)';
|
||||
}
|
||||
tableCont.addEventListener('scroll',scrollHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤及定位
|
||||
* @param filterItems
|
||||
* @return
|
||||
*/
|
||||
//输入框回车事件
|
||||
inputEnter() {
|
||||
if (this.FLT_POS === 1) {
|
||||
this.selectChange()
|
||||
} else {
|
||||
this.selectChange()
|
||||
this.inputPosition(this.render_data)
|
||||
}
|
||||
}
|
||||
|
||||
//下拉框选择筛选
|
||||
selectChange() {
|
||||
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 (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 (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;
|
||||
if (this.FLT_POS === 1) {
|
||||
this.inputFilter(filter_data);
|
||||
} else {
|
||||
return false;
|
||||
this.render_data = filter_data;
|
||||
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
}, 10)
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入框筛选
|
||||
* @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 {
|
||||
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.SEARCH, 'i'))) {
|
||||
is_satis = true;
|
||||
break;
|
||||
} else {
|
||||
is_satis = false;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
is_satis = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return is_satis;
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
if (this.FLT_POS === 1) {
|
||||
this.inputFilter(filter_data);
|
||||
} else {
|
||||
this.render_data = filter_data;
|
||||
this.render_data = filterData;
|
||||
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
|
||||
// this.inputPosition(this.render_data);
|
||||
this.changeDetectorRef.detectChanges();
|
||||
this.operateSpinServiceService.hideSpin()
|
||||
}
|
||||
}
|
||||
|
||||
//输入框筛选
|
||||
inputFilter(filterData) {
|
||||
if (this.SEARCH) {
|
||||
/**
|
||||
* 输入框定位
|
||||
*/
|
||||
positionArray: Array<any> = [];
|
||||
positionArrayIndex: number = 0;
|
||||
|
||||
inputPosition(filterData) {
|
||||
let transArray = []
|
||||
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;
|
||||
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) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
if (!this.SEARCH) {
|
||||
transArray.push(element)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
} 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'))) {
|
||||
filterData.forEach(element => {
|
||||
let cols = this.col_lists;
|
||||
for (let i = 0; i < cols.length; i++) {
|
||||
if (element['renderFlight'][cols[i]['COL_CODE']]) {
|
||||
if (element['renderFlight'][cols[i]['COL_CODE']].toString().match(new RegExp(this.SEARCH, 'i'))) {
|
||||
transArray.push(element)
|
||||
break;
|
||||
} else {
|
||||
@@ -345,35 +389,87 @@ inputPosition(filterData) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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];
|
||||
if (objTr) {
|
||||
$("#table-container").animate({ scrollTop: objTr.offsetTop - 42 }, "slow");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 选中某行
|
||||
* @param i
|
||||
*/
|
||||
selectRow(i) {
|
||||
this.row_state = i;
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* 单元格内容居左居右
|
||||
* @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';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 复选框勾选事件
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
this.changeDetectorRef.detectChanges();
|
||||
|
||||
let tr = $(".selected");
|
||||
let objTr = tr[0];
|
||||
$("#table-container").animate({ scrollTop: objTr.offsetTop - 42 }, "slow");
|
||||
|
||||
/**
|
||||
* tab项切换事件
|
||||
*/
|
||||
nzClick() {
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user