清理获取车辆的定时器
This commit is contained in:
parent
dbf7850eb0
commit
1747b773fc
@ -878,7 +878,7 @@ onMounted(() => {
|
|||||||
robotListTimerRef.value = setInterval(() => {
|
robotListTimerRef.value = setInterval(() => {
|
||||||
if (document.hidden) return // 页面不可见时暂停轮询
|
if (document.hidden) return // 页面不可见时暂停轮询
|
||||||
getRobotByFloorAndAreaList()
|
getRobotByFloorAndAreaList()
|
||||||
}, 5000)
|
}, 10000)
|
||||||
|
|
||||||
// 监听页面可见性变化
|
// 监听页面可见性变化
|
||||||
document.addEventListener('visibilitychange', () => {
|
document.addEventListener('visibilitychange', () => {
|
||||||
@ -892,6 +892,21 @@ onUnmounted(() => {
|
|||||||
document.removeEventListener('webkitfullscreenchange', handleFullscreenChange)
|
document.removeEventListener('webkitfullscreenchange', handleFullscreenChange)
|
||||||
document.removeEventListener('mozfullscreenchange', handleFullscreenChange)
|
document.removeEventListener('mozfullscreenchange', handleFullscreenChange)
|
||||||
document.removeEventListener('MSFullscreenChange', handleFullscreenChange)
|
document.removeEventListener('MSFullscreenChange', handleFullscreenChange)
|
||||||
|
|
||||||
|
// 清理定时器
|
||||||
|
if (robotListTimerRef.value) {
|
||||||
|
clearInterval(robotListTimerRef.value)
|
||||||
|
robotListTimerRef.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wsConnection.value) {
|
||||||
|
wsConnection.value.disconnect()
|
||||||
|
wsConnection.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清理其他引用
|
||||||
|
testCarList.value = []
|
||||||
|
robotByFloorAndAreaList.value = []
|
||||||
})
|
})
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (robotListTimerRef.value) {
|
if (robotListTimerRef.value) {
|
||||||
|
@ -2714,14 +2714,24 @@ const submitBatchCopyingFormSuccess = async (form) => {
|
|||||||
const validNodes = newPoints.filter((node) => isValidNodeType(node.type))
|
const validNodes = newPoints.filter((node) => isValidNodeType(node.type))
|
||||||
const validRoutes = newRoutes.filter((route) => isValidRoute(route))
|
const validRoutes = newRoutes.filter((route) => isValidRoute(route))
|
||||||
|
|
||||||
|
// 计算新坐标的辅助函数
|
||||||
|
const calculateNewCoordinates = (x, y) => {
|
||||||
|
const newX = (Number(x) + Number(form.x)).toString()
|
||||||
|
const newY = (Number(y) + Number(form.y)).toString()
|
||||||
|
const actualPoint = disposeEventPoint(newX, newY)
|
||||||
|
return { newX, newY, actualPoint }
|
||||||
|
}
|
||||||
|
|
||||||
const newPointList = await Promise.all(
|
const newPointList = await Promise.all(
|
||||||
validNodes.map(async (node) => {
|
validNodes.map(async (node) => {
|
||||||
const newId = await MapApi.getNodeId()
|
const newId = await MapApi.getNodeId()
|
||||||
nodeIdMap.set(node.id, newId)
|
nodeIdMap.set(node.id, newId)
|
||||||
|
|
||||||
const locationX = Number(node.locationX) + Number(form.x)
|
const {
|
||||||
const locationY = Number(node.locationY) + Number(form.y)
|
newX: locationX,
|
||||||
const actualPoint = disposeEventPoint(locationX, locationY)
|
newY: locationY,
|
||||||
|
actualPoint
|
||||||
|
} = calculateNewCoordinates(node.locationX, node.locationY)
|
||||||
|
|
||||||
const { sortNum, createTime, ...restNode } = node
|
const { sortNum, createTime, ...restNode } = node
|
||||||
|
|
||||||
@ -2733,14 +2743,14 @@ const submitBatchCopyingFormSuccess = async (form) => {
|
|||||||
dataList = []
|
dataList = []
|
||||||
dataJson = ''
|
dataJson = ''
|
||||||
} else if (restNode.type === 2) {
|
} else if (restNode.type === 2) {
|
||||||
dataList = restNode.dataList.map((item) => {
|
dataList = restNode.dataList.map(
|
||||||
return {
|
({ locationDeep, locationStorey, locationWide, positionMapId }) => ({
|
||||||
locationDeep: item.locationDeep,
|
locationDeep,
|
||||||
locationStorey: item.locationStorey,
|
locationStorey,
|
||||||
locationWide: item.locationWide,
|
locationWide,
|
||||||
positionMapId: item.positionMapId
|
positionMapId
|
||||||
}
|
})
|
||||||
})
|
)
|
||||||
dataJson = JSON.stringify(dataList)
|
dataJson = JSON.stringify(dataList)
|
||||||
} else if (restNode.type === 4) {
|
} else if (restNode.type === 4) {
|
||||||
dataObj = {
|
dataObj = {
|
||||||
@ -2771,21 +2781,27 @@ const submitBatchCopyingFormSuccess = async (form) => {
|
|||||||
|
|
||||||
// 更新起点
|
// 更新起点
|
||||||
if (nodeIdMap.has(route.startingPointId)) {
|
if (nodeIdMap.has(route.startingPointId)) {
|
||||||
|
const { newX, newY, actualPoint } = calculateNewCoordinates(
|
||||||
|
route.startPointX,
|
||||||
|
route.startPointY
|
||||||
|
)
|
||||||
newRoute.startingPointId = nodeIdMap.get(route.startingPointId)
|
newRoute.startingPointId = nodeIdMap.get(route.startingPointId)
|
||||||
newRoute.startPointX = (Number(route.startPointX) + Number(form.x)).toString()
|
newRoute.startPointX = newX
|
||||||
newRoute.startPointY = (Number(route.startPointY) + Number(form.y)).toString()
|
newRoute.startPointY = newY
|
||||||
|
newRoute.actualStartPointX = actualPoint.actualLocationX
|
||||||
const actualStartPoint = disposeEventPoint(newRoute.startPointX, newRoute.startPointY)
|
newRoute.actualStartPointY = actualPoint.actualLocationY
|
||||||
newRoute.actualStartPointX = actualStartPoint.actualLocationX
|
|
||||||
newRoute.actualStartPointY = actualStartPoint.actualLocationY
|
|
||||||
|
|
||||||
// 更新控制点
|
// 更新控制点
|
||||||
if (route.method == 1) {
|
if (route.method == 1) {
|
||||||
newRoute.beginControlX = (Number(route.beginControlX) + Number(form.x)).toString()
|
const {
|
||||||
newRoute.beginControlY = (Number(route.beginControlY) + Number(form.y)).toString()
|
newX: controlX,
|
||||||
const actualBeginControl = disposeEventPoint(newRoute.beginControlX, newRoute.beginControlY)
|
newY: controlY,
|
||||||
newRoute.actualBeginControlX = actualBeginControl.actualLocationX
|
actualPoint: controlPoint
|
||||||
newRoute.actualBeginControlY = actualBeginControl.actualLocationY
|
} = calculateNewCoordinates(route.beginControlX, route.beginControlY)
|
||||||
|
newRoute.beginControlX = controlX
|
||||||
|
newRoute.beginControlY = controlY
|
||||||
|
newRoute.actualBeginControlX = controlPoint.actualLocationX
|
||||||
|
newRoute.actualBeginControlY = controlPoint.actualLocationY
|
||||||
} else {
|
} else {
|
||||||
newRoute.beginControlX = 0
|
newRoute.beginControlX = 0
|
||||||
newRoute.beginControlY = 0
|
newRoute.beginControlY = 0
|
||||||
@ -2796,21 +2812,24 @@ const submitBatchCopyingFormSuccess = async (form) => {
|
|||||||
|
|
||||||
// 更新终点
|
// 更新终点
|
||||||
if (nodeIdMap.has(route.endPointId)) {
|
if (nodeIdMap.has(route.endPointId)) {
|
||||||
|
const { newX, newY, actualPoint } = calculateNewCoordinates(route.endPointX, route.endPointY)
|
||||||
newRoute.endPointId = nodeIdMap.get(route.endPointId)
|
newRoute.endPointId = nodeIdMap.get(route.endPointId)
|
||||||
newRoute.endPointX = (Number(route.endPointX) + Number(form.x)).toString()
|
newRoute.endPointX = newX
|
||||||
newRoute.endPointY = (Number(route.endPointY) + Number(form.y)).toString()
|
newRoute.endPointY = newY
|
||||||
|
newRoute.actualEndPointX = actualPoint.actualLocationX
|
||||||
const actualEndPoint = disposeEventPoint(newRoute.endPointX, newRoute.endPointY)
|
newRoute.actualEndPointY = actualPoint.actualLocationY
|
||||||
newRoute.actualEndPointX = actualEndPoint.actualLocationX
|
|
||||||
newRoute.actualEndPointY = actualEndPoint.actualLocationY
|
|
||||||
|
|
||||||
// 更新控制点
|
// 更新控制点
|
||||||
if (route.method == 1) {
|
if (route.method == 1) {
|
||||||
newRoute.endControlX = (Number(route.endControlX) + Number(form.x)).toString()
|
const {
|
||||||
newRoute.endControlY = (Number(route.endControlY) + Number(form.y)).toString()
|
newX: controlX,
|
||||||
const actualEndControl = disposeEventPoint(newRoute.endControlX, newRoute.endControlY)
|
newY: controlY,
|
||||||
newRoute.actualEndControlX = actualEndControl.actualLocationX
|
actualPoint: controlPoint
|
||||||
newRoute.actualEndControlY = actualEndControl.actualLocationY
|
} = calculateNewCoordinates(route.endControlX, route.endControlY)
|
||||||
|
newRoute.endControlX = controlX
|
||||||
|
newRoute.endControlY = controlY
|
||||||
|
newRoute.actualEndControlX = controlPoint.actualLocationX
|
||||||
|
newRoute.actualEndControlY = controlPoint.actualLocationY
|
||||||
} else {
|
} else {
|
||||||
newRoute.endControlX = 0
|
newRoute.endControlX = 0
|
||||||
newRoute.endControlY = 0
|
newRoute.endControlY = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user