From 91e24db0d65ca551cd0eb5be2928fb2b25f9b0aa Mon Sep 17 00:00:00 2001 From: zhouyuejun <505127606@qq.com> Date: Mon, 14 Jan 2019 11:01:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A3=E5=BA=A6=E8=AE=A1=E5=88=92=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E4=B8=8D=E5=AE=8C=E6=95=B4=E5=AD=97=E6=AE=B5=E5=8F=8A?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=9C=BA=E4=BD=8D=E3=80=81=E9=A3=9E=E6=9C=BA?= =?UTF-8?q?=E5=8F=B7=E5=8F=98=E6=9B=B4=E6=98=BE=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/main/main.component.html | 14 -- src/app/pages/main/main.component.scss | 5 +- src/app/pages/main/main.component.ts | 4 +- .../seasonal-plan.component.html | 36 +++- .../seasonal-plan.component.scss | 104 ++++++--- .../seasonal-plan/seasonal-plan.component.ts | 204 +++++++++++++++--- src/app/utils/flights-data-handle.ts | 1 + src/app/utils/transfer-render-handle.ts | 39 +++- src/app/utils/web-worker-handle.ts | 79 ++++--- src/assets/web-worker-handle.js | 79 ++++--- 10 files changed, 427 insertions(+), 138 deletions(-) diff --git a/src/app/pages/main/main.component.html b/src/app/pages/main/main.component.html index 692ae13..d3d5128 100644 --- a/src/app/pages/main/main.component.html +++ b/src/app/pages/main/main.component.html @@ -166,10 +166,6 @@
- @@ -181,16 +177,6 @@
{{common_col.COL_CN}}
- - diff --git a/src/app/pages/main/main.component.scss b/src/app/pages/main/main.component.scss index 3343c6e..2425d40 100644 --- a/src/app/pages/main/main.component.scss +++ b/src/app/pages/main/main.component.scss @@ -61,6 +61,7 @@ th { background-color: #ddd; color: rgb(0, 0, 255); + text-align: center; } } &::-webkit-scrollbar { @@ -98,8 +99,8 @@ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - border: none; - // text-align: center; + border: 1px solid #dee2e6; + text-align: center; } } &::-webkit-scrollbar { diff --git a/src/app/pages/main/main.component.ts b/src/app/pages/main/main.component.ts index 0092210..4c85bc5 100644 --- a/src/app/pages/main/main.component.ts +++ b/src/app/pages/main/main.component.ts @@ -126,7 +126,6 @@ export class MainComponent implements OnInit { ngOnInit() { - console.log(Object.prototype.toString.call({})); 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) { @@ -472,7 +471,7 @@ export class MainComponent implements OnInit { /** * 创建线程并执行 */ - public promise: Worker = new Worker('/adminweb/assets/web-worker-handle.js'); + public promise: Worker = new Worker('/assets/web-worker-handle.js'); creatWorkers() { let dynamicData = { raw_data: this.raw_data, @@ -485,6 +484,7 @@ export class MainComponent implements OnInit { } this.promise.postMessage(dynamicData); this.promise.onmessage = function (e) { + console.log('=====') this.combined_data = e.data; this.selectChange('dynamic'); // this.promise.terminate(); diff --git a/src/app/pages/seasonal-plan/seasonal-plan.component.html b/src/app/pages/seasonal-plan/seasonal-plan.component.html index dde31ba..8079caa 100644 --- a/src/app/pages/seasonal-plan/seasonal-plan.component.html +++ b/src/app/pages/seasonal-plan/seasonal-plan.component.html @@ -1,5 +1,5 @@ -
-
+
+
@@ -81,7 +81,33 @@
-
+
+
+ + + + + + +
序号{{airline_col.COL_CN}}
+
+
+
+ + + + + + + +
{{start+i+1}}{{seasonal[airline_col.COL_CODE]}}
+
+ + + + + + 运营日 开始日期 结束日期 @@ -113,7 +138,6 @@ {{seasonal.airlineChnName}} {{seasonal.routeTypeChn}} {{seasonal.flightTypeChnName}} - {{seasonal.operationDays}} {{seasonal.startDate}} {{seasonal.endDate}} @@ -126,7 +150,7 @@ {{seasonal.flyingTime}} - + -->
diff --git a/src/app/pages/seasonal-plan/seasonal-plan.component.scss b/src/app/pages/seasonal-plan/seasonal-plan.component.scss index 8111a88..a7c804f 100644 --- a/src/app/pages/seasonal-plan/seasonal-plan.component.scss +++ b/src/app/pages/seasonal-plan/seasonal-plan.component.scss @@ -4,9 +4,10 @@ height: 100%; overflow-y: auto; padding: 15px 10px; - background-color: #fff; + background-color: #fff; .page-content { border: 1px solid #ccc; + height: 100%; padding: 10px 20px; .search-filter { padding: 0 15px; @@ -38,42 +39,75 @@ } } .airline-table{ - .table-container{ + .table-container { display: inline-block; - // border: 1px solid #ccc; + // position: relative; width: 100%; - height: 700px; - overflow: auto; - box-shadow: 0 0 1px .5px #ddd; - table{ - width: max-content; - tr{ - cursor: pointer; - &.selected{ - background: rgb(181, 215, 255); + // overflow-x: auto; + overflow-y: hidden; + box-shadow: 0 0 1px 0.5px #ddd; + .table-head { + overflow: hidden; + overflow-y: scroll; + height: 42px; + table { + margin: 0; + width: max-content; + th { + background-color: #ddd; + text-align: center; + color: rgb(0, 0, 255); } } - th{ - background-color: #ddd; - color: rgb(0, 0, 255); - } - th,td{ - // border: none; - text-align: center; + &::-webkit-scrollbar { + width: 15px; + height: 15px; } } - &::-webkit-scrollbar { - width: 15px; - height: 15px; - } - &::-webkit-scrollbar-thumb { - /*滚动条里面小方块*/ - background: rgba(165, 207, 222, 1); - border-radius: 10px; - } - &::-webkit-scrollbar-track { - background: rgba(0, 0, 0, 0.06); - border-radius: 10px; + + .table-body { + position: relative; + // height: 600px; + overflow: auto; + width: 100%; + .list-view-phantom { + position: absolute; + left: 0; + top: 0; + right: 0; + z-index: -1; + } + table { + left: 0; + right: 0; + top: 0; + position: absolute; + width: max-content; + tr { + cursor: pointer; + height: 42px; + &.selected { + background: rgb(181, 215, 255); + } + } + td { + border: 1px solid #dee2e6; + text-align: center + } + } + &::-webkit-scrollbar { + width: 15px; + height: 15px; + } + &::-webkit-scrollbar-thumb { + /*滚动条里面小方块*/ + background: rgba(165, 207, 222, 1); + border-radius: 10px; + } + &::-webkit-scrollbar-track { + background: rgba(0, 0, 0, 0.06); + border-radius: 10px; + } } } .airline-message { @@ -95,6 +129,14 @@ } } } + /deep/ .ant-tabs-content{ + height: calc(100% - 65px); + overflow-y: auto; + border: 1px solid #ccc; + } + nz-tabset{ + height: 100%; + } &::-webkit-scrollbar { width: 15px; height: 15px; diff --git a/src/app/pages/seasonal-plan/seasonal-plan.component.ts b/src/app/pages/seasonal-plan/seasonal-plan.component.ts index 88a3b5c..e1ab54e 100644 --- a/src/app/pages/seasonal-plan/seasonal-plan.component.ts +++ b/src/app/pages/seasonal-plan/seasonal-plan.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, Renderer2, ChangeDetectorRef } from '@angular/core'; +import { Component, OnInit, ViewChild, Renderer2 } 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'; @@ -16,10 +16,8 @@ export class SeasonalPlanComponent implements OnInit { private httpCilent: HttpClientService, private basicDataService: BasicDataService, private operateSpinServiceService: OperateSpinServiceService, - private changeDetectorRef: ChangeDetectorRef ) { this.operateSpinServiceService.showSpin(); - this.changeDetectorRef.detach(); } //勾选复选框 @@ -40,7 +38,7 @@ export class SeasonalPlanComponent implements OnInit { { col_code: 'operationDays', col_chn: '运营日' }, { col_code: 'startDate', col_chn: '开始日期' }, { col_code: 'endDate', col_chn: '结束日期' }, - { col_code: 'AirportChn', col_chn: '航线' }, + { col_code: 'routChn', col_chn: '航线' }, { col_code: 'arriOrDeptChn', col_chn: '进/出港' }, { col_code: 'arrivalTimeTra', col_chn: '到达时间' }, { col_code: 'departureTimeTra', col_chn: '出发时间' }, @@ -71,20 +69,55 @@ export class SeasonalPlanComponent implements OnInit { airlines: Array; //航空公司 aircraftTypes: Array; //机型 flightTypes: Array; //航班类别 + airports: Array; //机场 public row_state: any = {}; public combined_data: Array = []; //组合数据,经过转换后的 + public wait_render_data: Array = []; public render_data: Array = []; //显示数据,即需要显示的数据 - public return_data: Array = []; //下拉框显示数据 - @ViewChild('mainPage') mainPage; + render_col_lists: Array = [ + { "COL_CODE": "flightNumber", "COL_CN": "航班号", "COL_WIDTH": "85px" }, + { "COL_CODE": "seasonRecIdChn", "COL_CN": "航班季度", "COL_WIDTH": "85px" }, + { "COL_CODE": "internationalCode", "COL_CN": "国际代码", "COL_WIDTH": "85px" }, + { "COL_CODE": "airlineChnName", "COL_CN": "航空公司", "COL_WIDTH": "205px" }, + { "COL_CODE": "routeTypeChn", "COL_CN": "航线类别", "COL_WIDTH": "85px" }, + { "COL_CODE": "flightTypeChnName", "COL_CN": "航班类别", "COL_WIDTH": "85px" }, + { "COL_CODE": "operationDays", "COL_CN": "运营日", "COL_WIDTH": "85px" }, + { "COL_CODE": "startDate", "COL_CN": "开始日期", "COL_WIDTH": "100px" }, + { "COL_CODE": "endDate", "COL_CN": "结束日期", "COL_WIDTH": "100px" }, + { "COL_CODE": "routChn", "COL_CN": "航线", "COL_WIDTH": "85px" }, + { "COL_CODE": "arriOrDeptChn", "COL_CN": "进/出港", "COL_WIDTH": "85px" }, + { "COL_CODE": "arrivalTimeTra", "COL_CN": "到达时间", "COL_WIDTH": "100px" }, + { "COL_CODE": "departureTimeTra", "COL_CN": "出发时间", "COL_WIDTH": "100px" }, + { "COL_CODE": "aircraftTypeName", "COL_CN": "机型", "COL_WIDTH": "175px" }, + { "COL_CODE": "flyingDistance", "COL_CN": "飞行距离(千米)", "COL_WIDTH": "125px" }, + { "COL_CODE": "flyingTime", "COL_CN": "飞行时间(分钟)", "COL_WIDTH": "125px" }, + ] + + + @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; ngOnInit() { - this.renderer2.setStyle(this.tableContainer.nativeElement, 'height', this.mainPage.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 55 + 'px'); + 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'); + } window.onresize = function () { - this.renderer2.setStyle(this.tableContainer.nativeElement, 'height', this.mainPage.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 55 + 'px'); + this.calcVisibleCount(); }.bind(this) this.httpCilent.get('/adminapi/schedule/flightSchdSeason/years').toPromise().then( @@ -94,9 +127,9 @@ export class SeasonalPlanComponent implements OnInit { 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.airports = this.basicDataService.airport; this.flightTypes = this.basicDataService.flightTypes; this.airlines = this.basicDataService.airline; if (this.airlines && this.airlines.length > 0) { @@ -107,6 +140,12 @@ export class SeasonalPlanComponent implements OnInit { this.aircraftTypes = data; } ); + this.basicDataService.airport_subject.subscribe( + data => { + this.airports = data; + this.dataTransfer(); + } + ) this.basicDataService.flightTypes_subject.subscribe( data => { this.flightTypes = data; @@ -115,7 +154,7 @@ export class SeasonalPlanComponent implements OnInit { this.basicDataService.airline_subject.subscribe( data => { this.airlines = data; - this.dataTransfer(); + } ) } @@ -187,6 +226,50 @@ export class SeasonalPlanComponent implements OnInit { return item; } + //航线数据转换处理 + routHandle(item) { + let startIndex = this.airports.findIndex(airport => airport.airportCodeIata === item['startAirport']); + let endIndex = this.airports.findIndex(airport => airport.airportCodeIata === item['endAirport']); + if (startIndex > -1) { + if (this.airports[startIndex]['briefNameChn']) { + item['startAirportChn'] = this.airports[startIndex]['briefNameChn']; + } else { + item['startAirportChn'] = this.airports[startIndex]['airportNameChn']; + } + } else { + item['startAirportChn'] = item['startAirport']; + } + + if (endIndex > -1) { + if (this.airports[endIndex]['briefNameChn']) { + item['endAirportChn'] = this.airports[endIndex]['briefNameChn']; + } else { + item['endAirportChn'] = this.airports[endIndex]['airportNameChn']; + } + } else { + item['endAirportChn'] = item['endAirport']; + } + + item['routChn'] = item['startAirportChn'] + ' - ' + item['endAirportChn']; + return item; + } + + arrDeptTimeHandle(item) { + if (item['arrivalTime']) { + item['arrivalTimeTra'] = item['arrivalTime'].substr(0, 2) + ':' + item['arrivalTime'].substr(2, 3) + } else { + item['arrivalTimeTra'] = ''; + } + + if (item['departureTime']) { + item['departureTimeTra'] = item['departureTime'].substr(0, 2) + ':' + item['departureTime'].substr(2, 3) + } else { + item['departureTimeTra'] = ''; + } + + return item; + } + //数据转换统一处理 dataTransfer() { this.seasonals.forEach(item => { @@ -196,10 +279,25 @@ export class SeasonalPlanComponent implements OnInit { line = this.flightTypesHandle(line); line = this.arriOrDeptHandle(line); line = this.routeTypeHandle(line); + line = this.routHandle(line); + line = this.arrDeptTimeHandle(line); this.combined_data.push(line); }) - this.render_data = this.combined_data; - this.changeDetectorRef.detectChanges(); + + this.wait_render_data = this.combined_data; + + 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.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); + setTimeout(() => { + $(".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).innerWidth() + 'px'); + }) + }, 500) this.operateSpinServiceService.hideSpin(); } @@ -230,7 +328,51 @@ export class SeasonalPlanComponent implements OnInit { //点击展开切换操作 toggleFilter() { this.filterClose = !this.filterClose; - this.changeDetectorRef.detectChanges(); + setTimeout(() => { + this.calcVisibleCount(); + }, 10) + } + + /** + * 纵向滚动条滚动渲染数据 + */ + 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); + setTimeout(() => { + $(".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).innerWidth() + 'px'); + }) + }, 500) + } + + /** + * 计算可视区域数据的渲染 + */ + 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); + setTimeout(() => { + $(".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).innerWidth() + 'px'); + }) + }, 500) } /** @@ -248,14 +390,6 @@ export class SeasonalPlanComponent implements OnInit { } } } - this.changeDetectorRef.detectChanges(); - } - - /** - * tab项切换事件 - */ - nzClick() { - this.changeDetectorRef.detectChanges(); } /** @@ -271,7 +405,6 @@ export class SeasonalPlanComponent implements OnInit { */ selectRow(seasonal) { this.row_state = seasonal; - this.changeDetectorRef.detectChanges(); } //输入框回车事件 @@ -279,7 +412,7 @@ export class SeasonalPlanComponent implements OnInit { if (this.FLT_POS === 1) { this.selectChange() } else { - this.inputPosition(this.render_data) + this.inputPosition(this.wait_render_data) } } @@ -302,12 +435,17 @@ export class SeasonalPlanComponent implements OnInit { } return is_satis; }) - this.render_data = filter_data; if (this.FLT_POS === 1) { - this.inputFilter(this.render_data); + this.inputFilter(filter_data); } else { + this.wait_render_data = filter_data; + this.render_data = this.wait_render_data.slice(this.start, this.end); + setTimeout(() => { + $(".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).innerWidth() + 'px'); + }) + }, 500) this.row_state = this.render_data.length > 0 ? this.render_data[0] : {}; - this.changeDetectorRef.detectChanges(); this.operateSpinServiceService.hideSpin(); } }, 10) @@ -318,7 +456,7 @@ export class SeasonalPlanComponent implements OnInit { if (this.SEARCH) { if (this.SEL_COL) { let sel_col = this.SEL_COL; - this.render_data = filterData.filter(item => { + filterData = filterData.filter(item => { if (item[sel_col]) { if (item[sel_col].toString().match(new RegExp(this.SEARCH, 'i'))) { return true; @@ -328,7 +466,7 @@ export class SeasonalPlanComponent implements OnInit { } }) } else { - this.render_data = filterData.filter(item => { + filterData = filterData.filter(item => { let is_satis = false; let cols = this.col_lists; for (let i = 0; i < cols.length; i++) { @@ -349,8 +487,13 @@ export class SeasonalPlanComponent implements OnInit { }) } } - // this.render_data = filterData; - this.changeDetectorRef.detectChanges(); + this.wait_render_data = filterData; + this.render_data = this.wait_render_data.slice(this.start, this.end); + setTimeout(() => { + $(".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).innerWidth() + 'px'); + }) + }, 500) this.operateSpinServiceService.hideSpin(); } @@ -411,7 +554,6 @@ export class SeasonalPlanComponent implements OnInit { } else { alert('没有搜索到相关数据'); } - this.changeDetectorRef.detectChanges(); let tr = $(".selected"); let objTr = tr[0]; if (objTr) { diff --git a/src/app/utils/flights-data-handle.ts b/src/app/utils/flights-data-handle.ts index 893f1b8..1cba1ff 100644 --- a/src/app/utils/flights-data-handle.ts +++ b/src/app/utils/flights-data-handle.ts @@ -5,6 +5,7 @@ export class FlightsDataHandle { public transferHandle = new TransferRenderHandle(); public formatter = { + 'RENO':this.transferHandle.renoFormatter.bind(this.transferHandle), 'GCTM': this.transferHandle.gctmFormatter.bind(this.transferHandle), 'BOTM': this.transferHandle.botmFormatter.bind(this.transferHandle), 'ABDG': this.transferHandle.abdgFormatter.bind(this.transferHandle), diff --git a/src/app/utils/transfer-render-handle.ts b/src/app/utils/transfer-render-handle.ts index cc5e66c..1a4fdd7 100644 --- a/src/app/utils/transfer-render-handle.ts +++ b/src/app/utils/transfer-render-handle.ts @@ -1,6 +1,21 @@ import timeFormatter from './time-formatter'; import dateWithNotimeFormatter from './date-with-notime-formatter'; export class TransferRenderHandle { + public renoFormatter(flight){ + if(flight['RENO']){ + if(flight['LRENO']){ + return flight['RENO'] + '(' + flight['LRENO'] + ')'; + }else{ + return flight['RENO']; + } + }else{ + if(flight['LRENO']){ + return '(' + flight['LRENO'] + ')'; + }else{ + return ''; + } + } + } public gctmFormatter(flight) { if (flight['GTDT']) { if (Array.isArray(flight['GTDT']) && flight['GTDT'].length > 0) { @@ -227,14 +242,30 @@ export class TransferRenderHandle { psst.push(flight['PSDT'][i]['PSST']); } let set = new Set(psst); - return Array.from(set).join(','); + if(flight['LPSDT']){ + return Array.from(set).join(',') + '(' + flight['LPSDT'] + ')'; + }else{ + return Array.from(set).join(','); + } } else if (Object.prototype.toString.call(flight['PSDT']) === '[object Object]') { - return flight['PSDT']['PSST']; + if(flight['LPSDT']){ + return flight['PSDT']['PSST'] + '(' + flight['LPSDT'] + ')'; + }else{ + return flight['PSDT']['PSST']; + } } else { - return ''; + if(flight['LPSDT']){ + return '(' + flight['LPSDT'] + ')'; + }else{ + return ''; + } } } else { - return ''; + if(flight['LPSDT']){ + return '(' + flight['LPSDT'] + ')'; + }else{ + return ''; + } } } public esttFormatter(flight) { diff --git a/src/app/utils/web-worker-handle.ts b/src/app/utils/web-worker-handle.ts index 15b94b7..43dc788 100644 --- a/src/app/utils/web-worker-handle.ts +++ b/src/app/utils/web-worker-handle.ts @@ -152,6 +152,21 @@ export default function (dynamicData) { * 数据转换处理方法集 */ let formatter = { + 'RENO': function renoFormatter(flight) { + if (flight['RENO']) { + if (flight['LRENO']) { + return flight['RENO'] + '(' + flight['LRENO'] + ')'; + } else { + return flight['RENO']; + } + } else { + if (flight['LRENO']) { + return '(' + flight['LRENO'] + ')'; + } else { + return ''; + } + } + }, 'GCTM': function gctmFormatter(flight) { if (flight['GTDT']) { if (Array.isArray(flight['GTDT']) && flight['GTDT'].length > 0) { @@ -378,14 +393,30 @@ export default function (dynamicData) { psst.push(flight['PSDT'][i]['PSST']); } let set = new Set(psst); - return Array.from(set).join(','); + if (flight['LPSDT']) { + return Array.from(set).join(',') + '(' + flight['LPSDT'] + ')'; + } else { + return Array.from(set).join(','); + } } else if (Object.prototype.toString.call(flight['PSDT']) === '[object Object]') { - return flight['PSDT']['PSST']; + if (flight['LPSDT']) { + return flight['PSDT']['PSST'] + '(' + flight['LPSDT'] + ')'; + } else { + return flight['PSDT']['PSST']; + } + } else { + if (flight['LPSDT']) { + return '(' + flight['LPSDT'] + ')'; + } else { + return ''; + } + } + } else { + if (flight['LPSDT']) { + return '(' + flight['LPSDT'] + ')'; } else { return ''; } - } else { - return ''; } }, 'ESTT': function esttFormatter(flight) { @@ -921,13 +952,13 @@ export default function (dynamicData) { for (let i = 0; i < erutCodeArray.length; i++) { try { let airportIndex = airports.findIndex(val => val.airportCodeIata === erutCodeArray[i]); - if(airportIndex>-1){ - if(airports[airportIndex].briefNameChn){ + if (airportIndex > -1) { + if (airports[airportIndex].briefNameChn) { erutChnArray.push(airports[airportIndex].briefNameChn); - }else{ - erutChnArray.push(airports[airportIndex].airportNameChn); + } else { + erutChnArray.push(airports[airportIndex].airportNameChn); } - }else{ + } else { erutChnArray.push(erutCodeArray[i]); } } catch (error) { @@ -949,13 +980,13 @@ export default function (dynamicData) { for (let i = 0; i < erutLinkCodeArray.length; i++) { try { let airportIndex = airports.findIndex(val => val.airportCodeIata === erutLinkCodeArray[i]); - if(airportIndex>-1){ - if(airports[airportIndex].briefNameChn){ + if (airportIndex > -1) { + if (airports[airportIndex].briefNameChn) { erutLinkChnArray.push(airports[airportIndex].briefNameChn); - }else{ - erutLinkChnArray.push(airports[airportIndex].airportNameChn); + } else { + erutLinkChnArray.push(airports[airportIndex].airportNameChn); } - }else{ + } else { erutLinkChnArray.push(erutLinkCodeArray[i]); } } catch (error) { @@ -988,13 +1019,13 @@ export default function (dynamicData) { for (let i = 0; i < erutPreCodeArray.length; i++) { try { let airportIndex = airports.findIndex(val => val.airportCodeIata === erutPreCodeArray[i]); - if(airportIndex>-1){ - if(airports[airportIndex].briefNameChn){ + if (airportIndex > -1) { + if (airports[airportIndex].briefNameChn) { erutPreChnArray.push(airports[airportIndex].briefNameChn); - }else{ - erutPreChnArray.push(airports[airportIndex].airportNameChn); + } else { + erutPreChnArray.push(airports[airportIndex].airportNameChn); } - }else{ + } else { erutPreChnArray.push(erutPreCodeArray[i]); } } catch (error) { @@ -1017,13 +1048,13 @@ export default function (dynamicData) { for (let i = 0; i < erutReaCodeArray.length; i++) { try { let airportIndex = airports.findIndex(val => val.airportCodeIata === erutReaCodeArray[i]); - if(airportIndex>-1){ - if(airports[airportIndex].briefNameChn){ + if (airportIndex > -1) { + if (airports[airportIndex].briefNameChn) { erutReaChnArray.push(airports[airportIndex].briefNameChn); - }else{ - erutReaChnArray.push(airports[airportIndex].airportNameChn); + } else { + erutReaChnArray.push(airports[airportIndex].airportNameChn); } - }else{ + } else { erutReaChnArray.push(erutReaCodeArray[i]); } } catch (error) { diff --git a/src/assets/web-worker-handle.js b/src/assets/web-worker-handle.js index 9db50c6..b6d5715 100644 --- a/src/assets/web-worker-handle.js +++ b/src/assets/web-worker-handle.js @@ -152,6 +152,21 @@ onmessage = function (dynamicData) { * 数据转换处理方法集 */ let formatter = { + 'RENO': function renoFormatter(flight) { + if (flight['RENO']) { + if (flight['LRENO']) { + return flight['RENO'] + '(' + flight['LRENO'] + ')'; + } else { + return flight['RENO']; + } + } else { + if (flight['LRENO']) { + return '(' + flight['LRENO'] + ')'; + } else { + return ''; + } + } + }, 'GCTM': function gctmFormatter(flight) { if (flight['GTDT']) { if (Array.isArray(flight['GTDT']) && flight['GTDT'].length > 0) { @@ -378,14 +393,30 @@ onmessage = function (dynamicData) { psst.push(flight['PSDT'][i]['PSST']); } let set = new Set(psst); - return Array.from(set).join(','); + if (flight['LPSDT']) { + return Array.from(set).join(',') + '(' + flight['LPSDT'] + ')'; + } else { + return Array.from(set).join(','); + } } else if (Object.prototype.toString.call(flight['PSDT']) === '[object Object]') { - return flight['PSDT']['PSST']; + if (flight['LPSDT']) { + return flight['PSDT']['PSST'] + '(' + flight['LPSDT'] + ')'; + } else { + return flight['PSDT']['PSST']; + } + } else { + if (flight['LPSDT']) { + return '(' + flight['LPSDT'] + ')'; + } else { + return ''; + } + } + } else { + if (flight['LPSDT']) { + return '(' + flight['LPSDT'] + ')'; } else { return ''; } - } else { - return ''; } }, 'ESTT': function esttFormatter(flight) { @@ -921,13 +952,13 @@ onmessage = function (dynamicData) { for (let i = 0; i < erutCodeArray.length; i++) { try { let airportIndex = airports.findIndex(val => val.airportCodeIata === erutCodeArray[i]); - if(airportIndex>-1){ - if(airports[airportIndex].briefNameChn){ + if (airportIndex > -1) { + if (airports[airportIndex].briefNameChn) { erutChnArray.push(airports[airportIndex].briefNameChn); - }else{ - erutChnArray.push(airports[airportIndex].airportNameChn); + } else { + erutChnArray.push(airports[airportIndex].airportNameChn); } - }else{ + } else { erutChnArray.push(erutCodeArray[i]); } } catch (error) { @@ -949,13 +980,13 @@ onmessage = function (dynamicData) { for (let i = 0; i < erutLinkCodeArray.length; i++) { try { let airportIndex = airports.findIndex(val => val.airportCodeIata === erutLinkCodeArray[i]); - if(airportIndex>-1){ - if(airports[airportIndex].briefNameChn){ + if (airportIndex > -1) { + if (airports[airportIndex].briefNameChn) { erutLinkChnArray.push(airports[airportIndex].briefNameChn); - }else{ - erutLinkChnArray.push(airports[airportIndex].airportNameChn); + } else { + erutLinkChnArray.push(airports[airportIndex].airportNameChn); } - }else{ + } else { erutLinkChnArray.push(erutLinkCodeArray[i]); } } catch (error) { @@ -988,13 +1019,13 @@ onmessage = function (dynamicData) { for (let i = 0; i < erutPreCodeArray.length; i++) { try { let airportIndex = airports.findIndex(val => val.airportCodeIata === erutPreCodeArray[i]); - if(airportIndex>-1){ - if(airports[airportIndex].briefNameChn){ + if (airportIndex > -1) { + if (airports[airportIndex].briefNameChn) { erutPreChnArray.push(airports[airportIndex].briefNameChn); - }else{ - erutPreChnArray.push(airports[airportIndex].airportNameChn); + } else { + erutPreChnArray.push(airports[airportIndex].airportNameChn); } - }else{ + } else { erutPreChnArray.push(erutPreCodeArray[i]); } } catch (error) { @@ -1017,13 +1048,13 @@ onmessage = function (dynamicData) { for (let i = 0; i < erutReaCodeArray.length; i++) { try { let airportIndex = airports.findIndex(val => val.airportCodeIata === erutReaCodeArray[i]); - if(airportIndex>-1){ - if(airports[airportIndex].briefNameChn){ + if (airportIndex > -1) { + if (airports[airportIndex].briefNameChn) { erutReaChnArray.push(airports[airportIndex].briefNameChn); - }else{ - erutReaChnArray.push(airports[airportIndex].airportNameChn); + } else { + erutReaChnArray.push(airports[airportIndex].airportNameChn); } - }else{ + } else { erutReaChnArray.push(erutReaCodeArray[i]); } } catch (error) {