继电器相关调整

This commit is contained in:
joylink_zhaoerwei 2023-10-09 10:09:50 +08:00
parent 6075ba474f
commit decd348c04
9 changed files with 47 additions and 108 deletions

View File

@ -109,7 +109,7 @@ export function initDrawApp(): IDrawApp {
},
})
);
app.on('postdataloaded', async () => {
app.on('postdataloaded', () => {
const map = new Map<string, string>();
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<IGraphicStorage> {
// const base64 = localStorage.getItem(StorageKey);
const relayCabinetStore = useRelayCabinetStore();
const id = relayCabinetStore.draftId;
if (!id) {

View File

@ -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 = [];
});
}

View File

@ -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.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)
);
phaseFailureProtectorGraphic.beginFill(
phaseFailureProtectorConsts.lineColor
);
phaseFailureProtectorGraphic.drawRect(
)
.beginFill(phaseFailureProtectorConsts.lineColor)
.drawRect(
0,
0,
phaseFailureProtectorConsts.width,
phaseFailureProtectorConsts.height
);
const rectP = new Rectangle(
phaseFailureProtectorGraphic.pivot = getRectangleCenter(
new Rectangle(
0,
0,
phaseFailureProtectorConsts.width,
phaseFailureProtectorConsts.height
)
);
phaseFailureProtectorGraphic.pivot = getRectangleCenter(rectP);
phaseFailureProtectorGraphic.endFill;
}
setTextGraphic(g: VectorText, name: string) {

View File

@ -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<P
bind(g: PhaseFailureProtector): 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: PhaseFailureProtector): void {
g.eventMode = 'none';
g.labelGraphic.eventMode = 'none';
g.labelGraphic.selectable = false;
g.labelGraphic.draggable = false;
g.off('transformstart', this.move, this);
}
move(): void {

View File

@ -53,14 +53,7 @@ export class Relay 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.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);

View File

@ -29,9 +29,6 @@ export class RelayDraw extends GraphicDrawAssistant<RelayTemplate, IRelayData> {
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<Relay> {
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 {

View File

@ -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);
}
const relayCabinetGraphic = this.relayCabinetGraphic;
relayCabinetGraphic
.clear()
.lineStyle(
relayCabinetConsts.lineWidth,
new Color(relayCabinetConsts.lineColor)
)
.drawRect(0, 0, relayCabinetConsts.width, relayCabinetConsts.height);
relayCabinetGraphic.pivot = getRectangleCenter(
new Rectangle(0, 0, relayCabinetConsts.width, relayCabinetConsts.height)
);
relayCabinetGraphic.drawRect(
0,
0,
relayCabinetConsts.width,
relayCabinetConsts.height
);
const rectP = new Rectangle(
0,
0,
relayCabinetConsts.width,
relayCabinetConsts.height
);
relayCabinetGraphic.pivot = getRectangleCenter(rectP);
this.batchBuild();
}
batchBuild() {
@ -109,8 +93,8 @@ export class RelayCabinet extends JlGraphic {
.lineStyle(
relayCabinetConsts.cellLineWidth,
new Color(relayCabinetConsts.lineColor)
);
relay.drawRect(
)
.drawRect(
0,
0,
relayCabinetConsts.cellWidth,

View File

@ -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<RelayCabin
bind(g: RelayCabinet): void {
g.eventMode = 'static';
g.cursor = 'pointer';
g.labelGraphic.eventMode = 'static';
g.labelGraphic.selectable = true;
g.labelGraphic.draggable = true;
g.relayCabinetGraphic.hitArea = new RectGraphicHitArea(g);
g.on('transformstart', this.move, this);
g.on('transforming', this.dragTogether, this);
@ -149,9 +143,6 @@ export class relayCabinetInteraction extends GraphicInteractionPlugin<RelayCabin
}
unbind(g: RelayCabinet): void {
g.eventMode = 'none';
g.labelGraphic.eventMode = 'none';
g.labelGraphic.selectable = false;
g.labelGraphic.draggable = false;
g.off('transformstart', this.move, this);
g.off('transforming', this.dragTogether, this);
g.off('transformend', this.recordGraphicMove, this);

View File

@ -6,24 +6,14 @@
<q-btn color="accent" label="功能菜单">
<q-menu>
<q-list style="min-width: 100px">
<q-item clickable v-close-popup @click="saveAllDrawDatas">
<q-item-section>保存</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="saveAsDialog = true">
<q-item-section>另存为</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="handleCheckData">
<q-item-section>数据校验</q-item-section>
</q-item>
<q-item
v-for="item in leftMenuConfig"
:key="item.label"
clickable
v-close-popup
@click="openUniqueIdPrefixDialog"
@click="item.click"
>
<q-item-section>UniqueId配置</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="batchBuild">
<q-item-section>批量生成继电器或继电器柜</q-item-section>
<q-item-section>{{ item.label }}</q-item-section>
</q-item>
</q-list>
</q-menu>
@ -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,
() => {