Browse Source

1别拉

master
menghao 2 months ago
parent
commit
0dbc8ccb22
  1. 7
      ruoyi-ui/src/views/cesiumMap/index.vue
  2. 48
      ruoyi-ui/src/views/childRoom/index.vue
  3. 2
      ruoyi-ui/vue.config.js

7
ruoyi-ui/src/views/cesiumMap/index.vue

@ -241,13 +241,18 @@ export default {
}, },
renderRouteWaypoints(waypoints, routeId = 'default') { renderRouteWaypoints(waypoints, routeId = 'default') {
console.log('renderRouteWaypoints被调用,航点数据:', waypoints);
console.log('航点数量:', waypoints ? waypoints.length : 0);
if (!waypoints || waypoints.length < 1) return; if (!waypoints || waypoints.length < 1) return;
const positions = []; const positions = [];
// 1. // 1.
waypoints.forEach((wp, index) => { waypoints.forEach((wp, index) => {
console.log(`处理航点${index}:`, wp);
console.log(`航点${index}的字段:`, Object.keys(wp));
const lon = parseFloat(wp.lng); const lon = parseFloat(wp.lng);
const lat = parseFloat(wp.lat); const lat = parseFloat(wp.lat);
const pos = Cesium.Cartesian3.fromDegrees(lon, lat, parseFloat(wp.alt || 500)); console.log(`航点${index}坐标:`, {lon, lat, alt: wp.altitude || wp.alt});
const pos = Cesium.Cartesian3.fromDegrees(lon, lat, parseFloat(wp.altitude || wp.alt || 500));
positions.push(pos); positions.push(pos);
this.viewer.entities.add({ this.viewer.entities.add({

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

@ -618,21 +618,21 @@ export default {
}, },
/** 弹窗点击“确定”:正式将数据保存到后端数据库 */ /** 弹窗点击“确定”:正式将数据保存到后端数据库 */
async confirmSaveNewRoute() { async confirmSaveNewRoute() {
// // 1.
if (!this.newRouteName || this.newRouteName.trim() === '') { if (!this.newRouteName || this.newRouteName.trim() === '') {
this.$message.error('新增航线未命名,请输入名称后保存!'); this.$message.error('新增航线未命名,请输入名称后保存!');
return; return;
} }
// ID
const currentScenarioId = this.selectedPlanId; const currentScenarioId = this.selectedPlanId;
if (!currentScenarioId) { if (!currentScenarioId) {
this.$message.warning('请先在左侧选择一个方案,再保存航线!'); this.$message.warning('请先在左侧选择一个方案,再保存航线!');
return; return;
} }
// Routes
// 2.
const routeData = { const routeData = {
callSign: this.newRouteName, callSign: this.newRouteName,
scenarioId: currentScenarioId || 1, // 使ID1 scenarioId: currentScenarioId,
platformId: 1, platformId: 1,
attributes: "{}", attributes: "{}",
waypoints: this.tempMapPoints.map((p, index) => ({ waypoints: this.tempMapPoints.map((p, index) => ({
@ -645,43 +645,53 @@ export default {
turnAngle: 0.0 turnAngle: 0.0
})) }))
}; };
try { try {
// 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 savedRoute = response.data;
const newRouteId = savedRoute ? savedRoute.id : null; const newRouteId = savedRoute ? savedRoute.id : null;
// 1. 线 clearRoute
if (this.$refs.cesiumMap) { if (this.$refs.cesiumMap) {
this.$refs.cesiumMap.clearRoute(); this.drawDom = false;
// ID线 if (this.$refs.cesiumMap.clearTempRoute) this.$refs.cesiumMap.clearTempRoute();
}
// 2.
await this.getList();
// 3.
this.$nextTick(async () => {
if (newRouteId) { if (newRouteId) {
if (!this.activeRouteIds.includes(savedRoute.id)) { // ID UI
this.activeRouteIds.push(savedRoute.id); if (!this.activeRouteIds.includes(newRouteId)) {
this.activeRouteIds.push(newRouteId);
} }
//
// getList
this.selectedRouteId = newRouteId;
this.selectedRouteDetails = { this.selectedRouteDetails = {
id: newRouteId, id: newRouteId,
name: this.newRouteName, name: this.newRouteName,
waypoints: routeData.waypoints waypoints: routeData.waypoints
}; };
//使 ID 线
// 线
if (this.$refs.cesiumMap) {
this.$refs.cesiumMap.renderRouteWaypoints(routeData.waypoints, newRouteId); this.$refs.cesiumMap.renderRouteWaypoints(routeData.waypoints, newRouteId);
} }
} }
// UI });
// 4. UI
this.showNameDialog = false; this.showNameDialog = false;
this.drawDom = false;
this.newRouteName = ''; this.newRouteName = '';
this.tempMapPoints = []; this.tempMapPoints = [];
// 线
await this.getList();
} }
} catch (error) { } catch (error) {
console.error("保存航线失败:", error); console.error("保存失败:", error);
this.$message.error('保存失败,请检查后端服务');
} }
}, },
// //

2
ruoyi-ui/vue.config.js

@ -10,7 +10,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin') const CopyWebpackPlugin = require('copy-webpack-plugin')
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题 const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
const baseUrl = 'http://192.168.50.145:8080' // 后端接口 const baseUrl = 'http://127.0.0.1:8080' // 后端接口
const port = process.env.port || process.env.npm_config_port || 80 // 端口 const port = process.env.port || process.env.npm_config_port || 80 // 端口
// 定义 Cesium 源码路径 // 定义 Cesium 源码路径

Loading…
Cancel
Save