ctw 2 months ago
parent
commit
c59b06d910
  1. 5
      ruoyi-ui/src/views/childRoom/RightPanel.vue
  2. 213
      ruoyi-ui/src/views/childRoom/index.vue

5
ruoyi-ui/src/views/childRoom/RightPanel.vue

@ -324,7 +324,7 @@ export default {
}) })
} }
}, },
// 线/ // 线/
toggleRoute(routeId) { toggleRoute(routeId) {
const route = this.routes.find(r => r.id === routeId) const route = this.routes.find(r => r.id === routeId)
@ -354,11 +354,12 @@ export default {
}) })
} }
}, },
handleHide() { handleHide() {
this.$emit('hide') this.$emit('hide')
}, },
// 线
handleSelectPlan(plan) { handleSelectPlan(plan) {
this.$emit('select-plan', plan) this.$emit('select-plan', plan)
}, },

213
ruoyi-ui/src/views/childRoom/index.vue

@ -114,7 +114,7 @@
:selected-plan-details="selectedPlanDetails" :selected-plan-details="selectedPlanDetails"
:selected-route-id="selectedRouteId" :selected-route-id="selectedRouteId"
:routes="routes" :routes="routes"
:activeRouteIds="activeRouteIds" :active-route-ids="activeRouteIds"
:selected-route-details="selectedRouteDetails" :selected-route-details="selectedRouteDetails"
:conflicts="conflicts" :conflicts="conflicts"
:conflict-count="conflictCount" :conflict-count="conflictCount"
@ -272,7 +272,8 @@ import LeftMenu from './LeftMenu'
import RightPanel from './RightPanel' import RightPanel from './RightPanel'
import BottomLeftPanel from './BottomLeftPanel' import BottomLeftPanel from './BottomLeftPanel'
import TopHeader from './TopHeader' import TopHeader from './TopHeader'
import { listRoutes, getRoutes, addRoutes } from "@/api/system/routes"; import { listScenario} from "@/api/system/scenario";
import { listRoutes, getRoutes, addRoutes,delRoutes } from "@/api/system/routes";
import { updateWaypoints } from "@/api/system/waypoints"; import { updateWaypoints } from "@/api/system/waypoints";
export default { export default {
name: 'MissionPlanningView', name: 'MissionPlanningView',
@ -303,9 +304,6 @@ export default {
selectedRoute: null, selectedRoute: null,
showWaypointDialog: false, showWaypointDialog: false,
selectedWaypoint: null, selectedWaypoint: null,
showNameDialog: false,
newRouteName: '',
tempMapPoints: [],
// //
showPowerZoneDialog: false, showPowerZoneDialog: false,
currentPowerZone: {}, currentPowerZone: {},
@ -315,6 +313,9 @@ export default {
currentExternalParams: {}, currentExternalParams: {},
showPageLayoutDialog: false, showPageLayoutDialog: false,
menuPosition: 'left', menuPosition: 'left',
showNameDialog: false,
newRouteName: '',
tempMapPoints: [],
// //
roomCode: 'JTF-7-ALPHA', roomCode: 'JTF-7-ALPHA',
@ -395,7 +396,6 @@ export default {
activeRightTab: 'plan', activeRightTab: 'plan',
activeRouteIds: [], // 线ID activeRouteIds: [], // 线ID
// //
conflictCount: 2, conflictCount: 2,
conflicts: [ conflicts: [
@ -437,20 +437,7 @@ export default {
], ],
// 线 - -线- // 线 - -线-
plans: [ plans: [],
{
id: 1,
name: '方案A',
routes: [
]
},
{
id: 2,
name: '方案B',
routes: [
]
}
],
// //
timeProgress: 45, timeProgress: 45,
@ -544,20 +531,60 @@ export default {
this.selectedPlanId = plan.id; this.selectedPlanId = plan.id;
this.selectedPlanDetails = plan; this.selectedPlanDetails = plan;
} }
if (this.$refs.cesiumMap) { if (this.$refs.cesiumMap) {
this.$refs.cesiumMap.startMissionRouteDrawing(); this.$refs.cesiumMap.startMissionRouteDrawing();
this.$message.success('进入航线规划模式'); 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() { async getList() {
const query = {}; // scenarioId线
try { try {
const response = await listRoutes(query); // 1.
if (response.code === 200) { const scenarioRes = await listScenario({});
this.routes = response.rows.map(item => ({ if (scenarioRes.code === 200) {
this.plans = scenarioRes.rows.map(s => ({
id: s.id,
name: s.name,
routes: []
}));
}
// 2. 线
const routeRes = await listRoutes({});
if (routeRes.code === 200) {
const allRoutes = routeRes.rows.map(item => ({
id: item.id, id: item.id,
name: item.callSign, name: item.callSign,
points: item.waypoints ? item.waypoints.length : 0, points: item.waypoints ? item.waypoints.length : 0,
@ -565,9 +592,18 @@ export default {
conflict: false, conflict: false,
scenarioId: item.scenarioId scenarioId: item.scenarioId
})); }));
// 3. 线
this.plans.forEach(plan => {
plan.routes = allRoutes.filter(r => r.scenarioId === plan.id);
});
// routes 使
this.routes = allRoutes;
} }
} catch (error) { } catch (error) {
this.$message.error("获取航线列表失败"); console.error("数据加载失败:", error);
this.$message.error("获取方案列表失败");
} }
}, },
handleMapDrawComplete(points) { handleMapDrawComplete(points) {
@ -586,10 +622,16 @@ export default {
this.$message.error('新增航线未命名,请输入名称后保存!'); this.$message.error('新增航线未命名,请输入名称后保存!');
return; return;
} }
// ID
const currentScenarioId = this.selectedPlanId;
if (!currentScenarioId) {
this.$message.warning('请先在左侧选择一个方案,再保存航线!');
return;
}
// Routes // Routes
const routeData = { const routeData = {
callSign: this.newRouteName, callSign: this.newRouteName,
scenarioId: this.selectedPlanId || 1, // 使ID1 scenarioId: currentScenarioId || 1, // 使ID1
platformId: 1, platformId: 1,
attributes: "{}", attributes: "{}",
waypoints: this.tempMapPoints.map((p, index) => ({ waypoints: this.tempMapPoints.map((p, index) => ({
@ -607,7 +649,27 @@ export default {
// API // API
const response = await addRoutes(routeData); const response = await addRoutes(routeData);
if (response.code === 200) { 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 // UI
this.showNameDialog = false; this.showNameDialog = false;
this.drawDom = false; this.drawDom = false;
@ -1147,15 +1209,7 @@ export default {
const minutes = (val % 4) * 15; const minutes = (val % 4) * 15;
return `K+${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:00`; return `K+${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:00`;
}, },
// 线
createPlan() {
this.$message.success('创建方案');
},
openPlanDialog(plan) {
this.$message.success('打开方案编辑对话框');
},
selectPlan(plan) { selectPlan(plan) {
if (plan && plan.id) { if (plan && plan.id) {
this.selectedPlanId = plan.id; this.selectedPlanId = plan.id;
@ -1167,11 +1221,10 @@ export default {
this.selectedRouteId = null; this.selectedRouteId = null;
this.selectedRouteDetails = null; this.selectedRouteDetails = null;
}, },
/** 切换航线:实现复杂的交互逻辑 */ /** 切换航线:实现多选/开关逻辑 */
async selectRoute(route) { async selectRoute(route) {
const index = this.activeRouteIds.indexOf(route.id); const index = this.activeRouteIds.indexOf(route.id);
const isRouteExpanded = this.$refs.rightPanel ? this.$refs.rightPanel.expandedRoutes.includes(route.id) : false; const isRouteExpanded = this.$refs.rightPanel ? this.$refs.rightPanel.expandedRoutes.includes(route.id) : false;
// 线 // 线
if (index > -1) { if (index > -1) {
if (isRouteExpanded) { if (isRouteExpanded) {
@ -1209,7 +1262,7 @@ export default {
return; return;
} }
} }
// 线线 // 线线
try { try {
const response = await getRoutes(route.id); const response = await getRoutes(route.id);
@ -1217,13 +1270,13 @@ export default {
const fullRouteData = response.data; const fullRouteData = response.data;
const waypoints = fullRouteData.waypoints || []; const waypoints = fullRouteData.waypoints || [];
this.activeRouteIds.push(route.id); this.activeRouteIds.push(route.id);
this.selectedRouteId = fullRouteData.id; this.selectedRouteId = fullRouteData.id;
this.selectedRouteDetails = { this.selectedRouteDetails = {
id: fullRouteData.id, id: fullRouteData.id,
name: fullRouteData.callSign, name: fullRouteData.callSign,
waypoints: waypoints waypoints: waypoints
}; };
// routes 线 waypoints // routes 线 waypoints
const routeIndex = this.routes.findIndex(r => r.id === route.id); const routeIndex = this.routes.findIndex(r => r.id === route.id);
if (routeIndex > -1) { if (routeIndex > -1) {
@ -1232,7 +1285,7 @@ export default {
waypoints: waypoints waypoints: waypoints
}); });
} }
if (waypoints.length > 0) { if (waypoints.length > 0) {
// //
if (this.$refs.cesiumMap) { if (this.$refs.cesiumMap) {
@ -1248,6 +1301,25 @@ export default {
} }
}, },
createPlan() {
const newId = Date.now();
const newPlan = {
id: newId,
name: `新方案${this.plans.length + 1}`,
routes: []
};
this.plans.push(newPlan);
this.selectPlan(newPlan);
},
openPlanDialog(plan) {
this.$prompt('请输入方案名称', '编辑方案', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputValue: plan.name
}).then(({ value }) => {
plan.name = value;
}).catch(() => {});
},
addWaypoint() { addWaypoint() {
if (this.selectedRouteDetails) { if (this.selectedRouteDetails) {
const count = this.selectedRouteDetails.waypoints.length + 1; const count = this.selectedRouteDetails.waypoints.length + 1;
@ -1257,7 +1329,12 @@ export default {
speed: '800km/h', speed: '800km/h',
eta: `K+01:${(count * 15).toString().padStart(2, '0')}:00` eta: `K+01:${(count * 15).toString().padStart(2, '0')}:00`
}); });
this.$message.success('添加航点成功'); if (this.selectedPlanDetails) {
const route = this.selectedPlanDetails.routes.find(r => r.id === this.selectedRouteId);
if (route) {
route.points = this.selectedRouteDetails.waypoints.length;
}
}
} }
}, },
@ -1276,7 +1353,7 @@ export default {
// 线/ // 线/
toggleRouteVisibility(route) { toggleRouteVisibility(route) {
const index = this.activeRouteIds.indexOf(route.id); const index = this.activeRouteIds.indexOf(route.id);
if (index > -1) { if (index > -1) {
// 线 // 线
// 使 Vue // 使 Vue
@ -1286,23 +1363,23 @@ export default {
} }
if (this.selectedRouteDetails && this.selectedRouteDetails.id === route.id) { if (this.selectedRouteDetails && this.selectedRouteDetails.id === route.id) {
if (this.activeRouteIds.length > 0) { if (this.activeRouteIds.length > 0) {
const lastId = this.activeRouteIds[this.activeRouteIds.length - 1]; const lastId = this.activeRouteIds[this.activeRouteIds.length - 1];
getRoutes(lastId).then(res => { getRoutes(lastId).then(res => {
if (res.code === 200 && res.data) { if (res.code === 200 && res.data) {
this.selectedRouteId = res.data.id; this.selectedRouteId = res.data.id;
this.selectedRouteDetails = { this.selectedRouteDetails = {
id: res.data.id, id: res.data.id,
name: res.data.callSign, name: res.data.callSign,
waypoints: res.data.waypoints || [] waypoints: res.data.waypoints || []
}; };
}
}).catch(e => {
console.error("获取航线详情失败", e);
});
} else {
this.selectedRouteId = null;
this.selectedRouteDetails = null;
} }
}).catch(e => {
console.error("获取航线详情失败", e);
});
} else {
this.selectedRouteId = null;
this.selectedRouteDetails = null;
}
} }
this.$message.info(`已隐藏航线: ${route.name}`); this.$message.info(`已隐藏航线: ${route.name}`);
} else { } else {
@ -1363,7 +1440,7 @@ export default {
background-position: center; background-position: center;
z-index: 1; z-index: 1;
} }
/* ...其余样式省略,保持不变... */
.map-overlay-text { .map-overlay-text {
position: absolute; position: absolute;
top: 50%; top: 50%;

Loading…
Cancel
Save