季度计划检测机制优化

This commit is contained in:
zhouyuejun
2018-12-25 14:04:41 +08:00
parent 0f9593b7fe
commit afa8646322
3 changed files with 272 additions and 337 deletions
+2 -1
View File
@@ -56,7 +56,7 @@ export class MainComponent implements OnInit {
this.airline_message_alert = JSON.parse(element.settingContent).targetList;
}
});
this.changeDetectorRef.detectChanges();
// this.changeDetectorRef.detectChanges();
// this.operateSpinServiceService.hideSpin();
}
)
@@ -584,6 +584,7 @@ export class MainComponent implements OnInit {
this.render_data = filter_data;
this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} };
this.changeDetectorRef.detectChanges();
this.operateSpinServiceService.hideSpin();
}
}, 10)
}
@@ -48,10 +48,10 @@
<option *ngFor="let item of flightTypes" [value]="item.flightTypeCode">{{item.flightTypeNameCn}}</option>
</select>
</div>
<div class="input-container mr-4">
<!-- <div class="input-container mr-4">
<label for="startDate">查询年份:&nbsp;&nbsp;</label>
<input readonly type="text" id="startDate" class="form-control" style="background:transparent;cursor: pointer">
</div>
</div> -->
<div class="input-container mr-4">
<label for="arriOrDept">到达/出发:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterItems.arriOrDept" (ngModelChange)="selectChange()">
@@ -60,6 +60,12 @@
<option value="D">出发</option>
</select>
</div>
<div class="input-container mr-4">
<label for="arriOrDept">查询年份:&nbsp;&nbsp;</label>
<select class="form-control" [(ngModel)]="filterYear" (ngModelChange)="selectYearChange($event)">
<option *ngFor="let year of yearLists" [value]="year">{{year}}</option>
</select>
</div>
</div>
<div class="third-condition row" [ngClass]="{'filterClose-c':filterClose,'filterClose-o':!filterClose}">
<label class="radio-inline custom-checkbox nowrap mr-4">
@@ -99,23 +105,22 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let seasonal of render_data;let i = index" (click)="selectRow(seasonal)"
[ngClass]="{'selected':row_state===seasonal}">
<td>{{i+1}}</td>
<tr *ngFor="let seasonal of render_data;let i = index" (click)="selectRow(seasonal)" [ngClass]="{'selected':row_state.seasonflightId===seasonal.seasonflightId}">
<td>{{i+1}}{{seasonal.seasonflightId}}</td>
<td>{{seasonal.flightNumber}}</td>
<td>{{seasonal.seasonRecId}}</td>
<td>{{seasonal.seasonRecIdChn}}</td>
<td>{{seasonal.internationalCode}}</td>
<td>{{seasonal.airlineChnName}}</td>
<td>{{seasonal.routeType}}</td>
<td>{{seasonal.flightTypeNameCn}}</td>
<td>{{seasonal.routeTypeChn}}</td>
<td>{{seasonal.flightTypeChnName}}</td>
<!-- <td>{{seasonal.flightTask}}</td> -->
<td>{{seasonal.operationDays}}</td>
<td>{{seasonal.startDate}}</td>
<td>{{seasonal.endDate}}</td>
<td>{{seasonal.startAirport}}</td>
<td>{{seasonal.arriOrDept}}</td>
<td>{{seasonal.arrivalTime}}</td>
<td>{{seasonal.departureTime}}</td>
<td>{{seasonal.AirportChn}}</td>
<td>{{seasonal.arriOrDeptChn}}</td>
<td>{{seasonal.arrivalTimeTra}}</td>
<td>{{seasonal.departureTimeTra}}</td>
<td>{{seasonal.aircraftTypeName}}</td>
<td>{{seasonal.flyingDistance}}</td>
<td>{{seasonal.flyingTime}}</td>
@@ -1,12 +1,17 @@
import { Component, OnInit ,ViewChild,Renderer2 } from '@angular/core';
import { Component, OnInit, ViewChild, Renderer2, ChangeDetectorRef } from '@angular/core';
import { OperateSpinServiceService } from '../../services/operate-spin-service.service';
import { HttpClientService } from '../../services/http-client.service';
import { BasicDataService } from '../../services/basic-data-service';
import { ChangeDetectorRef } from '@angular/core';
import { ToastService } from '../../components/toast/toast.service';
import { ToastConfig, ToastType } from '../../components/toast/toast-model';
import * as $ from 'jquery';
import { format } from 'util';
declare var laydate: any;
@Component({
selector: 'app-seasonal-plan',
templateUrl: './seasonal-plan.component.html',
@@ -18,9 +23,13 @@ export class SeasonalPlanComponent implements OnInit {
private renderer2: Renderer2,
private httpCilent: HttpClientService,
private basicDataService: BasicDataService,
private operateSpinServiceService: OperateSpinServiceService,
private toastService: ToastService,
private changeDetectorRef: ChangeDetectorRef
) { }
) {
this.operateSpinServiceService.showSpin();
this.changeDetectorRef.detach();
}
//勾选复选框
public checkboxGroup = {
@@ -31,19 +40,19 @@ export class SeasonalPlanComponent implements OnInit {
//选择列名
public col_lists = [
{ col_code: 'flightNumber', col_chn: '航班号' },
{ col_code: 'seasonRecId', col_chn: '航班季度' },
{ col_code: 'seasonRecIdChn', col_chn: '航班季度' },
{ col_code: 'internationalCode', col_chn: '国际代码' },
{ col_code: 'airlineChnName', col_chn: '航空公司' },
{ col_code: 'routeType', col_chn: '航线类别' },
{ col_code: 'flightTypeNameCn', col_chn: '航班类别' },
{ col_code: 'routeTypeChn', col_chn: '航线类别' },
{ col_code: 'flightTypeChnName', 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: 'AirportChn', col_chn: '航线' },
{ col_code: 'arriOrDeptChn', col_chn: '进/出港' },
{ col_code: 'arrivalTimeTra', col_chn: '到达时间' },
{ col_code: 'departureTimeTra', col_chn: '出发时间' },
{ col_code: 'aircraftTypeName', col_chn: '机型' },
{ col_code: 'flyingDistance', col_chn: '飞行距离(千米)' },
{ col_code: 'flyingTime', col_chn: '飞行时间(分钟)' },
@@ -63,97 +72,70 @@ export class SeasonalPlanComponent implements OnInit {
}
public tabClose: boolean = true;
seasonals : Array<any>;
yearLists: Array<any>;
filterYear: string = '';
yearOldValue: string = '';
seasonals: Array<any>; //季度计划
airlines: Array<any>; //航空公司
aircraftTypes: Array<any>; //机型
flightTypes: Array<any>; //航班类别
public row_state: any = { renderFlight: {} };
public row_state: any = {};
public combined_data: Array<object> = []; //组合数据,经过转换后的
public render_data: Array<object> = []; //显示数据,即需要显示的数据
public return_data: Array<object> = []; //下拉框显示数据
@ViewChild('mainPage') mainPage;
@ViewChild('searchFilter') searchFilter;
@ViewChild('tableContainer') tableContainer;
ngOnInit() {
//选择年份
this.laydateYear();
this.renderer2.setStyle(this.tableContainer.nativeElement, 'height', this.mainPage.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 55 + 'px');
window.onresize = function () {
this.renderer2.setStyle(this.tableContainer.nativeElement, 'height', this.mainPage.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 55 + 'px');
}.bind(this)
/* 获取季度计划信息 */
var value = new Date(new Date().getTime());
var subValue = format(value).substring(11,15); //时间截取到年份
this.httpCilent.get('/adminapi/schedule/flightSchdSeasons',{startDate: subValue}).subscribe(
this.httpCilent.get('/adminapi/schedule/flightSchdSeason/years').toPromise().then(
years => {
this.yearLists = years.body;
this.filterYear = this.yearLists[0];
this.httpCilent.get('/adminapi/schedule/flightSchdSeasons', { startDate: this.yearLists[0] }).subscribe(
data => {
this.seasonals = data.body;
this.render_data = this.seasonals;
this.airlinesHandle(); //航空公司
this.aircraftTypesHandle(); //机型
this.flightTypesHandle(); //航班类别
this.render_data.forEach(element => {//航线类别列表显示数据转换
if (element['routeType'] == 'D') {
element['routeType'] = '国内'
return element['routeType'];
}
if(element['routeType'] == 'I'){
element['routeType'] = '国际'
return element['routeType'];
}
if(element['routeType'] == 'M'){
element['routeType'] = '混合'
return element['routeType'];
}
if(element['routeType'] = 'R'){
element['routeType'] = '地区'
return element['routeType'];
}
});
this.render_data.forEach(item => {//到达/出发列表显示数据转换
if(item['arriOrDept'] == 'A'){
item['arriOrDept'] = '到达'
return item['arriOrDept']
}
if(item['arriOrDept'] == 'D'){
item['arriOrDept'] = '出发'
return item['arriOrDept']
}
});
}
)
//航空公司
this.airlines = this.basicDataService.airline;
this.basicDataService.airline_subject.subscribe(
data=>{
this.airlines = data;
if(this.airlines && this.airlines.length > 0){//航空公司列表数据转换
this.airlinesHandle();
}
}
)
//机型
// this.render_data = this.seasonals;
this.aircraftTypes = this.basicDataService.aircraft_type;
this.flightTypes = this.basicDataService.flightTypes;
this.airlines = this.basicDataService.airline;
if (this.airlines && this.airlines.length > 0) {
this.dataTransfer();
} else {
this.basicDataService.aircraft_type_subject.subscribe(
data => {
this.aircraftTypes = data;
if(this.aircraftTypes && this.aircraftTypes.length > 0){//机型列表数据转换
this.aircraftTypesHandle();
}
}
)
//航班类别
this.flightTypes = this.basicDataService.flightTypes;
);
this.basicDataService.flightTypes_subject.subscribe(
data => {
this.flightTypes = data;
if(this.flightTypes && this.flightTypes.length > 0){//航班类别列表数据转换
this.flightTypesHandle();
}
);
this.basicDataService.airline_subject.subscribe(
data => {
this.airlines = data;
this.dataTransfer();
}
)
}
}
)
/**
* 固定表头
*/
}
).catch(err => {
alert('请求失败')
})
var tableCont = document.querySelector('#table-container');
function scrollHandle() {
var scrollTop = this.scrollTop;
@@ -161,110 +143,97 @@ export class SeasonalPlanComponent implements OnInit {
}
tableCont.addEventListener('scroll', scrollHandle);
}
//航空公司名称数据转换处理
airlinesHandle() {
this.render_data.forEach(item => {
airlinesHandle(item) {
let airlineLinkIndex = this.airlines.findIndex(val => val.airlineId === item['airlineId']);
if(this.airlines[airlineLinkIndex]){
if (airlineLinkIndex > -1) {
item['airlineChnName'] = this.airlines[airlineLinkIndex].airlineName;
}
})
return item;
}
//机型数据转换处理
aircraftTypesHandle() {
this.render_data.forEach(item => {
aircraftTypesHandle(item) {
let aircraftTypesLinkIndex = this.aircraftTypes.findIndex(val => val.aircraftTypeCode === item['aircraftTypeCode']);
if(this.aircraftTypes[aircraftTypesLinkIndex]){
if (aircraftTypesLinkIndex > -1) {
item['aircraftTypeName'] = this.aircraftTypes[aircraftTypesLinkIndex].aircraftTypeName;
}
})
return item;
}
//航班类别数据转换处理
flightTypesHandle() {
this.render_data.forEach(item => {
flightTypesHandle(item) {
let flightTypesLinkIndex = this.flightTypes.findIndex(val => val.flightTypeCode === item['flightTypeCode']);
if(this.flightTypes[flightTypesLinkIndex]){
item['flightTypeNameCn'] = this.flightTypes[flightTypesLinkIndex].flightTypeNameCn;
if (flightTypesLinkIndex > -1) {
item['flightTypeChnName'] = this.flightTypes[flightTypesLinkIndex].flightTypeNameCn;
}
})
return item;
}
//选择年份
laydateYear(){
laydate.render({
elem: '#startDate',
showBottom: true,
value: new Date(new Date().getTime()),
type: 'year',
// format: 'yyyy',
done: (value) => {
this.httpCilent.get('/adminapi/schedule/flightSchdSeasons', { startDate: value }).subscribe(
//进/出港数据转换处理
arriOrDeptHandle(item) {
if (item['arriOrDept'] === 'A') {
item['arriOrDeptChn'] = '到达'
} else if (item['arriOrDept'] === 'D') {
item['arriOrDeptChn'] = '出发'
}
return item;
}
//航线类别数据转换处理
routeTypeHandle(item) {
if (item['routeType'] === 'D') {
item['routeTypeChn'] = '国内';
} else if (item['routeType'] === 'I') {
item['routeTypeChn'] = '国际';
} else if (item['routeType'] === 'M') {
item['routeTypeChn'] = '混合';
} else if (item['routeType'] === 'R') {
item['routeTypeChn'] = '地区';
} else {
item['routeTypeChn'] = '其他';
}
return item;
}
//数据转换统一处理
dataTransfer() {
this.seasonals.forEach(item => {
let line = Object.assign({}, item);
line = this.airlinesHandle(line);
line = this.aircraftTypesHandle(line);
line = this.flightTypesHandle(line);
line = this.arriOrDeptHandle(line);
line = this.routeTypeHandle(line);
this.combined_data.push(line);
})
this.render_data = this.combined_data;
this.changeDetectorRef.detectChanges();
this.operateSpinServiceService.hideSpin();
}
selectYearChange($event) {
this.operateSpinServiceService.showSpin();
this.SEARCH = '';
this.FLT_POS = 1;
this.SEL_COL = '';
this.filterItems = {
airlineId: '',
routeType: '',
flightTypeCode: '',
arriOrDept: '',
}
this.httpCilent.get('/adminapi/schedule/flightSchdSeasons', { startDate: $event }).subscribe(
data => {
this.seasonals = data.body;
this.render_data = this.seasonals;
if(this.airlines && this.airlines.length > 0){//航空公司列表数据转换
this.airlinesHandle();
}
if(this.aircraftTypes && this.aircraftTypes.length > 0){//机型列表数据转换
this.aircraftTypesHandle();
}
if(this.flightTypes && this.flightTypes.length > 0){//航班类别列表数据转换
this.flightTypesHandle();
}
this.render_data.forEach(element => {//航线类别列表显示数据转换
if (element['routeType'] == 'D') {
element['routeType'] = '国内'
return element['routeType'];
}
if(element['routeType'] == 'I'){
element['routeType'] = '国际'
return element['routeType'];
}
if(element['routeType'] == 'M'){
element['routeType'] = '混合'
return element['routeType'];
}
if(element['routeType'] = 'R'){
element['routeType'] = '地区'
return element['routeType'];
}
});
this.render_data.forEach(item => {//到达/出发列表显示数据转换
if(item['arriOrDept'] == 'A'){
item['arriOrDept'] = '到达'
return item['arriOrDept']
}
if(item['arriOrDept'] == 'D'){
item['arriOrDept'] = '出发'
return item['arriOrDept']
}
});
})
//航空公司
this.airlines = this.basicDataService.airline;
this.basicDataService.airline_subject.subscribe(
data=>{
this.airlines = data;
this.combined_data = [];
this.dataTransfer();
}
)
//机型
this.aircraftTypes = this.basicDataService.aircraft_type;
this.basicDataService.aircraft_type_subject.subscribe(
data => {
this.aircraftTypes = data;
}
)
//航班类别
this.flightTypes = this.basicDataService.flightTypes;
this.basicDataService.flightTypes_subject.subscribe(
data=> {
this.flightTypes = data;
}
)
}
});
}
public filterClose: boolean = true;
@@ -289,29 +258,30 @@ export class SeasonalPlanComponent implements OnInit {
}
}
}
this.changeDetectorRef.detectChanges();
}
/**
* tab项切换事件
*/
nzClick() {
this.changeDetectorRef.detectChanges();
}
/**
* 刷新
*/
refresh() {
const toastCfg = new ToastConfig(ToastType.SUCCESS, '', '刷新成功!', 3000);
this.toastService.toast(toastCfg);
this.selectYearChange(this.filterYear);
}
/**
* 选中某行
* @param i
* @param seasonal
*/
selectRow(i) {
this.row_state = i;
selectRow(seasonal) {
this.row_state = seasonal;
this.changeDetectorRef.detectChanges();
}
//输入框回车事件
@@ -325,30 +295,13 @@ export class SeasonalPlanComponent implements OnInit {
//下拉框选择筛选
selectChange() {
this.return_data = this.seasonals.filter(item=>{
this.operateSpinServiceService.showSpin();
setTimeout(() => {
let filter_data = this.combined_data.filter(item => {
let is_satis = true;
if(item['routeType'] == '国内'){
item['routeType'] = 'D'
}
if(item['routeType'] == '国际'){
item['routeType'] = 'I'
}
if(item['routeType'] == '混合'){
item['routeType'] = 'M'
}
if(item['routeType'] == '地区'){
item['routeType'] = 'R'
}
//到达/出发
if(item['arriOrDept'] == '到达'){
item['arriOrDept'] = 'A'
}
if(item['arriOrDept'] == '出发'){
item['arriOrDept'] = 'D'
}
for (const key in this.filterItems) {
if (this.filterItems.hasOwnProperty(key) && this.filterItems[key]) {
if (item[key] == this.filterItems[key]) {
if (item[key] === this.filterItems[key]) {
is_satis = true;
continue;
} else {
@@ -359,41 +312,15 @@ export class SeasonalPlanComponent implements OnInit {
}
return is_satis;
})
this.return_data.forEach(element => {//航线类别列表显示数据转换
if (element['routeType'] == 'D') {
element['routeType'] = '国内'
return element['routeType'];
}
if(element['routeType'] == 'I'){
element['routeType'] = '国际'
return element['routeType'];
}
if(element['routeType'] == 'M'){
element['routeType'] = '混合'
return element['routeType'];
}
if(element['routeType'] == 'R'){
element['routeType'] = '地区'
return element['routeType'];
}
});
this.return_data.forEach(item => {//到达/出发列表显示数据转换
if(item['arriOrDept'] == 'A'){
item['arriOrDept'] = '到达'
return item['arriOrDept']
}
if(item['arriOrDept'] == 'D'){
item['arriOrDept'] = '出发'
return item['arriOrDept']
}
});
this.render_data = this.return_data;
this.render_data = filter_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: {} };
this.row_state = this.render_data.length > 0 ? this.render_data[0] : {};
this.changeDetectorRef.detectChanges();
this.operateSpinServiceService.hideSpin();
}
}, 10)
}
//输入框筛选
@@ -431,9 +358,11 @@ export class SeasonalPlanComponent implements OnInit {
return is_satis;
})
}
} else {
this.render_data = filterData;
}
// this.render_data = filterData;
this.changeDetectorRef.detectChanges();
this.operateSpinServiceService.hideSpin();
}
positionArray: Array<any> = [];