web-map/src/components/card/point-detail-card.vue

113 lines
4.0 KiB
Vue
Raw Normal View History

2025-05-06 23:48:21 +08:00
<script setup lang="ts">
import { MapAreaType, type MapPen, type MapPointInfo, MapPointType } from '@api/map';
import type { EditorService } from '@core/editor.service';
import sTheme from '@core/theme.service';
import { computed, inject, type InjectionKey, type ShallowRef } from 'vue';
type Props = {
token: InjectionKey<ShallowRef<EditorService>>;
current?: string;
};
const props = defineProps<Props>();
const editor = inject(props.token)!;
const pen = computed<MapPen | undefined>(() => editor.value.getPenById(props.current));
const point = computed<MapPointInfo | null>(() => {
const point = pen.value?.point;
if (!point?.type) return null;
return point;
});
const bindRobot = computed<string>(
() =>
point.value?.robots
?.map((v) => editor.value.getRobotById(v)?.label)
.filter((v) => !!v)
.join('、') ?? '',
);
const bindAction = computed<string>(
() =>
point.value?.actions
?.map((v) => editor.value.getPenById(v)?.label)
.filter((v) => !!v)
.join('、') ?? '',
);
const mapAreas = (type: MapAreaType): string => {
const id = pen.value?.id;
if (!id) return '';
2025-05-08 00:42:08 +08:00
return editor.value
.getBoundAreas(id, 'point', type)
.map(({ label }) => label)
.filter((v) => !!v)
.join('、');
2025-05-06 23:48:21 +08:00
};
const coArea1 = computed<string>(() => mapAreas(MapAreaType.库区));
const coArea2 = computed<string>(() => mapAreas(MapAreaType.互斥区));
</script>
<template>
<a-card :bordered="false">
<template v-if="pen && point">
<a-row :gutter="[8, 8]">
<a-col :span="24">
<a-flex align="center" :gap="8">
<i class="icon point" />
<a-typography-text class="card-title" style="flex: auto" :content="pen.label" ellipsis />
<a-tag :bordered="false">{{ $t(MapPointType[point.type]) }}</a-tag>
</a-flex>
</a-col>
<a-col :span="24">
<a-typography-text code>{{ pen.desc || $t('暂无描述') }}</a-typography-text>
</a-col>
</a-row>
<a-list class="block mt-16">
<a-list-item>
<a-typography-text type="secondary">{{ $t('站点坐标') }}</a-typography-text>
<a-typography-text>({{ pen.x?.toFixed() }},{{ pen.y?.toFixed() }})</a-typography-text>
</a-list-item>
<a-list-item v-if="[MapPointType.充电点, MapPointType.停靠点].includes(point.type)">
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('绑定机器人') }}</a-typography-text>
<a-typography-text>{{ bindRobot || $t('暂无') }}</a-typography-text>
</a-flex>
</a-list-item>
<a-list-item v-if="MapPointType.等待点 === point.type">
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('绑定动作点') }}</a-typography-text>
<a-typography-text>{{ bindAction || $t('暂无') }}</a-typography-text>
</a-flex>
</a-list-item>
<a-list-item v-if="MapPointType.动作点 === point.type">
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('关联库区') }}</a-typography-text>
<a-typography-text>{{ coArea1 || $t('暂无') }}</a-typography-text>
</a-flex>
</a-list-item>
<a-list-item
v-if="
[
MapPointType.普通点,
MapPointType.电梯点,
MapPointType.自动门点,
MapPointType.等待点,
MapPointType.充电点,
MapPointType.停靠点,
MapPointType.动作点,
MapPointType.临时避让点,
].includes(point.type)
"
>
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('关联互斥区') }}</a-typography-text>
<a-typography-text>{{ coArea2 || $t('暂无') }}</a-typography-text>
</a-flex>
</a-list-item>
</a-list>
</template>
<a-empty v-else :image="sTheme.empty" />
</a-card>
</template>