diff --git a/src/drawApp/relayCabinetLayoutApp.ts b/src/drawApp/relayCabinetLayoutApp.ts index 071f348..6f9beff 100644 --- a/src/drawApp/relayCabinetLayoutApp.ts +++ b/src/drawApp/relayCabinetLayoutApp.ts @@ -109,7 +109,7 @@ export function initDrawApp(): IDrawApp { }, }) ); - app.on('postdataloaded', async () => { + app.on('postdataloaded', () => { const map = new Map(); refRelaysList.forEach((device) => { device.combinationtypes.forEach((combinationtype) => { @@ -132,7 +132,7 @@ export function initDrawApp(): IDrawApp { ) as string; }); }); - app.on('destroy', async () => { + app.on('destroy', () => { refRelaysList = []; combinationTypeList = []; }); @@ -211,12 +211,10 @@ export function saveDrawDatas(app: IDrawApp) { storage.UniqueIdPrefix = UniqueIdPrefix; const base64 = fromUint8Array(storage.serialize()); console.log('保存数据', storage); - // localStorage.setItem(StorageKey, base64); return base64; } export async function loadDrawDatas(): Promise { - // const base64 = localStorage.getItem(StorageKey); const relayCabinetStore = useRelayCabinetStore(); const id = relayCabinetStore.draftId; if (!id) { diff --git a/src/drawApp/relayScene.ts b/src/drawApp/relayScene.ts index 15e698a..387f1a8 100644 --- a/src/drawApp/relayScene.ts +++ b/src/drawApp/relayScene.ts @@ -58,7 +58,7 @@ export function initRelayScene(lineApp: IGraphicApp, sceneName: string) { relay.refDevice.text = map.get(relay.id) as string; }); }); - relayScene.on('destroy', async () => { + relayScene.on('destroy', () => { refRelaysList = []; }); } diff --git a/src/graphics/phaseFailureProtector/PhaseFailureProtector.ts b/src/graphics/phaseFailureProtector/PhaseFailureProtector.ts index b9d1bc1..020087a 100644 --- a/src/graphics/phaseFailureProtector/PhaseFailureProtector.ts +++ b/src/graphics/phaseFailureProtector/PhaseFailureProtector.ts @@ -41,14 +41,7 @@ export class PhaseFailureProtector extends JlGraphic { } doRepaint(): void { this.labelGraphic.text = this.datas.code; - const labelPosition = this.datas.childTransforms?.find( - (t) => t.name === this.labelGraphic.name - )?.transform.position; - if (labelPosition) { - this.labelGraphic.position.set(labelPosition.x, labelPosition.y); - } else { - this.labelGraphic.position.set(0, 20); - } + this.labelGraphic.position.set(0, 20); this.refDevice.position.set(0, -20); const phaseFailureProtectorGraphic = this.phaseFailureProtectorGraphic; phaseFailureProtectorGraphic @@ -56,23 +49,22 @@ export class PhaseFailureProtector extends JlGraphic { .lineStyle( phaseFailureProtectorConsts.lineWidth, new Color(phaseFailureProtectorConsts.lineColor) + ) + .beginFill(phaseFailureProtectorConsts.lineColor) + .drawRect( + 0, + 0, + phaseFailureProtectorConsts.width, + phaseFailureProtectorConsts.height ); - phaseFailureProtectorGraphic.beginFill( - phaseFailureProtectorConsts.lineColor + phaseFailureProtectorGraphic.pivot = getRectangleCenter( + new Rectangle( + 0, + 0, + phaseFailureProtectorConsts.width, + phaseFailureProtectorConsts.height + ) ); - phaseFailureProtectorGraphic.drawRect( - 0, - 0, - phaseFailureProtectorConsts.width, - phaseFailureProtectorConsts.height - ); - const rectP = new Rectangle( - 0, - 0, - phaseFailureProtectorConsts.width, - phaseFailureProtectorConsts.height - ); - phaseFailureProtectorGraphic.pivot = getRectangleCenter(rectP); phaseFailureProtectorGraphic.endFill; } setTextGraphic(g: VectorText, name: string) { diff --git a/src/graphics/phaseFailureProtector/PhaseFailureProtectorDrawAssistant.ts b/src/graphics/phaseFailureProtector/PhaseFailureProtectorDrawAssistant.ts index e9a8ee3..fae99d1 100644 --- a/src/graphics/phaseFailureProtector/PhaseFailureProtectorDrawAssistant.ts +++ b/src/graphics/phaseFailureProtector/PhaseFailureProtectorDrawAssistant.ts @@ -37,9 +37,6 @@ export class PhaseFailureProtectorDraw extends GraphicDrawAssistant< this.phaseFailureProtectorGraphic.doRepaint(); } - clearCache(): void { - //this.phaseFailureProtectorGraphic.clear(); - } onLeftDown(e: FederatedPointerEvent): void { this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); this.createAndStore(true); @@ -105,16 +102,10 @@ export class phaseFailureProtectorInteraction extends GraphicInteractionPlugin

t.name === this.labelGraphic.name - )?.transform.position; - if (labelPosition) { - this.labelGraphic.position.set(labelPosition.x, labelPosition.y); - } else { - this.labelGraphic.position.set(0, 20); - } + this.labelGraphic.position.set(0, 20); this.refDevice.position.set(0, -20); const relayGraphic = this.relayGraphic; let relayColor; @@ -71,10 +64,9 @@ export class Relay extends JlGraphic { } relayGraphic .clear() - .lineStyle(relayConsts.lineWidth, new Color(relayColor)); - relayGraphic.beginFill(relayColor); - relayGraphic.drawCircle(0, 0, relayConsts.radius); - relayGraphic.endFill; + .lineStyle(relayConsts.lineWidth, new Color(relayColor)) + .beginFill(relayColor) + .drawCircle(0, 0, relayConsts.radius).endFill; } setTextGraphic(g: VectorText, name: string) { g.setVectorFontSize(10); diff --git a/src/graphics/relay/RelayDrawAssistant.ts b/src/graphics/relay/RelayDrawAssistant.ts index 6d41920..4063ca0 100644 --- a/src/graphics/relay/RelayDrawAssistant.ts +++ b/src/graphics/relay/RelayDrawAssistant.ts @@ -29,9 +29,6 @@ export class RelayDraw extends GraphicDrawAssistant { this.relayGraphic.doRepaint(); } - clearCache(): void { - //this.relayGraphic.clear(); - } onLeftDown(e: FederatedPointerEvent): void { this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); this.createAndStore(true); @@ -81,16 +78,10 @@ export class relayInteraction extends GraphicInteractionPlugin { bind(g: Relay): void { g.eventMode = 'static'; g.cursor = 'pointer'; - g.labelGraphic.eventMode = 'static'; - g.labelGraphic.selectable = true; - g.labelGraphic.draggable = true; g.on('transformstart', this.move, this); } unbind(g: Relay): void { g.eventMode = 'none'; - g.labelGraphic.eventMode = 'none'; - g.labelGraphic.selectable = false; - g.labelGraphic.draggable = false; g.off('transformstart', this.move, this); } move(): void { diff --git a/src/graphics/relayCabinet/RelayCabinet.ts b/src/graphics/relayCabinet/RelayCabinet.ts index 9599291..12ad597 100644 --- a/src/graphics/relayCabinet/RelayCabinet.ts +++ b/src/graphics/relayCabinet/RelayCabinet.ts @@ -45,34 +45,18 @@ export class RelayCabinet extends JlGraphic { } doRepaint(): void { this.labelGraphic.text = this.datas.code; - const labelPosition = this.datas.childTransforms?.find( - (t) => t.name === this.labelGraphic.name - )?.transform.position; - if (labelPosition) { - this.labelGraphic.position.set(labelPosition.x, labelPosition.y); - } else { - this.labelGraphic.position.set(0, -relayCabinetConsts.height / 2 - 15); - } + this.labelGraphic.position.set(0, -relayCabinetConsts.height / 2 - 15); const relayCabinetGraphic = this.relayCabinetGraphic; relayCabinetGraphic .clear() .lineStyle( relayCabinetConsts.lineWidth, new Color(relayCabinetConsts.lineColor) - ); - relayCabinetGraphic.drawRect( - 0, - 0, - relayCabinetConsts.width, - relayCabinetConsts.height + ) + .drawRect(0, 0, relayCabinetConsts.width, relayCabinetConsts.height); + relayCabinetGraphic.pivot = getRectangleCenter( + new Rectangle(0, 0, relayCabinetConsts.width, relayCabinetConsts.height) ); - const rectP = new Rectangle( - 0, - 0, - relayCabinetConsts.width, - relayCabinetConsts.height - ); - relayCabinetGraphic.pivot = getRectangleCenter(rectP); this.batchBuild(); } batchBuild() { @@ -109,13 +93,13 @@ export class RelayCabinet extends JlGraphic { .lineStyle( relayCabinetConsts.cellLineWidth, new Color(relayCabinetConsts.lineColor) + ) + .drawRect( + 0, + 0, + relayCabinetConsts.cellWidth, + relayCabinetConsts.cellHeight ); - relay.drawRect( - 0, - 0, - relayCabinetConsts.cellWidth, - relayCabinetConsts.cellHeight - ); relay.position.set( -relayCabinetConsts.width / 2 + i * relayCabinetConsts.cellWidth, -relayCabinetConsts.height / 2 + j * relayCabinetConsts.cellHeight diff --git a/src/graphics/relayCabinet/RelayCabinetDrawAssistant.ts b/src/graphics/relayCabinet/RelayCabinetDrawAssistant.ts index a90ef1b..3ac5b1c 100644 --- a/src/graphics/relayCabinet/RelayCabinetDrawAssistant.ts +++ b/src/graphics/relayCabinet/RelayCabinetDrawAssistant.ts @@ -54,9 +54,6 @@ export class RelayCabinetDraw extends GraphicDrawAssistant< this.relayCabinetGraphic.doRepaint(); } - clearCache(): void { - //this.relayCabinetGraphic.clear(); - } onLeftDown(e: FederatedPointerEvent): void { this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); this.createAndStore(true); @@ -139,9 +136,6 @@ export class relayCabinetInteraction extends GraphicInteractionPlugin - - 保存 - - - 另存为 - - - 数据校验 - - UniqueId配置 - - - 批量生成继电器或继电器柜 + {{ item.label }} @@ -246,6 +236,15 @@ class ControlItem { } } +//左侧功能按钮 +const leftMenuConfig = [ + { label: '保存', click: saveAllDrawDatas }, + { label: '另存为', click: () => (saveAsDialog.value = true) }, + { label: '数据校验', click: handleCheckData }, + { label: 'UniqueId配置', click: openUniqueIdPrefixDialog }, + { label: '批量生成继电器或继电器柜', click: batchBuild }, +]; + watch( () => relayCabinetStore.drawMode, (drawMode) => { @@ -254,6 +253,7 @@ watch( } } ); + watch( () => searchId.value, () => {