diff --git a/src/drawApp/relayCabinetLayoutApp.ts b/src/drawApp/relayCabinetLayoutApp.ts index 55a971c..ce1811f 100644 --- a/src/drawApp/relayCabinetLayoutApp.ts +++ b/src/drawApp/relayCabinetLayoutApp.ts @@ -181,7 +181,7 @@ export function saveDrawDatas(app: IDrawApp) { } }); storage.deviceRelateRelayList.push(...refRelaysList); - storage.belongsConcentrationStation = belongsStation; + storage.UniqueIdPrefix = UniqueIdPrefix; const base64 = fromUint8Array(storage.serialize()); console.log('保存数据', storage); // localStorage.setItem(StorageKey, base64); @@ -211,7 +211,7 @@ export async function loadDrawDatas(): Promise { storage.deviceRelateRelayList.forEach((relay) => { refRelaysList.push(relay); }); - belongsStation = storage.belongsConcentrationStation; + UniqueIdPrefix = storage.UniqueIdPrefix; return Promise.resolve({ canvasProperty: storage.canvas, datas: datas, @@ -277,11 +277,13 @@ export function deleteDeviceRelateRelay(row: RelateRelaylistItem) { } //所属集中站 -let belongsStation = ''; +let UniqueIdPrefix = new relayCabinetGraphicData.UniqueIdType(); export function loadBelongsStation() { - return belongsStation; + return UniqueIdPrefix; } -export function setBelongsStation(newStation: string) { - belongsStation = newStation; +export function setBelongsStation( + newUniqueIdPrefix: relayCabinetGraphicData.UniqueIdType +) { + UniqueIdPrefix = newUniqueIdPrefix; } diff --git a/src/layouts/RelayCabinetLayout.vue b/src/layouts/RelayCabinetLayout.vue index 84e0051..2574180 100644 --- a/src/layouts/RelayCabinetLayout.vue +++ b/src/layouts/RelayCabinetLayout.vue @@ -20,7 +20,7 @@ v-close-popup @click="openBelongsToStationDialog" > - 所属集中站 + UniqueId配置 批量生成继电器或继电器柜 @@ -129,13 +129,25 @@ > -
所属集中站
+
UniqueId配置
+ + @@ -177,6 +189,7 @@ import { ApiError } from 'src/boot/axios'; import { DialogChainObject, useQuasar } from 'quasar'; import { Relay } from 'src/graphics/relay/Relay'; import { RelayCabinet } from 'src/graphics/relayCabinet/RelayCabinet'; +import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics'; const $q = useQuasar(); const route = useRoute(); @@ -304,7 +317,7 @@ const saveAsName = ref(''); async function saveAs(name: string) { try { const drawApp = getDrawApp(); - const base64 = await saveDrawDatas(drawApp as IDrawApp); + const base64 = saveDrawDatas(drawApp as IDrawApp); const record = await saveAsDraft(+route.params.id as number, { name, proto: base64, @@ -321,14 +334,22 @@ async function saveAs(name: string) { } const belongsToStationDialog = ref(false); -const stationName = ref(''); +const UniqueIdPrefix = ref(); + function openBelongsToStationDialog() { belongsToStationDialog.value = true; - stationName.value = loadBelongsStation(); + UniqueIdPrefix.value = + loadBelongsStation() ?? new relayCabinetGraphicData.UniqueIdType(); } function belongsToStation() { - setBelongsStation(stationName.value); + const newData = new relayCabinetGraphicData.UniqueIdType({ + city: UniqueIdPrefix.value.city, + lineId: UniqueIdPrefix.value.lineId, + belongsConcentrationStation: + UniqueIdPrefix.value.belongsConcentrationStation, + }); + setBelongsStation(newData); belongsToStationDialog.value = false; saveAllDrawDatas(); } diff --git a/src/protos/relayCabinetLayoutGraphics.ts b/src/protos/relayCabinetLayoutGraphics.ts index b70f29e..9e2afae 100644 --- a/src/protos/relayCabinetLayoutGraphics.ts +++ b/src/protos/relayCabinetLayoutGraphics.ts @@ -13,7 +13,7 @@ export namespace relayCabinetGraphicData { relayCabinets?: RelayCabinet[]; relays?: Relay[]; deviceRelateRelayList?: DeviceRelateRelay[]; - belongsConcentrationStation?: string; + UniqueIdPrefix?: UniqueIdType; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4], this.#one_of_decls); @@ -30,8 +30,8 @@ export namespace relayCabinetGraphicData { if ("deviceRelateRelayList" in data && data.deviceRelateRelayList != undefined) { this.deviceRelateRelayList = data.deviceRelateRelayList; } - if ("belongsConcentrationStation" in data && data.belongsConcentrationStation != undefined) { - this.belongsConcentrationStation = data.belongsConcentrationStation; + if ("UniqueIdPrefix" in data && data.UniqueIdPrefix != undefined) { + this.UniqueIdPrefix = data.UniqueIdPrefix; } } } @@ -62,18 +62,21 @@ export namespace relayCabinetGraphicData { set deviceRelateRelayList(value: DeviceRelateRelay[]) { pb_1.Message.setRepeatedWrapperField(this, 4, value); } - get belongsConcentrationStation() { - return pb_1.Message.getFieldWithDefault(this, 5, "") as string; + get UniqueIdPrefix() { + return pb_1.Message.getWrapperField(this, UniqueIdType, 6) as UniqueIdType; } - set belongsConcentrationStation(value: string) { - pb_1.Message.setField(this, 5, value); + set UniqueIdPrefix(value: UniqueIdType) { + pb_1.Message.setWrapperField(this, 6, value); + } + get has_UniqueIdPrefix() { + return pb_1.Message.getField(this, 6) != null; } static fromObject(data: { canvas?: ReturnType; relayCabinets?: ReturnType[]; relays?: ReturnType[]; deviceRelateRelayList?: ReturnType[]; - belongsConcentrationStation?: string; + UniqueIdPrefix?: ReturnType; }): RelayCabinetGraphicStorage { const message = new RelayCabinetGraphicStorage({}); if (data.canvas != null) { @@ -88,8 +91,8 @@ export namespace relayCabinetGraphicData { if (data.deviceRelateRelayList != null) { message.deviceRelateRelayList = data.deviceRelateRelayList.map(item => DeviceRelateRelay.fromObject(item)); } - if (data.belongsConcentrationStation != null) { - message.belongsConcentrationStation = data.belongsConcentrationStation; + if (data.UniqueIdPrefix != null) { + message.UniqueIdPrefix = UniqueIdType.fromObject(data.UniqueIdPrefix); } return message; } @@ -99,7 +102,7 @@ export namespace relayCabinetGraphicData { relayCabinets?: ReturnType[]; relays?: ReturnType[]; deviceRelateRelayList?: ReturnType[]; - belongsConcentrationStation?: string; + UniqueIdPrefix?: ReturnType; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -113,8 +116,8 @@ export namespace relayCabinetGraphicData { if (this.deviceRelateRelayList != null) { data.deviceRelateRelayList = this.deviceRelateRelayList.map((item: DeviceRelateRelay) => item.toObject()); } - if (this.belongsConcentrationStation != null) { - data.belongsConcentrationStation = this.belongsConcentrationStation; + if (this.UniqueIdPrefix != null) { + data.UniqueIdPrefix = this.UniqueIdPrefix.toObject(); } return data; } @@ -130,8 +133,8 @@ export namespace relayCabinetGraphicData { writer.writeRepeatedMessage(3, this.relays, (item: Relay) => item.serialize(writer)); if (this.deviceRelateRelayList.length) writer.writeRepeatedMessage(4, this.deviceRelateRelayList, (item: DeviceRelateRelay) => item.serialize(writer)); - if (this.belongsConcentrationStation.length) - writer.writeString(5, this.belongsConcentrationStation); + if (this.has_UniqueIdPrefix) + writer.writeMessage(6, this.UniqueIdPrefix, () => this.UniqueIdPrefix.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -153,8 +156,8 @@ export namespace relayCabinetGraphicData { case 4: reader.readMessage(message.deviceRelateRelayList, () => pb_1.Message.addToRepeatedWrapperField(message, 4, DeviceRelateRelay.deserialize(reader), DeviceRelateRelay)); break; - case 5: - message.belongsConcentrationStation = reader.readString(); + case 6: + reader.readMessage(message.UniqueIdPrefix, () => message.UniqueIdPrefix = UniqueIdType.deserialize(reader)); break; default: reader.skipField(); } @@ -580,4 +583,117 @@ export namespace relayCabinetGraphicData { return Combinationtype.deserialize(bytes); } } + export class UniqueIdType extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + city?: string; + lineId?: string; + belongsConcentrationStation?: string; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("city" in data && data.city != undefined) { + this.city = data.city; + } + if ("lineId" in data && data.lineId != undefined) { + this.lineId = data.lineId; + } + if ("belongsConcentrationStation" in data && data.belongsConcentrationStation != undefined) { + this.belongsConcentrationStation = data.belongsConcentrationStation; + } + } + } + get city() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set city(value: string) { + pb_1.Message.setField(this, 1, value); + } + get lineId() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set lineId(value: string) { + pb_1.Message.setField(this, 2, value); + } + get belongsConcentrationStation() { + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; + } + set belongsConcentrationStation(value: string) { + pb_1.Message.setField(this, 3, value); + } + static fromObject(data: { + city?: string; + lineId?: string; + belongsConcentrationStation?: string; + }): UniqueIdType { + const message = new UniqueIdType({}); + if (data.city != null) { + message.city = data.city; + } + if (data.lineId != null) { + message.lineId = data.lineId; + } + if (data.belongsConcentrationStation != null) { + message.belongsConcentrationStation = data.belongsConcentrationStation; + } + return message; + } + toObject() { + const data: { + city?: string; + lineId?: string; + belongsConcentrationStation?: string; + } = {}; + if (this.city != null) { + data.city = this.city; + } + if (this.lineId != null) { + data.lineId = this.lineId; + } + if (this.belongsConcentrationStation != null) { + data.belongsConcentrationStation = this.belongsConcentrationStation; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.city.length) + writer.writeString(1, this.city); + if (this.lineId.length) + writer.writeString(2, this.lineId); + if (this.belongsConcentrationStation.length) + writer.writeString(3, this.belongsConcentrationStation); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): UniqueIdType { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new UniqueIdType(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.city = reader.readString(); + break; + case 2: + message.lineId = reader.readString(); + break; + case 3: + message.belongsConcentrationStation = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): UniqueIdType { + return UniqueIdType.deserialize(bytes); + } + } }