diff --git a/src/app/pages/main/main.component.ts b/src/app/pages/main/main.component.ts index e43009c..dca7a17 100644 --- a/src/app/pages/main/main.component.ts +++ b/src/app/pages/main/main.component.ts @@ -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) } diff --git a/src/app/pages/seasonal-plan/seasonal-plan.component.html b/src/app/pages/seasonal-plan/seasonal-plan.component.html index 9a6efea..507aadf 100644 --- a/src/app/pages/seasonal-plan/seasonal-plan.component.html +++ b/src/app/pages/seasonal-plan/seasonal-plan.component.html @@ -1,39 +1,39 @@
-
-
-
-
- - -
-
+ +
+
- -
-
+ +
+
-
+
-
- @@ -43,25 +43,31 @@
-
-
+
-
-
-
+
+ + +
+
+
-
-
+
+
-
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
序号航班号航班季度国际代码航空公司航线类别航班类别运营日开始日期结束日期航线进/出港到达时间出发时间机型飞行距离(千米)飞行时间(分钟)
{{i+1}}{{seasonal.flightNumber}}{{seasonal.seasonRecId}}{{seasonal.internationalCode}}{{seasonal.airlineChnName}}{{seasonal.routeType}}{{seasonal.flightTypeNameCn}}{{seasonal.operationDays}}{{seasonal.startDate}}{{seasonal.endDate}}{{seasonal.startAirport}}{{seasonal.arriOrDept}}{{seasonal.arrivalTime}}{{seasonal.departureTime}}{{seasonal.aircraftTypeName}}{{seasonal.flyingDistance}}{{seasonal.flyingTime}}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
序号航班号航班季度国际代码航空公司航线类别航班类别运营日开始日期结束日期航线进/出港到达时间出发时间机型飞行距离(千米)飞行时间(分钟)
{{i+1}}{{seasonal.seasonflightId}}{{seasonal.flightNumber}}{{seasonal.seasonRecIdChn}}{{seasonal.internationalCode}}{{seasonal.airlineChnName}}{{seasonal.routeTypeChn}}{{seasonal.flightTypeChnName}}{{seasonal.operationDays}}{{seasonal.startDate}}{{seasonal.endDate}}{{seasonal.AirportChn}}{{seasonal.arriOrDeptChn}}{{seasonal.arrivalTimeTra}}{{seasonal.departureTimeTra}}{{seasonal.aircraftTypeName}}{{seasonal.flyingDistance}}{{seasonal.flyingTime}}
@@ -133,6 +138,6 @@
-
-
+ + \ No newline at end of file diff --git a/src/app/pages/seasonal-plan/seasonal-plan.component.ts b/src/app/pages/seasonal-plan/seasonal-plan.component.ts index 1180096..a6c8b6f 100644 --- a/src/app/pages/seasonal-plan/seasonal-plan.component.ts +++ b/src/app/pages/seasonal-plan/seasonal-plan.component.ts @@ -1,16 +1,21 @@ -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', - styleUrls: ['./seasonal-plan.component.scss'] + selector: 'app-seasonal-plan', + templateUrl: './seasonal-plan.component.html', + styleUrls: ['./seasonal-plan.component.scss'] }) export class SeasonalPlanComponent implements OnInit { @@ -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,208 +72,168 @@ export class SeasonalPlanComponent implements OnInit { } public tabClose: boolean = true; - seasonals : Array; - airlines : Array; //航空公司 - aircraftTypes : Array; //机型 - flightTypes : Array; //航班类别 - public row_state: any = { renderFlight: {} }; + yearLists: Array; + filterYear: string = ''; + yearOldValue: string = ''; + + seasonals: Array; //季度计划 + airlines: Array; //航空公司 + aircraftTypes: Array; //机型 + flightTypes: Array; //航班类别 + + public row_state: any = {}; + public combined_data: Array = []; //组合数据,经过转换后的 public render_data: Array = []; //显示数据,即需要显示的数据 public return_data: Array = []; //下拉框显示数据 @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( - 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']; + + + 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.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; + } + ); + this.basicDataService.flightTypes_subject.subscribe( + data => { + this.flightTypes = data; + } + ); + this.basicDataService.airline_subject.subscribe( + data => { + this.airlines = data; + this.dataTransfer(); + } + ) + } } - 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.aircraftTypes = this.basicDataService.aircraft_type; - 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(); - } - } - ) - /** - * 固定表头 - */ + ).catch(err => { + alert('请求失败') + }) + var tableCont = document.querySelector('#table-container'); - function scrollHandle (){ + function scrollHandle() { var scrollTop = this.scrollTop; this.querySelector('thead').style.transform = 'translateY(' + scrollTop + 'px)'; } - tableCont.addEventListener('scroll',scrollHandle); + tableCont.addEventListener('scroll', scrollHandle); } + //航空公司名称数据转换处理 - airlinesHandle() { - this.render_data.forEach(item => { - let airlineLinkIndex = this.airlines.findIndex(val => val.airlineId === item['airlineId']); - if(this.airlines[airlineLinkIndex]){ - item['airlineChnName'] = this.airlines[airlineLinkIndex].airlineName; - } - }) + airlinesHandle(item) { + let airlineLinkIndex = this.airlines.findIndex(val => val.airlineId === item['airlineId']); + if (airlineLinkIndex > -1) { + item['airlineChnName'] = this.airlines[airlineLinkIndex].airlineName; + } + return item; } //机型数据转换处理 - aircraftTypesHandle() { - this.render_data.forEach(item => { - let aircraftTypesLinkIndex = this.aircraftTypes.findIndex(val => val.aircraftTypeCode === item['aircraftTypeCode']); - if(this.aircraftTypes[aircraftTypesLinkIndex]){ - item['aircraftTypeName'] = this.aircraftTypes[aircraftTypesLinkIndex].aircraftTypeName; - } - }) + aircraftTypesHandle(item) { + let aircraftTypesLinkIndex = this.aircraftTypes.findIndex(val => val.aircraftTypeCode === item['aircraftTypeCode']); + if (aircraftTypesLinkIndex > -1) { + item['aircraftTypeName'] = this.aircraftTypes[aircraftTypesLinkIndex].aircraftTypeName; + } + return item; } //航班类别数据转换处理 - flightTypesHandle() { - this.render_data.forEach(item => { - let flightTypesLinkIndex = this.flightTypes.findIndex(val => val.flightTypeCode === item['flightTypeCode']); - if(this.flightTypes[flightTypesLinkIndex]){ - item['flightTypeNameCn'] = this.flightTypes[flightTypesLinkIndex].flightTypeNameCn; - } - }) + flightTypesHandle(item) { + let flightTypesLinkIndex = this.flightTypes.findIndex(val => val.flightTypeCode === item['flightTypeCode']); + 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( - 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.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; - } - ) + //进/出港数据转换处理 + 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.combined_data = []; + this.dataTransfer(); } - }); + ) + } 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,75 +295,32 @@ export class SeasonalPlanComponent implements OnInit { //下拉框选择筛选 selectChange() { - this.return_data = this.seasonals.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]) { - is_satis = true; - continue; - } else { - is_satis = false; - break; + this.operateSpinServiceService.showSpin(); + setTimeout(() => { + let filter_data = this.combined_data.filter(item => { + let is_satis = true; + for (const key in this.filterItems) { + if (this.filterItems.hasOwnProperty(key) && this.filterItems[key]) { + if (item[key] === this.filterItems[key]) { + is_satis = true; + continue; + } else { + is_satis = false; + break; + } } } + return is_satis; + }) + 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] : {}; + this.changeDetectorRef.detectChanges(); + this.operateSpinServiceService.hideSpin(); } - 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; - if (this.FLT_POS === 1) { - this.inputFilter(this.render_data); - } else { - this.row_state = this.render_data.length > 0 ? this.render_data[0] : { renderFlight: {} }; - } + }, 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 = [];