Browse Source

通过平台进行编辑航线

master
cuitw 1 month ago
parent
commit
3a449dabbe
  1. 17
      ruoyi-ui/src/views/cesiumMap/ContextMenu.vue
  2. 2
      ruoyi-ui/src/views/cesiumMap/DrawingToolbar.vue
  3. 645
      ruoyi-ui/src/views/cesiumMap/index.vue
  4. 71
      ruoyi-ui/src/views/childRoom/index.vue

17
ruoyi-ui/src/views/cesiumMap/ContextMenu.vue

@ -312,6 +312,15 @@
<span>修改朝向</span>
<span class="menu-value">{{ entityData.heading != null ? entityData.heading + '°' : '0°' }}</span>
</div>
<div class="menu-title" style="margin-top:8px;">航线</div>
<div class="menu-item" @click="handleStartRouteBeforePlatform">
<span class="menu-icon"></span>
<span>在此之前插入航线</span>
</div>
<div class="menu-item" @click="handleStartRouteAfterPlatform">
<span class="menu-icon"></span>
<span>在此之后插入航线</span>
</div>
</div>
</div>
</template>
@ -385,6 +394,14 @@ export default {
this.$emit('edit-platform-heading')
},
handleStartRouteBeforePlatform() {
this.$emit('start-route-before-platform', this.entityData)
},
handleStartRouteAfterPlatform() {
this.$emit('start-route-after-platform', this.entityData)
},
handleToggleRouteLabel() {
this.$emit('toggle-route-label')
},

2
ruoyi-ui/src/views/cesiumMap/DrawingToolbar.vue

