From a79f6c71ebc5673918ef5f1c97ac70a4d57e011a Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Sun, 8 Oct 2023 13:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E8=B0=83=E6=95=B4--=E6=BC=94?= =?UTF-8?q?=E7=A4=BA=E3=80=81=E5=8D=95=E9=80=89=E3=80=81=E7=BA=BF=E8=B7=AF?= =?UTF-8?q?Id=E3=80=81=E7=AB=99=E5=8F=B0=E9=97=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/AlertMock.ts | 2 +- src/components/alarm/setAlarmMock.vue | 23 ++++++++---- src/components/alarm/setAlarmText.vue | 8 +++-- .../graphics/LogicSectionInteraction.ts | 7 ++++ src/drawApp/graphics/SectionInteraction.ts | 35 ++++++++++++++++++- src/drawApp/graphics/TurnoutInteraction.ts | 7 ++++ src/drawApp/lineApp.ts | 6 +++- src/graphics/section/SectionDrawAssistant.ts | 2 +- src/layouts/MainLayout.vue | 2 +- 9 files changed, 78 insertions(+), 14 deletions(-) diff --git a/src/api/AlertMock.ts b/src/api/AlertMock.ts index c228e23..8ce3a5a 100644 --- a/src/api/AlertMock.ts +++ b/src/api/AlertMock.ts @@ -18,7 +18,7 @@ export function mockLocalDemoTestSet( return api.post(`${alertUriBase}/localDemoTest/${alertType}`, data); } -//故障演练 +//故障演示 export function mockAlertSet(data: { lineId: number; alertType: string; diff --git a/src/components/alarm/setAlarmMock.vue b/src/components/alarm/setAlarmMock.vue index 3e0803c..5c558b1 100644 --- a/src/components/alarm/setAlarmMock.vue +++ b/src/components/alarm/setAlarmMock.vue @@ -2,7 +2,7 @@ @@ -12,6 +12,7 @@ { clearSelect(); onReset(); + setAlartTextData.value.lineId = lineStore.lineId as unknown as string; }); const myForm = ref(null); @@ -198,7 +207,7 @@ async function onSubmit() { await mockAlertSet(params); $q.notify({ type: 'positive', - message: '设置故障演练成功', + message: '设置故障演示成功', }); onReset(); } catch (err) { @@ -231,7 +240,7 @@ function clearSelect() { function onReset() { setAlartTextData.value = { - lineId: '', + lineId: lineStore.lineId as unknown as string, alertType: '', deviceCodes: [], }; diff --git a/src/components/alarm/setAlarmText.vue b/src/components/alarm/setAlarmText.vue index bf73271..68c25c0 100644 --- a/src/components/alarm/setAlarmText.vue +++ b/src/components/alarm/setAlarmText.vue @@ -12,6 +12,7 @@ { clearSelect(); onReset(); + setAlartTextData.value.lineId = lineStore.lineId as unknown as string; }); const myForm = ref(null); @@ -255,7 +259,7 @@ function clearSelect() { function onReset() { setAlartTextData.value = { - lineId: '', + lineId: lineStore.lineId as unknown as string, rtuId: '', alertType: '', deviceInfos: [], diff --git a/src/drawApp/graphics/LogicSectionInteraction.ts b/src/drawApp/graphics/LogicSectionInteraction.ts index bf7ecc7..b8e8553 100644 --- a/src/drawApp/graphics/LogicSectionInteraction.ts +++ b/src/drawApp/graphics/LogicSectionInteraction.ts @@ -95,11 +95,18 @@ export class LogicSectionOperationPlugin extends GraphicInteractionPlugin { + static Name = 'logic_section_menu'; + constructor(app: IGraphicApp) { + super(sectionOperationPlugin.Name, app); + } + filter(...grahpics: JlGraphic[]): Section[] | undefined { + return grahpics.filter((g): g is Section => g instanceof Section); + } + static init(app: IGraphicApp) { + return new sectionOperationPlugin(app); + } + bind(g: Section): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.lineGraphic.hitArea = new SectionGraphicHitArea(g); + g.on('_leftclick', this.onLeftClick, this); + } + unbind(g: Section): void { + g.off('_leftclick', this.onLeftClick, this); + } + onLeftClick(e: FederatedMouseEvent) { + const target = e.target as DisplayObject; + const section = target.getGraphic() as Section; + this.app.updateSelected(section); + } +} diff --git a/src/drawApp/graphics/TurnoutInteraction.ts b/src/drawApp/graphics/TurnoutInteraction.ts index 3670ad9..fd00f12 100644 --- a/src/drawApp/graphics/TurnoutInteraction.ts +++ b/src/drawApp/graphics/TurnoutInteraction.ts @@ -158,6 +158,7 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin { sectionGraphic.cursor = 'pointer'; sectionGraphic.hitArea = new TurnoutSectionHitArea(sectionGraphic); }); + g.on('_leftclick', this.onLeftClick, this); g.on('rightclick', this.onContextMenu, this); } unbind(g: Turnout): void { @@ -165,8 +166,14 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin { g.graphics.sections.forEach((sectionGraphic) => { sectionGraphic.eventMode = 'none'; }); + g.off('_leftclick', this.onLeftClick, this); g.on('rightclick', this.onContextMenu, this); } + onLeftClick(e: FederatedMouseEvent) { + const target = e.target as DisplayObject; + const section = target.getGraphic() as Turnout; + this.app.updateSelected(section); + } onContextMenu(e: FederatedMouseEvent) { const target = e.target as DisplayObject; const turnout = target.getGraphic() as Turnout; diff --git a/src/drawApp/lineApp.ts b/src/drawApp/lineApp.ts index 14300fd..260711b 100644 --- a/src/drawApp/lineApp.ts +++ b/src/drawApp/lineApp.ts @@ -34,7 +34,10 @@ import { TurnoutStates, } from './graphics/TurnoutInteraction'; import { Turnout, TurnoutTemplate } from 'src/graphics/turnout/Turnout'; -import { SectionData } from './graphics/SectionInteraction'; +import { + SectionData, + sectionOperationPlugin, +} from './graphics/SectionInteraction'; import { SectionTemplate } from 'src/graphics/section/Section'; import { getPublishMapInfoByLineId } from 'src/api/PublishApi'; import { graphicData } from 'src/protos/stationLayoutGraphics'; @@ -175,6 +178,7 @@ export function initLineApp(lineId: number): IGraphicApp { TrainOperateInteraction.init(lineApp); TurnoutOperationPlugin.init(lineApp); LogicSectionOperationPlugin.init(lineApp); + sectionOperationPlugin.init(lineApp); lineApp.enableWsMassaging({ wsUrl: getWebsocketUrl(), diff --git a/src/graphics/section/SectionDrawAssistant.ts b/src/graphics/section/SectionDrawAssistant.ts index a4b8ec7..67c91c0 100644 --- a/src/graphics/section/SectionDrawAssistant.ts +++ b/src/graphics/section/SectionDrawAssistant.ts @@ -210,7 +210,7 @@ export class SectionDraw extends GraphicDrawAssistant< } } -class SectionGraphicHitArea implements IHitArea { +export class SectionGraphicHitArea implements IHitArea { section: Section; constructor(section: Section) { this.section = section; diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 32c1768..4b7915d 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -19,7 +19,7 @@