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; // 是否禁止避让
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; // 是否激活状态,用于控制光圈显示

View File

@ -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;

View File

@ -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(() => {
<a-typography-text>{{ bindRobot || $t('暂无') }}</a-typography-text>
</a-flex>
</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>{{ point.enabled === 1 ? $t('已启用') : $t('已禁用') }}</a-typography-text>
</a-list-item>

View File

@ -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
</a-list>
</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-col :span="24">
<a-select
@ -428,24 +431,11 @@ const deleteIconUrl = new URL('../../assets/icons/png/delete.png', import.meta.u
:placeholder="$t('请输入库位')"
@change="onChangeLocation(i, ($event.target as any).value)"
/>
<a-button
class="icon-btn"
size="small"
@click="onEditBinTask(l)"
:title="$t('编辑BinTask配置')"
>
<img
:src="settingIconUrl"
alt="设置"
style="width: 16px; height: 16px;"
/>
<a-button class="icon-btn" size="small" @click="onEditBinTask(l)" :title="$t('编辑BinTask配置')">
<img :src="settingIconUrl" alt="设置" style="width: 16px; height: 16px" />
</a-button>
<a-button class="icon-btn" size="small" danger @click="onRemoveLocation(i)">
<img
:src="deleteIconUrl"
alt="删除"
style="width: 16px; height: 16px;"
/>
<img :src="deleteIconUrl" alt="删除" style="width: 16px; height: 16px" />
</a-button>
</a-flex>
<a-button type="dashed" block @click="onAddLocation">

View File

@ -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(<any>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;
}