diff --git a/src/views/mapPage/realTimeMap/editMap.vue b/src/views/mapPage/realTimeMap/editMap.vue index 1706ccc6..4b6d3e5e 100644 --- a/src/views/mapPage/realTimeMap/editMap.vue +++ b/src/views/mapPage/realTimeMap/editMap.vue @@ -2701,6 +2701,38 @@ const submitBatchCopyingFormSuccess = async (form) => { 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( newPoints.map(async (node) => { const newId = await MapApi.getNodeId() @@ -2710,14 +2742,23 @@ const submitBatchCopyingFormSuccess = async (form) => { const locationY = Number(node.locationY) + Number(form.y) 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 { ...restNode, id: newId, locationX, locationY, actualLocationX: actualPoint.actualLocationX, - actualLocationY: actualPoint.actualLocationY + actualLocationY: actualPoint.actualLocationY, + dataObj: processedDataObj, + dataList: processedDataList, + dataJson } }) ) @@ -2780,9 +2821,6 @@ const submitBatchCopyingFormSuccess = async (form) => { return restRoute }) - // 添加到地图 - console.log(newPointList, newRouteList) - state.allMapPointInfo.push(...newPointList) state.mapRouteList.push(...newRouteList) message.success('复制成功') @@ -3748,30 +3786,6 @@ const cmConversionPx = (cWidth, cHeight) => { 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 坐标 const computedCurveTextX = (item) => {