feat: 更新点位信息接口,支持充电点和停靠点的启用状态默认值为1,优化相关逻辑以提升代码可读性

This commit is contained in:
xudan 2025-09-15 14:57:10 +08:00
parent 3a83d15db4
commit de1ffcdd16
5 changed files with 39 additions and 35 deletions

View File

@ -31,7 +31,7 @@ export interface MapPointInfo {
isForbidAvoid?: boolean; // 是否禁止避让 isForbidAvoid?: boolean; // 是否禁止避让
associatedStorageLocations?: string[]; // 库位名称 associatedStorageLocations?: string[]; // 库位名称
deviceId?: string; // 设备ID deviceId?: string; // 设备ID
enabled?: 0 | 1; // 是否启用(停靠点使用0=禁用1=启用) enabled?: 0 | 1; // 是否启用(充电点/停靠点使用0=禁用1=启用)
deviceStatus?: number; // 设备状态仅自动门点使用0=关门1=开门) deviceStatus?: number; // 设备状态仅自动门点使用0=关门1=开门)
isConnected?: boolean; // 连接状态仅自动门点使用true=已连接false=未连接) isConnected?: boolean; // 连接状态仅自动门点使用true=已连接false=未连接)
active?: boolean; // 是否激活状态,用于控制光圈显示 active?: boolean; // 是否激活状态,用于控制光圈显示

View File

@ -48,7 +48,7 @@ export interface StandardScenePoint {
config?: object; // 其它属性配置(可按需增加) config?: object; // 其它属性配置(可按需增加)
properties?: unknown; // 附加数据(前端不做任何处理) properties?: unknown; // 附加数据(前端不做任何处理)
deviceId?: string; // 设备ID deviceId?: string; // 设备ID
enabled?: 0 | 1; // 是否启用(停靠点使用0=禁用1=启用) enabled?: 0 | 1; // 是否启用(充电点/停靠点使用0=禁用1=启用)
} }
export interface StandardSceneRoute { export interface StandardSceneRoute {
id: string; id: string;

View File

@ -146,7 +146,7 @@ const binTaskData = computed(() => {
<a-typography-text>{{ bindRobot || $t('暂无') }}</a-typography-text> <a-typography-text>{{ bindRobot || $t('暂无') }}</a-typography-text>
</a-flex> </a-flex>
</a-list-item> </a-list-item>
<a-list-item v-if="point.type === MapPointType.停靠点"> <a-list-item v-if="[MapPointType.充电点, MapPointType.停靠点].includes(point.type)">
<a-typography-text type="secondary">{{ $t('启用状态') }}</a-typography-text> <a-typography-text type="secondary">{{ $t('启用状态') }}</a-typography-text>
<a-typography-text>{{ point.enabled === 1 ? $t('已启用') : $t('已禁用') }}</a-typography-text> <a-typography-text>{{ point.enabled === 1 ? $t('已启用') : $t('已禁用') }}</a-typography-text>
</a-list-item> </a-list-item>

View File

@ -375,7 +375,10 @@ const deleteIconUrl = new URL('../../assets/icons/png/delete.png', import.meta.u
</a-list> </a-list>
</a-collapse-panel> </a-collapse-panel>
<a-collapse-panel v-if="point.type === MapPointType.停靠点" :header="$t('是否启用')"> <a-collapse-panel
v-if="[MapPointType.充电点, MapPointType.停靠点].includes(point.type)"
:header="$t('是否启用')"
>
<a-row :gutter="[8, 8]"> <a-row :gutter="[8, 8]">
<a-col :span="24"> <a-col :span="24">
<a-select <a-select
@ -428,24 +431,11 @@ const deleteIconUrl = new URL('../../assets/icons/png/delete.png', import.meta.u
:placeholder="$t('请输入库位')" :placeholder="$t('请输入库位')"
@change="onChangeLocation(i, ($event.target as any).value)" @change="onChangeLocation(i, ($event.target as any).value)"
/> />
<a-button <a-button class="icon-btn" size="small" @click="onEditBinTask(l)" :title="$t('编辑BinTask配置')">
class="icon-btn" <img :src="settingIconUrl" alt="设置" style="width: 16px; height: 16px" />
size="small"
@click="onEditBinTask(l)"
:title="$t('编辑BinTask配置')"
>
<img
:src="settingIconUrl"
alt="设置"
style="width: 16px; height: 16px;"
/>
</a-button> </a-button>
<a-button class="icon-btn" size="small" danger @click="onRemoveLocation(i)"> <a-button class="icon-btn" size="small" danger @click="onRemoveLocation(i)">
<img <img :src="deleteIconUrl" alt="删除" style="width: 16px; height: 16px" />
:src="deleteIconUrl"
alt="删除"
style="width: 16px; height: 16px;"
/>
</a-button> </a-button>
</a-flex> </a-flex>
<a-button type="dashed" block @click="onAddLocation"> <a-button type="dashed" block @click="onAddLocation">

View File

@ -232,13 +232,27 @@ export class EditorService extends Meta2d {
finalY = transformedCoords.y; finalY = transformedCoords.y;
} }
await this.addPoint({ x: finalX, y: finalY }, type, id); await this.addPoint({ x: finalX, y: finalY }, type, id);
// 若为充电点/停靠点,且未提供 enabled则默认启用为 1
const pointPayload: any = {
type,
extensionType,
robots,
actions,
associatedStorageLocations,
deviceId,
};
if ([MapPointType., MapPointType.].includes(<any>type)) {
pointPayload.enabled = (enabled ?? 1) as 0 | 1;
} else if (enabled !== undefined) {
pointPayload.enabled = enabled;
}
this.setValue( this.setValue(
{ {
id, id,
label: name, label: name,
desc, desc,
properties, properties,
point: { type, extensionType, robots, actions, associatedStorageLocations, deviceId, enabled }, point: pointPayload,
}, },
{ render: false, history: false, doEvent: false }, { render: false, history: false, doEvent: false },
); );
@ -386,6 +400,8 @@ export class EditorService extends Meta2d {
}; };
if ([MapPointType., MapPointType.].includes(type)) { if ([MapPointType., MapPointType.].includes(type)) {
point.robots = robots?.filter((v) => this.#robotMap.has(v)); point.robots = robots?.filter((v) => this.#robotMap.has(v));
// 若未提供 enabled则默认启用
point.enabled = (enabled ?? 1) as 0 | 1;
} }
if (MapPointType. === type) { if (MapPointType. === type) {
point.actions = actions?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.); point.actions = actions?.filter((v) => this.getPenById(v)?.point?.type === MapPointType.);
@ -396,9 +412,7 @@ export class EditorService extends Meta2d {
if (MapPointType. === type) { if (MapPointType. === type) {
point.deviceId = deviceId; point.deviceId = deviceId;
} }
if (MapPointType. === type) {
point.enabled = enabled === 0 ? 0 : 1; //默认启用
}
return point; return point;
} }
#mapSceneRoute(pen?: MapPen): StandardSceneRoute | null { #mapSceneRoute(pen?: MapPen): StandardSceneRoute | null {
@ -1228,8 +1242,8 @@ export class EditorService extends Meta2d {
id ||= s8(); id ||= s8();
const pointInfo: MapPointInfo = { type }; const pointInfo: MapPointInfo = { type };
// 为停靠点设置默认启用状态 // 为充电点/停靠点设置默认启用状态
if (type === MapPointType.) { if ([MapPointType., MapPointType.].includes(type)) {
pointInfo.enabled = 1; pointInfo.enabled = 1;
} }
@ -1281,8 +1295,8 @@ export class EditorService extends Meta2d {
const point = this.#mapPoint(type); const point = this.#mapPoint(type);
const pointInfo: MapPointInfo = { type }; const pointInfo: MapPointInfo = { type };
// 为停靠点设置默认启用状态 // 为充电点/停靠点设置默认启用状态
if (type === MapPointType.) { if ([MapPointType., MapPointType.].includes(type)) {
pointInfo.enabled = 1; pointInfo.enabled = 1;
} }