车站关联继电器的code

This commit is contained in:
joylink_zhaoerwei 2023-12-06 14:35:33 +08:00
parent c47bea57ce
commit 165c77f1e8
6 changed files with 89 additions and 77 deletions

View File

@ -52,7 +52,7 @@ import {
deleteStationRelateDevice, deleteStationRelateDevice,
loadStationRelateDeviceList, loadStationRelateDeviceList,
RelateDevicelistItem, RelateDevicelistItem,
} from 'src/drawApp/thApp'; } from 'src/drawApp/commonApp';
import { useDrawStore } from 'src/stores/draw-store'; import { useDrawStore } from 'src/stores/draw-store';
const drawStore = useDrawStore(); const drawStore = useDrawStore();

View File

@ -20,6 +20,7 @@
label="设备编号" label="设备编号"
v-model="relateDeviceConfig.code" v-model="relateDeviceConfig.code"
:rules="[(val) => val.trim() != '' || '名称不能为空']" :rules="[(val) => val.trim() != '' || '名称不能为空']"
@blur="onSelectDeviceType"
/> />
<selectConfig-utils <selectConfig-utils
ref="selectConfigUtils" ref="selectConfigUtils"
@ -46,9 +47,11 @@ import {
creatStationRelateDevice, creatStationRelateDevice,
editStationRelateDevice, editStationRelateDevice,
RelateDevicelistItem, RelateDevicelistItem,
} from 'src/drawApp/thApp'; } from 'src/drawApp/commonApp';
import { graphicData } from 'src/protos/stationLayoutGraphics'; import { graphicData } from 'src/protos/stationLayoutGraphics';
import SelectConfigUtils from 'src/components/common/SelectConfigUtils.vue'; import SelectConfigUtils from 'src/components/common/SelectConfigUtils.vue';
import { Station } from 'src/graphics/station/Station';
import { Platform } from 'src/graphics/platform/Platform';
const filterSelect = (g: JlGraphic) => g.type == EsbButton.Type; const filterSelect = (g: JlGraphic) => g.type == EsbButton.Type;
const selectConfigUtils = ref<InstanceType<typeof SelectConfigUtils> | null>( const selectConfigUtils = ref<InstanceType<typeof SelectConfigUtils> | 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>(Station.Type)
.find((g) => g.datas.stationName == relateDeviceConfig.value.code);
const platforms = drawStore
.getDrawApp()
.queryStore.queryByType<Platform>(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() { function onReset() {
handleState.value = '新建车站关联设备'; handleState.value = '新建车站关联设备';
relateDeviceConfig.value = { relateDeviceConfig.value = {

View File

@ -252,6 +252,7 @@ export function loadCommonDrawDatas(
kilometerConvertList = storage.kilometerConvertList; kilometerConvertList = storage.kilometerConvertList;
sectionCodePointList = storage.sectionCodePointList; sectionCodePointList = storage.sectionCodePointList;
otherLineList = storage.otherLineList; otherLineList = storage.otherLineList;
refDevicesList = storage.stationRelateDeviceList;
storage.Platforms.forEach((platform) => { storage.Platforms.forEach((platform) => {
datas.push(new PlatformData(platform)); datas.push(new PlatformData(platform));
}); });
@ -315,10 +316,7 @@ export function loadCommonDrawDatas(
return datas; return datas;
} }
export function saveCommonDrawDatas( export function saveCommonDrawDatas(app: IDrawApp) {
app: IDrawApp,
refDevicesList?: graphicData.StationRelateDevice[]
) {
const storage = new graphicData.RtssGraphicStorage(); const storage = new graphicData.RtssGraphicStorage();
const canvasData = app.canvas.saveData(); const canvasData = app.canvas.saveData();
storage.canvas = new graphicData.Canvas({ storage.canvas = new graphicData.Canvas({
@ -395,15 +393,13 @@ export function saveCommonDrawDatas(
); );
} }
}); });
if (refDevicesList) {
storage.stationRelateDeviceList = refDevicesList;
}
storage.UniqueIdPrefix = UniqueIdPrefix; storage.UniqueIdPrefix = UniqueIdPrefix;
storage.screenDoorConfig = screenDoorConfig; storage.screenDoorConfig = screenDoorConfig;
storage.generateAxleCountingConfig = generateAxleCountingConfig; storage.generateAxleCountingConfig = generateAxleCountingConfig;
storage.kilometerConvertList = kilometerConvertList; storage.kilometerConvertList = kilometerConvertList;
storage.sectionCodePointList = sectionCodePointList; storage.sectionCodePointList = sectionCodePointList;
storage.otherLineList = otherLineList; storage.otherLineList = otherLineList;
storage.stationRelateDeviceList = refDevicesList;
return storage; return storage;
} }
@ -559,3 +555,51 @@ export function editOtherLine(row: graphicData.OtherLine) {
export function deleteOtherLine(index: number) { export function deleteOtherLine(index: number) {
otherLineList.splice(index, 1); 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;
}
}
}

View File

@ -138,7 +138,6 @@ export async function loadThDrawDatas(): Promise<IGraphicStorage> {
storage.esbButtons.forEach((esbButton) => { storage.esbButtons.forEach((esbButton) => {
datas.push(new EsbButtonData(esbButton)); datas.push(new EsbButtonData(esbButton));
}); });
refDevicesList = storage.stationRelateDeviceList;
return Promise.resolve({ return Promise.resolve({
canvasProperty: storage.canvas, canvasProperty: storage.canvas,
datas: datas, datas: datas,
@ -151,7 +150,7 @@ export async function loadThDrawDatas(): Promise<IGraphicStorage> {
} }
export function saveThDrawDatas(app: IDrawApp) { export function saveThDrawDatas(app: IDrawApp) {
const storage = saveCommonDrawDatas(app, refDevicesList); const storage = saveCommonDrawDatas(app);
console.log(storage, '保存数据'); console.log(storage, '保存数据');
const graphics = app.queryStore.getAllGraphics(); const graphics = app.queryStore.getAllGraphics();
graphics.forEach((g) => { graphics.forEach((g) => {
@ -171,53 +170,3 @@ export function saveThDrawDatas(app: IDrawApp) {
const base64 = fromUint8Array(storage.serialize()); const base64 = fromUint8Array(storage.serialize());
return base64; 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;
}
}
}

View File

@ -187,7 +187,6 @@ export async function loadZdwxDrawDatas(): Promise<IGraphicStorage> {
storage.autoReturnBoxs.forEach((autoReturnBox) => { storage.autoReturnBoxs.forEach((autoReturnBox) => {
datas.push(new AutoReturnBoxData(autoReturnBox)); datas.push(new AutoReturnBoxData(autoReturnBox));
}); });
refDevicesList = storage.stationRelateDeviceList;
return Promise.resolve({ return Promise.resolve({
canvasProperty: storage.canvas, canvasProperty: storage.canvas,
datas: datas, datas: datas,
@ -200,7 +199,7 @@ export async function loadZdwxDrawDatas(): Promise<IGraphicStorage> {
} }
export function saveZdwxDrawDatas(app: IDrawApp) { export function saveZdwxDrawDatas(app: IDrawApp) {
const storage = saveCommonDrawDatas(app, refDevicesList); const storage = saveCommonDrawDatas(app);
console.log(storage, '保存数据'); console.log(storage, '保存数据');
const graphics = app.queryStore.getAllGraphics(); const graphics = app.queryStore.getAllGraphics();
graphics.forEach((g) => { graphics.forEach((g) => {
@ -233,17 +232,3 @@ export function saveZdwxDrawDatas(app: IDrawApp) {
const base64 = fromUint8Array(storage.serialize()); const base64 = fromUint8Array(storage.serialize());
return base64; 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[] = [];

View File

@ -949,6 +949,10 @@ onUnmounted(() => {
drawStore.setEditOtherLineIndex(-1); drawStore.setEditOtherLineIndex(-1);
drawStore.destroy(); drawStore.destroy();
drawStore.setCategoryType(null); drawStore.setCategoryType(null);
drawStore.setRelateDeviceConfigVisible(false);
if (relateDeviceDialogInstance) {
relateDeviceDialogInstance.hide();
}
}); });
const dialogInstance = ref(); const dialogInstance = ref();