传递参数给实时地图

This commit is contained in:
yyy 2025-02-28 11:25:01 +08:00
parent 9e50046f72
commit 30ce5ae75b
3 changed files with 39 additions and 37 deletions

View File

@ -29,8 +29,8 @@ export const downloadPositionMap = async (params) => {
return await request.get({ url: `/system/position-map/download`, params })
}
//获得仓库点位地图
export const getPositionMap = async (params) => {
return await request.get({ url: `/system/position-map/get`, params })
export const getPositionMap = async (id) => {
return await request.get({ url: `/system/position-map/get?id=` + id })
}
// 文件上传
export const uploadPositionMap = async (data) => {

View File

@ -1993,20 +1993,25 @@ const imgBgObj = reactive({
height: '',
floor: '',
area: '',
resolution: 0.05,
origin: [-54.4, -34.2]
resolution: 0,
origin: null
})
//
const { query } = useRoute() //
//
const getMapList = async () => {
if (query.mapId) {
imgBgObj.positionMapId = query.mapId
imgBgObj.floor = query.floor
imgBgObj.area = query.area
//png
if (!query.mapId) return
let res = await MapApi.getPositionMap(query.mapId)
let yamlJson = JSON.parse(res.yamlJson)
imgBgObj.positionMapId = res.id
imgBgObj.floor = res.floor
imgBgObj.area = res.area
imgBgObj.width = yamlJson.width
imgBgObj.height = yamlJson.height
imgBgObj.origin = yamlJson.origin
imgBgObj.resolution = yamlJson.resolution
// //png
getMapData(imgBgObj)
}
}
//png
const getMapData = async (mapInfo) => {
@ -2016,20 +2021,9 @@ const getMapData = async (mapInfo) => {
})
imgBgObj.imgUrl = data
//
const img = new Image()
img.src = imgBgObj.imgUrl
//
img.onload = () => {
imgBgObj.width = img.naturalWidth
imgBgObj.height = img.naturalHeight
//
getAllNodeList()
getAllMapRoute()
}
//
img.onerror = () => {
console.error('图片加载失败')
}
}
//
const getAllNodeList = async () => {
@ -2306,6 +2300,20 @@ const removeEventListener = () => {
window.removeEventListener('keydown', handleKeyDown)
}
const router = useRouter()
onBeforeRouteLeave((to, from) => {
if (to.fullPath == '/mapPage/realTimeMap') {
router.replace({
name: 'MapPageRealTimeMap',
query: {
floor: imgBgObj.floor,
area: imgBgObj.area,
mapId: imgBgObj.positionMapId
}
})
}
})
onMounted(() => {
getMapList()
window.addEventListener('keydown', handleKeyDown)

View File

@ -112,7 +112,6 @@ const getList = async () => {
}
list.value = mapList
console.log(list.value, data)
if (mapValue.value.length) {
handleChangeMap(mapValue.value)
} else {
@ -135,7 +134,6 @@ const handleChangeMap = async (e) => {
floor: '',
area: ''
}
console.log(mapInfo.value)
indexPageRef.value.getMapData(mapInfo.value)
}
//
@ -163,9 +161,7 @@ const editMap = () => {
router.push({
name: 'editMapPageRealTimeMap',
query: {
mapId: mapInfo.value.id,
floor: mapInfo.value.floor,
area: mapInfo.value.area
mapId: mapInfo.value.id
}
})
}
@ -176,14 +172,12 @@ const mapInfo = ref({
floor: '',
area: ''
})
// const transmitMapInfo = (map) => {
// mapInfo.value = map
// }
onMounted(() => {
if (route.query.floorArea) {
console.log(route.query.floorArea, route)
mapValue.value = JSON.parse(route.query.floorArea)
if (route.query.mapId) {
mapInfo.value.mapId = route.query.mapId
mapInfo.value.floor = route.query.floor
mapInfo.value.area = route.query.area
}
getList()
})