From f7579acbfe2cca2aacf2a5a460fccf8fc5bb5406 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Tue, 13 Jan 2026 16:19:42 +0800
Subject: [PATCH] feat: 完成场景
---
applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue | 119 +++++++++++++++++++++++++++++++----------------------------
1 files changed, 62 insertions(+), 57 deletions(-)
diff --git a/applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue b/applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue
index 91c7626..8d6b6ac 100644
--- a/applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue
+++ b/applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue
@@ -4,32 +4,21 @@
<div class="leftMap ztzf-cesium" id="mapContainer"></div>
<div class="rightInfo">
<div v-if="readonly">
- <el-row>
- <el-col :span="24">
- <div>场景名称: {{ formData.sceneName }}</div>
- </el-col>
- <el-col :span="24">
- <div>指挥点位置: {{ formatLocation(formData) }}</div>
- </el-col>
- <el-col :span="24">
- <div>场景类型: {{ getDictLabel(formData.sceneType, dictObj.sceneType) }}</div>
- </el-col>
- <el-col :span="24">
- <div>防控负责人: {{ formData.defenseLeader }}</div>
- </el-col>
- <el-col :span="24">
- <div>防控负责人电话: {{ formData.leaderPhone }}</div>
- </el-col>
- <el-col :span="24">
- <div>设备模式: {{ getDictLabel(formData.deviceMode, dictObj.deviceMode) }}</div>
- </el-col>
- <el-col :span="24">
- <div>关联区域: {{ formatAreaNames() }}</div>
- </el-col>
- <el-col :span="24">
- <div>防控面积: {{ formatDefenseArea(formData.defenseArea) }}</div>
- </el-col>
- </el-row>
+ <div>场景名称: {{ formData.sceneName }}</div>
+ <div>指挥点位置: {{ formatLocation(formData) }}</div>
+ <div>场景类型: {{ getDictLabel(formData.sceneType, dictObj.sceneType) }}</div>
+ <div>防控负责人: {{ formData.defenseLeader }}</div>
+ <div>防控负责人电话: {{ formData.leaderPhone }}</div>
+ <div>设备模式: {{ getDictLabel(formData.deviceMode, dictObj.deviceMode) }}</div>
+ <div>防控面积: {{ formatDefenseArea(formData.defenseArea) }}</div>
+ <el-table ref="areaTableRef" :data="areaList" row-key="id">
+ <el-table-column prop="areaName" label="区域名称" />
+ <el-table-column prop="areaType" label="区域类型">
+ <template v-slot="{ row }">
+ {{ getDictLabel(row.areaType, dictObj.areaType) }}
+ </template>
+ </el-table-column>
+ </el-table>
</div>
<el-form v-else ref="formRef" :model="formData" :rules="rules" :disabled="readonly" label-width="100px">
<el-row>
@@ -117,10 +106,11 @@
import { computed, inject, nextTick, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { fwDefenseSceneDetailApi, fwDefenseSceneSubmitApi } from './sceneConfigApi'
-import { fieldRules, getDictLabel } from '@ztzf/utils'
+import { fieldRules, geomAnalysis, getDictLabel } from '@ztzf/utils'
import { PublicCesium } from '@/utils/cesium/publicCesium'
import * as Cesium from 'cesium'
import { fwAreaDivideListApi } from '../partition/partitionApi'
+import { DrawPolygon } from '@/utils/cesium/DrawPolygon'
const initForm = () => ({
sceneName: '', // 场景名称
@@ -145,8 +135,10 @@
const titleEnum = ref({ edit: '编辑', view: '查看', add: '新增' })
const areaTableRef = ref(null)
const areaList = ref([]) // 关联区域列表
-const selectedAreaRows = ref([])
+const selectedAreaRows = ref([]) //选中列表
const dictObj = inject('dictObj')
+let viewer
+let redPointEntity
const rules = {
sceneName: fieldRules(true, 50),
@@ -192,36 +184,53 @@
// 获取区域列表
async function getAreaList() {
if (areaList.value.length) return
- const res = await fwAreaDivideListApi()
+ const res = await fwAreaDivideListApi({ filterSelected: 1, sceneId: formData.value.id })
areaList.value = res?.data?.data ?? []
}
// 关联区域变更
function handleAreaSelectionChange(rows) {
selectedAreaRows.value = rows
- const ids = rows.map(item => item.id)
- formData.value.areaDivideIds = ids.join(',')
- formData.value.areaCount = ids.length
+ formData.value.areaDivideIds = rows.map(item => item.id)
+ formData.value.areaCount = rows.length
formData.value.defenseArea = calcDefenseArea(rows)
}
+
+// 渲染面
+function renderingSurface() {
+ geometricSource && geometricSource.entities.removeAll()
+ selectedAreaRows.value.forEach(item => {
+ if (item.geom) {
+ const pointList = geomAnalysis(item.geom)
+ const result = pointList.map(item => [item.longitude, item.latitude]).flat()
+ geometricSource.entities?.add({
+ customType: 'control_group',
+ position: Cesium.Cartesian3.fromDegrees(result[0], result[1]),
+ polyline: {
+ positions: Cesium.Cartesian3.fromDegreesArray(result),
+ clampToGround: true,
+ width: 3,
+ material: Cesium.Color.RED,
+ },
+ })
+ }
+ })
+}
+
+watch(() => selectedAreaRows.value, renderingSurface)
function calcDefenseArea(rows) {
const total = rows.reduce((sum, item) => sum + (Number(item.areaSize) || 0), 0)
return _.round(total, 2)
}
-function getAreaIdList() {
- if (!formData.value.areaDivideIds) return []
- return formData.value.areaDivideIds.split(',').filter(Boolean)
-}
-
+// 同步关联区域
function syncAreaSelection() {
if (!areaTableRef.value) return
areaTableRef.value.clearSelection()
- const ids = new Set(getAreaIdList())
const rows = []
areaList.value.forEach(row => {
- if (ids.has(row.id)) {
+ if (formData.value.areaDivideIds.includes(row.id)) {
areaTableRef.value.toggleRowSelection(row, true)
rows.push(row)
}
@@ -230,16 +239,6 @@
if (!rows.length) return
formData.value.areaCount = rows.length
formData.value.defenseArea = calcDefenseArea(rows)
-}
-
-function formatAreaNames() {
- const rows = selectedAreaRows.value.length ? selectedAreaRows.value : getAreaRowsByIds()
- return rows.map(item => item.areaName).join(', ')
-}
-
-function getAreaRowsByIds() {
- const ids = new Set(getAreaIdList().map(String))
- return areaList.value.filter(item => ids.has(String(item.id)))
}
function formatDefenseArea(value) {
@@ -253,6 +252,7 @@
return `${_.round(row.longitude, 6)}, ${_.round(row.latitude, 6)}`
}
+let geometricSource
// 初始化地图实例
function initMap() {
const publicCesiumInstance = new PublicCesium({
@@ -266,6 +266,8 @@
publicCesiumInstance.addLeftClickEvent(null, LeftClickEvent)
}
viewer = publicCesiumInstance.getViewer()
+ geometricSource = new Cesium.CustomDataSource('geometricSource')
+ viewer.dataSources.add(geometricSource)
}
function LeftClickEvent(click) {
@@ -291,12 +293,18 @@
},
label: {
text: `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`,
- fillColor: Cesium.Color.WHITE,
- outlineColor: Cesium.Color.BLACK,
- outlineWidth: 2,
+ font: '14px',
+ fillColor: Cesium.Color.WHITE, // 文字颜色:白色
+ backgroundColor: Cesium.Color.BLACK.withAlpha(0.45), //背景颜色
+ backgroundPadding: new Cesium.Cartesian2(5, 5), // 水平/垂直内边距(像素)
+ pixelOffset: new Cesium.Cartesian2(0, -20), // 可选:微调位置
+ showBackground: true, // 确保背景显示(某些版本需要)
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
- verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
- pixelOffset: new Cesium.Cartesian2(0, -12),
+ horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
+ verticalOrigin: Cesium.VerticalOrigin.CENTER,
+ outlineWidth: 1,
+ outlineColor: Cesium.Color.WHITE,
+ eyeOffset: new Cesium.Cartesian3(0, 0, -20), // 负值更靠近相机(显示在前)
},
})
} else {
@@ -304,9 +312,6 @@
redPointEntity.label.text = `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`
}
}
-
-let viewer
-let redPointEntity
// 打开弹框
async function open({ mode, row } = {}) {
--
Gitblit v1.9.3