传递参数给实时地图

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

View File

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

View File

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