优化标记功能,将窗口自动滚动到以标记成功的点为中心

This commit is contained in:
yyy 2025-07-15 11:50:19 +08:00
parent b5785e88e1
commit 6dcda7cdd4

View File

@ -2784,8 +2784,6 @@ const markFormSubmit = async () => {
message.warning('请选择车辆')
return
}
// '{"area":"E","batSoc":"80","floor":"3","robotNo":"100","x":"-1.720683217048645","y":"-14.308184623718262","yaw":"-3.0042707920074463"}'
let res = await MapApi.getAGVPointInformation(state.markForm.macAddress)
if (res) {
//
@ -2828,7 +2826,10 @@ const markFormSubmit = async () => {
route.actualEndPointY = point.y
}
})
//
scrollToPosition(pointPx.x, pointPx.y)
message.success('修改位置成功')
addEditHistory()
} else {
//
@ -2854,6 +2855,10 @@ const markFormSubmit = async () => {
dataObj: {}, //
locationYaw: point.yaw //
})
//
state.currentItemIndex = state.allMapPointInfo.length - 1
scrollToPosition(pointPx.x, pointPx.y)
message.success('标记成功')
addEditHistory()
}
@ -4675,28 +4680,39 @@ const toggleSelect = () => {
state.isSearchSelectVisible = !state.isSearchSelectVisible
state.searchSelectedOption = ''
}
const searchSelectChange = (sortNum) => {
const currentIndex = state.allMapPointInfo.findIndex((item) => item.sortNum === sortNum)
const currentItem = state.allMapPointInfo.find((item) => item.sortNum === sortNum)
//
//
const scrollToPosition = (x, y) => {
const rect = mapContainerRef.value
if (!rect) return
//
const maxScrollLeft = rect.scrollWidth - rect.clientWidth
const maxScrollTop = rect.scrollHeight - rect.clientHeight
const scrollToX = Math.max(
0,
Math.min(currentItem.locationX - rect.clientWidth / 2, maxScrollLeft)
Math.min(x * state.imageChangeMultiple - rect.clientWidth / 2, maxScrollLeft)
)
const scrollToY = Math.max(
0,
Math.min(currentItem.locationY - rect.clientHeight / 2, maxScrollTop)
Math.min(y * state.imageChangeMultiple - rect.clientHeight / 2, maxScrollTop)
)
//
rect.scrollTo({
left: scrollToX,
top: scrollToY,
behavior: 'smooth'
})
}
const searchSelectChange = (sortNum) => {
const currentIndex = state.allMapPointInfo.findIndex((item) => item.sortNum === sortNum)
const currentItem = state.allMapPointInfo.find((item) => item.sortNum === sortNum)
// 使
if (currentItem) {
scrollToPosition(currentItem.locationX, currentItem.locationY)
}
state.currentItemIndex = currentIndex
}