批量复制
This commit is contained in:
parent
243e1b5d87
commit
715b97dbc5
@ -2701,6 +2701,38 @@ const submitBatchCopyingFormSuccess = async (form) => {
|
|||||||
const nodeIdMap = new Map()
|
const nodeIdMap = new Map()
|
||||||
|
|
||||||
// 处理节点列表
|
// 处理节点列表
|
||||||
|
const processNodeData = (node) => {
|
||||||
|
const { type, dataObj, dataList } = node
|
||||||
|
const dataProcessors = {
|
||||||
|
1: () => ({ dataObj: {}, dataList: [], dataJson: '' }),
|
||||||
|
2: () => {
|
||||||
|
const processedList = dataList.map(
|
||||||
|
({ locationDeep, locationStorey, locationWide, positionMapId }) => ({
|
||||||
|
locationDeep,
|
||||||
|
locationStorey,
|
||||||
|
locationWide,
|
||||||
|
positionMapId
|
||||||
|
})
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
dataObj: {},
|
||||||
|
dataList: processedList,
|
||||||
|
dataJson: JSON.stringify(processedList)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
4: () => {
|
||||||
|
const { locationDeep, locationWide, positionMapId } = dataObj
|
||||||
|
const processedObj = { locationDeep, locationWide, positionMapId }
|
||||||
|
return {
|
||||||
|
dataObj: processedObj,
|
||||||
|
dataList: [],
|
||||||
|
dataJson: JSON.stringify(processedObj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dataProcessors[type]?.() || { dataObj: {}, dataList: [], dataJson: '' }
|
||||||
|
}
|
||||||
|
|
||||||
const newPointList = await Promise.all(
|
const newPointList = await Promise.all(
|
||||||
newPoints.map(async (node) => {
|
newPoints.map(async (node) => {
|
||||||
const newId = await MapApi.getNodeId()
|
const newId = await MapApi.getNodeId()
|
||||||
@ -2710,14 +2742,23 @@ const submitBatchCopyingFormSuccess = async (form) => {
|
|||||||
const locationY = Number(node.locationY) + Number(form.y)
|
const locationY = Number(node.locationY) + Number(form.y)
|
||||||
const actualPoint = disposeEventPoint(locationX, locationY)
|
const actualPoint = disposeEventPoint(locationX, locationY)
|
||||||
|
|
||||||
const { sortNum, createTime, ...restNode } = node
|
const { sortNum, createTime, type, dataObj, dataList, ...restNode } = node
|
||||||
|
const {
|
||||||
|
dataObj: processedDataObj,
|
||||||
|
dataList: processedDataList,
|
||||||
|
dataJson
|
||||||
|
} = processNodeData({ type, dataObj, dataList })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...restNode,
|
...restNode,
|
||||||
id: newId,
|
id: newId,
|
||||||
locationX,
|
locationX,
|
||||||
locationY,
|
locationY,
|
||||||
actualLocationX: actualPoint.actualLocationX,
|
actualLocationX: actualPoint.actualLocationX,
|
||||||
actualLocationY: actualPoint.actualLocationY
|
actualLocationY: actualPoint.actualLocationY,
|
||||||
|
dataObj: processedDataObj,
|
||||||
|
dataList: processedDataList,
|
||||||
|
dataJson
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@ -2780,9 +2821,6 @@ const submitBatchCopyingFormSuccess = async (form) => {
|
|||||||
return restRoute
|
return restRoute
|
||||||
})
|
})
|
||||||
|
|
||||||
// 添加到地图
|
|
||||||
console.log(newPointList, newRouteList)
|
|
||||||
|
|
||||||
state.allMapPointInfo.push(...newPointList)
|
state.allMapPointInfo.push(...newPointList)
|
||||||
state.mapRouteList.push(...newRouteList)
|
state.mapRouteList.push(...newRouteList)
|
||||||
message.success('复制成功')
|
message.success('复制成功')
|
||||||
@ -3748,30 +3786,6 @@ const cmConversionPx = (cWidth, cHeight) => {
|
|||||||
pHeight
|
pHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计算直线中间箭头的路径
|
|
||||||
const getLineMidArrowPath = (item) => {
|
|
||||||
const midX = (Number(item.startPointX) + Number(item.endPointX)) / 2
|
|
||||||
const midY = (Number(item.startPointY) + Number(item.endPointY)) / 2
|
|
||||||
|
|
||||||
let dx = item.endPointX - item.startPointX
|
|
||||||
let dy = item.endPointY - item.startPointY
|
|
||||||
let length = Math.sqrt(dx * dx + dy * dy)
|
|
||||||
|
|
||||||
if (length === 0) {
|
|
||||||
return `M ${midX} ${midY} L ${midX} ${midY}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const unitDx = dx / length
|
|
||||||
const unitDy = dy / length
|
|
||||||
|
|
||||||
const arrowLength = 1
|
|
||||||
const startXArrow = midX - unitDx * arrowLength
|
|
||||||
const startYArrow = midY - unitDy * arrowLength
|
|
||||||
const endXArrow = midX
|
|
||||||
const endYArrow = midY
|
|
||||||
|
|
||||||
return `M ${startXArrow} ${startYArrow} L ${endXArrow} ${endYArrow}`
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算贝塞尔曲线中间文字的 x 坐标
|
// 计算贝塞尔曲线中间文字的 x 坐标
|
||||||
const computedCurveTextX = (item) => {
|
const computedCurveTextX = (item) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user