diff --git a/src/apis/map/type.ts b/src/apis/map/type.ts index 4010f56..049cc41 100644 --- a/src/apis/map/type.ts +++ b/src/apis/map/type.ts @@ -31,7 +31,7 @@ export interface MapPointInfo { isForbidAvoid?: boolean; // 是否禁止避让 associatedStorageLocations?: string[]; // 库位名称 deviceId?: string; // 设备ID - enabled?: 0 | 1; // 是否启用(仅停靠点使用,0=禁用,1=启用) + enabled?: 0 | 1; // 是否启用(充电点/停靠点使用,0=禁用,1=启用) deviceStatus?: number; // 设备状态(仅自动门点使用,0=关门,1=开门) isConnected?: boolean; // 连接状态(仅自动门点使用,true=已连接,false=未连接) active?: boolean; // 是否激活状态,用于控制光圈显示 diff --git a/src/apis/scene/type.ts b/src/apis/scene/type.ts index 2681f06..94da9f4 100644 --- a/src/apis/scene/type.ts +++ b/src/apis/scene/type.ts @@ -48,7 +48,7 @@ export interface StandardScenePoint { config?: object; // 其它属性配置(可按需增加) properties?: unknown; // 附加数据(前端不做任何处理) deviceId?: string; // 设备ID - enabled?: 0 | 1; // 是否启用(仅停靠点使用,0=禁用,1=启用) + enabled?: 0 | 1; // 是否启用(充电点/停靠点使用,0=禁用,1=启用) } export interface StandardSceneRoute { id: string; diff --git a/src/components/card/point-detail-card.vue b/src/components/card/point-detail-card.vue index 2aa985e..acab732 100644 --- a/src/components/card/point-detail-card.vue +++ b/src/components/card/point-detail-card.vue @@ -89,7 +89,7 @@ const getStorageStatusTag = (location: StorageLocationInfo): Array<{ text: strin // 获取当前动作点对应的库位任务数据 const binTaskData = computed(() => { if (!point.value) return []; - + const currentPointName = pen.value?.label || pen.value?.id; if (!currentPointName) return []; @@ -146,7 +146,7 @@ const binTaskData = computed(() => { {{ bindRobot || $t('暂无') }} - + {{ $t('启用状态') }} {{ point.enabled === 1 ? $t('已启用') : $t('已禁用') }} diff --git a/src/components/card/point-edit-card.vue b/src/components/card/point-edit-card.vue index 578f7f3..55d968b 100644 --- a/src/components/card/point-edit-card.vue +++ b/src/components/card/point-edit-card.vue @@ -116,10 +116,10 @@ function onAddLocation() { const defaultName = generateDefaultLocationName(); p.associatedStorageLocations.push(defaultName); editor.value.updatePen(props.id!, { point: { ...p } }, false); - + // 重新创建库位pen对象以反映最新的库位列表,但不立即渲染 editor.value.createStorageLocationPens(props.id!, p.associatedStorageLocations, false); - + // 延迟渲染并重新选中点位,避免失焦 requestAnimationFrame(() => { editor.value.render(); @@ -159,7 +159,7 @@ function onRemoveLocation(i: number) { if (pointName && removedLocationName) { editor.value.removeBinLocation(pointName, removedLocationName); } - + // 延迟渲染并重新选中点位,避免失焦 requestAnimationFrame(() => { editor.value.render(); @@ -182,7 +182,7 @@ function onRemoveLocation(i: number) { if (pointName && removedLocationName) { editor.value.removeBinLocation(pointName, removedLocationName); } - + // 延迟渲染并重新选中点位,避免失焦 requestAnimationFrame(() => { editor.value.render(); @@ -213,7 +213,7 @@ function onChangeLocation(i: number, v: string) { if (pointName && oldLocationName !== newLocationName) { editor.value.updateBinLocationName(pointName, oldLocationName, newLocationName); } - + // 延迟渲染并重新选中点位,避免失焦 requestAnimationFrame(() => { editor.value.render(); @@ -235,7 +235,7 @@ function onBinTaskSave(data: { pointName: string; locationName: string; binTasks // 更新场景文件中的BinTask配置 editor.value.updateBinTask(pointName, data.locationName, data.binTasks); - + // 延迟渲染并重新选中点位,避免失焦 requestAnimationFrame(() => { editor.value.render(); @@ -375,7 +375,10 @@ const deleteIconUrl = new URL('../../assets/icons/png/delete.png', import.meta.u - + - - 设置 + + 设置 - 删除 + 删除 diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index 46bbf6d..52847ce 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -232,13 +232,27 @@ export class EditorService extends Meta2d { finalY = transformedCoords.y; } await this.addPoint({ x: finalX, y: finalY }, type, id); + // 若为充电点/停靠点,且未提供 enabled,则默认启用为 1 + const pointPayload: any = { + type, + extensionType, + robots, + actions, + associatedStorageLocations, + deviceId, + }; + if ([MapPointType.充电点, MapPointType.停靠点].includes(type)) { + pointPayload.enabled = (enabled ?? 1) as 0 | 1; + } else if (enabled !== undefined) { + pointPayload.enabled = enabled; + } this.setValue( { id, label: name, desc, properties, - point: { type, extensionType, robots, actions, associatedStorageLocations, deviceId, enabled }, + point: pointPayload, }, { render: false, history: false, doEvent: false }, ); @@ -386,6 +400,8 @@ export class EditorService extends Meta2d { }; if ([MapPointType.充电点, MapPointType.停靠点].includes(type)) { point.robots = robots?.filter((v) => this.#robotMap.has(v)); + // 若未提供 enabled,则默认启用 + point.enabled = (enabled ?? 1) as 0 | 1; } if (MapPointType.等待点 === type) { point.actions = actions?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.动作点); @@ -396,9 +412,7 @@ export class EditorService extends Meta2d { if (MapPointType.自动门点 === type) { point.deviceId = deviceId; } - if (MapPointType.停靠点 === type) { - point.enabled = enabled === 0 ? 0 : 1; //默认启用 - } + return point; } #mapSceneRoute(pen?: MapPen): StandardSceneRoute | null { @@ -1228,8 +1242,8 @@ export class EditorService extends Meta2d { id ||= s8(); const pointInfo: MapPointInfo = { type }; - // 为停靠点设置默认启用状态 - if (type === MapPointType.停靠点) { + // 为充电点/停靠点设置默认启用状态 + if ([MapPointType.充电点, MapPointType.停靠点].includes(type)) { pointInfo.enabled = 1; } @@ -1281,8 +1295,8 @@ export class EditorService extends Meta2d { const point = this.#mapPoint(type); const pointInfo: MapPointInfo = { type }; - // 为停靠点设置默认启用状态 - if (type === MapPointType.停靠点) { + // 为充电点/停靠点设置默认启用状态 + if ([MapPointType.充电点, MapPointType.停靠点].includes(type)) { pointInfo.enabled = 1; }