优化季度计划

This commit is contained in:
714943302@qq.com
2018-12-11 17:42:48 +08:00
parent 7d04e9a4c7
commit e9845dd9bd
2 changed files with 65 additions and 74 deletions
@@ -5,24 +5,7 @@
<div class="line-operator-left input-container mb-3 col-xlg-8 col-mlg-8 col-xl-8 col-lg-10">
<select class="mr-4 form-control" [(ngModel)]="SEL_COL" name="" id="">
<option value="">选择列名</option>
<option value="flightNumber">航班号</option>
<option value="seasonRecId">航班季度</option>
<option value="internationalCode">国际代码</option>
<option value="airlineChnName">航空公司</option>
<option value="routeType">航线类别</option>
<option value="flightTypeCode">航班类别</option>
<option value="flightTask">航班任务</option>
<option value="operationDays">运营日</option>
<option value="startDate">开始日期</option>
<option value="endDate">结束日期</option>
<option value="startAirport">航线</option>
<option value="arriOrDept">进/出港</option>
<option value="arrivalTime">到达时间</option>
<option value="departureTime">出发时间</option>
<option value="aircraftTypeName">机型</option>
<option value="flyingDistance">飞行距离(千米)</option>
<option value="flyingTime">飞行时间(分钟)</option>
<!-- <option *ngFor="let col of col_lists" [value]="col.col_code">{{col.col_chn}}</option> -->
<option *ngFor="let col of col_lists" [value]="col.col_code">{{col.col_chn}}</option>
</select>
<label class="radio-inline custom-radio nowrap mr-4">
<input type="radio" [(ngModel)]="FLT_POS" [value]="1" name="filter-position">
@@ -1,6 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { HttpClientService } from '../../services/http-client.service';
import { HttpParams } from '@angular/common/http';
import * as $ from 'jquery';
import { BasicDataService } from '../basic-data-service'
@Component({
@@ -21,6 +20,27 @@ export class SeasonalPlanComponent implements OnInit {
'detail': false
}
//选择列名
public col_lists = [
{ col_code: 'flightNumber', col_chn: '航班号' },
{ col_code: 'seasonRecId', col_chn: '航班季度' },
{ col_code: 'internationalCode', col_chn: '国际代码' },
{ col_code: 'airlineChnName', col_chn: '航空公司' },
{ col_code: 'routeType', col_chn: '航线类别' },
{ col_code: 'flightTypeCode', col_chn: '航班类别' },
{ col_code: 'flightTask', col_chn: '航班任务' },
{ col_code: 'operationDays', col_chn: '运营日' },
{ col_code: 'startDate', col_chn: '开始日期' },
{ col_code: 'endDate', col_chn: '结束日期' },
{ col_code: 'startAirport', col_chn: '航线' },
{ col_code: 'arriOrDept', col_chn: '进/出港' },
{ col_code: 'arrivalTime', col_chn: '到达时间' },
{ col_code: 'departureTime', col_chn: '出发时间' },
{ col_code: 'aircraftTypeCode', col_chn: '机型' },
{ col_code: 'flyingDistance', col_chn: '飞行距离(千米)' },
{ col_code: 'flyingTime', col_chn: '飞行时间(分钟)' },
]
// 搜索条件
SEARCH = ''; //手动输入条件
FLT_POS = 1; //过滤还是定位
@@ -237,10 +257,9 @@ export class SeasonalPlanComponent implements OnInit {
//输入框回车事件
inputEnter() {
if (this.FLT_POS === 1) {
this.inputFilter(this.seasonals)
this.selectChange()
} else {
this.inputFilter(this.seasonals)
this.inputPosition(this.seasonals)
this.inputPosition(this.render_data)
}
}
@@ -319,10 +338,10 @@ export class SeasonalPlanComponent implements OnInit {
}
for (const key in this.filterItems) {
if (this.filterItems.hasOwnProperty(key) && this.filterItems[key]) {
if (item[key] === +this.filterItems[key] || item[key] === this.filterItems[key]) {
if (item[key] == this.filterItems[key]) {
is_satis = true;
continue;
}else {
} else {
is_satis = false;
break;
}
@@ -330,6 +349,7 @@ export class SeasonalPlanComponent implements OnInit {
}
return is_satis;
})
this.return_data.forEach(element => {//航线类别列表显示数据转换
if (element['routeType'] == 'D') {
element['routeType'] = '国内'
@@ -427,6 +447,11 @@ export class SeasonalPlanComponent implements OnInit {
}
});
this.render_data = this.return_data;
if (this.FLT_POS === 1) {
this.inputFilter(this.render_data);
} else {
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
}
}
//输入框筛选
@@ -434,52 +459,39 @@ export class SeasonalPlanComponent implements OnInit {
if (this.SEARCH) {
if (this.SEL_COL) {
let sel_col = this.SEL_COL;
filterData = filterData.filter(item => {
this.render_data = filterData.filter(item => {
if (item[sel_col]) {
if (item[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) {
return true;
}
} else {
if (this.SEARCH) {
return false;
} else {
return true;
}
return false;
}
})
} else {
filterData = filterData.filter(item => {
this.render_data = filterData.filter(item => {
let is_satis = false;
for (const key in item) {
if (item.hasOwnProperty(key)) {
if (item[key]) {
if (item[key].toString().match(new RegExp(this.SEARCH, 'i'))) {
is_satis = true;
break;
} else {
is_satis = false;
continue;
}
let cols = this.col_lists;
for (let i = 0; i < cols.length; i++) {
if (item[cols[i].col_code]) {
if (item[cols[i].col_code].toString().match(new RegExp(this.SEARCH, 'i'))) {
is_satis = true;
break;
} else {
if (this.SEARCH) {
is_satis = false;
continue;
} else {
is_satis = true;
break;
}
is_satis = false;
continue;
}
} else {
is_satis = false;
continue;
}
}
return is_satis;
})
}
} else {
this.render_data = filterData;
}
this.render_data = filterData;
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
}
positionArray: Array<any> = [];
@@ -502,26 +514,22 @@ export class SeasonalPlanComponent implements OnInit {
});
} else {
filterData.forEach(element => {
for (const key in element) {
if (element.hasOwnProperty(key)) {
if (element[key]) {
if (element[key].toString().match(new RegExp(this.SEARCH, 'i'))) {
transArray.push(element)
break;
} else {
continue;
}
let cols = this.col_lists;
for (let i = 0; i < cols.length; i++) {
if (element[cols[i].col_code]) {
if (element[cols[i].col_code].toString().match(new RegExp(this.SEARCH, 'i'))) {
transArray.push(element)
break;
} else {
if (this.SEARCH) {
continue;
} else {
transArray.push(element)
break;
}
continue;
}
} else {
continue;
if (this.SEARCH) {
continue;
} else {
transArray.push(element)
break;
}
}
}
});
@@ -542,11 +550,11 @@ export class SeasonalPlanComponent implements OnInit {
} else {
alert('没有搜索到相关数据');
}
let tr = $(".selected");
let objTr = tr[0];
if (objTr) {
$("#table-container").animate({ scrollTop: objTr.offsetTop - 42 }, "slow");
}
let tr = $(".selected");
let objTr = tr[0];
if (objTr) {
$("#table-container").animate({ scrollTop: objTr.offsetTop - 42 }, "slow");
}
}
}