控制模式 割刀速度 加入 支持删除 返航点和障碍物点
This commit is contained in:
@@ -823,7 +823,94 @@ export default function MapEditorPage() {
|
||||
console.error('[MapEditor] preview route failed:', e);
|
||||
}
|
||||
};
|
||||
// 修改已配置障碍物点的半径
|
||||
|
||||
// ========== 删除已配置的返航点 / 障碍物点 ==========
|
||||
const handleDeleteMapPoint = (item: any, index: number) => {
|
||||
const isReturnPoint = activeType === 'returnPoint';
|
||||
const isObstaclePoint = activeType === 'obstaclePoint';
|
||||
|
||||
if (!isReturnPoint && !isObstaclePoint) return;
|
||||
|
||||
const pointName = isReturnPoint
|
||||
? item.alias || `返航点-${index + 1}`
|
||||
: item.name || item.alias || `障碍物点-${index + 1}`;
|
||||
|
||||
modal.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定删除「${pointName}」吗?`,
|
||||
okText: '删除',
|
||||
cancelText: '取消',
|
||||
okButtonProps: { danger: true },
|
||||
|
||||
onOk: async () => {
|
||||
try {
|
||||
let payload: any;
|
||||
|
||||
if (isReturnPoint) {
|
||||
// 删除当前返航点,保留其他返航点
|
||||
const nextPoints = returnPointConfigList
|
||||
.filter((_: any, i: number) => i !== index);
|
||||
|
||||
payload = {
|
||||
restPoints: nextPoints.map((p: any) => ({
|
||||
alias: p.alias || '',
|
||||
position: p.position,
|
||||
bindDeviceId: p.bindDeviceId || null,
|
||||
})),
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
} else {
|
||||
// 删除当前障碍物点,保留其他障碍物点
|
||||
const nextPoints = obstaclePointConfigList.filter(
|
||||
(point: any) =>
|
||||
String(point.id) !== String(item.id)
|
||||
);
|
||||
|
||||
payload = {
|
||||
tempObstaclePoints: nextPoints.map((point: any) => ({
|
||||
position: {
|
||||
lat: Number(
|
||||
point.position?.lat ?? point.lat ?? 0
|
||||
),
|
||||
lng: Number(
|
||||
point.position?.lng ??
|
||||
point.position?.lon ??
|
||||
point.lon ??
|
||||
0
|
||||
),
|
||||
},
|
||||
radius: Number(point.radius) || 2,
|
||||
alias: point.name ?? point.alias ?? '',
|
||||
})),
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
}
|
||||
|
||||
// 更新已有站点地图信息时,带上后端返回的主键 ID
|
||||
if (siteMapInfoId != null) {
|
||||
payload.id = siteMapInfoId;
|
||||
}
|
||||
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('删除成功');
|
||||
|
||||
// 刷新服务端数据及地图覆盖物
|
||||
await getSiteMapInfoFn();
|
||||
setOverlayRefreshKey((k) => k + 1);
|
||||
} else {
|
||||
messageApi.error(res?.msg || '删除失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[MapEditor] 删除返航点/障碍物点失败:', error);
|
||||
messageApi.error('删除失败,请稍后重试');
|
||||
}
|
||||
},
|
||||
});
|
||||
}; // 修改已配置障碍物点的半径
|
||||
const handleUpdateObstacleRadius = async (
|
||||
item: any,
|
||||
radius: number
|
||||
@@ -1951,6 +2038,22 @@ export default function MapEditorPage() {
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 返航点 / 障碍物点:增加删除按钮 */}
|
||||
{(isReturnPoint || isObstaclePoint) && (
|
||||
<Button
|
||||
size="small"
|
||||
type="text"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
title={t('common.delete')}
|
||||
onClick={(e) => {
|
||||
// 防止触发行项目的地图聚焦事件
|
||||
e.stopPropagation();
|
||||
handleDeleteMapPoint(item, idx);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user