From 6dcda7cdd450d4af8925671b06e6b7bff21e7427 Mon Sep 17 00:00:00 2001 From: yyy <2605810609@qq.com> Date: Tue, 15 Jul 2025 11:50:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=87=E8=AE=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=B0=86=E7=AA=97=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E5=88=B0=E4=BB=A5=E6=A0=87=E8=AE=B0=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E7=9A=84=E7=82=B9=E4=B8=BA=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mapPage/realTimeMap/editMap.vue | 34 +++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/views/mapPage/realTimeMap/editMap.vue b/src/views/mapPage/realTimeMap/editMap.vue index 2f96a378..e615fa64 100644 --- a/src/views/mapPage/realTimeMap/editMap.vue +++ b/src/views/mapPage/realTimeMap/editMap.vue @@ -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 }