diff --git a/src/views/home/components/modal-content/add-or-edit-form.vue b/src/views/home/components/modal-content/add-or-edit-form.vue index 47dbe53..c30e73e 100644 --- a/src/views/home/components/modal-content/add-or-edit-form.vue +++ b/src/views/home/components/modal-content/add-or-edit-form.vue @@ -620,12 +620,19 @@ const handleChangeMap = (value) => { // 途径点的change事件 const handleChangePointName = (event, index) => { // 先判断是否重复 - if (!event) return + if (!event) { + routeList.value[index].pointName = null + routeList.value[index].pointId = null + routeList.value[index].theta = null + devicePoints.value.splice(index, 1) + return + } if (event) { const isRepeat = routeList.value.some((item) => item.pointId == event) - if (isRepeat) { + if (isRepeat && routeList.value[index].pointId !== event) { message.warning('该点位已存在,不可重复添加') - routeList.value.splice(index, 1) + routeList.value[index].pointName = null + // routeList.value.splice(index, 1) return } @@ -640,7 +647,7 @@ const handleChangePointName = (event, index) => { routeList.value[index].ptzy = ptzy routeList.value[index].ptzz = ptzz - markPoints(positionX, positionY, pointInfo?.value) + markPoints(positionX, positionY, pointInfo?.value, index) } } @@ -789,11 +796,11 @@ const getRobotId = async (puId) => { } // 标记点位 -const markPoints = (Robot_x, Robot_y, pointId) => { +const markPoints = (Robot_x, Robot_y, pointId, index) => { const svgRect = svgMapRef.value.getBoundingClientRect() const clientY = svgHeight.value - yScale.value * Robot_y + svgRect.top const logicalY1 = (clientY - svgRect.top) / yScale.value - devicePoints.value.push({ x: Robot_x, y: logicalY1, pointId }) + devicePoints.value[index] = { x: Robot_x, y: logicalY1, pointId } if (devicePoints.value.length > 1) { animatePath() @@ -1000,6 +1007,8 @@ watch( routeList.value[index].interval = item.actions[0].interval routeList.value[index].actionType = item.actions[0].type } + + markPoints(item.x, item.y, item.positionId, index) }) } })