feat(editor): 删除门区域时清空绑定路段的设备ID以保持数据一致性

This commit is contained in:
xudan 2025-12-08 17:51:05 +08:00
parent 10df768c2d
commit 1b0f6866a5

View File

@ -11,6 +11,7 @@ import {
type Point, type Point,
type Rect, type Rect,
} from '@api/map'; } from '@api/map';
import { DOOR_AREA_TYPE } from '@api/map/door-area';
import type { RobotGroup, RobotInfo, RobotLabel } from '@api/robot'; import type { RobotGroup, RobotInfo, RobotLabel } from '@api/robot';
import type { import type {
GroupSceneDetail, GroupSceneDetail,
@ -1291,6 +1292,26 @@ export class EditorService extends Meta2d {
case 'point': case 'point':
this.delete(this.getLines(pen), true, false); this.delete(this.getLines(pen), true, false);
break; break;
case 'area':
// 删除门区域时清空绑定路段的设备ID
if (pen.area?.type === DOOR_AREA_TYPE && pen.area?.routes) {
pen.area.routes.forEach((routeId: string) => {
const routePen = this.getPenById(routeId) as MapPen | undefined;
if (routePen?.route?.deviceId) {
// 清空路段的设备ID
const updatedRoute = { ...routePen.route };
delete updatedRoute.deviceId;
this.setValue(
{
id: routeId,
route: updatedRoute
},
{ render: true, history: true, doEvent: false }
);
}
});
}
break;
default: default:
break; break;
} }