站台关联物理区段
This commit is contained in:
parent
4f1e58aac6
commit
bd84045111
@ -48,6 +48,16 @@
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
<q-item>
|
||||
<q-item-section no-wrap class="q-gutter-y-sm column">
|
||||
<q-item-label> 关联的物理区段 </q-item-label>
|
||||
<div class="q-gutter-sm row">
|
||||
<q-chip square color="primary" text-color="white">
|
||||
{{ sectionName }}
|
||||
</q-chip>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-form>
|
||||
</template>
|
||||
@ -56,16 +66,36 @@
|
||||
import { useFormData } from 'src/components/DrawAppFormUtils';
|
||||
import { PlatformData } from 'src/drawApp/graphics/PlatformInteraction';
|
||||
import { Platform } from 'src/graphics/platform/Platform';
|
||||
import { Section } from 'src/graphics/section/Section';
|
||||
import { Station } from 'src/graphics/station/Station';
|
||||
import { useDrawStore } from 'src/stores/draw-store';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
const drawStore = useDrawStore();
|
||||
const { data: platformModel, onUpdate } = useFormData(
|
||||
new PlatformData(),
|
||||
drawStore.getDrawApp()
|
||||
);
|
||||
const stationName = ref('');
|
||||
const stationName = computed(() => {
|
||||
const platform = drawStore.selectedGraphic as Platform;
|
||||
if (platformModel.refStation) {
|
||||
const refStation = platform.queryStore.queryById<Station>(
|
||||
platformModel.refStation
|
||||
);
|
||||
return refStation.datas.name;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
const sectionName = computed(() => {
|
||||
const platform = drawStore.selectedGraphic as Platform;
|
||||
if (platformModel.refSectionId) {
|
||||
const refSection = platform.queryStore.queryById<Section>(
|
||||
platformModel.refSectionId
|
||||
);
|
||||
return refSection.datas.code;
|
||||
}
|
||||
return '';
|
||||
});
|
||||
const optionsDoor = [
|
||||
{ label: '是', value: true },
|
||||
{ label: '否', value: false },
|
||||
@ -78,16 +108,4 @@ const optionsUpAndDown = [
|
||||
{ label: '上行', value: true },
|
||||
{ label: '下行', value: false },
|
||||
];
|
||||
|
||||
onMounted(() => {
|
||||
const platform = drawStore.selectedGraphic as Platform;
|
||||
if (platform) {
|
||||
if (platformModel.refStation) {
|
||||
const refStation = platform.queryStore.queryById<Station>(
|
||||
platformModel.refStation
|
||||
) as Station;
|
||||
stationName.value = refStation.datas.name;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -65,6 +65,12 @@ export class PlatformData extends GraphicDataBase implements IPlatformData {
|
||||
set refStation(v: string) {
|
||||
this.data.refStation = v;
|
||||
}
|
||||
get refSectionId(): string {
|
||||
return this.data.refSectionId;
|
||||
}
|
||||
set refSectionId(v: string) {
|
||||
this.data.refSectionId = v;
|
||||
}
|
||||
|
||||
clone(): PlatformData {
|
||||
return new PlatformData(this.data.cloneMessage());
|
||||
|
@ -6,9 +6,11 @@ import {
|
||||
JlGraphicTemplate,
|
||||
VectorText,
|
||||
calculateMirrorPoint,
|
||||
distance2,
|
||||
getRectangleCenter,
|
||||
} from 'src/jl-graphic';
|
||||
import { Station } from '../station/Station';
|
||||
import { Section } from '../section/Section';
|
||||
|
||||
export interface IPlatformData extends GraphicData {
|
||||
get code(): string; // 编号
|
||||
@ -21,6 +23,8 @@ export interface IPlatformData extends GraphicData {
|
||||
set up(v: boolean);
|
||||
get refStation(): string; // 关联的车站
|
||||
set refStation(v: string);
|
||||
get refSectionId(): string; // 关联的物理区段
|
||||
set refSectionId(v: string);
|
||||
clone(): IPlatformData;
|
||||
copyFrom(data: IPlatformData): void;
|
||||
eq(other: IPlatformData): boolean;
|
||||
@ -435,6 +439,29 @@ export class Platform extends JlGraphic {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const sections = this.queryStore.queryByType<Section>(Section.Type);
|
||||
const minDistanceRefSections: Section[] = [];
|
||||
sections.forEach((section) => {
|
||||
const sP = section.localBoundsToCanvasPoints();
|
||||
if (this.x > sP[0].x && this.x < sP[1].x) {
|
||||
minDistanceRefSections.push(section);
|
||||
}
|
||||
});
|
||||
if (minDistanceRefSections) {
|
||||
const refSection = minDistanceRefSections.reduce((prev, cur) => {
|
||||
return distance2(
|
||||
prev.localToCanvasPoint(getRectangleCenter(prev.getLocalBounds())),
|
||||
this.position
|
||||
) >
|
||||
distance2(
|
||||
cur.localToCanvasPoint(getRectangleCenter(cur.getLocalBounds())),
|
||||
this.position
|
||||
)
|
||||
? cur
|
||||
: prev;
|
||||
});
|
||||
this.datas.refSectionId = refSection.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1708,6 +1708,7 @@ export namespace graphicData {
|
||||
direction?: string;
|
||||
refStation?: string;
|
||||
up?: boolean;
|
||||
refSectionId?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@ -1730,6 +1731,9 @@ export namespace graphicData {
|
||||
if ("up" in data && data.up != undefined) {
|
||||
this.up = data.up;
|
||||
}
|
||||
if ("refSectionId" in data && data.refSectionId != undefined) {
|
||||
this.refSectionId = data.refSectionId;
|
||||
}
|
||||
}
|
||||
}
|
||||
get common() {
|
||||
@ -1771,6 +1775,12 @@ export namespace graphicData {
|
||||
set up(value: boolean) {
|
||||
pb_1.Message.setField(this, 7, value);
|
||||
}
|
||||
get refSectionId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 8, "") as string;
|
||||
}
|
||||
set refSectionId(value: string) {
|
||||
pb_1.Message.setField(this, 8, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
@ -1778,6 +1788,7 @@ export namespace graphicData {
|
||||
direction?: string;
|
||||
refStation?: string;
|
||||
up?: boolean;
|
||||
refSectionId?: string;
|
||||
}): Platform {
|
||||
const message = new Platform({});
|
||||
if (data.common != null) {
|
||||
@ -1798,6 +1809,9 @@ export namespace graphicData {
|
||||
if (data.up != null) {
|
||||
message.up = data.up;
|
||||
}
|
||||
if (data.refSectionId != null) {
|
||||
message.refSectionId = data.refSectionId;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@ -1808,6 +1822,7 @@ export namespace graphicData {
|
||||
direction?: string;
|
||||
refStation?: string;
|
||||
up?: boolean;
|
||||
refSectionId?: string;
|
||||
} = {};
|
||||
if (this.common != null) {
|
||||
data.common = this.common.toObject();
|
||||
@ -1827,6 +1842,9 @@ export namespace graphicData {
|
||||
if (this.up != null) {
|
||||
data.up = this.up;
|
||||
}
|
||||
if (this.refSectionId != null) {
|
||||
data.refSectionId = this.refSectionId;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@ -1845,6 +1863,8 @@ export namespace graphicData {
|
||||
writer.writeString(6, this.refStation);
|
||||
if (this.up != false)
|
||||
writer.writeBool(7, this.up);
|
||||
if (this.refSectionId.length)
|
||||
writer.writeString(8, this.refSectionId);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -1872,6 +1892,9 @@ export namespace graphicData {
|
||||
case 7:
|
||||
message.up = reader.readBool();
|
||||
break;
|
||||
case 8:
|
||||
message.refSectionId = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user