继电器柜uniqueId配置

This commit is contained in:
joylink_zhaoerwei 2023-09-20 15:32:59 +08:00
parent f17284d3a8
commit 5399615e05
3 changed files with 169 additions and 30 deletions

View File

@ -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<IGraphicStorage> {
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;
}

View File

@ -20,7 +20,7 @@
v-close-popup
@click="openBelongsToStationDialog"
>
<q-item-section>所属集中站</q-item-section>
<q-item-section>UniqueId配置</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="batchBuild">
<q-item-section>批量生成继电器或继电器柜</q-item-section>
@ -129,13 +129,25 @@
>
<q-card style="width: 300px">
<q-card-section>
<div class="text-h6">所属集中站</div>
<div class="text-h6">UniqueId配置</div>
</q-card-section>
<q-card-section>
<q-input
outlined
label="所属城市"
v-model="UniqueIdPrefix.city"
:rules="[(val) => val.trim() != '' || '集中站名称不能为空']"
/>
<q-input
outlined
label="线路号"
v-model="UniqueIdPrefix.lineId"
:rules="[(val) => val.trim() != '' || '集中站名称不能为空']"
/>
<q-input
outlined
label="集中站名称"
v-model="stationName"
v-model="UniqueIdPrefix.belongsConcentrationStation"
:rules="[(val) => val.trim() != '' || '集中站名称不能为空']"
/>
</q-card-section>
@ -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();
}

View File

@ -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<typeof dependency_1.graphicData.Canvas.prototype.toObject>;
relayCabinets?: ReturnType<typeof RelayCabinet.prototype.toObject>[];
relays?: ReturnType<typeof Relay.prototype.toObject>[];
deviceRelateRelayList?: ReturnType<typeof DeviceRelateRelay.prototype.toObject>[];
belongsConcentrationStation?: string;
UniqueIdPrefix?: ReturnType<typeof UniqueIdType.prototype.toObject>;
}): 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<typeof RelayCabinet.prototype.toObject>[];
relays?: ReturnType<typeof Relay.prototype.toObject>[];
deviceRelateRelayList?: ReturnType<typeof DeviceRelateRelay.prototype.toObject>[];
belongsConcentrationStation?: string;
UniqueIdPrefix?: ReturnType<typeof UniqueIdType.prototype.toObject>;
} = {};
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);
}
}
}