From 165c77f1e807075ba773c3cda8c2d3fda3b05625 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 6 Dec 2023 14:35:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E7=AB=99=E5=85=B3=E8=81=94=E7=BB=A7?= =?UTF-8?q?=E7=94=B5=E5=99=A8=E7=9A=84code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dialogs/StationRelateDeviceList.vue | 2 +- .../properties/StationRelateDeviceConfig.vue | 32 +++++++++- src/drawApp/commonApp.ts | 58 ++++++++++++++++--- src/drawApp/thApp.ts | 53 +---------------- src/drawApp/zdwxApp.ts | 17 +----- src/layouts/DrawLayout.vue | 4 ++ 6 files changed, 89 insertions(+), 77 deletions(-) diff --git a/src/components/draw-app/dialogs/StationRelateDeviceList.vue b/src/components/draw-app/dialogs/StationRelateDeviceList.vue index 9aec704..9e2e5a3 100644 --- a/src/components/draw-app/dialogs/StationRelateDeviceList.vue +++ b/src/components/draw-app/dialogs/StationRelateDeviceList.vue @@ -52,7 +52,7 @@ import { deleteStationRelateDevice, loadStationRelateDeviceList, RelateDevicelistItem, -} from 'src/drawApp/thApp'; +} from 'src/drawApp/commonApp'; import { useDrawStore } from 'src/stores/draw-store'; const drawStore = useDrawStore(); diff --git a/src/components/draw-app/properties/StationRelateDeviceConfig.vue b/src/components/draw-app/properties/StationRelateDeviceConfig.vue index e30f79a..adcd20d 100644 --- a/src/components/draw-app/properties/StationRelateDeviceConfig.vue +++ b/src/components/draw-app/properties/StationRelateDeviceConfig.vue @@ -20,6 +20,7 @@ label="设备编号" v-model="relateDeviceConfig.code" :rules="[(val) => val.trim() != '' || '名称不能为空']" + @blur="onSelectDeviceType" /> g.type == EsbButton.Type; const selectConfigUtils = ref | null>( @@ -167,6 +170,33 @@ async function editRelateDevices(row: RelateDevicelistItem) { } } +function onSelectDeviceType() { + if ( + relateDeviceConfig.value.deviceType == + graphicData.RelatedRef.DeviceType.station + ) { + const targetStation = drawStore + .getDrawApp() + .queryStore.queryByType(Station.Type) + .find((g) => g.datas.stationName == relateDeviceConfig.value.code); + const platforms = drawStore + .getDrawApp() + .queryStore.queryByType(Platform.Type) + .filter((g) => g.datas.refStation == targetStation?.id); + selectConfigUtils.value.selectConfig = []; + let refEsbRelayCodes = platforms.map((g) => g.datas.refEsbRelayCode); + refEsbRelayCodes = Array.from(new Set(refEsbRelayCodes)); + refEsbRelayCodes.forEach((relayCode) => { + selectConfigUtils.value.selectConfig.push({ + code: relayCode, + refDevices: [], + refDevicesCode: [], + expanded: false, + }); + }); + } +} + function onReset() { handleState.value = '新建车站关联设备'; relateDeviceConfig.value = { diff --git a/src/drawApp/commonApp.ts b/src/drawApp/commonApp.ts index 340bda5..6941c85 100644 --- a/src/drawApp/commonApp.ts +++ b/src/drawApp/commonApp.ts @@ -252,6 +252,7 @@ export function loadCommonDrawDatas( kilometerConvertList = storage.kilometerConvertList; sectionCodePointList = storage.sectionCodePointList; otherLineList = storage.otherLineList; + refDevicesList = storage.stationRelateDeviceList; storage.Platforms.forEach((platform) => { datas.push(new PlatformData(platform)); }); @@ -315,10 +316,7 @@ export function loadCommonDrawDatas( return datas; } -export function saveCommonDrawDatas( - app: IDrawApp, - refDevicesList?: graphicData.StationRelateDevice[] -) { +export function saveCommonDrawDatas(app: IDrawApp) { const storage = new graphicData.RtssGraphicStorage(); const canvasData = app.canvas.saveData(); storage.canvas = new graphicData.Canvas({ @@ -395,15 +393,13 @@ export function saveCommonDrawDatas( ); } }); - if (refDevicesList) { - storage.stationRelateDeviceList = refDevicesList; - } storage.UniqueIdPrefix = UniqueIdPrefix; storage.screenDoorConfig = screenDoorConfig; storage.generateAxleCountingConfig = generateAxleCountingConfig; storage.kilometerConvertList = kilometerConvertList; storage.sectionCodePointList = sectionCodePointList; storage.otherLineList = otherLineList; + storage.stationRelateDeviceList = refDevicesList; return storage; } @@ -559,3 +555,51 @@ export function editOtherLine(row: graphicData.OtherLine) { export function deleteOtherLine(index: number) { otherLineList.splice(index, 1); } + +//关联设备列表的增删改查 +export interface RelateDevicelistItem { + deviceType: graphicData.RelatedRef.DeviceType | undefined; + code: string; + combinationtypes: { + code: string; + refDevices: string[]; + refDevicesCode?: string[]; + expanded?: boolean; + }[]; +} + +let refDevicesList: graphicData.StationRelateDevice[] = []; +export function loadStationRelateDeviceList() { + return refDevicesList; +} + +export function creatStationRelateDevice(row: graphicData.StationRelateDevice) { + refDevicesList.push(row); +} + +export function editStationRelateDevice( + editRow: RelateDevicelistItem, + newData: graphicData.StationRelateDevice +) { + for (let i = 0; i < refDevicesList.length; i++) { + if ( + refDevicesList[i].deviceType == editRow.deviceType && + refDevicesList[i].code == editRow.code + ) { + refDevicesList[i] = newData; + break; + } + } +} + +export function deleteStationRelateDevice(row: RelateDevicelistItem) { + for (let i = 0; i < refDevicesList.length; i++) { + if ( + refDevicesList[i].deviceType == row.deviceType && + refDevicesList[i].code == row.code + ) { + refDevicesList.splice(i, 1); + break; + } + } +} diff --git a/src/drawApp/thApp.ts b/src/drawApp/thApp.ts index 54a2da6..bd51601 100644 --- a/src/drawApp/thApp.ts +++ b/src/drawApp/thApp.ts @@ -138,7 +138,6 @@ export async function loadThDrawDatas(): Promise { storage.esbButtons.forEach((esbButton) => { datas.push(new EsbButtonData(esbButton)); }); - refDevicesList = storage.stationRelateDeviceList; return Promise.resolve({ canvasProperty: storage.canvas, datas: datas, @@ -151,7 +150,7 @@ export async function loadThDrawDatas(): Promise { } export function saveThDrawDatas(app: IDrawApp) { - const storage = saveCommonDrawDatas(app, refDevicesList); + const storage = saveCommonDrawDatas(app); console.log(storage, '保存数据'); const graphics = app.queryStore.getAllGraphics(); graphics.forEach((g) => { @@ -171,53 +170,3 @@ export function saveThDrawDatas(app: IDrawApp) { const base64 = fromUint8Array(storage.serialize()); return base64; } - -//关联设备列表的增删改查 -export interface RelateDevicelistItem { - deviceType: graphicData.RelatedRef.DeviceType | undefined; - code: string; - combinationtypes: { - code: string; - refDevices: string[]; - refDevicesCode?: string[]; - expanded?: boolean; - }[]; -} - -let refDevicesList: graphicData.StationRelateDevice[] = []; -export function loadStationRelateDeviceList() { - return refDevicesList; -} - -export function creatStationRelateDevice(row: graphicData.StationRelateDevice) { - refDevicesList.push(row); - thDrawApp?.emit('postdataloaded'); -} - -export function editStationRelateDevice( - editRow: RelateDevicelistItem, - newData: graphicData.StationRelateDevice -) { - for (let i = 0; i < refDevicesList.length; i++) { - if ( - refDevicesList[i].deviceType == editRow.deviceType && - refDevicesList[i].code == editRow.code - ) { - refDevicesList[i] = newData; - break; - } - } - thDrawApp?.emit('postdataloaded'); -} - -export function deleteStationRelateDevice(row: RelateDevicelistItem) { - for (let i = 0; i < refDevicesList.length; i++) { - if ( - refDevicesList[i].deviceType == row.deviceType && - refDevicesList[i].code == row.code - ) { - refDevicesList.splice(i, 1); - break; - } - } -} diff --git a/src/drawApp/zdwxApp.ts b/src/drawApp/zdwxApp.ts index bf07b5b..ab7d819 100644 --- a/src/drawApp/zdwxApp.ts +++ b/src/drawApp/zdwxApp.ts @@ -187,7 +187,6 @@ export async function loadZdwxDrawDatas(): Promise { storage.autoReturnBoxs.forEach((autoReturnBox) => { datas.push(new AutoReturnBoxData(autoReturnBox)); }); - refDevicesList = storage.stationRelateDeviceList; return Promise.resolve({ canvasProperty: storage.canvas, datas: datas, @@ -200,7 +199,7 @@ export async function loadZdwxDrawDatas(): Promise { } export function saveZdwxDrawDatas(app: IDrawApp) { - const storage = saveCommonDrawDatas(app, refDevicesList); + const storage = saveCommonDrawDatas(app); console.log(storage, '保存数据'); const graphics = app.queryStore.getAllGraphics(); graphics.forEach((g) => { @@ -233,17 +232,3 @@ export function saveZdwxDrawDatas(app: IDrawApp) { const base64 = fromUint8Array(storage.serialize()); return base64; } - -//关联设备列表的增删改查 -export interface RelateDevicelistItem { - deviceType: graphicData.RelatedRef.DeviceType | undefined; - code: string; - combinationtypes: { - code: string; - refDevices: string[]; - refDevicesCode?: string[]; - expanded?: boolean; - }[]; -} - -let refDevicesList: graphicData.StationRelateDevice[] = []; diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 1b5c77b..650c121 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -949,6 +949,10 @@ onUnmounted(() => { drawStore.setEditOtherLineIndex(-1); drawStore.destroy(); drawStore.setCategoryType(null); + drawStore.setRelateDeviceConfigVisible(false); + if (relateDeviceDialogInstance) { + relateDeviceDialogInstance.hide(); + } }); const dialogInstance = ref();