feat: 添加库位名称支持,更新相关接口和组件以处理库位信息

This commit is contained in:
xudan 2025-07-14 16:26:45 +08:00
parent 4379bcc533
commit c3181d4d37
5 changed files with 54 additions and 3 deletions

View File

@ -28,6 +28,7 @@ export interface MapPointInfo {
actions?: Array<string>; // 绑定动作点id集合
isBlock?: boolean; // 是否禁行
isForbidAvoid?: boolean; // 是否禁止避让
locationNames?: string[]; // 库位名称
}
//#endregion

View File

@ -40,6 +40,7 @@ export interface StandardScenePoint {
type: number; // 点位类型
robots?: Array<string>; // 绑定机器人id集合
actions?: Array<string>; // 绑定动作点id集合
locationNames?: string[]; // 库位名称
config?: object; // 其它属性配置(可按需增加)
properties?: unknown; // 附加数据(前端不做任何处理)
}

View File

@ -101,6 +101,12 @@ const storageStatus = computed<string>(() => {
<a-typography-text>{{ coArea1 || $t('暂无') }}</a-typography-text>
</a-flex>
</a-list-item>
<a-list-item v-if="MapPointType.动作点 === point.type && point.locationNames?.length">
<a-flex :gap="8" vertical>
<a-typography-text type="secondary">{{ $t('库位') }}</a-typography-text>
<a-typography-text>{{ point.locationNames.join('、') }}</a-typography-text>
</a-flex>
</a-list-item>
<a-list-item
v-if="
[

View File

@ -1,4 +1,5 @@
<script setup lang="ts">
import { PlusOutlined } from '@ant-design/icons-vue';
import { MAP_POINT_TYPES, MapAreaType, type MapPen, type MapPointInfo, MapPointType, type Rect } from '@api/map';
import type { RobotInfo } from '@api/robot';
import type { PointBindModalRef } from '@common/modal/point-bind-modal.vue';
@ -56,6 +57,25 @@ const actions = computed<MapPen[]>(
const coArea1 = computed<MapPen[]>(() => editor.value.getBoundAreas(props.id, 'point', MapAreaType.库区));
const coArea2 = computed<MapPen[]>(() => editor.value.getBoundAreas(props.id, 'point', MapAreaType.互斥区));
function onAddLocation() {
const p = point.value!;
if (!p.locationNames) p.locationNames = [];
p.locationNames.push('');
editor.value.updatePen(props.id!, { point: { ...p } }, false);
}
function onRemoveLocation(i: number) {
const p = point.value!;
p.locationNames?.splice(i, 1);
editor.value.updatePen(props.id!, { point: { ...p } }, false);
}
function onChangeLocation(i: number, v: string) {
const p = point.value!;
if (p.locationNames) {
p.locationNames[i] = v;
editor.value.updatePen(props.id!, { point: { ...p } }, false);
}
}
</script>
<template>
@ -74,7 +94,7 @@ const coArea2 = computed<MapPen[]>(() => editor.value.getBoundAreas(props.id, 'p
<a-input
:maxlength="10"
:value="pen.label"
@change="editor.updatePen(id, { label: $event.target.value }, false)"
@change="editor.updatePen(id, { label: ($event.target as any).value }, false)"
>
<template #suffix><EditOutlined /></template>
</a-input>
@ -92,7 +112,7 @@ const coArea2 = computed<MapPen[]>(() => editor.value.getBoundAreas(props.id, 'p
:maxlength="100"
:autoSize="{ minRows: 3, maxRows: 3 }"
:value="pen?.desc"
@change="editor.updatePen(id, { desc: $event.target.value }, false)"
@change="editor.updatePen(id, { desc: ($event.target as any).value }, false)"
/>
</a-col>
</a-row>
@ -187,6 +207,26 @@ const coArea2 = computed<MapPen[]>(() => editor.value.getBoundAreas(props.id, 'p
</a-list>
</a-collapse-panel>
<a-collapse-panel v-if="MapPointType.动作点 === point.type" :header="$t('库位')">
<a-flex vertical :gap="8">
<a-flex v-for="(l, i) in point.locationNames" :key="i" :gap="8" align="center">
<a-input
style="flex: 1"
:value="l"
:placeholder="$t('请输入库位')"
@change="onChangeLocation(i, ($event.target as any).value)"
/>
<a-button class="icon-btn" size="small" danger @click="onRemoveLocation(i)">
<i class="mask trash" />
</a-button>
</a-flex>
<a-button type="dashed" block @click="onAddLocation">
<template #icon><PlusOutlined /></template>
{{ $t('添加库位') }}
</a-button>
</a-flex>
</a-collapse-panel>
<a-collapse-panel
v-if="
[

View File

@ -166,7 +166,7 @@ export class EditorService extends Meta2d {
#mapScenePoint(pen?: MapPen): StandardScenePoint | null {
if (!pen?.id || isEmpty(pen?.point)) return null;
const { id, label, desc, properties } = pen;
const { type, robots, actions } = pen.point;
const { type, robots, actions, locationNames } = pen.point;
const { x = 0, y = 0 } = this.getPointRect(pen) ?? {};
// 进行坐标转换:左上角原点 -> 中心点原点同时应用ratio缩放
@ -188,6 +188,9 @@ export class EditorService extends Meta2d {
if (MapPointType. === type) {
point.actions = actions?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.);
}
if (MapPointType. === type) {
point.locationNames = locationNames;
}
return point;
}
#mapSceneRoute(pen?: MapPen): StandardSceneRoute | null {