From f71c12150081890720934db2ad221cd6e4efe7b0 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Fri, 30 Jan 2026 10:40:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue | 240 +++++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 198 insertions(+), 42 deletions(-)
diff --git a/applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue b/applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue
index 0b15bc6..16ca5b4 100644
--- a/applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue
+++ b/applications/drone-command/src/views/areaManage/sceneConfig/FormDiaLog.vue
@@ -41,9 +41,9 @@
<div class="command-table-content">
<el-table class="command-table" ref="areaTableRef" :data="areaList" row-key="id">
<el-table-column prop="areaName" label="区域名称" />
- <el-table-column prop="areaType" label="区域类型">
+ <el-table-column prop="areaTypeKeys" label="区域类型">
<template v-slot="{ row }">
- {{ getDictLabel(row.areaType, dictObj.areaType) }}
+ {{ getDictLabel(row.areaTypeKeys, dictObj.areaType) }}
</template>
</el-table-column>
</el-table>
@@ -119,9 +119,9 @@
>
<el-table-column type="selection" width="55" :reserve-selection="true" />
<el-table-column prop="areaName" show-overflow-tooltip label="区域名称" />
- <el-table-column prop="areaType" show-overflow-tooltip label="区域类型">
+ <el-table-column prop="areaTypeKeys" show-overflow-tooltip label="区域类型">
<template v-slot="{ row }">
- {{ getDictLabel(row.areaType, dictObj.areaType) }}
+ {{ getDictLabel(row.areaTypeKeys, dictObj.areaType) }}
</template>
</el-table-column>
</el-table>
@@ -152,15 +152,14 @@
<script setup>
import { Close } from '@element-plus/icons-vue'
-import { computed, inject, nextTick, onMounted, ref, watch } from 'vue'
+import { computed, inject, nextTick, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { fwDefenseSceneDetailApi, fwDefenseSceneSubmitApi } from './sceneConfigApi'
-import { fieldRules, geomAnalysis, getDictLabel } from '@ztzf/utils'
+import { fieldRules, getDictLabel } from '@ztzf/utils'
import CommonCesiumMap from '@/components/map-container/common-cesium-map.vue'
import * as Cesium from 'cesium'
import { fwAreaDivideDetailApi, fwAreaDivideListApi } from '../partition/partitionApi'
-import { DrawPolygon } from '@/utils/cesium/DrawPolygon'
-import commandPost from '@/assets/images/dataCockpit/legend/command-post.png'
+import { buildEllipsePositions } from '@/utils/cesium/shapeTools'
import { saveOperationLog } from '@ztzf/apis'
import { useRoute } from 'vue-router'
@@ -188,8 +187,21 @@
const mapRef = ref(null)
const route = useRoute()
let viewer
-let redPointEntity
-let leftClickBound = false
+let areaDisplaySource
+const areaTypeStyleMap = {
+ '1': {
+ fill: Cesium.Color.fromBytes(25, 178, 230, 128),
+ outline: Cesium.Color.fromBytes(0, 251, 255, 255),
+ },
+ '2': {
+ fill: Cesium.Color.fromBytes(255, 235, 59, 128),
+ outline: Cesium.Color.fromBytes(255, 235, 59, 255),
+ },
+ '3': {
+ fill: Cesium.Color.fromBytes(247, 20, 20, 128),
+ outline: Cesium.Color.fromBytes(255, 0, 0, 255),
+ },
+}
const rules = {
sceneName: fieldRules(true, 50),
@@ -242,7 +254,7 @@
// 关联区域变更
async function handleAreaSelectionChange(rows) {
- const selectedRows = await ensureAreaGeom(rows)
+ const selectedRows = await ensureAreaExtList(rows)
selectedAreaRows.value = selectedRows
const ids = selectedRows.map(item => item.id)
formData.value.areaDivideIds = ids.join(',')
@@ -250,34 +262,184 @@
}
// 渲染面
-function renderingSurface() {
- if (!geometricSource) {
- initMap()
+function ensureAreaDisplaySource() {
+ if (!viewer) return null
+ if (!areaDisplaySource) {
+ areaDisplaySource = new Cesium.CustomDataSource('scene-area-display')
+ viewer.dataSources.add(areaDisplaySource)
}
- if (!geometricSource) return
- 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]),
+ return areaDisplaySource
+}
+
+function clearAreaDisplay() {
+ if (!areaDisplaySource) return
+ areaDisplaySource.entities.removeAll()
+}
+
+function normalizeShapePoint(point) {
+ if (!point) return null
+ const lng = point?.lng ?? point?.longitude
+ const lat = point?.lat ?? point?.latitude
+ const height = Number.isFinite(Number(point?.height)) ? Number(point.height) : 0
+ if (!Number.isFinite(Number(lng)) || !Number.isFinite(Number(lat))) return null
+ return { lng: Number(lng), lat: Number(lat), height }
+}
+
+function buildShapePositions(points = []) {
+ const normalized = points.map(normalizeShapePoint).filter(Boolean)
+ return normalized.map(point => Cesium.Cartesian3.fromDegrees(point.lng, point.lat, point.height))
+}
+
+function getShapeDisplayPoints(shape) {
+ if (Array.isArray(shape?.displayPoints) && shape.displayPoints.length) {
+ return shape.displayPoints
+ }
+ return shape?.points || []
+}
+
+function getAreaTypeStyle(areaType) {
+ return areaTypeStyleMap?.[String(areaType)] || {
+ fill: Cesium.Color.fromBytes(45, 140, 240, 99),
+ outline: Cesium.Color.fromBytes(45, 140, 240, 255),
+ }
+}
+
+function parseGeomJson(geomJson) {
+ if (!geomJson) return null
+ if (typeof geomJson === 'object') return geomJson
+ if (typeof geomJson !== 'string') return null
+ const trimmed = geomJson.trim()
+ if (!trimmed) return null
+ try {
+ return JSON.parse(trimmed)
+ } catch (error) {
+ return null
+ }
+}
+
+function resolveAreaShapes(area) {
+ const extList = Array.isArray(area?.fwAreaDivideExtList) ? area.fwAreaDivideExtList : []
+ if (!extList.length) return []
+ return extList
+ .map((item, index) => {
+ const isShapePayload = item?.drawType || item?.points
+ if (isShapePayload) {
+ return {
+ id: item?.id || `shape_${Date.now()}_${index}_${Math.random().toString(16).slice(2, 6)}`,
+ drawType: item?.drawType ?? 'polygon',
+ areaType: item?.areaType ?? item?.areaTypeKey ?? '',
+ points: Array.isArray(item?.points) ? item.points : [],
+ displayPoints: Array.isArray(item?.displayPoints) ? item.displayPoints : null,
+ meta: item?.meta ?? null,
+ }
+ }
+ const parsed = parseGeomJson(item?.geomJson)
+ if (!parsed) return null
+ return {
+ id: parsed?.id || `shape_${Date.now()}_${index}_${Math.random().toString(16).slice(2, 6)}`,
+ drawType: parsed?.drawType ?? 'polygon',
+ areaType: item?.areaTypeKey ?? parsed?.areaType ?? '',
+ points: Array.isArray(parsed?.points) ? parsed.points : [],
+ displayPoints: Array.isArray(parsed?.displayPoints) ? parsed.displayPoints : null,
+ meta: parsed?.meta ?? null,
+ }
+ })
+ .filter(Boolean)
+}
+
+function renderSelectedAreas() {
+ if (!visible.value) {
+ clearAreaDisplay()
+ return
+ }
+ if (!viewer) initMap()
+ const dataSource = ensureAreaDisplaySource()
+ if (!dataSource) return
+ dataSource.entities.removeAll()
+ selectedAreaRows.value.forEach(area => {
+ const shapes = resolveAreaShapes(area)
+ shapes.forEach(shape => {
+ if (shape.drawType === 'buffer' && shape.meta?.bufferRadii?.length && shape.meta?.center) {
+ const center = shape.meta.center
+ const centerCartesian = Cesium.Cartesian3.fromDegrees(center.lng, center.lat, center.height || 0)
+ const radii = shape.meta.bufferRadii
+ .map(radius => Number(radius))
+ .filter(radius => Number.isFinite(radius) && radius > 0)
+ const styles = [
+ {
+ fill: Cesium.Color.fromBytes(247, 20, 20, 128),
+ outline: Cesium.Color.fromBytes(255, 0, 0, 255),
+ },
+ {
+ fill: Cesium.Color.fromBytes(255, 235, 59, 128),
+ outline: Cesium.Color.fromBytes(255, 235, 59, 255),
+ },
+ {
+ fill: Cesium.Color.fromBytes(25, 178, 230, 128),
+ outline: Cesium.Color.fromBytes(0, 251, 255, 255),
+ },
+ ]
+ radii.forEach((radius, index) => {
+ const style = styles[index] || styles[styles.length - 1]
+ dataSource.entities.add({
+ name: 'scene-area-display',
+ customData: { drawType: shape.drawType, level: index + 1 },
+ position: centerCartesian,
+ ellipse: {
+ semiMajorAxis: radius,
+ semiMinorAxis: radius,
+ material: style.fill,
+ outline: false,
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
+ },
+ })
+ const positions = buildEllipsePositions(centerCartesian, radius, radius)
+ dataSource.entities.add({
+ name: 'scene-area-display',
+ customData: { drawType: shape.drawType, level: index + 1, outline: true },
+ polyline: {
+ positions: positions.length ? [...positions, positions[0]] : positions,
+ clampToGround: true,
+ width: 2,
+ material: style.outline,
+ },
+ })
+ })
+ return
+ }
+ const positions = buildShapePositions(getShapeDisplayPoints(shape))
+ if (positions.length < 3) return
+ const style = getAreaTypeStyle(shape.areaType)
+ dataSource.entities.add({
+ name: 'scene-area-display',
+ customData: { drawType: shape.drawType },
+ polygon: {
+ hierarchy: new Cesium.PolygonHierarchy(positions),
+ material: style.fill,
+ outline: false,
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
+ },
polyline: {
- positions: Cesium.Cartesian3.fromDegreesArray(result),
+ positions: positions.length ? [...positions, positions[0]] : positions,
clampToGround: true,
- width: 3,
- material: Cesium.Color.RED,
+ width: 2,
+ material: style.outline,
},
})
- }
+ })
})
}
-watch(() => selectedAreaRows.value, renderingSurface)
+watch(() => selectedAreaRows.value, renderSelectedAreas)
+watch(
+ () => visible.value,
+ val => {
+ if (!val) clearAreaDisplay()
+ }
+)
-async function ensureAreaGeom(rows) {
- const missingRows = rows.filter(row => row?.id && !row.geom)
+async function ensureAreaExtList(rows) {
+ const missingRows = rows.filter(row => row?.id && !Array.isArray(row?.fwAreaDivideExtList))
if (!missingRows.length) return rows
const detailList = await Promise.all(
missingRows.map(row =>
@@ -299,7 +461,7 @@
}
// 同步关联区域
-function syncAreaSelection() {
+async function syncAreaSelection() {
if (!areaTableRef.value) return
areaTableRef.value.clearSelection()
const rows = []
@@ -315,30 +477,24 @@
rows.push(row)
}
})
- selectedAreaRows.value = rows
- if (!rows.length) return
- formData.value.areaCount = rows.length
+ const ensuredRows = await ensureAreaExtList(rows)
+ selectedAreaRows.value = ensuredRows
+ if (!ensuredRows.length) return
+ formData.value.areaCount = ensuredRows.length
}
-let geometricSource
// 初始化地图实例
function initMap() {
if (viewer) return
const map = mapRef.value?.getMap()
if (!map?.viewer) return
viewer = map.viewer
- if (!geometricSource) {
- geometricSource = new Cesium.CustomDataSource('geometricSource')
- viewer.dataSources.add(geometricSource)
- }
}
-// 打开弹框
async function open({ mode, row } = {}) {
dialogMode.value = mode || 'add'
formData.value = dialogMode.value === 'add' ? initForm() : row
selectedAreaRows.value = []
- redPointEntity = null
await nextTick()
initMap()
await getAreaList()
@@ -346,7 +502,7 @@
await loadDetail()
}
await nextTick()
- syncAreaSelection()
+ await syncAreaSelection()
}
defineExpose({
open,
--
Gitblit v1.9.3