diff --git a/src/components/common/DraggableDialog.vue b/src/components/common/DraggableDialog.vue
index 2375f0b..387776f 100644
--- a/src/components/common/DraggableDialog.vue
+++ b/src/components/common/DraggableDialog.vue
@@ -26,6 +26,7 @@
{{ props.title }}
+
-
-
-
@@ -35,7 +32,6 @@ import CanvasRelayCabinetProperty from './properties/CanvasRelayCabinetProperty.
import RelayCabinetProperty from './properties/RelayCabinetProperty.vue';
import { RelayCabinet } from 'src/graphics/relayCabinet/RelayCabinet';
import RelayProperty from './properties/RelayProperty.vue';
-import SelectRelaysProperty from './properties/SelectRelaysProperty.vue';
import { Relay } from 'src/graphics/relay/Relay';
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
diff --git a/src/components/draw-app/dialogs/DeviceRelateRelayList.vue b/src/components/draw-app/dialogs/DeviceRelateRelayList.vue
new file mode 100644
index 0000000..25d3c0d
--- /dev/null
+++ b/src/components/draw-app/dialogs/DeviceRelateRelayList.vue
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/draw-app/properties/RelateRelayConfig.vue b/src/components/draw-app/properties/RelateRelayConfig.vue
new file mode 100644
index 0000000..1f0cc34
--- /dev/null
+++ b/src/components/draw-app/properties/RelateRelayConfig.vue
@@ -0,0 +1,225 @@
+
+
+
+
+ {{ handleState }}
+
+
+
+
+
+
+
+
+ 关联的继电器
+
+
+ {{ item }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/draw-app/properties/RelayCabinetProperty.vue b/src/components/draw-app/properties/RelayCabinetProperty.vue
index 5a64855..72d6b2e 100644
--- a/src/components/draw-app/properties/RelayCabinetProperty.vue
+++ b/src/components/draw-app/properties/RelayCabinetProperty.vue
@@ -5,7 +5,7 @@
outlined
v-model="relayCabinetModel.code"
@blur="onUpdate"
- label="继电器柜"
+ label="编号"
lazy-rules
/>
diff --git a/src/components/draw-app/properties/RelayProperty.vue b/src/components/draw-app/properties/RelayProperty.vue
index d478d84..f6575c5 100644
--- a/src/components/draw-app/properties/RelayProperty.vue
+++ b/src/components/draw-app/properties/RelayProperty.vue
@@ -1,13 +1,20 @@
-
-
+
+
+
@@ -19,8 +26,8 @@ import { onMounted, reactive, watch } from 'vue';
const relayCabinetStore = useRelayCabinetStore();
const relayModel = reactive(new RelayData());
+const optionsModel = ['JWXC-1700', 'JWXC-1000', 'JPXC-1000'];
-relayCabinetStore.$subscribe;
watch(
() => relayCabinetStore.selectedGraphic,
(val) => {
diff --git a/src/components/draw-app/properties/SelectRelaysProperty.vue b/src/components/draw-app/properties/SelectRelaysProperty.vue
deleted file mode 100644
index 32551ad..0000000
--- a/src/components/draw-app/properties/SelectRelaysProperty.vue
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/drawApp/relayCabinetGraphics/RelayInteraction.ts b/src/drawApp/relayCabinetGraphics/RelayInteraction.ts
index 3a4298d..c2ce9f1 100644
--- a/src/drawApp/relayCabinetGraphics/RelayInteraction.ts
+++ b/src/drawApp/relayCabinetGraphics/RelayInteraction.ts
@@ -26,6 +26,12 @@ export class RelayData extends GraphicDataBase implements IRelayData {
set code(v: string) {
this.data.code = v;
}
+ get model(): string {
+ return this.data.model;
+ }
+ set model(v: string) {
+ this.data.model = v;
+ }
clone(): RelayData {
return new RelayData(this.data.cloneMessage());
}
diff --git a/src/drawApp/relayCabinetLayoutApp.ts b/src/drawApp/relayCabinetLayoutApp.ts
index f1a225b..d072edb 100644
--- a/src/drawApp/relayCabinetLayoutApp.ts
+++ b/src/drawApp/relayCabinetLayoutApp.ts
@@ -95,13 +95,22 @@ export function initDrawApp(): IDrawApp {
global: true,
combinations: [CombinationKey.Ctrl],
onPress: () => {
- saveDrawToServer(app);
+ saveDrawDatasOnly(app);
},
})
);
return drawApp;
}
+export async function saveDrawDatasOnly(app: IDrawApp) {
+ try {
+ saveDrawToServer(app);
+ successNotify('保存数据成功!');
+ } catch (error) {
+ errorNotify('保存数据失败', '');
+ }
+}
+
export function checkDataToServer(app: IDrawApp) {
const base64 = saveDrawDatas(app);
checkMapData({ mapProto: base64 })
@@ -129,23 +138,23 @@ export function checkDataToServer(app: IDrawApp) {
});
}
-export function saveDrawToServer(app: IDrawApp) {
- const base64 = saveDrawDatas(app);
+export function saveDrawToServer(
+ app: IDrawApp,
+ deviceRelateRelay?: relayCabinetGraphicData.DeviceRelateRelay[] | undefined
+) {
+ const base64 = saveDrawDatas(app, deviceRelateRelay);
const relayCabinetStore = useRelayCabinetStore();
const id = relayCabinetStore.draftId;
if (!id) {
return;
}
- saveDraft(id as number, { proto: base64 })
- .then(() => {
- successNotify('保存数据成功!');
- })
- .catch((err) => {
- errorNotify(err.message, err);
- });
+ saveDraft(id as number, { proto: base64 });
}
-export function saveDrawDatas(app: IDrawApp) {
+export function saveDrawDatas(
+ app: IDrawApp,
+ deviceRelateRelay?: relayCabinetGraphicData.DeviceRelateRelay[] | undefined
+) {
const storage = new relayCabinetGraphicData.RelayCabinetGraphicStorage();
const canvasData = app.canvas.saveData();
storage.canvas = new graphicData.Canvas({
@@ -163,6 +172,9 @@ export function saveDrawDatas(app: IDrawApp) {
storage.relays.push((relayData as RelayData).data);
}
});
+ if (deviceRelateRelay !== undefined) {
+ storage.deviceRelateRelayList.push(...deviceRelateRelay);
+ }
const base64 = fromUint8Array(storage.serialize());
console.log('保存数据', storage);
// localStorage.setItem(StorageKey, base64);
@@ -199,3 +211,35 @@ export async function loadDrawDatas(): Promise {
});
}
}
+
+export interface RelateRelaylistItem {
+ type: string;
+ code: string;
+ refRelay: string[];
+}
+
+export async function loadDeviceRelateRelayList() {
+ const relayCabinetStore = useRelayCabinetStore();
+ const id = relayCabinetStore.draftId;
+ if (!id) {
+ throw new Error('获取数据异常:未获取到草稿地图ID');
+ }
+ const { proto: base64 } = await getDraft(id);
+ if (base64) {
+ const storage =
+ relayCabinetGraphicData.RelayCabinetGraphicStorage.deserialize(
+ toUint8Array(base64)
+ );
+ const datas: relayCabinetGraphicData.DeviceRelateRelay[] = [];
+ storage.deviceRelateRelayList.forEach((relay) => {
+ datas.push(relay);
+ });
+ return Promise.resolve({
+ datas: datas,
+ });
+ } else {
+ return Promise.resolve({
+ datas: [],
+ });
+ }
+}
diff --git a/src/graphics/relay/Relay.ts b/src/graphics/relay/Relay.ts
index 6880991..1e26df9 100644
--- a/src/graphics/relay/Relay.ts
+++ b/src/graphics/relay/Relay.ts
@@ -9,6 +9,8 @@ import {
export interface IRelayData extends GraphicData {
get code(): string; // 编号
set code(v: string);
+ get model(): string; // 型号
+ set model(v: string);
clone(): IRelayData;
copyFrom(data: IRelayData): void;
eq(other: IRelayData): boolean;
diff --git a/src/layouts/RelayCabinetLayout.vue b/src/layouts/RelayCabinetLayout.vue
index 97ecaa8..602afdf 100644
--- a/src/layouts/RelayCabinetLayout.vue
+++ b/src/layouts/RelayCabinetLayout.vue
@@ -64,6 +64,12 @@
+
@@ -72,7 +78,13 @@
-
+
+
@@ -89,7 +101,6 @@
另存为
-
import DrawRelayCabinetProperties from 'src/components/draw-app/DrawRelayCabinetProperties.vue';
import BatchBuildRelayCabinetOrRelay from 'src/components/draw-app/dialogs/BatchBuildRelayCabinetOrRelay.vue';
+import DeviceRelateRelayList from 'src/components/draw-app/dialogs/DeviceRelateRelayList.vue';
+import RelateRelayConfig from 'src/components/draw-app/properties/RelateRelayConfig.vue';
import {
getDrawApp,
saveDrawDatas,
- saveDrawToServer,
checkDataToServer,
+ RelateRelaylistItem,
+ saveDrawDatasOnly,
} from 'src/drawApp/relayCabinetLayoutApp';
import { IDrawApp } from 'src/jl-graphic';
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
@@ -132,38 +146,8 @@ const $q = useQuasar();
const route = useRoute();
const router = useRouter();
const searchId = ref('');
-
const relayCabinetStore = useRelayCabinetStore();
-watch(
- () => relayCabinetStore.drawMode,
- (drawMode) => {
- if (!drawMode) {
- selectUtil.value = '';
- }
- }
-);
-watch(
- () => searchId.value,
- () => {
- try {
- if (searchId.value) {
- const device = relayCabinetStore
- .getDrawApp()
- .queryStore.queryById(searchId.value);
- relayCabinetStore.getDrawApp().makeGraphicCenterShow(device);
- relayCabinetStore.getDrawApp().updateSelected(device);
- }
- } catch (err) {
- $q.notify({
- type: 'negative',
- message: `未查找到id为【${searchId.value}】的设备`,
- });
- }
- }
-);
-
-const leftDrawerOpen = ref(false);
const rightDrawerOpen = ref(false);
function toggleRightDrawer() {
rightDrawerOpen.value = !rightDrawerOpen.value;
@@ -194,6 +178,34 @@ class ControlItem {
}
}
+watch(
+ () => relayCabinetStore.drawMode,
+ (drawMode) => {
+ if (!drawMode) {
+ selectUtil.value = '';
+ }
+ }
+);
+watch(
+ () => searchId.value,
+ () => {
+ try {
+ if (searchId.value) {
+ const device = relayCabinetStore
+ .getDrawApp()
+ .queryStore.queryById(searchId.value);
+ relayCabinetStore.getDrawApp().makeGraphicCenterShow(device);
+ relayCabinetStore.getDrawApp().updateSelected(device);
+ }
+ } catch (err) {
+ $q.notify({
+ type: 'negative',
+ message: `未查找到id为【${searchId.value}】的设备`,
+ });
+ }
+ }
+);
+
onMounted(() => {
console.log('绘制应用layout mounted');
const dom = document.getElementById('draw-app-container');
@@ -225,7 +237,6 @@ onMounted(() => {
const canvasWidth = ref(0);
const canvasHeight = ref(0);
const headerHeight = ref(0);
-const leftWidth = ref(0);
const rightWidth = ref(0);
function onHeaderResize(size: { height: number; width: number }) {
@@ -242,9 +253,7 @@ function onResize() {
const clientWidth = document.documentElement.clientWidth;
const clientHeight = document.documentElement.clientHeight;
canvasWidth.value =
- clientWidth -
- (leftDrawerOpen.value ? leftWidth.value : 0) -
- (rightDrawerOpen.value ? rightWidth.value : 0);
+ clientWidth - (rightDrawerOpen.value ? rightWidth.value : 0);
canvasHeight.value = clientHeight - headerHeight.value;
const dom = document.getElementById('draw-app-container');
if (dom) {
@@ -277,9 +286,8 @@ async function saveAs(name: string) {
function saveAllDrawDatas() {
const drawApp = getDrawApp();
- saveDrawToServer(drawApp as IDrawApp);
+ saveDrawDatasOnly(drawApp as IDrawApp);
}
-
function handleCheckData() {
const drawApp = getDrawApp();
checkDataToServer(drawApp as IDrawApp);
@@ -291,7 +299,6 @@ function buildRelations() {
}
let batchBuildDialogInstance: DialogChainObject | null = null;
-
function batchBuild() {
if (batchBuildDialogInstance) return;
batchBuildDialogInstance = $q
@@ -301,6 +308,24 @@ function batchBuild() {
});
}
+let relateRelayDialogInstance: DialogChainObject | null = null;
+const relateRelayConfigEdit = ref>();
+function openDeviceRelateRelayList() {
+ if (relateRelayDialogInstance) return;
+ relateRelayDialogInstance = $q
+ .dialog({
+ component: DeviceRelateRelayList,
+ componentProps: {
+ onEditClick: (row: RelateRelaylistItem) => {
+ relateRelayConfigEdit.value?.editRelateRelays(row);
+ },
+ },
+ })
+ .onCancel(() => {
+ relateRelayDialogInstance = null;
+ });
+}
+
function backConfirm() {
router.go(-1);
}
diff --git a/src/protos/relayCabinetLayoutGraphics.ts b/src/protos/relayCabinetLayoutGraphics.ts
index a589f6a..92856b8 100644
--- a/src/protos/relayCabinetLayoutGraphics.ts
+++ b/src/protos/relayCabinetLayoutGraphics.ts
@@ -12,9 +12,10 @@ export namespace relayCabinetGraphicData {
canvas?: dependency_1.graphicData.Canvas;
relayCabinets?: RelayCabinet[];
relays?: Relay[];
+ deviceRelateRelayList?: DeviceRelateRelay[];
}) {
super();
- pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3], this.#one_of_decls);
+ pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("canvas" in data && data.canvas != undefined) {
this.canvas = data.canvas;
@@ -25,6 +26,9 @@ export namespace relayCabinetGraphicData {
if ("relays" in data && data.relays != undefined) {
this.relays = data.relays;
}
+ if ("deviceRelateRelayList" in data && data.deviceRelateRelayList != undefined) {
+ this.deviceRelateRelayList = data.deviceRelateRelayList;
+ }
}
}
get canvas() {
@@ -48,10 +52,17 @@ export namespace relayCabinetGraphicData {
set relays(value: Relay[]) {
pb_1.Message.setRepeatedWrapperField(this, 3, value);
}
+ get deviceRelateRelayList() {
+ return pb_1.Message.getRepeatedWrapperField(this, DeviceRelateRelay, 4) as DeviceRelateRelay[];
+ }
+ set deviceRelateRelayList(value: DeviceRelateRelay[]) {
+ pb_1.Message.setRepeatedWrapperField(this, 4, value);
+ }
static fromObject(data: {
canvas?: ReturnType;
relayCabinets?: ReturnType[];
relays?: ReturnType[];
+ deviceRelateRelayList?: ReturnType[];
}): RelayCabinetGraphicStorage {
const message = new RelayCabinetGraphicStorage({});
if (data.canvas != null) {
@@ -63,6 +74,9 @@ export namespace relayCabinetGraphicData {
if (data.relays != null) {
message.relays = data.relays.map(item => Relay.fromObject(item));
}
+ if (data.deviceRelateRelayList != null) {
+ message.deviceRelateRelayList = data.deviceRelateRelayList.map(item => DeviceRelateRelay.fromObject(item));
+ }
return message;
}
toObject() {
@@ -70,6 +84,7 @@ export namespace relayCabinetGraphicData {
canvas?: ReturnType;
relayCabinets?: ReturnType[];
relays?: ReturnType[];
+ deviceRelateRelayList?: ReturnType[];
} = {};
if (this.canvas != null) {
data.canvas = this.canvas.toObject();
@@ -80,6 +95,9 @@ export namespace relayCabinetGraphicData {
if (this.relays != null) {
data.relays = this.relays.map((item: Relay) => item.toObject());
}
+ if (this.deviceRelateRelayList != null) {
+ data.deviceRelateRelayList = this.deviceRelateRelayList.map((item: DeviceRelateRelay) => item.toObject());
+ }
return data;
}
serialize(): Uint8Array;
@@ -92,6 +110,8 @@ export namespace relayCabinetGraphicData {
writer.writeRepeatedMessage(2, this.relayCabinets, (item: RelayCabinet) => item.serialize(writer));
if (this.relays.length)
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 (!w)
return writer.getResultBuffer();
}
@@ -110,6 +130,9 @@ export namespace relayCabinetGraphicData {
case 3:
reader.readMessage(message.relays, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Relay.deserialize(reader), Relay));
break;
+ case 4:
+ reader.readMessage(message.deviceRelateRelayList, () => pb_1.Message.addToRepeatedWrapperField(message, 4, DeviceRelateRelay.deserialize(reader), DeviceRelateRelay));
+ break;
default: reader.skipField();
}
}
@@ -220,6 +243,7 @@ export namespace relayCabinetGraphicData {
constructor(data?: any[] | {
common?: dependency_1.graphicData.CommonInfo;
code?: string;
+ model?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@@ -230,6 +254,9 @@ export namespace relayCabinetGraphicData {
if ("code" in data && data.code != undefined) {
this.code = data.code;
}
+ if ("model" in data && data.model != undefined) {
+ this.model = data.model;
+ }
}
}
get common() {
@@ -247,9 +274,16 @@ export namespace relayCabinetGraphicData {
set code(value: string) {
pb_1.Message.setField(this, 2, value);
}
+ get model() {
+ return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
+ }
+ set model(value: string) {
+ pb_1.Message.setField(this, 3, value);
+ }
static fromObject(data: {
common?: ReturnType;
code?: string;
+ model?: string;
}): Relay {
const message = new Relay({});
if (data.common != null) {
@@ -258,12 +292,16 @@ export namespace relayCabinetGraphicData {
if (data.code != null) {
message.code = data.code;
}
+ if (data.model != null) {
+ message.model = data.model;
+ }
return message;
}
toObject() {
const data: {
common?: ReturnType;
code?: string;
+ model?: string;
} = {};
if (this.common != null) {
data.common = this.common.toObject();
@@ -271,6 +309,9 @@ export namespace relayCabinetGraphicData {
if (this.code != null) {
data.code = this.code;
}
+ if (this.model != null) {
+ data.model = this.model;
+ }
return data;
}
serialize(): Uint8Array;
@@ -281,6 +322,8 @@ export namespace relayCabinetGraphicData {
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
if (this.code.length)
writer.writeString(2, this.code);
+ if (this.model.length)
+ writer.writeString(3, this.model);
if (!w)
return writer.getResultBuffer();
}
@@ -296,6 +339,9 @@ export namespace relayCabinetGraphicData {
case 2:
message.code = reader.readString();
break;
+ case 3:
+ message.model = reader.readString();
+ break;
default: reader.skipField();
}
}
@@ -308,4 +354,117 @@ export namespace relayCabinetGraphicData {
return Relay.deserialize(bytes);
}
}
+ export class DeviceRelateRelay extends pb_1.Message {
+ #one_of_decls: number[][] = [];
+ constructor(data?: any[] | {
+ type?: string;
+ code?: string;
+ refRelay?: string[];
+ }) {
+ super();
+ pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4], this.#one_of_decls);
+ if (!Array.isArray(data) && typeof data == "object") {
+ if ("type" in data && data.type != undefined) {
+ this.type = data.type;
+ }
+ if ("code" in data && data.code != undefined) {
+ this.code = data.code;
+ }
+ if ("refRelay" in data && data.refRelay != undefined) {
+ this.refRelay = data.refRelay;
+ }
+ }
+ }
+ get type() {
+ return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
+ }
+ set type(value: string) {
+ pb_1.Message.setField(this, 2, value);
+ }
+ get code() {
+ return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
+ }
+ set code(value: string) {
+ pb_1.Message.setField(this, 3, value);
+ }
+ get refRelay() {
+ return pb_1.Message.getFieldWithDefault(this, 4, []) as string[];
+ }
+ set refRelay(value: string[]) {
+ pb_1.Message.setField(this, 4, value);
+ }
+ static fromObject(data: {
+ type?: string;
+ code?: string;
+ refRelay?: string[];
+ }): DeviceRelateRelay {
+ const message = new DeviceRelateRelay({});
+ if (data.type != null) {
+ message.type = data.type;
+ }
+ if (data.code != null) {
+ message.code = data.code;
+ }
+ if (data.refRelay != null) {
+ message.refRelay = data.refRelay;
+ }
+ return message;
+ }
+ toObject() {
+ const data: {
+ type?: string;
+ code?: string;
+ refRelay?: string[];
+ } = {};
+ if (this.type != null) {
+ data.type = this.type;
+ }
+ if (this.code != null) {
+ data.code = this.code;
+ }
+ if (this.refRelay != null) {
+ data.refRelay = this.refRelay;
+ }
+ 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.type.length)
+ writer.writeString(2, this.type);
+ if (this.code.length)
+ writer.writeString(3, this.code);
+ if (this.refRelay.length)
+ writer.writeRepeatedString(4, this.refRelay);
+ if (!w)
+ return writer.getResultBuffer();
+ }
+ static deserialize(bytes: Uint8Array | pb_1.BinaryReader): DeviceRelateRelay {
+ const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new DeviceRelateRelay();
+ while (reader.nextField()) {
+ if (reader.isEndGroup())
+ break;
+ switch (reader.getFieldNumber()) {
+ case 2:
+ message.type = reader.readString();
+ break;
+ case 3:
+ message.code = reader.readString();
+ break;
+ case 4:
+ pb_1.Message.addToRepeatedField(message, 4, reader.readString());
+ break;
+ default: reader.skipField();
+ }
+ }
+ return message;
+ }
+ serializeBinary(): Uint8Array {
+ return this.serialize();
+ }
+ static deserializeBinary(bytes: Uint8Array): DeviceRelateRelay {
+ return DeviceRelateRelay.deserialize(bytes);
+ }
+ }
}
diff --git a/src/stores/relayCabinet-store.ts b/src/stores/relayCabinet-store.ts
index 259b948..5acf09f 100644
--- a/src/stores/relayCabinet-store.ts
+++ b/src/stores/relayCabinet-store.ts
@@ -12,6 +12,7 @@ export const useRelayCabinetStore = defineStore('relayCabinet', {
drawAssistant: null as DrawAssistant | null,
selectedGraphics: null as JlGraphic[] | null,
draftId: null as number | null,
+ showRelateRelayConfig: false,
}),
getters: {
drawMode: (state) => state.drawAssistant != null,