@ -41,7 +41,7 @@ export default {
return {
// 线
allToolbarItems: [
{ id: 'mouse', name: '鼠标', icon: 'el-icon-position' },
{ id: 'mouse', name: '鼠标', icon: 'cursor' },
{ id: 'polygon', name: '多边形空域', icon: 'el-icon-house' },
{ id: 'rectangle', name: '矩形空域', icon: 'jx' },
{ id: 'circle', name: '圆形空域', icon: 'circle' },

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

File diff suppressed because it is too large

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

@ -15,6 +15,8 @@
:coordinateFormat="coordinateFormat"
@draw-complete="handleMapDrawComplete"
@drawing-points-update="missionDrawingPointsCount = $event"
@platform-route-drawing-started="missionDrawingActive = true"
@drawing-cancelled="missionDrawingActive = false"
@open-waypoint-dialog="handleOpenWaypointEdit"
@open-route-dialog="handleOpenRouteEdit"
@scale-click="handleScaleClick"
@ -41,11 +43,17 @@
<div class="red-dot"></div>
<i class="el-icon-s-unfold icon-inside"></i>
</div>
<el-dialog title="保存新航线" :visible.sync="showNameDialog" width="30%" :append-to-body="true">
<el-dialog title="保存新航线" :visible.sync="showNameDialog" width="30%" :append-to-body="true" @open="onSaveRouteDialogOpen" @close="tempMapPlatform = null; saveDialogScenarioId = null">
<el-form label-width="80px">
<el-form-item label="航线名称">
<el-input v-model="newRouteName" placeholder="例如:航线一"></el-input>
</el-form-item>
<el-form-item label="所属方案">
<el-select v-model="saveDialogScenarioId" placeholder="请选择方案" style="width:100%" clearable>
<el-option v-for="p in plans" :key="p.id" :label="p.name" :value="p.id" />
</el-select>
<div v-if="plans.length === 0" class="el-form-item__error" style="margin-top:4px;">暂无方案请先点击地图左侧红点展开菜单选择方案并新建方案后再保存</div>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="showNameDialog = false"> </el-button>
@ -468,6 +476,10 @@ export default {
showNameDialog: false,
newRouteName: '',
tempMapPoints: [],
/** 从平台右键「在此之前/在此之后插入航线」完成时传入,保存航线时用作 platformId */
tempMapPlatform: null,
/** 保存新航线弹窗内选择的方案 ID(弹窗内可直接选方案,无需先展开侧边) */
saveDialogScenarioId: null,
platformIconSaveTimer: null,
//
showImportDialog: false,
@ -1000,7 +1012,7 @@ export default {
if (idx > -1) {
this.activeRouteIds.splice(idx, 1);
}
await this.getList();
await this.getList({ skipRoomPlatformIcons: true });
}
} catch (e) {
if (e !== 'cancel') {
@ -1009,8 +1021,12 @@ export default {
}
}
},
/** 从数据库拉取最新的航线列表数据 */
async getList() {
/**
* 从数据库拉取最新的航线列表数据
* @param {Object} opts - 可选{ skipRoomPlatformIcons: true } 时不再加载房间平台图标用于删除航线等仅航线变化的场景避免地图上的平台图标被清空再重画导致闪一下
*/
async getList(opts = {}) {
const { skipRoomPlatformIcons = false } = opts;
try {
const roomId = this.$route.query.roomId || this.currentRoomId;
const scenarioRes = await listScenario({ roomId: roomId });
@ -1056,7 +1072,8 @@ export default {
});
});
}
//
// 线
if (!skipRoomPlatformIcons) {
const rId = roomId || this.currentRoomId;
if (rId && this.$refs.cesiumMap && typeof this.$refs.cesiumMap.loadRoomPlatformIcons === 'function') {
listRoomPlatformIcons(rId).then(res => {
@ -1064,20 +1081,26 @@ export default {
}).catch(() => {});
}
}
}
} catch (error) {
console.error("数据加载失败:", error);
this.$message.error("获取方案列表失败");
}
},
handleMapDrawComplete(points) {
handleMapDrawComplete(points, options) {
this.missionDrawingActive = false;
if (!points || points.length < 2) {
this.$message.error('航点太少,无法生成航线');
this.drawDom = false;
return;
}
this.tempMapPoints = points; //
this.showNameDialog = true; //
this.tempMapPoints = points;
this.tempMapPlatform = (options && (options.platformId != null || options.platform)) ? options : null;
this.showNameDialog = true;
},
/** 保存新航线弹窗打开时:若当前未选方案则用已选方案或第一个方案填充,便于在弹窗内直接选择 */
onSaveRouteDialogOpen() {
this.saveDialogScenarioId = this.selectedPlanId || (this.plans[0] && this.plans[0].id) || null;
},
openAddHoldDuringDrawing() {
@ -1093,9 +1116,9 @@ export default {
this.$message.error('新增航线未命名,请输入名称后保存!');
return;
}
const currentScenarioId = this.selectedPlanId;
const currentScenarioId = this.saveDialogScenarioId != null ? this.saveDialogScenarioId : this.selectedPlanId;
if (!currentScenarioId) {
this.$message.warning('请先在左侧选择一个方案,再保存航线!');
this.$message.warning(this.plans.length === 0 ? '暂无方案,请先点击地图左侧红点展开菜单,选择「方案」并新建方案后再保存。' : '请在上方选择所属方案后再保存。');
return;
}
@ -1123,7 +1146,7 @@ export default {
const routeData = {
callSign: this.newRouteName,
scenarioId: currentScenarioId,
platformId: 1,
platformId: (this.tempMapPlatform && this.tempMapPlatform.platformId != null) ? this.tempMapPlatform.platformId : 1,
attributes: this.getDefaultRouteAttributes(),
waypoints: finalWaypoints
};
@ -1150,25 +1173,37 @@ export default {
this.activeRouteIds.push(newRouteId);
}
// 3. UI
// 3. 线
const platformToRemove = this.tempMapPlatform;
// 4. UI
this.drawDom = false;
this.showNameDialog = false;
this.newRouteName = '';
this.tempMapPoints = [];
this.tempMapPlatform = null;
// 4. B clearAllWaypoints()
// 线
// 5. B clearAllWaypoints
if (this.$refs.cesiumMap) {
//
// tempPreviewEntity
if (this.$refs.cesiumMap.tempPreviewEntity) {
this.viewer.entities.remove(this.$refs.cesiumMap.tempPreviewEntity);
this.$refs.cesiumMap.tempPreviewEntity = null;
}
// clearAllWaypoints
}
// 5. 线getList activeRouteIds 线
// 6. 线 getList
if (platformToRemove && this.$refs.cesiumMap) {
if (platformToRemove.serverId) {
await delRoomPlatformIcon(platformToRemove.serverId).catch(() => {});
if (typeof this.$refs.cesiumMap.removePlatformIconByServerId === 'function') {
this.$refs.cesiumMap.removePlatformIconByServerId(platformToRemove.serverId);
}
} else if (platformToRemove.mapEntityId && typeof this.$refs.cesiumMap.removeEntity === 'function') {
this.$refs.cesiumMap.removeEntity(platformToRemove.mapEntityId);
}
}
// 7. 线getList
await this.getList();
const routeFromList = this.routes.find(r => r.id === newRouteId);
if (routeFromList) {

Loading…
Cancel
Save