|
|
|
@ -125,6 +125,7 @@ |
|
|
|
@select-route="selectRoute" |
|
|
|
@create-plan="createPlan" |
|
|
|
@create-route="createRoute" |
|
|
|
@delete-route="handleDeleteRoute" |
|
|
|
@open-plan-dialog="openPlanDialog" |
|
|
|
@open-route-dialog="openRouteDialog" |
|
|
|
@open-waypoint-dialog="openWaypointDialog" |
|
|
|
@ -270,7 +271,7 @@ import LeftMenu from './LeftMenu' |
|
|
|
import RightPanel from './RightPanel' |
|
|
|
import BottomLeftPanel from './BottomLeftPanel' |
|
|
|
import TopHeader from './TopHeader' |
|
|
|
import { listRoutes, getRoutes, addRoutes } from "@/api/system/routes"; |
|
|
|
import { listRoutes, getRoutes, addRoutes,delRoutes } from "@/api/system/routes"; |
|
|
|
import { updateWaypoints } from "@/api/system/waypoints"; |
|
|
|
export default { |
|
|
|
name: 'MissionPlanningView', |
|
|
|
@ -546,7 +547,36 @@ export default { |
|
|
|
this.$refs.cesiumMap.startMissionRouteDrawing(); |
|
|
|
this.$message.success('进入航线规划模式'); |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
async handleDeleteRoute(route) { |
|
|
|
try { |
|
|
|
// 二次确认,防止误删 |
|
|
|
await this.$confirm(`确定要彻底删除航线 "${route.name}" 吗?`, '提示', { |
|
|
|
type: 'warning' |
|
|
|
}); |
|
|
|
if (this.selectedRouteDetails && this.selectedRouteDetails.id === route.id) { |
|
|
|
this.selectedRouteDetails = null; |
|
|
|
} |
|
|
|
const res = await delRoutes(route.id); |
|
|
|
if (res.code === 200) { |
|
|
|
this.$message.success('删除成功'); |
|
|
|
// 同步地图:如果该航线正在显示,立即清除 |
|
|
|
if (this.$refs.cesiumMap) { |
|
|
|
this.$refs.cesiumMap.removeRouteById(route.id); |
|
|
|
} |
|
|
|
// 同步状态:从选中列表中移除该 ID |
|
|
|
const idx = this.activeRouteIds.indexOf(route.id); |
|
|
|
if (idx > -1) { |
|
|
|
this.activeRouteIds.splice(idx, 1); |
|
|
|
} |
|
|
|
await this.getList(); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
if (e !== 'cancel') { |
|
|
|
console.error("删除航线失败:", e); |
|
|
|
this.$message.error('删除操作失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
/** 从数据库拉取最新的航线列表数据 */ |
|
|
|
async getList() { |
|
|
|
@ -581,10 +611,16 @@ export default { |
|
|
|
this.$message.error('新增航线未命名,请输入名称后保存!'); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 获取当前选中的方案 ID |
|
|
|
const currentScenarioId = this.selectedPlanId; |
|
|
|
if (!currentScenarioId) { |
|
|
|
this.$message.warning('请先在左侧选择一个方案,再保存航线!'); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 构造符合后端 Routes 实体类的数据结构 |
|
|
|
const routeData = { |
|
|
|
callSign: this.newRouteName, |
|
|
|
scenarioId: 1, // 示例:当前归属方案ID(实际应从全局状态获取) |
|
|
|
scenarioId: currentScenarioId, |
|
|
|
platformId: 1, |
|
|
|
attributes: "{}", |
|
|
|
waypoints: this.tempMapPoints.map((p, index) => ({ |
|
|
|
@ -602,7 +638,27 @@ export default { |
|
|
|
// 调用后端 API 保存到数据库 |
|
|
|
const response = await addRoutes(routeData); |
|
|
|
if (response.code === 200) { |
|
|
|
this.$message.success('航线及其航点已成功保存至数据库'); |
|
|
|
this.$message.success('航线及其航点已成功保存至当前方案'); |
|
|
|
// 获取后端生成的正式 ID |
|
|
|
const savedRoute = response.data; |
|
|
|
const newRouteId = savedRoute ? savedRoute.id : null; |
|
|
|
if (this.$refs.cesiumMap) { |
|
|
|
this.$refs.cesiumMap.clearRoute(); |
|
|
|
// 如果拿到了正式 ID,则按照“正式航线”的规则渲染一次 |
|
|
|
if (newRouteId) { |
|
|
|
if (!this.activeRouteIds.includes(savedRoute.id)) { |
|
|
|
this.activeRouteIds.push(savedRoute.id); |
|
|
|
} |
|
|
|
// 更新当前详情,确保右侧下方航点列表立刻显示 |
|
|
|
this.selectedRouteDetails = { |
|
|
|
id: newRouteId, |
|
|
|
name: this.newRouteName, |
|
|
|
waypoints: routeData.waypoints |
|
|
|
}; |
|
|
|
//使用正式 ID 渲染点和线 |
|
|
|
this.$refs.cesiumMap.renderRouteWaypoints(routeData.waypoints, newRouteId); |
|
|
|
} |
|
|
|
} |
|
|
|
// 重置 UI 状态 |
|
|
|
this.showNameDialog = false; |
|
|
|
this.drawDom = false; |
|
|
|
@ -1108,7 +1164,6 @@ export default { |
|
|
|
/** 切换航线:实现多选/开关逻辑 */ |
|
|
|
async selectRoute(route) { |
|
|
|
const index = this.activeRouteIds.indexOf(route.id); |
|
|
|
|
|
|
|
// 航线已在选中列表中 |
|
|
|
if (index > -1) { |
|
|
|
this.activeRouteIds.splice(index, 1); |
|
|
|
|