From baeb96afcefcb3fecf05f892b7f2c84cb5182c18 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Sat, 31 Jan 2026 14:47:41 +0800
Subject: [PATCH] feat:侦测范围管理增加地图提示

---
 applications/drone-command/src/views/detectionCountermeasure/detectionRange/DetectionRangeDialog.vue |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/applications/drone-command/src/views/detectionCountermeasure/detectionRange/DetectionRangeDialog.vue b/applications/drone-command/src/views/detectionCountermeasure/detectionRange/DetectionRangeDialog.vue
index ca54c44..b2fa130 100644
--- a/applications/drone-command/src/views/detectionCountermeasure/detectionRange/DetectionRangeDialog.vue
+++ b/applications/drone-command/src/views/detectionCountermeasure/detectionRange/DetectionRangeDialog.vue
@@ -123,6 +123,7 @@
 							v-model="formData.effectiveRangeKm"
 							:min="0"
 							:precision="0"
+							:step="1"
 							:controls="false"
 							placeholder="请输入"
 						/>
@@ -162,6 +163,7 @@
 import * as Cesium from 'cesium'
 import { saveOperationLog } from '@ztzf/apis'
 import { useRoute } from 'vue-router'
+import { MapTooltip } from '@/utils/cesium/shapeTools/Tooltip'
 
 import equipment from '@/assets/images/dataCockpit/legend/equipment.png'
 
@@ -189,6 +191,10 @@
 let viewer
 let redPointEntity
 let rangeCircleEntity
+let mouseMoveBound = false
+let mapTooltip
+let publicCesium
+const tooltipEventKey = 'detection-range-point-tip'
 const formTitle = computed(() => {
 	if (dialogMode.value === 'edit') {
 		return '编辑侦测范围'
@@ -227,7 +233,14 @@
 
 function formatRange(value) {
 	if (value == null || value === '') return '-'
-	return `${value}`
+	const normalized = normalizeRange(value)
+	return normalized == null ? '-' : `${normalized}`
+}
+
+function normalizeRange(value) {
+	const numeric = Number(value)
+	if (!Number.isFinite(numeric)) return null
+	return Math.trunc(numeric)
 }
 
 // 关闭弹框
@@ -242,14 +255,16 @@
 	submitting.value = true
 	try {
 		const {longitude, latitude} = parseDeployLocation(formData.value.deployLocation)
+		const normalizedRange = normalizeRange(formData.value.effectiveRangeKm)
 
 		const payload = {
 			id: formData.value.id || formData.value.deviceId || undefined,
-			effectiveRangeKmIsNotNull: formData.value.effectiveRangeKm ? 1 : 2,
-			effectiveRangeKm: formData.value.effectiveRangeKm,
+			effectiveRangeKmIsNotNull: normalizedRange != null ? 1 : 2,
+			effectiveRangeKm: normalizedRange,
 			longitude,
 			latitude
 		}
+		formData.value.effectiveRangeKm = normalizedRange
 		delete payload.deviceId
 		await detectionRangeSubmitApi(payload)
 
@@ -280,6 +295,7 @@
 		current: 1,
 		size: 200,
 		effectiveRangeKmIsNotNull: 2,
+		isTrack: 1
 	})
 	const records = res?.data?.data?.records ?? []
 	deviceOptions.value = records.map(item => ({
@@ -296,6 +312,7 @@
 	viewer = null
 	redPointEntity = null
 	rangeCircleEntity = null
+	clearPointTooltip()
 }
 
 function setMapPoint(longitude, latitude) {
@@ -378,8 +395,32 @@
 	const map = mapRef.value?.getMap()
 	if (!map?.viewer) return
 	viewer = map.viewer
+	publicCesium = map.publicCesium
 	if (!dialogReadonly.value) {
 		map.publicCesium?.addLeftClickEvent?.(null, handleMapClick)
+		ensurePointTooltip()
+	}
+}
+
+function ensurePointTooltip() {
+	if (!viewer || !publicCesium || mouseMoveBound) return
+	mapTooltip ||= new MapTooltip(viewer, { offset: { x: 28, y: 24 } })
+	publicCesium.addMouseHandler?.(
+		null,
+		movement => {
+			if (!visible.value || dialogReadonly.value) return
+			mapTooltip?.show('点击地图选择设备位置', movement.endPosition)
+		},
+		tooltipEventKey
+	)
+	mouseMoveBound = true
+}
+
+function clearPointTooltip() {
+	mapTooltip?.hide()
+	if (publicCesium && mouseMoveBound) {
+		publicCesium.removeMouseHandler?.(tooltipEventKey)
+		mouseMoveBound = false
 	}
 }
 
@@ -397,6 +438,7 @@
 // 打开弹框
 async function open({ mode, row } = {}) {
 	dialogMode.value = mode || 'add'
+	clearPointTooltip()
 	await nextTick()
 	initMap()
 	if (dialogMode.value === 'add') {
@@ -432,9 +474,18 @@
 watch(
 	() => formData.value.effectiveRangeKm,
 	value => {
+		const normalized = normalizeRange(value)
+		if (value != null && normalized == null) {
+			formData.value.effectiveRangeKm = null
+			return
+		}
+		if (value != null && normalized !== value) {
+			formData.value.effectiveRangeKm = normalized
+			return
+		}
 		const parsed = parseDeployLocation(formData.value.deployLocation)
 		if (!parsed) return
-		updateRangeCircle(parsed.longitude, parsed.latitude, value)
+		updateRangeCircle(parsed.longitude, parsed.latitude, normalized)
 	}
 )
 </script>

--
Gitblit v1.9.3