计轴增加虚拟计轴字段

This commit is contained in:
joylink_zhaoerwei 2023-08-03 09:56:35 +08:00
parent e584681ada
commit dd471e3a5e
4 changed files with 53 additions and 1 deletions

View File

@ -43,6 +43,13 @@
@blur="onUpdate"
label="公里标(mm):"
/>
<q-select
outlined
@blur="onUpdate"
v-model="invent"
:options="optionsInvent"
label="是否虚拟计轴"
/>
<q-list bordered separator class="rounded-borders">
<q-item>
<q-item-section no-wrap class="q-gutter-y-sm column">
@ -86,7 +93,7 @@ import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting';
import { Section } from 'src/graphics/section/Section';
import { Turnout } from 'src/graphics/turnout/Turnout';
import { useDrawStore } from 'src/stores/draw-store';
import { computed, onMounted, reactive, watch } from 'vue';
import { computed, onMounted, reactive, ref, watch } from 'vue';
const drawStore = useDrawStore();
const axleCountingModel = reactive(new AxleCountingData());
@ -99,12 +106,24 @@ const CoordinateSystemOptions = [
{ label: '换线', value: 'TRANSFER' },
];
const invent = ref('');
const optionsInvent = ['是', '否'];
enum showSelect {
= 'true',
= 'false',
}
enum showSelectData {
true = '是',
false = '否',
}
drawStore.$subscribe;
watch(
() => drawStore.selectedGraphic,
(val) => {
if (val && val.type == AxleCounting.Type) {
axleCountingModel.copyFrom(val.saveData() as AxleCountingData);
invent.value = (showSelectData as never)[axleCountingModel.invent + ''];
if (axleCountingModel.kilometerSystem) {
kilometerSystem.coordinateSystem =
axleCountingModel.kilometerSystem.coordinateSystem;
@ -118,6 +137,7 @@ onMounted(() => {
const axleCounting = drawStore.selectedGraphic as AxleCounting;
if (axleCounting) {
axleCountingModel.copyFrom(axleCounting.saveData());
invent.value = (showSelectData as never)[axleCountingModel.invent + ''];
if (axleCountingModel.kilometerSystem) {
kilometerSystem.coordinateSystem =
axleCountingModel.kilometerSystem.coordinateSystem;
@ -128,6 +148,7 @@ onMounted(() => {
function onUpdate() {
const axleCounting = drawStore.selectedGraphic as AxleCounting;
axleCountingModel.invent = JSON.parse((showSelect as never)[invent.value]);
axleCountingModel.kilometerSystem = {
coordinateSystem: kilometerSystem.coordinateSystem,
kilometer: kilometerSystem.kilometer,

View File

@ -50,6 +50,12 @@ export class AxleCountingData
set index(v: number) {
this.data.index = v;
}
get invent(): boolean {
return this.data.invent;
}
set invent(v: boolean) {
this.data.invent = v;
}
clone(): AxleCountingData {
return new AxleCountingData(this.data.cloneMessage());
}

View File

@ -18,6 +18,8 @@ export interface IAxleCountingData extends GraphicData {
set axleCountingRef(ref: IRelatedRefData[]);
get index(): number; // 索引编号
set index(v: number);
get invent(): boolean; // 是否虚拟计轴
set invent(v: boolean);
clone(): IAxleCountingData;
copyFrom(data: IAxleCountingData): void;
eq(other: IAxleCountingData): boolean;

View File

@ -1523,6 +1523,7 @@ export namespace graphicData {
kilometerSystem?: KilometerSystem;
axleCountingRef?: RelatedRef[];
index?: number;
invent?: boolean;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4], this.#one_of_decls);
@ -1542,6 +1543,9 @@ export namespace graphicData {
if ("index" in data && data.index != undefined) {
this.index = data.index;
}
if ("invent" in data && data.invent != undefined) {
this.invent = data.invent;
}
}
}
get common() {
@ -1580,12 +1584,19 @@ export namespace graphicData {
set index(value: number) {
pb_1.Message.setField(this, 5, value);
}
get invent() {
return pb_1.Message.getFieldWithDefault(this, 6, false) as boolean;
}
set invent(value: boolean) {
pb_1.Message.setField(this, 6, value);
}
static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string;
kilometerSystem?: ReturnType<typeof KilometerSystem.prototype.toObject>;
axleCountingRef?: ReturnType<typeof RelatedRef.prototype.toObject>[];
index?: number;
invent?: boolean;
}): AxleCounting {
const message = new AxleCounting({});
if (data.common != null) {
@ -1603,6 +1614,9 @@ export namespace graphicData {
if (data.index != null) {
message.index = data.index;
}
if (data.invent != null) {
message.invent = data.invent;
}
return message;
}
toObject() {
@ -1612,6 +1626,7 @@ export namespace graphicData {
kilometerSystem?: ReturnType<typeof KilometerSystem.prototype.toObject>;
axleCountingRef?: ReturnType<typeof RelatedRef.prototype.toObject>[];
index?: number;
invent?: boolean;
} = {};
if (this.common != null) {
data.common = this.common.toObject();
@ -1628,6 +1643,9 @@ export namespace graphicData {
if (this.index != null) {
data.index = this.index;
}
if (this.invent != null) {
data.invent = this.invent;
}
return data;
}
serialize(): Uint8Array;
@ -1644,6 +1662,8 @@ export namespace graphicData {
writer.writeRepeatedMessage(4, this.axleCountingRef, (item: RelatedRef) => item.serialize(writer));
if (this.index != 0)
writer.writeInt32(5, this.index);
if (this.invent != false)
writer.writeBool(6, this.invent);
if (!w)
return writer.getResultBuffer();
}
@ -1668,6 +1688,9 @@ export namespace graphicData {
case 5:
message.index = reader.readInt32();
break;
case 6:
message.invent = reader.readBool();
break;
default: reader.skipField();
}
}