|
@@ -2,7 +2,7 @@
|
|
<el-dialog
|
|
<el-dialog
|
|
v-model="visible"
|
|
v-model="visible"
|
|
title="选择地图位置"
|
|
title="选择地图位置"
|
|
- width="80%"
|
|
|
|
|
|
+ width="1200px"
|
|
:before-close="handleClose"
|
|
:before-close="handleClose"
|
|
destroy-on-close
|
|
destroy-on-close
|
|
class="map-fire-dialog"
|
|
class="map-fire-dialog"
|
|
@@ -11,21 +11,27 @@
|
|
<!-- 搜索框 -->
|
|
<!-- 搜索框 -->
|
|
<div id="panel" class="scrollbar1">
|
|
<div id="panel" class="scrollbar1">
|
|
<div id="searchBar">
|
|
<div id="searchBar">
|
|
- <input id="searchInput" @input="handleSearch" placeholder="输入关键字搜素POI" />
|
|
|
|
|
|
+ <el-select class="search-select" v-model="selectedSearchAdress" placeholder="地址">
|
|
|
|
+ <el-option label="地址" value="1"></el-option>
|
|
|
|
+ <el-option label="经纬度" value="2"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ <input class="search-input-latlng" v-if="selectedSearchAdress === '2'" @input="handleSearch" autocomplete="off" @keydown="handleKeyDown" placeholder="输入经纬度" />
|
|
|
|
+ <input class="search-input-address" v-else id="searchInput" @input="handleSearch" autocomplete="off" placeholder="输入地址" />
|
|
|
|
+ <!-- <input id="searchInput" @input="handleSearch" autocomplete="off" @keydown="handleKeyDown" :placeholder="selectedSearchAdress === '1' ? '输入地址' : '输入经纬度'" /> -->
|
|
</div>
|
|
</div>
|
|
<div id="searchResults">暂无数据</div>
|
|
<div id="searchResults">暂无数据</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<!-- 地图容器 -->
|
|
<!-- 地图容器 -->
|
|
<div class="map-container">
|
|
<div class="map-container">
|
|
- <div id="container" class="map" style="width: 100%; height: 100%" tabindex="0"></div>
|
|
|
|
|
|
+ <div id="container" class="map" style="width: 800px; height: 600px" tabindex="0"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
<template #footer>
|
|
<div class="dialog-footer">
|
|
<div class="dialog-footer">
|
|
<el-button @click="handleClose">取消</el-button>
|
|
<el-button @click="handleClose">取消</el-button>
|
|
- <el-button type="primary" @click="handleConfirm" :disabled="!selectedLocation">
|
|
|
|
|
|
+ <el-button type="primary" @click="handleConfirm">
|
|
确定
|
|
确定
|
|
</el-button>
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
@@ -38,20 +44,32 @@ import { ref, watch, nextTick, onUnmounted, onMounted } from 'vue'
|
|
import { ElDialog, ElInput, ElButton, ElDescriptions, ElDescriptionsItem, ElIcon, ElMessage } from 'element-plus'
|
|
import { ElDialog, ElInput, ElButton, ElDescriptions, ElDescriptionsItem, ElIcon, ElMessage } from 'element-plus'
|
|
import { Search } from '@element-plus/icons-vue'
|
|
import { Search } from '@element-plus/icons-vue'
|
|
import AMapLoader from '@amap/amap-jsapi-loader'
|
|
import AMapLoader from '@amap/amap-jsapi-loader'
|
|
|
|
+import html2canvas from 'html2canvas'
|
|
|
|
+import { uploadFileToServer, canvasToBlob, blobToFile } from '@/util/upload-utils'
|
|
|
|
+import { axios } from '@/request'
|
|
|
|
+import { addOrUpdateCaseTabulation } from '@/request/urls'
|
|
|
|
+import { user } from "@/store/user";
|
|
|
|
+
|
|
|
|
+// 添加高德地图类型声明
|
|
|
|
+declare const AMap: any
|
|
|
|
+declare const AMapUI: any
|
|
|
|
|
|
// 定义组件props和emits
|
|
// 定义组件props和emits
|
|
interface Props {
|
|
interface Props {
|
|
modelValue: boolean
|
|
modelValue: boolean
|
|
|
|
+ caseId?: string | number
|
|
}
|
|
}
|
|
|
|
|
|
interface LocationInfo {
|
|
interface LocationInfo {
|
|
- name: string
|
|
|
|
- address: string
|
|
|
|
- lat: number
|
|
|
|
- lng: number
|
|
|
|
|
|
+ name?: string
|
|
|
|
+ address?: string
|
|
|
|
+ lat?: number
|
|
|
|
+ lng?: number
|
|
adcode?: string
|
|
adcode?: string
|
|
citycode?: string
|
|
citycode?: string
|
|
district?: string
|
|
district?: string
|
|
|
|
+ screenshotUrl?: string
|
|
|
|
+ screenshotFileName?: string
|
|
}
|
|
}
|
|
|
|
|
|
const props = defineProps<Props>()
|
|
const props = defineProps<Props>()
|
|
@@ -76,7 +94,11 @@ let poiPicker: any = null
|
|
|
|
|
|
// 高德地图配置
|
|
// 高德地图配置
|
|
const AMAP_KEY = '2ae5a7713612a8d5a65cfd54c989c969'
|
|
const AMAP_KEY = '2ae5a7713612a8d5a65cfd54c989c969'
|
|
|
|
+const selectedSearchAdress = ref('1')
|
|
|
|
+const searchInputValue = ref('')
|
|
|
|
|
|
|
|
+// 防抖定时器
|
|
|
|
+let searchDebounceTimer: number | null = null
|
|
// 监听visible变化
|
|
// 监听visible变化
|
|
watch(() => props.modelValue, (newVal) => {
|
|
watch(() => props.modelValue, (newVal) => {
|
|
visible.value = newVal
|
|
visible.value = newVal
|
|
@@ -90,12 +112,49 @@ watch(() => props.modelValue, (newVal) => {
|
|
watch(visible, (newVal) => {
|
|
watch(visible, (newVal) => {
|
|
emit('update:modelValue', newVal)
|
|
emit('update:modelValue', newVal)
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+// 监听搜索类型变化,切换时清空输入框和重置搜索
|
|
|
|
+watch(selectedSearchAdress, (newVal, oldVal) => {
|
|
|
|
+ if (newVal !== oldVal) {
|
|
|
|
+ // 清空输入框
|
|
|
|
+ searchInputValue.value = ''
|
|
|
|
+ const searchInput = document.getElementById('searchInput') as HTMLInputElement
|
|
|
|
+ if (searchInput) {
|
|
|
|
+ searchInput.value = ''
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 重置搜索结果
|
|
|
|
+ const searchResults = document.getElementById('searchResults')
|
|
|
|
+ if (searchResults) {
|
|
|
|
+ searchResults.innerHTML = '暂无数据'
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 清空地图标记
|
|
|
|
+ if (map) {
|
|
|
|
+ map.clearMap()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 根据搜索类型调整POI选择器的显示
|
|
|
|
+ if (poiPicker) {
|
|
|
|
+ if (newVal === '2') {
|
|
|
|
+ // 经纬度搜索模式,隐藏选择列表
|
|
|
|
+ poiPicker.hideSearchResults()
|
|
|
|
+ } else {
|
|
|
|
+ // 地址搜索模式,可以显示选择列表
|
|
|
|
+ poiPicker.searchByKeyword('')
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+})
|
|
// 初始化地图
|
|
// 初始化地图
|
|
const initMap = async () => {
|
|
const initMap = async () => {
|
|
map = new AMap.Map('container', {
|
|
map = new AMap.Map('container', {
|
|
- zoom: 10,
|
|
|
|
|
|
+ zoom: 11,
|
|
key: AMAP_KEY, // 替换为你的API密钥
|
|
key: AMAP_KEY, // 替换为你的API密钥
|
|
center: [116.35, 39.86],
|
|
center: [116.35, 39.86],
|
|
|
|
+ WebGLParams: {
|
|
|
|
+ preserveDrawingBuffer: true
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
AMapUI.loadUI(['misc/PoiPicker'], function(PoiPicker) {
|
|
AMapUI.loadUI(['misc/PoiPicker'], function(PoiPicker) {
|
|
@@ -118,7 +177,8 @@ const initMap = async () => {
|
|
poiPicker.searchByKeyword(poi.name);
|
|
poiPicker.searchByKeyword(poi.name);
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- addMarker(poi.location.lng, poi.location.lat)
|
|
|
|
|
|
+ // 舒琪说不需要marker
|
|
|
|
+ // addMarker(poi.location.lng, poi.location.lat)
|
|
// console.log(poi);
|
|
// console.log(poi);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -129,15 +189,169 @@ const initMap = async () => {
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
-const handleSearch = (e) => {
|
|
|
|
- // console.log('handleSearch', e.target.value)
|
|
|
|
- let mapData = e.target.value
|
|
|
|
- poiPicker.searchByKeyword( e.target.value)
|
|
|
|
- // setTimeout(() => {
|
|
|
|
- // map.clearMap();
|
|
|
|
- // }, 100)
|
|
|
|
|
|
+const handleKeyDown = (e: KeyboardEvent) => {
|
|
|
|
+ if (e.key === 'Enter') {
|
|
|
|
+ if(selectedSearchAdress.value === '2'){
|
|
|
|
+ console.log(11111)
|
|
|
|
+ e.preventDefault()
|
|
|
|
+ e.stopPropagation()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+// 验证经纬度格式的函数
|
|
|
|
+const validateCoordinates = (input: string): { isValid: boolean; lat?: number; lng?: number } => {
|
|
|
|
+ // 移除空格
|
|
|
|
+ const trimmed = input.trim()
|
|
|
|
+
|
|
|
|
+ // 检查是否包含逗号
|
|
|
|
+ if (!trimmed.includes(',')) {
|
|
|
|
+ return { isValid: false }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 分割经纬度
|
|
|
|
+ const parts = trimmed.split(',')
|
|
|
|
+ if (parts.length !== 2) {
|
|
|
|
+ return { isValid: false }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 转换为数字并验证
|
|
|
|
+ const lat = parseFloat(parts[0].trim())
|
|
|
|
+ const lng = parseFloat(parts[1].trim())
|
|
|
|
+
|
|
|
|
+ // 验证是否为有效数字
|
|
|
|
+ if (isNaN(lat) || isNaN(lng)) {
|
|
|
|
+ return { isValid: false }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 验证纬度范围 (-90 到 90)
|
|
|
|
+ if (lat < -90 || lat > 90) {
|
|
|
|
+ return { isValid: false }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 验证经度范围 (-180 到 180)
|
|
|
|
+ if (lng < -180 || lng > 180) {
|
|
|
|
+ return { isValid: false }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return { isValid: true, lat, lng }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// 根据经纬度定位地图
|
|
|
|
+const locateByCoordinates = (lat: number, lng: number) => {
|
|
|
|
+ if (!map) {
|
|
|
|
+ ElMessage.error('地图未初始化')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ // 创建经纬度点
|
|
|
|
+ const lngLat = new AMap.LngLat(lng, lat)
|
|
|
|
+
|
|
|
|
+ // 设置地图中心点并调整缩放级别
|
|
|
|
+ map.setZoomAndCenter(15, lngLat)
|
|
|
|
+
|
|
|
|
+ // 清除之前的标记
|
|
|
|
+ map.clearMap()
|
|
|
|
+
|
|
|
|
+ // 添加标记
|
|
|
|
+ const marker = new AMap.Marker({
|
|
|
|
+ position: lngLat,
|
|
|
|
+ content: '<div class="amap_lib_placeSearch_poi"></div>',
|
|
|
|
+ offset: new AMap.Pixel(-10, -31)
|
|
|
|
+ })
|
|
|
|
+ map.add(marker)
|
|
|
|
+
|
|
|
|
+ // 清空搜索结果显示
|
|
|
|
+ const searchResults = document.getElementById('searchResults')
|
|
|
|
+ if (searchResults) {
|
|
|
|
+ searchResults.innerHTML = `
|
|
|
|
+ <div style="padding: 16px; text-align: center; color: #606266;">
|
|
|
|
+ <div style="font-weight: 500; margin-bottom: 8px;">经纬度定位成功</div>
|
|
|
|
+ <div style="font-size: 12px;">
|
|
|
|
+ 纬度: ${lat}<br/>
|
|
|
|
+ 经度: ${lng}
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ `
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ElMessage.success('经纬度定位成功')
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('经纬度定位失败:', error)
|
|
|
|
+ ElMessage.error('经纬度定位失败')
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 清除防抖定时器
|
|
|
|
+const clearSearchDebounce = () => {
|
|
|
|
+ if (searchDebounceTimer) {
|
|
|
|
+ clearTimeout(searchDebounceTimer)
|
|
|
|
+ searchDebounceTimer = null
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 防抖搜索函数
|
|
|
|
+const debouncedSearch = (inputValue: string, searchType: string) => {
|
|
|
|
+ clearSearchDebounce()
|
|
|
|
+
|
|
|
|
+ searchDebounceTimer = setTimeout(() => {
|
|
|
|
+ if (searchType === '2') {
|
|
|
|
+ // 经纬度搜索
|
|
|
|
+ if (!inputValue.trim()) {
|
|
|
|
+ // 输入为空时,清空搜索结果
|
|
|
|
+ const searchResults = document.getElementById('searchResults')
|
|
|
|
+ if (searchResults) {
|
|
|
|
+ searchResults.innerHTML = '暂无数据'
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const validation = validateCoordinates(inputValue)
|
|
|
|
+
|
|
|
|
+ if (validation.isValid && validation.lat !== undefined && validation.lng !== undefined) {
|
|
|
|
+ // 经纬度格式正确,进行定位
|
|
|
|
+ locateByCoordinates(validation.lat, validation.lng)
|
|
|
|
+ } else {
|
|
|
|
+ // 经纬度格式错误,只在搜索结果区域显示提示,不弹窗
|
|
|
|
+ const searchResults = document.getElementById('searchResults')
|
|
|
|
+ if (searchResults) {
|
|
|
|
+ searchResults.innerHTML = `
|
|
|
|
+ <div style="padding: 16px; text-align: center; color: #f56c6c;">
|
|
|
|
+ <div style="font-weight: 500; margin-bottom: 8px;">经纬度格式错误</div>
|
|
|
|
+ <div style="font-size: 12px; line-height: 1.5;">
|
|
|
|
+ 请输入正确的经纬度格式:<br/>
|
|
|
|
+ 纬度,经度(例如:23.11766,113.28122)<br/>
|
|
|
|
+ 纬度范围:-90 到 90<br/>
|
|
|
|
+ 经度范围:-180 到 180
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ `
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ console.log(22222)
|
|
|
|
+ // 地址搜索,保持原有逻辑
|
|
|
|
+ if (poiPicker) {
|
|
|
|
+ poiPicker.searchByKeyword(inputValue)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }, 500) // 500ms防抖延迟
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const handleSearch = (e) => {
|
|
|
|
+ console.log('handleSearch', e.target.value)
|
|
|
|
+ const inputValue = e.target.value
|
|
|
|
+ searchInputValue.value = inputValue
|
|
|
|
+
|
|
|
|
+ // 对于经纬度搜索,强制隐藏POI选择列表
|
|
|
|
+ if (selectedSearchAdress.value === '2' && poiPicker) {
|
|
|
|
+ poiPicker.hideSearchResults()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 使用防抖搜索
|
|
|
|
+ debouncedSearch(inputValue, selectedSearchAdress.value)
|
|
|
|
+}
|
|
|
|
|
|
// 添加标记
|
|
// 添加标记
|
|
const addMarker = (lng: number, lat: number) => {
|
|
const addMarker = (lng: number, lat: number) => {
|
|
@@ -165,11 +379,171 @@ const handleClose = () => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const getMapSize = () => {
|
|
|
|
+ if (!map) {
|
|
|
|
+ ElMessage.error('地图未初始化')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ // 获取当前地图的可视区域边界
|
|
|
|
+ const bounds = map.getBounds()
|
|
|
|
+ const southwest = bounds.getSouthWest() // 西南角
|
|
|
|
+ const northeast = bounds.getNorthEast() // 东北角
|
|
|
|
+ const northwest = new (window as any).AMap.LngLat(southwest.lng, northeast.lat) // 西北角
|
|
|
|
+ const southeast = new (window as any).AMap.LngLat(northeast.lng, southwest.lat) // 东南角
|
|
|
|
+
|
|
|
|
+ // 使用高德地图的几何工具计算距离(单位:米)
|
|
|
|
+ const AMap = (window as any).AMap
|
|
|
|
+
|
|
|
|
+ // 计算宽度(东西方向距离)
|
|
|
|
+ const width = AMap.GeometryUtil.distance(southwest, southeast)
|
|
|
|
+
|
|
|
|
+ // 计算高度(南北方向距离)
|
|
|
|
+ const height = AMap.GeometryUtil.distance(southwest, northwest)
|
|
|
|
+
|
|
|
|
+ // 计算面积(平方米)
|
|
|
|
+ const area = width * height
|
|
|
|
+
|
|
|
|
+ // 获取当前缩放级别
|
|
|
|
+ const zoom = map.getZoom()
|
|
|
|
+
|
|
|
|
+ // 获取地图中心点
|
|
|
|
+ const center = map.getCenter()
|
|
|
|
+
|
|
|
|
+ const viewportInfo = {
|
|
|
|
+ width: width, // 宽度(米)
|
|
|
|
+ height: height, // 高度(米)
|
|
|
|
+ area: Math.round(area), // 面积(平方米)
|
|
|
|
+ zoom: zoom, // 缩放级别
|
|
|
|
+ center: {
|
|
|
|
+ lat: center.lat,
|
|
|
|
+ lng: center.lng
|
|
|
|
+ },
|
|
|
|
+ bounds: {
|
|
|
|
+ southwest: { lat: southwest.lat, lng: southwest.lng },
|
|
|
|
+ northeast: { lat: northeast.lat, lng: northeast.lng }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ console.log('当前可视区域信息:', viewportInfo)
|
|
|
|
+
|
|
|
|
+ // ElMessage.success(`
|
|
|
|
+ // 可视区域信息:
|
|
|
|
+ // 宽度:${viewportInfo.width.toLocaleString()} 米
|
|
|
|
+ // 高度:${viewportInfo.height.toLocaleString()} 米
|
|
|
|
+ // 面积:${viewportInfo.area.toLocaleString()} 平方米
|
|
|
|
+ // 缩放级别:${viewportInfo.zoom.toFixed(2)}
|
|
|
|
+ // `)
|
|
|
|
+ return {
|
|
|
|
+ width: viewportInfo.width,
|
|
|
|
+ height: viewportInfo.height,
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('计算可视区域失败:', error)
|
|
|
|
+ ElMessage.error('计算可视区域失败')
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const getCanvasImage = async (): Promise<{url: string, fileName: string} | null> => {
|
|
|
|
+ try {
|
|
|
|
+ // 使用html2canvas截图高德地图可视化区域
|
|
|
|
+ const mapElement = document.getElementById('container')
|
|
|
|
+ if (!mapElement) {
|
|
|
|
+ ElMessage.error('地图容器未找到')
|
|
|
|
+ return null
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ElMessage.info('正在生成地图截图...')
|
|
|
|
+
|
|
|
|
+ // 配置html2canvas选项
|
|
|
|
+ const canvas = await html2canvas(mapElement, {
|
|
|
|
+ useCORS: true,
|
|
|
|
+ allowTaint: true,
|
|
|
|
+ scale: 1,
|
|
|
|
+ logging: false,
|
|
|
|
+ imageTimeout: 15000,
|
|
|
|
+ // 忽略某些元素(比如控件)
|
|
|
|
+ ignoreElements: (element) => {
|
|
|
|
+ return element.classList.contains('amap-logo') ||
|
|
|
|
+ element.classList.contains('amap-copyright') ||
|
|
|
|
+ element.classList.contains('amap-controls')
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // 将canvas转换为Blob
|
|
|
|
+ const blob = await canvasToBlob(canvas, 0.8, 'image/jpeg')
|
|
|
|
+
|
|
|
|
+ // 生成文件名
|
|
|
|
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-')
|
|
|
|
+ const fileName = `map-screenshot-${timestamp}.jpg`
|
|
|
|
+
|
|
|
|
+ // 转换为File对象
|
|
|
|
+ const file = blobToFile(blob, fileName)
|
|
|
|
+
|
|
|
|
+ // 上传文件
|
|
|
|
+ const uploadResult = await uploadFileToServer(file, (progressEvent) => {
|
|
|
|
+ // 可选:显示上传进度
|
|
|
|
+ if (progressEvent.lengthComputable) {
|
|
|
|
+ const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
|
|
|
+ console.log(`上传进度: ${percentCompleted}%`)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ console.log('上传成功:', uploadResult)
|
|
|
|
+ return uploadResult
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('截图或上传失败:', error)
|
|
|
|
+ ElMessage.error('截图或上传失败,请重试')
|
|
|
|
+ return null
|
|
|
|
+ }
|
|
|
|
+}
|
|
// 处理确认选择
|
|
// 处理确认选择
|
|
-const handleConfirm = () => {
|
|
|
|
- if (selectedLocation.value) {
|
|
|
|
- emit('confirm', selectedLocation.value)
|
|
|
|
|
|
+const handleConfirm = async () => {
|
|
|
|
+ try {
|
|
|
|
+ if (!props.caseId) {
|
|
|
|
+ ElMessage.error('缺少案件ID参数')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取地图尺寸信息
|
|
|
|
+ const mapSizeInfo = getMapSize()
|
|
|
|
+ if (!mapSizeInfo) {
|
|
|
|
+ ElMessage.error('获取地图尺寸失败')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 获取截图并上传
|
|
|
|
+ const uploadResult = await getCanvasImage()
|
|
|
|
+ if (!uploadResult) {
|
|
|
|
+ ElMessage.error('截图上传失败')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ElMessage.info('正在保存方位图信息...')
|
|
|
|
+
|
|
|
|
+ // 调用案件制表接口
|
|
|
|
+ const response = await axios({
|
|
|
|
+ url: addOrUpdateCaseTabulation,
|
|
|
|
+ method: 'POST',
|
|
|
|
+ data: {
|
|
|
|
+ caseId: props.caseId,
|
|
|
|
+ width: mapSizeInfo.width,
|
|
|
|
+ high: mapSizeInfo.height,
|
|
|
|
+ listCover: uploadResult.url, // 封面图
|
|
|
|
+ mapUrl: uploadResult.url, // 地图URL
|
|
|
|
+ title: '方位图'
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ ElMessage.success('方位图保存成功!')
|
|
|
|
+ console.log('方位图保存成功:', response)
|
|
|
|
+ console.log(`http://test-mix3d.4dkankan.com/draw/index.html#/tabulation?caseId=${props.caseId}&tabulationId=${response.data.id}&token=${user.value.token}`)
|
|
|
|
+ window.open(`http://test-mix3d.4dkankan.com/draw/index.html#/tabulation?caseId=${props.caseId}&tabulationId=${response.data.id}&token=${user.value.token}`, '_blank')
|
|
handleClose()
|
|
handleClose()
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('保存方位图失败:', error)
|
|
|
|
+ ElMessage.error('保存方位图失败,请重试')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -178,6 +552,8 @@ onUnmounted(() => {
|
|
if (map) {
|
|
if (map) {
|
|
map.destroy()
|
|
map.destroy()
|
|
}
|
|
}
|
|
|
|
+ // 清除防抖定时器
|
|
|
|
+ clearSearchDebounce()
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|
|
|
|
|
|
@@ -188,9 +564,9 @@ onUnmounted(() => {
|
|
margin-bottom: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
}
|
|
// https://a.amap.com/jsapi/static/image/plugin/marker_red.png
|
|
// https://a.amap.com/jsapi/static/image/plugin/marker_red.png
|
|
- // .amap-marker{
|
|
|
|
- // display: none!important;
|
|
|
|
- // }
|
|
|
|
|
|
+ .amap-marker{
|
|
|
|
+ display: none!important;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
@@ -213,15 +589,25 @@ onUnmounted(() => {
|
|
display: none;
|
|
display: none;
|
|
}
|
|
}
|
|
#searchBar{
|
|
#searchBar{
|
|
- width: 300px;
|
|
|
|
|
|
+ display: flex;
|
|
|
|
+ width: 380px;
|
|
text-align: left;
|
|
text-align: left;
|
|
margin-bottom: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
}
|
|
- :deep(#searchInput) {
|
|
|
|
- width: 378px;
|
|
|
|
|
|
+ .search-select{
|
|
|
|
+ width: 100px;
|
|
height: 40px;
|
|
height: 40px;
|
|
- border-radius: 4px;
|
|
|
|
|
|
+
|
|
|
|
+ :deep(.el-select__wrapper){
|
|
|
|
+ border-radius: 4px 0 0 4px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ :deep(#searchInput) {
|
|
|
|
+ width: 260px;
|
|
|
|
+ height: 38px;
|
|
|
|
+ border-radius: 0 4px 4px 0;
|
|
border: 1px solid #dcdfe6;
|
|
border: 1px solid #dcdfe6;
|
|
|
|
+ border-left: 0;
|
|
padding: 0 10px;
|
|
padding: 0 10px;
|
|
font-size: 14px;
|
|
font-size: 14px;
|
|
color: #303133;
|
|
color: #303133;
|
|
@@ -281,7 +667,8 @@ onUnmounted(() => {
|
|
}
|
|
}
|
|
|
|
|
|
.map-container {
|
|
.map-container {
|
|
- flex: 1;
|
|
|
|
|
|
+ width: 800px;
|
|
|
|
+ height: 600px;
|
|
position: relative;
|
|
position: relative;
|
|
border: 1px solid #dcdfe6;
|
|
border: 1px solid #dcdfe6;
|
|
border-radius: 4px;
|
|
border-radius: 4px;
|