车站关联继电器的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,
loadStationRelateDeviceList,
RelateDevicelistItem,
} from 'src/drawApp/thApp';
} from 'src/drawApp/commonApp';
import { useDrawStore } from 'src/stores/draw-store';
const drawStore = useDrawStore();

View File

@ -20,6 +20,7 @@
label="设备编号"
v-model="relateDeviceConfig.code"
:rules="[(val) => val.trim() != '' || '名称不能为空']"
@blur="onSelectDeviceType"
/>
<selectConfig-utils
ref="selectConfigUtils"
@ -46,9 +47,11 @@ import {
creatStationRelateDevice,
editStationRelateDevice,
RelateDevicelistItem,
} from 'src/drawApp/thApp';
} from 'src/drawApp/commonApp';
import { graphicData } from 'src/protos/stationLayoutGraphics';
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 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() {
handleState.value = '新建车站关联设备';
relateDeviceConfig.value = {

View File

@ -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;
}
}
}

View File

@ -138,7 +138,6 @@ export async function loadThDrawDatas(): Promise<IGraphicStorage> {
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<IGraphicStorage> {
}
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;
}
}
}

View File

@ -187,7 +187,6 @@ export async function loadZdwxDrawDatas(): Promise<IGraphicStorage> {
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<IGraphicStorage> {
}
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[] = [];

View File

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