From 616b75805f20daac24728c4b152cb9f71da8d401 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 13 Sep 2023 17:28:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E8=81=94=E7=BB=A7=E7=94=B5=E5=99=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E5=90=88=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dialogs/DeviceRelateRelayList.vue | 19 +- .../draw-app/properties/RelateRelayConfig.vue | 212 ++++++++++++------ .../properties/RelayCabinetProperty.vue | 3 +- .../draw-app/properties/RelayProperty.vue | 6 +- src/drawApp/relayCabinetLayoutApp.ts | 18 +- src/protos/relayCabinetLayoutGraphics.ts | 126 +++++++++-- 6 files changed, 285 insertions(+), 99 deletions(-) diff --git a/src/components/draw-app/dialogs/DeviceRelateRelayList.vue b/src/components/draw-app/dialogs/DeviceRelateRelayList.vue index d21f2af..c6bde20 100644 --- a/src/components/draw-app/dialogs/DeviceRelateRelayList.vue +++ b/src/components/draw-app/dialogs/DeviceRelateRelayList.vue @@ -54,7 +54,6 @@ import { RelateRelaylistItem, } from 'src/drawApp/relayCabinetLayoutApp'; import { useRelayCabinetStore } from 'src/stores/relayCabinet-store'; -import { Relay } from 'src/graphics/relay/Relay'; const relayCabinetStore = useRelayCabinetStore(); const $q = useQuasar(); @@ -72,17 +71,13 @@ const columns: QTable['columns'] = [ }, { name: 'code', label: '设备编号', field: 'code', align: 'center' }, { - name: 'refRelay', - label: '关联的继电器', - field: (row) => { - if (row.refRelay) { - const ref: string[] = []; - row.refRelay.forEach((id: string) => { - const g = useRelayCabinetStore() - .getDrawApp() - .queryStore.queryById(id); - ref.push((g as Relay).datas.code); - }); + name: 'combinationtypes', + label: '关联的组合类型', + field: (row: RelateRelaylistItem) => { + if (row.combinationtypes) { + const ref = row.combinationtypes.map( + (combinationtype) => combinationtype.code + ); return ref.join('\\'); } }, diff --git a/src/components/draw-app/properties/RelateRelayConfig.vue b/src/components/draw-app/properties/RelateRelayConfig.vue index 14d9152..62474b4 100644 --- a/src/components/draw-app/properties/RelateRelayConfig.vue +++ b/src/components/draw-app/properties/RelateRelayConfig.vue @@ -22,32 +22,56 @@ :rules="[(val) => val.trim() != '' || '名称不能为空']" /> - - - 关联的继电器 -
- - {{ item }} - -
- -
-
+ + + + + +
+ + {{ item }} + +
+ +
+
+
+
+
@@ -59,7 +83,7 @@ diff --git a/src/components/draw-app/properties/RelayCabinetProperty.vue b/src/components/draw-app/properties/RelayCabinetProperty.vue index 72d6b2e..d1605fa 100644 --- a/src/components/draw-app/properties/RelayCabinetProperty.vue +++ b/src/components/draw-app/properties/RelayCabinetProperty.vue @@ -4,7 +4,8 @@ diff --git a/src/components/draw-app/properties/RelayProperty.vue b/src/components/draw-app/properties/RelayProperty.vue index 661408d..5b4411b 100644 --- a/src/components/draw-app/properties/RelayProperty.vue +++ b/src/components/draw-app/properties/RelayProperty.vue @@ -5,14 +5,18 @@ outlined v-model="relayModel.code" @blur="onUpdate" + :emit-value="true" + @update:model-value="onUpdate" label="编号" lazy-rules /> diff --git a/src/drawApp/relayCabinetLayoutApp.ts b/src/drawApp/relayCabinetLayoutApp.ts index 22e1027..55a971c 100644 --- a/src/drawApp/relayCabinetLayoutApp.ts +++ b/src/drawApp/relayCabinetLayoutApp.ts @@ -102,8 +102,10 @@ export function initDrawApp(): IDrawApp { app.on('postdataloaded', async () => { const map = new Map(); refRelaysList.forEach((device) => { - device.refRelay.forEach((relayId) => { - map.set(relayId, device.code); + device.combinationtypes.forEach((combinationtype) => { + combinationtype.refRelays.forEach((relayId) => { + map.set(relayId, device.code); + }); }); }); const relays = app.queryStore.queryByType(Relay.Type); @@ -111,6 +113,9 @@ export function initDrawApp(): IDrawApp { relay.refDevice.text = map.get(relay.id) as string; }); }); + app.on('destroy', async () => { + refRelaysList = []; + }); return drawApp; } @@ -221,11 +226,16 @@ export async function loadDrawDatas(): Promise { export interface RelateRelaylistItem { type: string; code: string; - refRelay: string[]; + combinationtypes: { + code: string; + refRelays: string[]; + refRelaysCode?: string[]; + expanded?: boolean; + }[]; } //关联继电器列表的增删改查 -const refRelaysList: relayCabinetGraphicData.DeviceRelateRelay[] = []; +let refRelaysList: relayCabinetGraphicData.DeviceRelateRelay[] = []; export function loadDeviceRelateRelayList() { return refRelaysList; } diff --git a/src/protos/relayCabinetLayoutGraphics.ts b/src/protos/relayCabinetLayoutGraphics.ts index e609e71..b70f29e 100644 --- a/src/protos/relayCabinetLayoutGraphics.ts +++ b/src/protos/relayCabinetLayoutGraphics.ts @@ -382,10 +382,10 @@ export namespace relayCabinetGraphicData { constructor(data?: any[] | { type?: string; code?: string; - refRelay?: string[]; + combinationtypes?: Combinationtype[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [5], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("type" in data && data.type != undefined) { this.type = data.type; @@ -393,8 +393,8 @@ export namespace relayCabinetGraphicData { if ("code" in data && data.code != undefined) { this.code = data.code; } - if ("refRelay" in data && data.refRelay != undefined) { - this.refRelay = data.refRelay; + if ("combinationtypes" in data && data.combinationtypes != undefined) { + this.combinationtypes = data.combinationtypes; } } } @@ -410,16 +410,16 @@ export namespace relayCabinetGraphicData { set code(value: string) { pb_1.Message.setField(this, 3, value); } - get refRelay() { - return pb_1.Message.getFieldWithDefault(this, 4, []) as string[]; + get combinationtypes() { + return pb_1.Message.getRepeatedWrapperField(this, Combinationtype, 5) as Combinationtype[]; } - set refRelay(value: string[]) { - pb_1.Message.setField(this, 4, value); + set combinationtypes(value: Combinationtype[]) { + pb_1.Message.setRepeatedWrapperField(this, 5, value); } static fromObject(data: { type?: string; code?: string; - refRelay?: string[]; + combinationtypes?: ReturnType[]; }): DeviceRelateRelay { const message = new DeviceRelateRelay({}); if (data.type != null) { @@ -428,8 +428,8 @@ export namespace relayCabinetGraphicData { if (data.code != null) { message.code = data.code; } - if (data.refRelay != null) { - message.refRelay = data.refRelay; + if (data.combinationtypes != null) { + message.combinationtypes = data.combinationtypes.map(item => Combinationtype.fromObject(item)); } return message; } @@ -437,7 +437,7 @@ export namespace relayCabinetGraphicData { const data: { type?: string; code?: string; - refRelay?: string[]; + combinationtypes?: ReturnType[]; } = {}; if (this.type != null) { data.type = this.type; @@ -445,8 +445,8 @@ export namespace relayCabinetGraphicData { if (this.code != null) { data.code = this.code; } - if (this.refRelay != null) { - data.refRelay = this.refRelay; + if (this.combinationtypes != null) { + data.combinationtypes = this.combinationtypes.map((item: Combinationtype) => item.toObject()); } return data; } @@ -458,8 +458,8 @@ export namespace relayCabinetGraphicData { writer.writeString(2, this.type); if (this.code.length) writer.writeString(3, this.code); - if (this.refRelay.length) - writer.writeRepeatedString(4, this.refRelay); + if (this.combinationtypes.length) + writer.writeRepeatedMessage(5, this.combinationtypes, (item: Combinationtype) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -475,8 +475,8 @@ export namespace relayCabinetGraphicData { case 3: message.code = reader.readString(); break; - case 4: - pb_1.Message.addToRepeatedField(message, 4, reader.readString()); + case 5: + reader.readMessage(message.combinationtypes, () => pb_1.Message.addToRepeatedWrapperField(message, 5, Combinationtype.deserialize(reader), Combinationtype)); break; default: reader.skipField(); } @@ -490,4 +490,94 @@ export namespace relayCabinetGraphicData { return DeviceRelateRelay.deserialize(bytes); } } + export class Combinationtype extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + code?: string; + refRelays?: string[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("code" in data && data.code != undefined) { + this.code = data.code; + } + if ("refRelays" in data && data.refRelays != undefined) { + this.refRelays = data.refRelays; + } + } + } + get code() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set code(value: string) { + pb_1.Message.setField(this, 1, value); + } + get refRelays() { + return pb_1.Message.getFieldWithDefault(this, 2, []) as string[]; + } + set refRelays(value: string[]) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + code?: string; + refRelays?: string[]; + }): Combinationtype { + const message = new Combinationtype({}); + if (data.code != null) { + message.code = data.code; + } + if (data.refRelays != null) { + message.refRelays = data.refRelays; + } + return message; + } + toObject() { + const data: { + code?: string; + refRelays?: string[]; + } = {}; + if (this.code != null) { + data.code = this.code; + } + if (this.refRelays != null) { + data.refRelays = this.refRelays; + } + 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.code.length) + writer.writeString(1, this.code); + if (this.refRelays.length) + writer.writeRepeatedString(2, this.refRelays); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Combinationtype { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Combinationtype(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.code = reader.readString(); + break; + case 2: + pb_1.Message.addToRepeatedField(message, 2, reader.readString()); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Combinationtype { + return Combinationtype.deserialize(bytes); + } + } }