批量复制优化,增加校验点位和路线之前是否存在,存在的自动跳过不生成
This commit is contained in:
parent
9341e90017
commit
dcef37c9f1
@ -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
|
||||
)
|
||||
// 使用映射后的ID(可能是新ID或已存在节点的ID)
|
||||
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)
|
||||
// 使用映射后的ID(可能是新ID或已存在节点的ID)
|
||||
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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user