diff --git a/src/components/draw-app/dialogs/TurnoutOperation.vue b/src/components/draw-app/dialogs/TurnoutOperation.vue index 9e48dc0..f56f4d0 100644 --- a/src/components/draw-app/dialogs/TurnoutOperation.vue +++ b/src/components/draw-app/dialogs/TurnoutOperation.vue @@ -56,7 +56,7 @@ import DraggableDialog from 'src/components/common/DraggableDialog.vue'; import { request } from 'src/protos/request'; import { useLineStore } from 'src/stores/line-store'; import { errorNotify } from 'src/utils/CommonNotify'; -import { onMounted, ref } from 'vue'; +import { onMounted, onUnmounted, ref } from 'vue'; const props = defineProps({ id: { @@ -116,5 +116,9 @@ function onCreate() { } }); } + +onUnmounted(() => { + lineStore.deviceOpreratDialogInstance = null; +}); diff --git a/src/components/line-app/states/TurnoutState.vue b/src/components/line-app/states/TurnoutState.vue index e15be9b..61df82e 100644 --- a/src/components/line-app/states/TurnoutState.vue +++ b/src/components/line-app/states/TurnoutState.vue @@ -159,7 +159,7 @@ import { Turnout } from 'src/graphics/turnout/Turnout'; import { useLineStore } from 'src/stores/line-store'; import { ref, watch, onMounted, onUnmounted } from 'vue'; -import { Dialog, DialogChainObject } from 'quasar'; +import { Dialog } from 'quasar'; import { TurnoutStates } from 'src/drawApp/graphics/TurnoutInteraction'; import TurnoutOperation from 'src/components/draw-app/dialogs/TurnoutOperation.vue'; import { JlGraphic } from 'jl-graphic'; @@ -218,19 +218,14 @@ onMounted(() => { setTurnoutState(lineStore.selectedGraphics[0] as Turnout); } }); -onUnmounted(() => { - if (graphic.value) { - unSubscribeState(graphic.value as JlGraphic); - } -}); const options = [{ label: '设置参数' }]; -let turnoutOpreratDialogInstance: DialogChainObject | null = null; + function doTurnoutOperation(item: { label: string }) { if (!lineStore.simulationId) return; if (item.label == '设置参数') { - if (turnoutOpreratDialogInstance) return; - turnoutOpreratDialogInstance = Dialog.create({ + if (lineStore.deviceOpreratDialogInstance) return; + lineStore.deviceOpreratDialogInstance = Dialog.create({ title: '道岔设置参数', message: '', component: TurnoutOperation, @@ -242,7 +237,7 @@ function doTurnoutOperation(item: { label: string }) { cancel: true, persistent: true, }).onCancel(() => { - turnoutOpreratDialogInstance = null; + lineStore.deviceOpreratDialogInstance = null; }); } } @@ -263,8 +258,8 @@ function updateState(newVal: TurnoutStates) { } onUnmounted(() => { - if (turnoutOpreratDialogInstance) { - turnoutOpreratDialogInstance?.hide(); + if (graphic.value) { + unSubscribeState(graphic.value as JlGraphic); } }); diff --git a/src/drawApp/graphics/TurnoutInteraction.ts b/src/drawApp/graphics/TurnoutInteraction.ts index a008912..6ce777b 100644 --- a/src/drawApp/graphics/TurnoutInteraction.ts +++ b/src/drawApp/graphics/TurnoutInteraction.ts @@ -93,11 +93,13 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin { const target = e.target as DisplayObject; const turnout = target.getGraphic(); if (!turnout) return; + const lineStore = useLineStore(); this.app.updateSelected(turnout); - const simulationId = useLineStore().simulationId || ''; - const mapId = useLineStore().mapId as number; + const simulationId = lineStore.simulationId || ''; + const mapId = lineStore.mapId as number; setTurnoutParam.handler = async () => { - Dialog.create({ + if (lineStore.deviceOpreratDialogInstance) return; + lineStore.deviceOpreratDialogInstance = Dialog.create({ title: '道岔设置参数', message: '', component: TurnoutOperation, @@ -112,7 +114,7 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin { }; const port = (target as TurnoutSection).port; - addTrainConfig.disabled = !port || !useLineStore().trainConfigList; + addTrainConfig.disabled = !port || !lineStore.trainConfigList; addTrainConfig.handler = () => { const relations = turnout.relationManage.getRelationsOfGraphicAndOtherType( diff --git a/src/layouts/LineLayout.vue b/src/layouts/LineLayout.vue index 735c319..8735ea5 100644 --- a/src/layouts/LineLayout.vue +++ b/src/layouts/LineLayout.vue @@ -209,6 +209,7 @@ onMounted(async () => { // drawerRight.value = false; }); onUnmounted(() => { + lineStore.deviceOpreratDialogInstance?.hide(); if (dialogInstance.value && lineStore.showLayerDialog) { dialogInstance.value.hide(); } @@ -343,6 +344,8 @@ function destroySimAndBack() { function switchScene(val: MapInfo) { if (val.id == lineStore.mapId) return; lineStore.selectedGraphics = null; + lineApp.getScene(lineStore.sceneName).updateSelected(); + lineStore.deviceOpreratDialogInstance?.hide(); lineStore.setMapId(val.id); sceneName = getSceneNameFn(val); lineStore.setSceneName(sceneName); diff --git a/src/router/routes.ts b/src/router/routes.ts index be9c4de..95b0db7 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -6,14 +6,8 @@ export const user = '2'; // 普通用户 export const routes: RouteRecordRaw[] = [ { path: '/', - component: () => import('layouts/MainLayout.vue'), - children: [ - { - path: '', - name: 'home', - component: () => import('pages/IndexPage.vue'), - }, - ], + name: 'home', + redirect: '/testManage/test', }, { diff --git a/src/stores/line-store.ts b/src/stores/line-store.ts index 71c996a..0d9e2fe 100644 --- a/src/stores/line-store.ts +++ b/src/stores/line-store.ts @@ -15,6 +15,7 @@ import { TrainState } from 'src/drawApp/graphics/TrainInteraction'; import { esbButtonOperation } from 'src/api/Simulation'; import { TrainConfigItem, getAllTrainList } from 'src/api/TrainModelApi'; import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { DialogChainObject } from 'quasar'; export const useLineStore = defineStore('line', { state: () => ({ @@ -34,6 +35,7 @@ export const useLineStore = defineStore('line', { trainStateMap: new Map() as Map, trainConfigList: null as TrainConfigItem[] | null, screenDoorGroupList: [] as graphicData.ScreenDoorGroup[], + deviceOpreratDialogInstance: null as DialogChainObject | null, }), getters: { selectedGraphicType: (state) => {