| | |
| | | </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' |
| | |
| | | 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: '', // 位置 |
| | |
| | | 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, // 文字颜色:白色 |
| | |
| | | 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 |
| | | } |
| | | } |
| | | |
| | |
| | | formData.value = dialogMode.value === 'add' ? initForm() : row |
| | | redPointEntity = null |
| | | leftClickBound = false |
| | | clearPointTooltip() |
| | | if (dialogMode.value !== 'add') { |
| | | await loadDetail() |
| | | } |
| | |
| | | }, 500) |
| | | } |
| | | |
| | | watch( |
| | | () => visible.value, |
| | | val => { |
| | | if (!val) { |
| | | clearPointTooltip() |
| | | } |
| | | } |
| | | ) |
| | | |
| | | defineExpose({ open }) |
| | | </script> |
| | | <style scoped lang="scss"> |