From 595a3f38abc80d973551bab8e39fd13c0764b29e Mon Sep 17 00:00:00 2001 From: zhouyuejun <505127606@qq.com> Date: Sat, 15 Dec 2018 14:06:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=BF=A1=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E9=86=92=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/main/main.component.ts | 55 ++++++++++++ .../pages/main/utils/alert-message-handle.ts | 89 +++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 src/app/pages/main/utils/alert-message-handle.ts diff --git a/src/app/pages/main/main.component.ts b/src/app/pages/main/main.component.ts index 8f85043..7deac4e 100644 --- a/src/app/pages/main/main.component.ts +++ b/src/app/pages/main/main.component.ts @@ -12,6 +12,7 @@ import { WebsocketService } from '../../services/websocket.service'; import { DynamicFlightOrder } from './utils/dynamic-flight-order'; import { FlightsDataHandle } from './utils/flights-data-handle'; import { CellColorHandle } from './utils/cell-color-handle'; +import { AlertMessageHandle } from './utils/alert-message-handle'; import dateFormatter from '../../utils/data-formatter'; @@ -36,12 +37,16 @@ export class MainComponent implements OnInit { public orderHandle = new DynamicFlightOrder(); public dataHandle = new FlightsDataHandle(); public cellColorHandle = new CellColorHandle(); + public alertMessageHandle = new AlertMessageHandle(); public tabClose: boolean = true; public canHandleDynamicMessage: boolean = false; public dynamicMessageArray: Array = []; + public canHandleDynamicAlert: boolean = false; + public dynamicAlertArray: Array = []; + //各项基础数据 public flightTypes: Array; public terminals: Array; @@ -61,6 +66,7 @@ export class MainComponent implements OnInit { public render_col_lists: Array; public airline_color: Array = []; + public airline_message_alert: Array = []; public row_state: any = { renderFlight: {} }; public checkboxGroup = { @@ -88,6 +94,12 @@ export class MainComponent implements OnInit { } else if (data.topic === 'msg') { let message = JSON.parse(data.message); console.log(message); + if (this.canHandleDynamicAlert) { + this.dynamicAlertHandle(message); + } else { + this.dynamicAlertArray.push(message); + } + } } ) @@ -101,6 +113,8 @@ export class MainComponent implements OnInit { this.render_col_lists = JSON.parse(element.settingContent).targetList; } else if (element.groupCode === 'userSettingColor') { this.airline_color = JSON.parse(element.settingContent); + } else if (element.groupCode === 'userSettingMsgAlert') { + this.airline_message_alert = JSON.parse(element.settingContent).targetList; } }) } @@ -228,6 +242,43 @@ export class MainComponent implements OnInit { this.changeDetectorRef.detectChanges(); } + /** + * 动态警示处理方法 + * @param message + */ + public alertMessage = { + 'FLOP-CNCL': this.alertMessageHandle.flopCncl.bind(this.alertMessageHandle), + 'FLOP-FRET': this.alertMessageHandle.flopFret.bind(this.alertMessageHandle), + 'FLOP-FDIV': this.alertMessageHandle.flopFdiv.bind(this.alertMessageHandle), + 'FLOP-FDEL': this.alertMessageHandle.flopFdel.bind(this.alertMessageHandle), + 'FLOP-DELY': this.alertMessageHandle.flopDely.bind(this.alertMessageHandle), + 'FLOP-ACTT': this.alertMessageHandle.flopActt.bind(this.alertMessageHandle), + 'FLOP-GTDT': this.alertMessageHandle.flopGtdt.bind(this.alertMessageHandle), + 'FLOP-PSDT': this.alertMessageHandle.flopPsdt.bind(this.alertMessageHandle), + 'FLOP-ESTT': this.alertMessageHandle.flopEstt.bind(this.alertMessageHandle), + 'FLOP-PADT': this.alertMessageHandle.flopPadt.bind(this.alertMessageHandle), + 'FLOP-CKDT': this.alertMessageHandle.flopCkdt.bind(this.alertMessageHandle), + 'FLOP-BOTM': this.alertMessageHandle.flopBotm.bind(this.alertMessageHandle), + 'FLOP-CLDT': this.alertMessageHandle.flopCldt.bind(this.alertMessageHandle), + 'FLOP-ROUT': this.alertMessageHandle.flopRout.bind(this.alertMessageHandle), + 'FLOP-VIPP': this.alertMessageHandle.flopVipp.bind(this.alertMessageHandle), + 'FLOP-HNAG': this.alertMessageHandle.flopHnag.bind(this.alertMessageHandle), + 'FLOP-FLBG': this.alertMessageHandle.flopFlbg.bind(this.alertMessageHandle), + 'FLOP-RENO': this.alertMessageHandle.flopReno.bind(this.alertMessageHandle), + 'FLOP-ABTM': this.alertMessageHandle.flopAbtm.bind(this.alertMessageHandle), + 'FLOP-CHDT': this.alertMessageHandle.flopChdt.bind(this.alertMessageHandle), + 'FLOP-TRML': this.alertMessageHandle.flopTrml.bind(this.alertMessageHandle), + } + dynamicAlertHandle(message) { + let alertType = message.META.TYPE + '-' + message.META.STYP; + let index = this.airline_message_alert.findIndex(val => val['COL_CODE'] === alertType); + if (index > -1) { + let alertText = this.alertMessage[alertType](); + const toastCfg = new ToastConfig(ToastType.SUCCESS, '', alertText, 10000); + this.toastService.toast(toastCfg); + } + } + /** * 数据组合完毕,执行排序、渲染以及动态信息处理 * @param combined_data @@ -260,6 +311,10 @@ export class MainComponent implements OnInit { this.dynamicMessageArray.forEach(message => { this.dynamicMessageHandle(message); }) + this.canHandleDynamicAlert = true; + this.dynamicAlertArray.forEach(message => { + this.dynamicAlertHandle(message); + }) } /** diff --git a/src/app/pages/main/utils/alert-message-handle.ts b/src/app/pages/main/utils/alert-message-handle.ts new file mode 100644 index 0000000..11e4cef --- /dev/null +++ b/src/app/pages/main/utils/alert-message-handle.ts @@ -0,0 +1,89 @@ +export class AlertMessageHandle{ + public alertMessage = { + 'FLOP-CNCL':'', + 'FLOP-FRET':'', + 'FLOP-FDIV':'', + 'FLOP-FDEL':'', + 'FLOP-DELY':'', + 'FLOP-ACTT':'', + 'FLOP-GTDT':'', + 'FLOP-PSDT':'', + 'FLOP-ESTT':'', + 'FLOP-PADT':'', + 'FLOP-CKDT':'', + 'FLOP-BOTM':'', + 'FLOP-CLDT':'', + 'FLOP-ROUT':'', + 'FLOP-VIPP':'', + 'FLOP-HNAG':'', + 'FLOP-FLBG':'', + 'FLOP-RENO':'', + 'FLOP-ABTM':'', + 'FLOP-CHOT':'', + 'FLOP-TRML':'', + } + + public flopCncl(){ + return '航班取消事件' + } + public flopFret(){ + return '航班返航事件' + } + public flopFdiv(){ + return '航班备降事件' + } + public flopFdel(){ + return '航班删除事件' + } + public flopDely(){ + return '航班延误事件' + } + public flopActt(){ + return '航班实际时间事件' + } + public flopGtdt(){ + return '航班登机门事件' + } + public flopPsdt(){ + return '航班机位变更事件' + } + public flopEstt(){ + return '航班预计时间事件' + } + public flopPadt(){ + return '航班站起飞时间事件' + } + public flopCkdt(){ + return '航班值机柜台事件' + } + public flopBotm(){ + return '航班登机开始事件' + } + public flopCldt(){ + return '航班行李转盘事件' + } + public flopRout(){ + return '航班航线事件' + } + public flopVipp(){ + return '航班VIP事件' + } + public flopHnag(){ + return '航班代理事件' + } + public flopFlbg(){ + return '航班首末件行李到达事件' + } + public flopReno(){ + return '航班飞机号变更事件' + } + public flopAbtm(){ + return '航班靠桥撤桥事件' + } + public flopChdt(){ + return '航班上下轮档事件' + } + public flopTrml(){ + return '航班航站楼事件' + } +} \ No newline at end of file