吉安感知网项目-前端
张含笑
2026-01-31 d54e0b172d77e2bd42b0866e6e80d5f414da3914
applications/drone-command/src/views/areaManage/precinctInfo/FormDiaLog.vue
@@ -111,7 +111,7 @@
</template>
<script setup>
import { computed, nextTick, ref } from 'vue'
import { computed, nextTick, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { fwPoliceStationDetailApi, fwPoliceStationSubmitApi } from './precinctInfoApi'
import { fieldRules } from '@ztzf/utils'
@@ -121,6 +121,7 @@
import { saveOperationLog } from '@ztzf/apis'
import { useRoute } from 'vue-router'
import positionIcon from '@/assets/images/areaManage/positionIcon.png'
import { MapTooltip } from '@/utils/cesium/shapeTools/Tooltip'
const initForm = () => ({
   address: '', // 位置
@@ -185,6 +186,10 @@
let viewer
let redPointEntity
let leftClickBound = false
let mouseMoveBound = false
let mapTooltip
let publicCesium
const tooltipEventKey = 'precinct-info-point-tip'
const labelParams = {
   font: '18px',
   fillColor: Cesium.Color.WHITE, // 文字颜色:白色
@@ -271,12 +276,38 @@
   await nextTick()
   const map = inlineMapRef.value?.getMap()
   viewer = map?.viewer || null
   publicCesium = map?.publicCesium || null
   if (viewer && !leftClickBound) {
      map.publicCesium?.addLeftClickEvent?.(null, LeftClickEvent)
      leftClickBound = true
   }
   if (viewer && !readonly.value) {
      ensurePointTooltip()
   }
   if (formData.value.longitude != null && formData.value.latitude != null) {
      setMapPoint(formData.value.longitude, formData.value.latitude)
   }
}
function ensurePointTooltip() {
   if (!viewer || !publicCesium || mouseMoveBound) return
   mapTooltip ||= new MapTooltip(viewer, { offset: { x: 16, y: 24 } })
   publicCesium.addMouseHandler?.(
      null,
      movement => {
         if (!visible.value || readonly.value) return
         mapTooltip?.show('点击地图选择派出所位置', movement.endPosition)
      },
      tooltipEventKey
   )
   mouseMoveBound = true
}
function clearPointTooltip() {
   mapTooltip?.hide()
   if (publicCesium && mouseMoveBound) {
      publicCesium.removeMouseHandler?.(tooltipEventKey)
      mouseMoveBound = false
   }
}
@@ -296,6 +327,7 @@
   formData.value = dialogMode.value === 'add' ? initForm() : row
   redPointEntity = null
   leftClickBound = false
   clearPointTooltip()
   if (dialogMode.value !== 'add') {
      await loadDetail()
   }
@@ -305,6 +337,15 @@
   }, 500)
}
watch(
   () => visible.value,
   val => {
      if (!val) {
         clearPointTooltip()
      }
   }
)
defineExpose({ open })
</script>
<style scoped lang="scss">