This commit is contained in:
fan 2023-12-15 09:55:47 +08:00
commit 266f1ce829
4 changed files with 5386 additions and 4390 deletions

View File

@ -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>

View File

@ -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());

View File

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

File diff suppressed because it is too large Load Diff