批量复制优化,增加校验点位和路线之前是否存在,存在的自动跳过不生成

This commit is contained in:
yyy 2025-06-13 15:57:07 +08:00
parent 9341e90017
commit dcef37c9f1

View File

@ -2746,14 +2746,16 @@ const submitBatchCopyingFormSuccess = async (form) => {
} = calculateNewCoordinates(node.locationX, node.locationY)
//
const isDuplicate = state.allMapPointInfo.some(
const existingNode = state.allMapPointInfo.find(
(item) =>
Number(item.locationX).toFixed(1) === Number(locationX).toFixed(1) &&
Number(item.locationY).toFixed(1) === Number(locationY).toFixed(1)
)
if (isDuplicate) {
if (existingNode) {
message.warning(`节点(${locationX}, ${locationY})已存在,已跳过`)
//
nodeIdMap.set(node.id, existingNode.id)
return null
}
@ -2812,6 +2814,7 @@ const submitBatchCopyingFormSuccess = async (form) => {
route.startPointX,
route.startPointY
)
// 使IDIDID
newRoute.startingPointId = nodeIdMap.get(route.startingPointId)
newRoute.startPointX = newX
newRoute.startPointY = newY
@ -2840,6 +2843,7 @@ const submitBatchCopyingFormSuccess = async (form) => {
//
if (nodeIdMap.has(route.endPointId)) {
const { newX, newY, actualPoint } = calculateNewCoordinates(route.endPointX, route.endPointY)
// 使IDIDID
newRoute.endPointId = nodeIdMap.get(route.endPointId)
newRoute.endPointX = newX
newRoute.endPointY = newY
@ -2869,8 +2873,31 @@ const submitBatchCopyingFormSuccess = async (form) => {
return restRoute
})
// 线
const filteredRouteList = newRouteList.filter((newRoute) => {
// 线
const isDuplicate = state.mapRouteList.some(
(existingRoute) =>
Number(existingRoute.startPointX).toFixed(1) === Number(newRoute.startPointX).toFixed(1) &&
Number(existingRoute.startPointY).toFixed(1) === Number(newRoute.startPointY).toFixed(1) &&
Number(existingRoute.endPointX).toFixed(1) === Number(newRoute.endPointX).toFixed(1) &&
Number(existingRoute.endPointY).toFixed(1) === Number(newRoute.endPointY).toFixed(1)
)
if (isDuplicate) {
message.warning(
`路线(${newRoute.startPointX}, ${newRoute.startPointY}) -> (${newRoute.endPointX}, ${newRoute.endPointY})已存在,已跳过`
)
return false
}
return true
})
console.log(filteredPointList)
console.log(filteredRouteList)
state.allMapPointInfo.push(...filteredPointList)
state.mapRouteList.push(...newRouteList)
state.mapRouteList.push(...filteredRouteList)
message.success('复制成功')
addEditHistory()
}