feat: 添加设备ID字段到点位信息和场景点接口,更新相关组件以显示和编辑设备ID

This commit is contained in:
xudan 2025-07-18 17:51:04 +08:00
parent 7f761ceaad
commit 5f90174c57
5 changed files with 25 additions and 3 deletions

View File

@ -29,6 +29,7 @@ export interface MapPointInfo {
isBlock?: boolean; // 是否禁行
isForbidAvoid?: boolean; // 是否禁止避让
associatedStorageLocations?: string[]; // 库位名称
deviceId?: string; // 设备ID
}
//#endregion

View File

@ -44,6 +44,7 @@ export interface StandardScenePoint {
associatedStorageLocations?: string[]; // 库位名称
config?: object; // 其它属性配置(可按需增加)
properties?: unknown; // 附加数据(前端不做任何处理)
deviceId?: string; // 设备ID
}
export interface StandardSceneRoute {
id: string;

View File

@ -109,6 +109,10 @@ const getStorageStatusTag = (location: StorageLocationInfo) => {
<a-typography-text type="secondary">{{ $t('站点坐标') }}</a-typography-text>
<a-typography-text>({{ rect.x?.toFixed() }},{{ rect.y?.toFixed() }})</a-typography-text>
</a-list-item>
<a-list-item v-if="point.type === MapPointType.自动门点 && point.deviceId">
<a-typography-text type="secondary">{{ $t('设备ID') }}</a-typography-text>
<a-typography-text>{{ point.deviceId }}</a-typography-text>
</a-list-item>
<a-list-item v-if="point.extensionType">
<a-typography-text type="secondary">{{ $t('扩展类型') }}</a-typography-text>
<a-typography-text>{{ $t(MapPointType[point.extensionType]) }}</a-typography-text>

View File

@ -109,6 +109,19 @@ function onChangeLocation(i: number, v: string) {
</a-col>
</a-row>
<a-row v-if="point.type === MapPointType.自动门点" :gutter="[8, 8]">
<a-col :span="24">
<a-typography-text>{{ $t('设备ID') }}:</a-typography-text>
</a-col>
<a-col :span="24">
<a-input
:placeholder="$t('请输入设备ID')"
:value="point.deviceId"
@change="editor.updatePen(id, { point: { ...point, deviceId: ($event.target as any).value } }, false)"
/>
</a-col>
</a-row>
<a-row :gutter="[8, 8]">
<a-col :span="24">
<a-typography-text>{{ $t('描述') }}:</a-typography-text>

View File

@ -110,10 +110,10 @@ export class EditorService extends Meta2d {
if (!points?.length) return;
await Promise.all(
points.map(async (v) => {
const { id, name, desc, x, y, type, extensionType, robots, actions, properties } = v;
const { id, name, desc, x, y, type, extensionType, robots, actions, properties, deviceId } = v;
await this.addPoint({ x, y }, type, id);
this.setValue(
{ id, label: name, desc, properties, point: { type, extensionType, robots, actions } },
{ id, label: name, desc, properties, point: { type, extensionType, robots, actions, deviceId } },
{ render: false, history: false, doEvent: false },
);
}),
@ -199,7 +199,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, extensionType, robots, actions, associatedStorageLocations } = pen.point;
const { type, extensionType, robots, actions, associatedStorageLocations, deviceId } = pen.point;
const { x = 0, y = 0 } = this.getPointRect(pen) ?? {};
// 进行坐标转换:左上角原点 -> 中心点原点同时应用ratio缩放
@ -225,6 +225,9 @@ export class EditorService extends Meta2d {
if (MapPointType. === type) {
point.associatedStorageLocations = associatedStorageLocations;
}
if (MapPointType. === type) {
point.deviceId = deviceId;
}
return point;
}
#mapSceneRoute(pen?: MapPen): StandardSceneRoute | null {