diff --git a/src/components/draw-app/properties/PlatformProperty.vue b/src/components/draw-app/properties/PlatformProperty.vue index dd0984b..c89bb31 100644 --- a/src/components/draw-app/properties/PlatformProperty.vue +++ b/src/components/draw-app/properties/PlatformProperty.vue @@ -125,7 +125,7 @@ onMounted(() => { .queryStore.queryByType(Station.Type); centralizedStations.value = [{ label: '', value: 0 }]; stations.forEach((station) => { - if (station.datas.concentrationStations) { + if (station.datas.concentrationStations || station.datas.depots) { centralizedStations.value.push({ label: station.datas.name, value: station.datas.id, diff --git a/src/components/draw-app/properties/SectionProperty.vue b/src/components/draw-app/properties/SectionProperty.vue index 3ce3c50..5413f25 100644 --- a/src/components/draw-app/properties/SectionProperty.vue +++ b/src/components/draw-app/properties/SectionProperty.vue @@ -156,7 +156,7 @@ onMounted(() => { .queryStore.queryByType(Station.Type); centralizedStations.value = [{ label: '', value: 0 }]; stations.forEach((station) => { - if (station.datas.concentrationStations) { + if (station.datas.concentrationStations || station.datas.depots) { centralizedStations.value.push({ label: station.datas.name, value: station.datas.id, diff --git a/src/components/draw-app/properties/SignalProperty.vue b/src/components/draw-app/properties/SignalProperty.vue index d7614c6..f297a31 100644 --- a/src/components/draw-app/properties/SignalProperty.vue +++ b/src/components/draw-app/properties/SignalProperty.vue @@ -120,7 +120,7 @@ onMounted(() => { .queryStore.queryByType(Station.Type); centralizedStations.value = [{ label: '', value: 0 }]; stations.forEach((station) => { - if (station.datas.concentrationStations) { + if (station.datas.concentrationStations || station.datas.depots) { centralizedStations.value.push({ label: station.datas.name, value: station.datas.id, diff --git a/src/components/draw-app/properties/TurnoutProperty.vue b/src/components/draw-app/properties/TurnoutProperty.vue index ebd7858..a41d3f8 100644 --- a/src/components/draw-app/properties/TurnoutProperty.vue +++ b/src/components/draw-app/properties/TurnoutProperty.vue @@ -139,7 +139,7 @@ onMounted(() => { .queryStore.queryByType(Station.Type); centralizedStations.value = [{ label: '', value: 0 }]; stations.forEach((station) => { - if (station.datas.concentrationStations) { + if (station.datas.concentrationStations || station.datas.depots) { centralizedStations.value.push({ label: station.datas.name, value: station.datas.id, diff --git a/src/graphics/concentrationDividingLine/ConcentrationDividingLineUtils.ts b/src/graphics/concentrationDividingLine/ConcentrationDividingLineUtils.ts index bf6da02..ead0b28 100644 --- a/src/graphics/concentrationDividingLine/ConcentrationDividingLineUtils.ts +++ b/src/graphics/concentrationDividingLine/ConcentrationDividingLineUtils.ts @@ -8,6 +8,8 @@ import { TurnoutData } from 'src/drawApp/graphics/TurnoutInteraction'; import { SectionData } from 'src/drawApp/graphics/SectionInteraction'; import { SignalData } from 'src/drawApp/graphics/SignalInteraction'; import { Signal } from '../signal/Signal'; +import { Platform } from '../platform/Platform'; +import { PlatformData } from 'src/drawApp/graphics/PlatformInteraction'; //判断线段与线段有木有交点 export function isSegmentsIntersect( @@ -155,22 +157,23 @@ export function findContainDevice( export function handleCentralizedStationsData( devices: JlGraphic[], - centralizedStations: number[] + centralizedStation: number ) { interface GraphicData { - centralizedStations: number[]; + centralizedStation: number; } const dataMap = new Map([ [Turnout.Type, new TurnoutData()], [Section.Type, new SectionData()], [Signal.Type, new SignalData()], + [Platform.Type, new PlatformData()], ]); devices.forEach((device) => { const data = dataMap.get(device.type); if (data) { data.copyFrom(device.saveData()); const dataCopy = data as GraphicDataBase & GraphicData; - dataCopy.centralizedStations = centralizedStations; + dataCopy.centralizedStation = centralizedStation; device.updateData(data); } }); diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 95fc9fa..8a48b7c 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -246,10 +246,10 @@ const leftMenuConfig = [ { label: '一键生成分隔符', click: oneClickSeparator }, { label: '一键生成计轴', click: oneClickAxleCounting }, { label: '一键生成道岔区段', click: oneClickTurnoutSection }, - /* { + { label: '一键关联设备所属的集中站', click: oneClickRelateCentralizedStation, - }, */ + }, ]; onMounted(() => { @@ -343,7 +343,6 @@ function saveAllDrawDatas() { function buildRelations() { const app = getDrawApp(); app?.detectRelations(); - console.log(app); } function oneClickGeneration() { @@ -372,7 +371,7 @@ function oneClickTurnoutSection() { SDA.generateTurnoutSection(); } -/* function oneClickRelateCentralizedStation() { +function oneClickRelateCentralizedStation() { const drawApp = drawStore.getDrawApp(); const concentrationDividingLines = drawApp.queryStore .queryByType(ConcentrationDividingLine.Type) @@ -427,10 +426,10 @@ function oneClickTurnoutSection() { containDeviceIds = Array.from(new Set(containDeviceIds)); }); if (rightDatas.refRightStationId) { - handleContainDevices(containDeviceIds, [rightDatas.refRightStationId]); + handleContainDevices(containDeviceIds, rightDatas.refRightStationId); } } - //需要考虑是否绘制左右边界和车辆段这种 + //需要考虑是否绘制左右边界 const leftBoundary = concentrationDividingLines[0]; handleLeftBoundary(leftBoundary); const rightBoundary = @@ -485,7 +484,7 @@ function oneClickTurnoutSection() { function handleContainDevices( containDeviceIds: number[], - centralizedStations: number + centralizedStation: number ) { const containDevices = containDeviceIds.map((id) => { return drawApp.queryStore.queryById(id); @@ -495,13 +494,26 @@ function oneClickTurnoutSection() { .filter((g) => containDeviceIds.includes(g.datas.refDevice?.id as number) ); - const allSetCentralizedStationsDevice = [...containDevices, ...signals]; + let platforms: Platform[] = []; + if (centralizedStation !== 0) { + const station = drawApp.queryStore.queryById(centralizedStation); + platforms = drawApp.queryStore + .queryByType(Platform.Type) + .filter((g) => + station.datas.manageStations.includes(g.datas.refStation) + ); + } + const allSetCentralizedStationsDevice = [ + ...containDevices, + ...signals, + ...platforms, + ]; allSetCentralizedStationsDevice.forEach( - (g) => ((g as Signal).datas.centralizedStation = []) + (g) => ((g as Signal).datas.centralizedStation = 0) ); handleCentralizedStationsData( allSetCentralizedStationsDevice, - centralizedStations + centralizedStation ); } function handleLeftBoundary(leftBoundary: ConcentrationDividingLine) { @@ -529,11 +541,12 @@ function oneClickTurnoutSection() { containDeviceIds = Array.from(new Set(containDeviceIds)); }); if (!leftBoundary.datas.refLeftStationId) { - handleContainDevices(containDeviceIds, []); + handleContainDevices(containDeviceIds, 0); } else { - handleContainDevices(containDeviceIds, [ - leftBoundary.datas.refLeftStationId, - ]); + handleContainDevices( + containDeviceIds, + leftBoundary.datas.refLeftStationId + ); } } function handleRightBoundary(rightBoundary: ConcentrationDividingLine) { @@ -560,15 +573,16 @@ function oneClickTurnoutSection() { ); containDeviceIds = Array.from(new Set(containDeviceIds)); }); - if (rightBoundary.datas.refRightStationId) { - handleContainDevices(containDeviceIds, []); + if (!rightBoundary.datas.refRightStationId) { + handleContainDevices(containDeviceIds, 0); } else { - handleContainDevices(containDeviceIds, [ - rightBoundary.datas.refRightStationId, - ]); + handleContainDevices( + containDeviceIds, + rightBoundary.datas.refRightStationId + ); } } -} */ +} function backConfirm() { router.go(-1);