From 17dd7260fca137e379988300c6b91a1365c27e7e Mon Sep 17 00:00:00 2001 From: yyy <2605810609@qq.com> Date: Mon, 24 Feb 2025 10:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=98=E8=B4=B4=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mapPage/realTimeMap/editMap.vue | 422 +++++++++++----------- 1 file changed, 213 insertions(+), 209 deletions(-) diff --git a/src/views/mapPage/realTimeMap/editMap.vue b/src/views/mapPage/realTimeMap/editMap.vue index 7c997f02..16fdffba 100644 --- a/src/views/mapPage/realTimeMap/editMap.vue +++ b/src/views/mapPage/realTimeMap/editMap.vue @@ -229,7 +229,7 @@ > { break case 'copy': //复制 - let copyMapItem = state.allMapPointInfo[state.currentItemIndex] - state.copyMapItem = { - positionMapId: copyMapItem.positionMapId, - locationX: copyMapItem.locationX, - locationY: copyMapItem.locationY, - type: copyMapItem.type, - dataJson: copyMapItem.dataJson || '', - dataObj: copyMapItem.dataObj || {}, - dataList: copyMapItem.dataList || [], - locationDeep: copyMapItem.locationDeep, - locationWide: copyMapItem.locationWide, - draggable: copyMapItem.draggable, - resizable: copyMapItem.resizable, - rotatable: copyMapItem.rotatable, - lockAspectRatio: copyMapItem.lockAspectRatio - } - message.success('复制成功') + replicationNode() break case 'paste': //粘贴 - let copyObj = JSON.parse(JSON.stringify(state.copyMapItem)) - copyObj.locationX = Number(copyObj.locationX) + 50 - copyObj.locationY = Number(copyObj.locationY) + 50 - state.allMapPointInfo.push(copyObj) - addEditHistory() + pasteNode() break case 'delete': //删除 @@ -1303,6 +1283,43 @@ const toolbarClick = (item) => { } } +//复制 +const replicationNode = () => { + let copyMapItem = state.allMapPointInfo[state.currentItemIndex] + let locationX = Number(copyMapItem.locationX) + 20 + let locationY = Number(copyMapItem.locationY) + 20 + let actualPoint = disposeEventPoint(locationX, locationY) + + state.copyMapItem = { + positionMapId: copyMapItem.positionMapId, + locationX: locationX, + locationY: locationY, + actualLocationX: actualPoint.actualLocationX, + actualLocationY: actualPoint.actualLocationY, + type: copyMapItem.type, + dataJson: copyMapItem.dataJson || '', + dataObj: copyMapItem.dataObj || {}, + dataList: copyMapItem.dataList || [], + locationDeep: copyMapItem.locationDeep, + locationWide: copyMapItem.locationWide, + draggable: copyMapItem.draggable, + resizable: copyMapItem.resizable, + rotatable: copyMapItem.rotatable, + lockAspectRatio: copyMapItem.lockAspectRatio, + layerSelectionShow: copyMapItem.layerSelectionShow, + mapImageUrl: copyMapItem.mapImageUrl, + areaId: copyMapItem.areaId + } + message.success('复制成功') +} +//粘贴 +const pasteNode = () => { + let copyObj = JSON.parse(JSON.stringify(state.copyMapItem)) + state.allMapPointInfo.push(copyObj) + message.success('粘贴成功') + addEditHistory() +} + //移动工具表单提交 const moveFormSubmit = () => { state.allMapPointInfo[state.currentItemIndex].locationX = Number(state.moveForm.locationX) @@ -1318,21 +1335,23 @@ const rotationFormSubmit = () => { //鼠标拖动绘制节点 // 从点开始绘制 const startFromPoint = (index, event) => { - let list = state.allMapPointInfo - const point = list[index] - if (point.id) { - state.startDrawPoint = point //开始点 - state.startDrawPointIndex = index - state.isDrawing = true - event.preventDefault() // 防止默认行为 - } else { - message.warning('选择的节点未保存') - // 重置状态 - state.startDrawPointIndex = -1 // 起始点的索引 - state.startDrawPoint = null - state.isDrawing = false - state.currentDrawX = 0 - state.currentDrawY = 0 + if (toolbarSwitchType.value === 'clickDrawRoute') { + let list = state.allMapPointInfo + const point = list[index] + if (point.id) { + state.startDrawPoint = point //开始点 + state.startDrawPointIndex = index + state.isDrawing = true + event.preventDefault() // 防止默认行为 + } else { + message.warning('选择的节点未保存') + // 重置状态 + state.startDrawPointIndex = -1 // 起始点的索引 + state.startDrawPoint = null + state.isDrawing = false + state.currentDrawX = 0 + state.currentDrawY = 0 + } } } //开始框选绘制 @@ -1410,20 +1429,21 @@ const endDrawSelection = (event) => { // 找到最近的终点 const endPointIndex = findClosestPoint(state.currentDrawX, state.currentDrawY) - if (!endPointIndex.id) { - message.warning('选择的节点未保存') - // 重置状态 - state.startDrawPointIndex = -1 // 起始点的索引 - state.startDrawPoint = null - state.isDrawing = false - state.currentDrawX = 0 - state.currentDrawY = 0 - return - } - if (endPointIndex !== null && endPointIndex !== state.startDrawPointIndex) { let list = state.allMapPointInfo const endPoint = list[endPointIndex] + + if (!endPoint.id) { + message.warning('选择的节点未保存') + // 重置状态 + state.startDrawPointIndex = -1 // 起始点的索引 + state.startDrawPoint = null + state.isDrawing = false + state.currentDrawX = 0 + state.currentDrawY = 0 + return + } + const newLine = { startPointX: state.startDrawPoint.locationX, startPointY: state.startDrawPoint.locationY, @@ -2068,42 +2088,25 @@ window.document.oncontextmenu = function () { const handleKeyDown = (event) => { if (event.ctrlKey) { if (event.key === 'c') { + //复制 if (state.currentItemIndex === -1) { message.warning('请先选择要操作的对象') return } - let copyMapItem = state.allMapPointInfo[state.currentItemIndex] - state.copyMapItem = { - positionMapId: copyMapItem.positionMapId, - locationX: copyMapItem.locationX, - locationY: copyMapItem.locationY, - type: copyMapItem.type, - dataJson: copyMapItem.dataJson || '', - dataObj: copyMapItem.dataObj || {}, - dataList: copyMapItem.dataList || [], - locationDeep: copyMapItem.locationDeep, - locationWide: copyMapItem.locationWide, - draggable: copyMapItem.draggable, - resizable: copyMapItem.resizable, - rotatable: copyMapItem.rotatable, - lockAspectRatio: copyMapItem.lockAspectRatio - } - message.success('复制成功') + replicationNode() } else if (event.key === 'v') { //粘贴 if (!state.copyMapItem) { message.warning('请先复制对象') return } - //粘贴 - let copyObj = JSON.parse(JSON.stringify(state.copyMapItem)) - copyObj.locationX = Number(copyObj.locationX) + 50 - copyObj.locationY = Number(copyObj.locationY) + 50 - state.allMapPointInfo.push(copyObj) - addEditHistory() + pasteNode() } else if (event.key === 'z') { //撤回 backPreviousStep() + } else if (event.key === 'y') { + //重写 + backNextStep() } } } @@ -2120,52 +2123,86 @@ onUnmounted(() => {