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

121 lines
4.3 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, type Rect } from '@api/map';
2025-05-06 23:48:21 +08:00
import type { EditorService } from '@core/editor.service';
import sTheme from '@core/theme.service';
import { isNil } from 'lodash-es';
2025-05-06 23:48:21 +08:00
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>(() => {
2025-05-09 20:15:04 +08:00
const v = pen.value?.point;
if (!v?.type) return null;
return v;
2025-05-06 23:48:21 +08:00
});
const rect = computed<Partial<Rect>>(() => {
if (isNil(point.value)) return {};
const { x, y } = editor.value.getPointRect(pen.value!) ?? {};
return { x, y };
});
2025-05-06 23:48:21 +08:00
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
2025-05-10 00:49:45 +08:00
?.map((v) => editor.value.getPenById(v))
.filter((v) => v?.point?.type === MapPointType.动作点)
.map((v) => v?.label)
2025-05-06 23:48:21 +08:00
.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>({{ rect.x?.toFixed() }},{{ rect.y?.toFixed() }})</a-typography-text>
2025-05-06 23:48:21 +08:00
</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>