feat: 更新点位信息接口,支持充电点和停靠点的启用状态默认值为1,优化相关逻辑以提升代码可读性
This commit is contained in:
parent
3a83d15db4
commit
de1ffcdd16
@ -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; // 是否激活状态,用于控制光圈显示
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
|
@ -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">
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user