任务监控界面 完善 点击任务池 显示轨迹 路径功能,清空规划功能
This commit is contained in:
@@ -124,6 +124,9 @@ export default function MapEditorPage() {
|
||||
if (activeType === 'obstaclePoint') return obstaclePoints;
|
||||
return [];
|
||||
}, [activeType, returnPoints, restAreas, routePoints, obstaclePoints]);
|
||||
useEffect(() => {
|
||||
getSiteMapInfoFn()
|
||||
}, [activeType])
|
||||
|
||||
// 传给Cesium地图渲染的点位
|
||||
const drawingPoints = useMemo(() => {
|
||||
@@ -559,218 +562,7 @@ export default function MapEditorPage() {
|
||||
},
|
||||
});
|
||||
};
|
||||
// ========== 修改已配置返航点名称 ==========
|
||||
const handleUpdateReturnPointAlias = async (
|
||||
index: number,
|
||||
alias: string
|
||||
) => {
|
||||
console.log('[MapEditor] 修改返航点名称:', index, alias);
|
||||
const updated = returnPointConfigList.map((p: any, i: number) =>
|
||||
i === index ? { ...p, alias } : p
|
||||
);
|
||||
|
||||
// 同时更新已配置列表和编辑列表,保证二者一致
|
||||
setReturnPointConfigList(updated);
|
||||
setReturnPoints(prev => prev.map((p, i) => i === index ? { ...p, name: alias } : p));
|
||||
|
||||
const payload: any = {
|
||||
restPoints: updated.map((p: any) => ({
|
||||
alias: p.alias || '',
|
||||
position: p.position,
|
||||
bindDeviceId: p.bindDeviceId || null,
|
||||
})),
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
|
||||
if (siteMapInfoId != null) {
|
||||
payload.id = siteMapInfoId;
|
||||
}
|
||||
|
||||
try {
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('返航点名称修改成功');
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
getSiteMapInfoFn();
|
||||
} else {
|
||||
messageApi.error(res?.msg || '返航点名称修改失败');
|
||||
getSiteMapInfoFn();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新返航点名称失败:', error);
|
||||
messageApi.error('返航点名称修改失败');
|
||||
getSiteMapInfoFn();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// ========== 修改已配置障碍物点名称 ==========
|
||||
const handleUpdateObstacleAlias = async (
|
||||
item: any,
|
||||
alias: string
|
||||
) => {
|
||||
const updated = obstaclePointConfigList.map((point: any) =>
|
||||
String(point.id) === String(item.id)
|
||||
? { ...point, alias: alias, name: alias }
|
||||
: point
|
||||
);
|
||||
|
||||
setObstaclePointConfigList(updated);
|
||||
setObstaclePoints(updated); // 同时更新编辑中的列表,触发地图重绘
|
||||
|
||||
const payload: any = {
|
||||
tempObstaclePoints: updated.map((point: any) => ({
|
||||
position: {
|
||||
lat: Number(point.lat ?? point.position?.lat ?? 0),
|
||||
lng: Number(
|
||||
point.lon ??
|
||||
point.position?.lng ??
|
||||
point.position?.lon ??
|
||||
0
|
||||
),
|
||||
},
|
||||
radius: Number(point.radius) || 0,
|
||||
size_x: Number(point.size_x) || 0,
|
||||
size_y: Number(point.size_y) || 0,
|
||||
shapeType: point.shapeType || 'rect',
|
||||
alias: point.alias || point.name || '',
|
||||
source: 'platform'
|
||||
})),
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
|
||||
if (siteMapInfoId != null) {
|
||||
payload.id = siteMapInfoId;
|
||||
}
|
||||
|
||||
try {
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('障碍物点名称修改成功');
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
getSiteMapInfoFn();
|
||||
} else {
|
||||
messageApi.error(res?.msg || '障碍物点名称修改失败');
|
||||
getSiteMapInfoFn();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新障碍物点名称失败:', error);
|
||||
messageApi.error('障碍物点名称修改失败');
|
||||
getSiteMapInfoFn();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// ========== 修改已配置分区名称 ==========
|
||||
const handleUpdateRegionName = async (
|
||||
item: any,
|
||||
regionName: string
|
||||
) => {
|
||||
// 更新列表显示
|
||||
setRegionList(prev =>
|
||||
prev.map((region: any) =>
|
||||
String(region.id) === String(item.id)
|
||||
? { ...region, regionName }
|
||||
: region
|
||||
)
|
||||
);
|
||||
|
||||
const payload: any = {
|
||||
...item,
|
||||
id: item.id,
|
||||
regionName,
|
||||
siteId: item.siteId ?? stationId,
|
||||
type: item.type || 'region',
|
||||
scope: item.scope || [],
|
||||
status: item.status ?? 1,
|
||||
defaultRoute: item.defaultRoute ?? null,
|
||||
bindRoutes: item.bindRoutes || [],
|
||||
};
|
||||
|
||||
try {
|
||||
const res: any = await saveRegion(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('分区名称修改成功');
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
|
||||
const r: any = await getStationRegions({ siteId: stationId });
|
||||
if (r?.code === 200) {
|
||||
const list = r.data || r.rows || [];
|
||||
setRegionList(Array.isArray(list) ? list : []);
|
||||
}
|
||||
} else {
|
||||
messageApi.error(res?.msg || '分区名称修改失败');
|
||||
|
||||
// 保存失败时恢复服务端数据
|
||||
const r: any = await getStationRegions({ siteId: stationId });
|
||||
if (r?.code === 200) {
|
||||
const list = r.data || r.rows || [];
|
||||
setRegionList(Array.isArray(list) ? list : []);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('更新分区名称失败:', error);
|
||||
messageApi.error('分区名称修改失败');
|
||||
}
|
||||
};
|
||||
// ========== 修改已配置返航点的绑定设备 ==========
|
||||
const handleUpdateReturnPointBind = (index: number, bindDeviceId: string | undefined) => {
|
||||
const updated = returnPointConfigList.map((p: any, i: number) =>
|
||||
i === index ? { ...p, bindDeviceId: bindDeviceId || null } : p
|
||||
);
|
||||
setReturnPointConfigList(updated);
|
||||
setReturnPoints(prev => prev.map((p, i) => i === index ? { ...p, deviceId: bindDeviceId || undefined } : p));
|
||||
|
||||
const restPoints = updated.map((p: any) => ({
|
||||
alias: p.alias,
|
||||
position: p.position,
|
||||
bindDeviceId: p.bindDeviceId || null,
|
||||
}));
|
||||
const idArr = restPoints.map(item => item.bindDeviceId);
|
||||
const repeatIds: string[] = [];
|
||||
const seen = new Set();
|
||||
|
||||
for (const id of idArr) {
|
||||
if (seen.has(id)) {
|
||||
repeatIds.push(id);
|
||||
} else {
|
||||
seen.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (repeatIds.length > 0) {
|
||||
// 去重展示重复id
|
||||
const dupSet = [...new Set(repeatIds)];
|
||||
messageApi.warning(t('devices.mapEditor.duplicateBindDevice'));
|
||||
return;
|
||||
}
|
||||
|
||||
const payload: any = {
|
||||
restPoints,
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
if (siteMapInfoId != null) payload.id = siteMapInfoId;
|
||||
|
||||
saveSiteMapInfo(payload).then((res: any) => {
|
||||
if (res?.code === 200) {
|
||||
messageApi.success(t('devices.mapEditor.bindUpdateSuccess'));
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
// 刷新以获取最新 id
|
||||
getSiteMapInfoFn();
|
||||
} else {
|
||||
messageApi.error(res?.msg || t('common.saveFail'));
|
||||
}
|
||||
}).catch((e: any) => {
|
||||
console.error(e);
|
||||
messageApi.error(t('common.saveFail'));
|
||||
});
|
||||
};
|
||||
|
||||
const handleObstacleRadiusChange = async (
|
||||
index: number,
|
||||
@@ -906,54 +698,6 @@ export default function MapEditorPage() {
|
||||
}
|
||||
},
|
||||
});
|
||||
}; // 修改已配置障碍物点的尺寸
|
||||
const handleUpdateObstacleDimensions = async (
|
||||
item: any,
|
||||
dimensions: { radius?: number; size_x?: number; size_y?: number; shapeType?: 'circle' | 'rect' }
|
||||
) => {
|
||||
try {
|
||||
// 保留其他已配置障碍物点的数据,只修改当前项
|
||||
const tempObstaclePoints = obstaclePointConfigList.map(
|
||||
(point: any) => {
|
||||
const isTarget = String(point.id) === String(item.id);
|
||||
return {
|
||||
position: {
|
||||
lat: Number(point.position?.lat ?? point.lat ?? 0),
|
||||
lng: Number(point.position?.lng ?? point.position?.lon ?? point.lon ?? 0),
|
||||
},
|
||||
radius: isTarget ? (dimensions.radius ?? point.radius) : Number(point.radius),
|
||||
size_x: isTarget ? (dimensions.size_x ?? point.size_x) : Number(point.size_x),
|
||||
size_y: isTarget ? (dimensions.size_y ?? point.size_y) : Number(point.size_y),
|
||||
shapeType: isTarget ? (dimensions.shapeType ?? point.shapeType) : (point.shapeType || 'rect'),
|
||||
alias: point.alias ?? point.name ?? '',
|
||||
source: 'platform'
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const payload: any = {
|
||||
tempObstaclePoints,
|
||||
siteId: stationId,
|
||||
orgId: currentStation?.orgId,
|
||||
};
|
||||
|
||||
if (siteMapInfoId != null) {
|
||||
payload.id = siteMapInfoId;
|
||||
}
|
||||
|
||||
const res: any = await saveSiteMapInfo(payload);
|
||||
|
||||
if (res?.code === 200) {
|
||||
messageApi.success('障碍物点修改成功');
|
||||
getSiteMapInfoFn();
|
||||
setOverlayRefreshKey(k => k + 1);
|
||||
} else {
|
||||
messageApi.error(res?.msg || '障碍物点修改失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[MapEditor] update obstacle dimensions failed:', error);
|
||||
messageApi.error('障碍物点修改失败');
|
||||
}
|
||||
};
|
||||
|
||||
// ========== 删除预设路径 ==========
|
||||
|
||||
Reference in New Issue
Block a user