修复 拖动障碍物 优化dpadcontrol 未测试

This commit is contained in:
mmc
2026-10-30 09:58:29 +08:00
parent 04f74277bf
commit e8cb77a6bc
5 changed files with 426 additions and 181 deletions

View File

@@ -746,53 +746,61 @@ export default function MapEditorPage() {
const handleObstacleRadiusChange = async (
index: number,
radius: number,
siteMapInfoId: number | null
idFromMap: number | null = null
) => {
console.log("nextList")
const roundedRadius = Number(radius.toFixed(2));
const nextList = obstaclePointConfigList.map(
(item, idx) =>
idx === index
? { ...item, radius: roundedRadius }
: item
);
console.log(nextList, "333", siteMapInfoId, "siteMapInfoIdnextList")
const payload = {
id: siteMapInfoId,
tempObstaclePoints: nextList?.map((item) => ({
radius: item.radius,
position: {
lat: item.lat,
lng: item.lon,
},
// 以服务端最新数据为准:本地列表可能为空,或顺序与地图上的不一致
let infoRes: any = null;
try {
infoRes = await getSiteMapInfo({ siteId: stationId });
} catch (e) {
infoRes = null;
}
alias: item.name,
})),
const remoteList: any[] =
infoRes?.code === 200 && Array.isArray(infoRes.data?.tempObstaclePoints)
? infoRes.data.tempObstaclePoints
: [];
const infoId: number | null =
(infoRes?.code === 200 ? infoRes.data?.id : null) ?? idFromMap ?? null;
// 远端列表优先,为空时退回本地已配置列表
const baseList: any[] = remoteList.length > 0 ? remoteList : obstaclePointConfigList;
if (!baseList.length || index < 0 || index >= baseList.length) {
messageApi.error('未找到障碍物点数据,请刷新后重试');
return;
}
const nextPoints = baseList.map((item: any, idx: number) => ({
radius: idx === index ? roundedRadius : Number(item.radius) || 0,
position: {
lat: Number(item.position?.lat ?? item.lat ?? 0),
lng: Number(item.position?.lng ?? item.position?.lon ?? item.lon ?? 0),
},
alias: item.alias ?? item.name ?? '',
}));
const payload: any = {
tempObstaclePoints: nextPoints,
siteId: stationId,
orgId: currentStation?.orgId,
}
};
// id 为空时不要传 id 字段,否则后端会把 null 主键当成非法新增
if (infoId != null) payload.id = infoId;
const res: any = await saveSiteMapInfo(payload);
if (res?.code === 200) {
messageApi.success('障碍物点半径修改成功');
getSiteMapInfoFn();
setOverlayRefreshKey(k => k + 1);
} else {
messageApi.error(
res?.msg || '障碍物点半径修改失败'
);
}
console.log(nextList, "nextList")
//setObstaclePointConfigList(nextList);
// 使用 nextList 调用你现有的保存接口
};
// ========== 点击预设路径在地图上预览(覆盖=框,单点=线) ==========
const handlePreviewRoute = async (route: any) => {