ctrl+c ctrl+v等键盘操作

This commit is contained in:
yyy 2025-02-22 17:41:46 +08:00
parent 59a7eea5fe
commit 1c8ea3b7e4
3 changed files with 393 additions and 317 deletions

View File

@ -127,18 +127,16 @@
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="正向限速" prop="forwardSpeedLimit" required> <el-form-item label="正向限速" prop="forwardSpeedLimit" required>
<el-input <el-slider v-model="form.forwardSpeedLimit" :min="0" :max="10" :step="0.1" />
v-model="form.forwardSpeedLimit" </el-form-item>
type="number" </el-col>
placeholder="请输入正向限速"
/> </el-form-item
></el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="反向限速" prop="reverseSpeedLimit" required> <el-form-item label="反向限速" prop="reverseSpeedLimit" required>
<el-input <el-slider
v-model="form.reverseSpeedLimit" v-model="form.reverseSpeedLimit"
type="number" :min="0"
placeholder="请输入反向限速" :max="10"
:step="0.1"
/> </el-form-item /> </el-form-item
></el-col> ></el-col>
</el-row> </el-row>

View File

@ -334,7 +334,7 @@ const dragCalc = (list, page, spacing, ruler, type) => {
} }
} }
// //
const horizontalDragRuler = () => { const horizontalDragRuler = (e) => {
newLine('x') newLine('x')
} }
// //

View File

@ -8,7 +8,7 @@
:width="170" :width="170"
trigger="click" trigger="click"
v-if="item.switchType === 'move' || item.switchType === 'revolve'" v-if="item.switchType === 'move' || item.switchType === 'revolve'"
:disabled="currentItemIndex === -1" :disabled="state.currentItemIndex === -1"
> >
<template #reference> <template #reference>
<div <div
@ -32,7 +32,7 @@
<el-input v-model="state.moveForm.locationX" placeholder="请输入" /> <el-input v-model="state.moveForm.locationX" placeholder="请输入" />
</el-form-item> </el-form-item>
<el-form-item label="Y"> <el-form-item label="Y">
<el-input v-model="state.moveForm.y" placeholder="请输入" /> <el-input v-model="state.moveForm.locationY" placeholder="请输入" />
</el-form-item> </el-form-item>
<div style="text-align: right"> <div style="text-align: right">
<el-button <el-button
@ -203,14 +203,6 @@
</div> </div>
<div class="map-container" ref="mapContainer" :style="{ cursor: state.cursorStyle }"> <div class="map-container" ref="mapContainer" :style="{ cursor: state.cursorStyle }">
<map-scale-tool
v-if="imgBgObj.height && imgBgObj.width"
@input="input"
:value="presetLine"
:step-length="50"
:height="imgBgObj.height"
:width="imgBgObj.width"
>
<div <div
class="map-bg" class="map-bg"
:style="{ :style="{
@ -236,7 +228,7 @@
v-if="interfaceRefreshed" v-if="interfaceRefreshed"
> >
<VueDragResizeRotate <VueDragResizeRotate
v-for="(item, index) in allHistoryList[currentIndex]" v-for="(item, index) in state.allMapPointInfo"
:key="item.locationX" :key="item.locationX"
:parent="true" :parent="true"
:x="Number(item.locationX) - Number(item.locationWide) / 2" :x="Number(item.locationX) - Number(item.locationWide) / 2"
@ -263,7 +255,7 @@
:style="{ :style="{
width: item.locationWide + 'px', width: item.locationWide + 'px',
height: item.locationDeep + 'px', height: item.locationDeep + 'px',
backgroundColor: currentItemIndex === index ? '#f48924' : '#000', backgroundColor: state.currentItemIndex === index ? '#f48924' : '#000',
borderRadius: '50%', borderRadius: '50%',
zIndex: 999 zIndex: 999
}" }"
@ -277,7 +269,7 @@
:style="{ :style="{
width: item.locationWide + 'px', width: item.locationWide + 'px',
height: item.locationDeep + 'px', height: item.locationDeep + 'px',
border: currentItemIndex === index ? '1px dashed #000' : 'none' border: state.currentItemIndex === index ? '1px dashed #000' : 'none'
}" }"
/> />
<!-- 3 设备点 --> <!-- 3 设备点 -->
@ -291,7 +283,7 @@
:style="{ :style="{
width: item.locationWide + 'px', width: item.locationWide + 'px',
height: item.locationDeep + 'px', height: item.locationDeep + 'px',
border: currentItemIndex === index ? '1px dashed #000' : 'none' border: state.currentItemIndex === index ? '1px dashed #000' : 'none'
}" }"
/> />
<!-- 4 停车点 --> <!-- 4 停车点 -->
@ -302,7 +294,7 @@
:style="{ :style="{
width: item.locationWide + 'px', width: item.locationWide + 'px',
height: item.locationDeep + 'px', height: item.locationDeep + 'px',
border: currentItemIndex === index ? '1px dashed #000' : 'none' border: state.currentItemIndex === index ? '1px dashed #000' : 'none'
}" }"
/> />
<!-- 5 区域变更点 --> <!-- 5 区域变更点 -->
@ -313,7 +305,7 @@
:style="{ :style="{
width: item.locationWidee + 'px', width: item.locationWidee + 'px',
height: item.locationDeep + 'px', height: item.locationDeep + 'px',
border: currentItemIndex === index ? '1px dashed #000' : 'none' border: state.currentItemIndex === index ? '1px dashed #000' : 'none'
}" }"
/> />
<!-- 6 等待点 --> <!-- 6 等待点 -->
@ -324,7 +316,7 @@
:style="{ :style="{
width: item.locationWide + 'px', width: item.locationWide + 'px',
height: item.locationDeep + 'px', height: item.locationDeep + 'px',
border: currentItemIndex === index ? '1px dashed #000' : 'none' border: state.currentItemIndex === index ? '1px dashed #000' : 'none'
}" }"
/> />
<div <div
@ -333,7 +325,7 @@
color: item.fontColor, color: item.fontColor,
fontSize: item.fontSize + 'px', fontSize: item.fontSize + 'px',
fontFamily: item.fontFamily, fontFamily: item.fontFamily,
border: currentItemIndex === index ? '1px dashed #000' : 'none' border: state.currentItemIndex === index ? '1px dashed #000' : 'none'
}" }"
> >
{{ item.text }} {{ item.text }}
@ -348,7 +340,6 @@
style="position: absolute; top: 0; left: 0; z-index: 9" style="position: absolute; top: 0; left: 0; z-index: 9"
id="svgId" id="svgId"
> >
<template v-for="(curve, index) in state.mapRouteList" :key="index">
<!-- 实时绘制当前直线 --> <!-- 实时绘制当前直线 -->
<line <line
v-if="state.isDrawing && toolbarSwitchType === 'clickDrawRoute'" v-if="state.isDrawing && toolbarSwitchType === 'clickDrawRoute'"
@ -359,7 +350,8 @@
stroke="#00329F" stroke="#00329F"
stroke-width="5" stroke-width="5"
/> />
<template v-if="state.mapRouteList.length > 0">
<template v-for="(curve, index) in state.mapRouteList" :key="index">
<!-- 直线 --> <!-- 直线 -->
<line <line
v-if="curve.method === 0" v-if="curve.method === 0"
@ -384,6 +376,7 @@
/> />
<!-- 第一条控制线 --> <!-- 第一条控制线 -->
<line <line
v-if="state.currentDragTarget.index == index"
:x1="Number(curve.startPointX)" :x1="Number(curve.startPointX)"
:y1="Number(curve.startPointY)" :y1="Number(curve.startPointY)"
:x2="curve.beginControlX" :x2="curve.beginControlX"
@ -394,6 +387,7 @@
/> />
<!-- 第二条控制线 --> <!-- 第二条控制线 -->
<line <line
v-if="state.currentDragTarget.index == index"
:x1="Number(curve.endPointX)" :x1="Number(curve.endPointX)"
:y1="Number(curve.endPointY)" :y1="Number(curve.endPointY)"
:x2="curve.endControlX" :x2="curve.endControlX"
@ -403,6 +397,7 @@
stroke-width="2" stroke-width="2"
/> />
<circle <circle
v-if="state.currentDragTarget.index == index"
id="startCircle" id="startCircle"
:cx="curve.beginControlX" :cx="curve.beginControlX"
:cy="curve.beginControlY" :cy="curve.beginControlY"
@ -411,6 +406,7 @@
@mousedown="startDrag(curve, index, 'start')" @mousedown="startDrag(curve, index, 'start')"
/> />
<circle <circle
v-if="state.currentDragTarget.index == index"
id="endCircle" id="endCircle"
:cx="curve.endControlX" :cx="curve.endControlX"
:cy="curve.endControlY" :cy="curve.endControlY"
@ -420,6 +416,7 @@
/> />
</template> </template>
</template> </template>
</template>
</svg> </svg>
</div> </div>
</div> </div>
@ -505,7 +502,6 @@
class="input-box-class" class="input-box-class"
/> />
</div> </div>
</map-scale-tool>
</div> </div>
<!-- 节点编辑 --> <!-- 节点编辑 -->
@ -587,16 +583,6 @@ const inputBoxRef = ref() //文字输入框
const message = useMessage() // const message = useMessage() //
const allHistoryList = ref([]) //
const currentIndex = ref(0) //
const currentItemIndex = ref(-1) //
const allMapPointInfo = ref([]) //
const presetLine = ref([])
const input = (list) => {
presetLine.value = list
}
// //
const interfaceRefreshed = ref(true) const interfaceRefreshed = ref(true)
const resizeEnd = (locationX, locationY, w, h, item, index) => { const resizeEnd = (locationX, locationY, w, h, item, index) => {
@ -605,10 +591,10 @@ const resizeEnd = (locationX, locationY, w, h, item, index) => {
let x = Number(locationX) + Number(item.locationWide) / 2 let x = Number(locationX) + Number(item.locationWide) / 2
let y = Number(locationY) + Number(item.locationDeep) / 2 let y = Number(locationY) + Number(item.locationDeep) / 2
allMapPointInfo.value[index].locationX = x state.allMapPointInfo[index].locationX = x
allMapPointInfo.value[index].locationY = y state.allMapPointInfo[index].locationY = y
allMapPointInfo.value[index].locationWide = w state.allMapPointInfo[index].locationWide = w
allMapPointInfo.value[index].locationDeep = h state.allMapPointInfo[index].locationDeep = h
addEditHistory() addEditHistory()
state.mapRouteList.forEach((route) => { state.mapRouteList.forEach((route) => {
@ -631,6 +617,7 @@ const resizeEnd = (locationX, locationY, w, h, item, index) => {
}) })
}) })
} }
// //
const dragEnd = (locationX, locationY, item, index) => { const dragEnd = (locationX, locationY, item, index) => {
let x = Number(locationX) + Number(item.locationWide) / 2 let x = Number(locationX) + Number(item.locationWide) / 2
@ -638,10 +625,10 @@ const dragEnd = (locationX, locationY, item, index) => {
if (x === item.locationX && y === item.locationY) return if (x === item.locationX && y === item.locationY) return
let actualPoint = disposeEventPoint(x, y) let actualPoint = disposeEventPoint(x, y)
allMapPointInfo.value[index].locationX = x state.allMapPointInfo[index].locationX = x
allMapPointInfo.value[index].locationY = y state.allMapPointInfo[index].locationY = y
allMapPointInfo.value[index].actualStartPointX = actualPoint.actualLocationX state.allMapPointInfo[index].actualStartPointX = actualPoint.actualLocationX
allMapPointInfo.value[index].actualStartPointY = actualPoint.actualLocationY state.allMapPointInfo[index].actualStartPointY = actualPoint.actualLocationY
addEditHistory() addEditHistory()
//线 //线
state.mapRouteList.forEach((route) => { state.mapRouteList.forEach((route) => {
@ -665,26 +652,26 @@ const dragEnd = (locationX, locationY, item, index) => {
} }
// //
const rotateEnd = (angle, item, index) => { const rotateEnd = (angle, item, index) => {
allMapPointInfo.value[index].angle = angle state.allMapPointInfo[index].angle = angle
addEditHistory() addEditHistory()
} }
// //
const editNodePropertiesRef = ref() const editNodePropertiesRef = ref()
const activatedHandle = (item, index) => { const activatedHandle = (item, index) => {
currentItemIndex.value = index state.currentItemIndex = index
//线 //线
state.selectedCurve = '' state.selectedCurve = ''
if (state.currentDragTarget.index !== null) { if (state.mapRouteList.length > 0 && state.currentDragTarget.index !== null) {
state.mapRouteList[state.currentDragTarget.index].isSelected = false state.mapRouteList[state.currentDragTarget.index].isSelected = false
state.currentDragTarget = { index: null, type: null } state.currentDragTarget = { index: null, type: null }
} }
// //
if (toolbarSwitchType.value === 'editNode') { if (toolbarSwitchType.value === 'editNode') {
let list = allHistoryList.value[currentIndex.value].filter((item) => item.type === 3) let list = state.allMapPointInfo.filter((item) => item.type === 3)
editNodePropertiesRef.value.open(JSON.parse(JSON.stringify(item)), list) editNodePropertiesRef.value.open(JSON.parse(JSON.stringify(item)), list)
} }
} }
@ -694,31 +681,42 @@ const deactivatedHandle = () => {}
// //
const addEditHistory = () => { const addEditHistory = () => {
// currentIndex // currentIndex
if (currentIndex.value !== allHistoryList.value.length - 1) { if (state.currentIndex !== state.allHistoryList.length - 1) {
allHistoryList.value = allHistoryList.value.splice(0, currentIndex.value) state.allHistoryList = state.allHistoryList.splice(0, state.currentIndex)
currentIndex.value = allHistoryList.value.length state.currentIndex = state.allHistoryList.length
allHistoryList.value.push(JSON.parse(JSON.stringify(allMapPointInfo.value))) state.allHistoryList.push({
allMapPointInfo: JSON.parse(JSON.stringify(state.allMapPointInfo)),
mapRouteList: JSON.parse(JSON.stringify(state.mapRouteList))
})
} else { } else {
allHistoryList.value.push(JSON.parse(JSON.stringify(allMapPointInfo.value))) state.allHistoryList.push({
currentIndex.value++ allMapPointInfo: JSON.parse(JSON.stringify(state.allMapPointInfo)),
mapRouteList: JSON.parse(JSON.stringify(state.mapRouteList))
})
state.currentIndex++
} }
interfaceRefreshed.value = true interfaceRefreshed.value = true
} }
// //
const backPreviousStep = () => { const backPreviousStep = () => {
if (currentIndex.value > 0) { console.log(state.currentIndex)
currentIndex.value-- console.log(state.allMapPointInfo)
allMapPointInfo.value = allHistoryList.value[currentIndex.value] console.log(state.allHistoryList)
if (state.currentIndex > 0) {
state.currentIndex--
state.allMapPointInfo = state.allHistoryList[state.currentIndex]?.allMapPointInfo || []
state.mapRouteList = state.allHistoryList[state.currentIndex]?.mapRouteList || []
} else { } else {
message.warning('没了老铁') message.warning('没了老铁')
} }
} }
// //
const backNextStep = () => { const backNextStep = () => {
if (currentIndex.value < allHistoryList.value.length - 1) { if (state.currentIndex < state.allHistoryList.length - 1) {
currentIndex.value++ state.currentIndex++
allMapPointInfo.value = allHistoryList.value[currentIndex.value] state.allMapPointInfo = state.allHistoryList[state.currentIndex]?.allMapPointInfo || []
state.mapRouteList = state.allHistoryList[state.currentIndex]?.mapRouteList || []
} else { } else {
message.warning('没了老铁') message.warning('没了老铁')
} }
@ -733,7 +731,7 @@ const mapClick = (e) => {
// //
if (toolbarSwitchType.value === 'drawNodes') { if (toolbarSwitchType.value === 'drawNodes') {
allMapPointInfo.value.push({ state.allMapPointInfo.push({
positionMapId: imgBgObj.positionMapId, //id positionMapId: imgBgObj.positionMapId, //id
layerSelectionShow: true, layerSelectionShow: true,
locationX: x, locationX: x,
@ -782,7 +780,7 @@ const textFormSuccess = (form) => {
const handleInputEnd = () => { const handleInputEnd = () => {
if (state.inputBoxValue) { if (state.inputBoxValue) {
state.showInputBox = false state.showInputBox = false
allMapPointInfo.value.push({ state.allMapPointInfo.push({
type: 7, // 7 type: 7, // 7
positionMapId: imgBgObj.positionMapId, //id positionMapId: imgBgObj.positionMapId, //id
locationX: state.inputBoxStyle.locationX, //x locationX: state.inputBoxStyle.locationX, //x
@ -810,9 +808,7 @@ const handleInputEnd = () => {
} }
// //
const submitNodeSuccess = (form) => { const submitNodeSuccess = (form) => {
allMapPointInfo.value[currentItemIndex.value] = form state.allMapPointInfo[state.currentItemIndex] = form
allHistoryList.value[currentIndex.value][currentItemIndex.value] = form
// //
state.mapRouteList.forEach((item) => { state.mapRouteList.forEach((item) => {
if (form.id === item.startingPointId) { if (form.id === item.startingPointId) {
@ -832,6 +828,7 @@ const submitNodeSuccess = (form) => {
item.actualEndPointY = disposeEventPoint(form.locationX, form.locationY).actualLocationY item.actualEndPointY = disposeEventPoint(form.locationX, form.locationY).actualLocationY
} }
}) })
addEditHistory()
} }
// //
@ -1036,21 +1033,26 @@ const state = reactive({
measureDistancesNum: 0, // measureDistancesNum: 0, //
imageChangeMultiple: 1, // imageChangeMultiple: 1, //
prohibitedOperation: false, // prohibitedOperation: false, //
mapRouteList: [], //线
currentDragTarget: { currentDragTarget: {
index: null, index: null,
type: null type: null
}, // }, //
selectedCurve: '', // 线 selectedCurve: '', // 线
startDrawPointIndex: -1, // startDrawPointIndex: -1, //
startDrawPoint: null, startDrawPoint: null, //线
isDrawing: false, isDrawing: false, //
currentDrawX: 0, currentDrawX: 0, //x
currentDrawY: 0 currentDrawY: 0, //y
allHistoryList: [], // [{allMapPointInfo:[],mapRouteList:[]}]
allMapPointInfo: [], //
mapRouteList: [], //线
currentIndex: 0, //
currentItemIndex: -1 //
}) })
const toolbarClick = (item) => { const toolbarClick = (item) => {
let type = item.switchType let type = item.switchType
if (currentItemIndex.value === -1 && (type === 'move' || type === 'revolve' || type === 'copy')) { if (state.currentItemIndex === -1 && (type === 'move' || type === 'revolve' || type === 'copy')) {
message.warning('请先选择要操作的对象') message.warning('请先选择要操作的对象')
return return
} }
@ -1058,7 +1060,7 @@ const toolbarClick = (item) => {
if ( if (
type === 'delete' && type === 'delete' &&
state.currentDragTarget.index === null && state.currentDragTarget.index === null &&
currentItemIndex.value === -1 state.currentItemIndex === -1
) { ) {
message.warning('请先选择要操作的对象') message.warning('请先选择要操作的对象')
return return
@ -1125,7 +1127,7 @@ const toolbarClick = (item) => {
break break
case 'saveAs': case 'saveAs':
// json 访 // json 访
const jsonString = JSON.stringify(allHistoryList.value[currentIndex.value], null, 2) const jsonString = JSON.stringify(state.allHistoryList[state.currentIndex], null, 2)
const blob = new Blob([jsonString], { type: 'application/json' }) const blob = new Blob([jsonString], { type: 'application/json' })
const url = URL.createObjectURL(blob) const url = URL.createObjectURL(blob)
@ -1149,7 +1151,7 @@ const toolbarClick = (item) => {
break break
case 'copy': case 'copy':
// //
let copyMapItem = allHistoryList.value[currentIndex.value][currentItemIndex.value] let copyMapItem = state.allMapPointInfo[state.currentItemIndex]
state.copyMapItem = { state.copyMapItem = {
positionMapId: copyMapItem.positionMapId, positionMapId: copyMapItem.positionMapId,
locationX: copyMapItem.locationX, locationX: copyMapItem.locationX,
@ -1172,18 +1174,20 @@ const toolbarClick = (item) => {
let copyObj = JSON.parse(JSON.stringify(state.copyMapItem)) let copyObj = JSON.parse(JSON.stringify(state.copyMapItem))
copyObj.locationX = Number(copyObj.locationX) + 50 copyObj.locationX = Number(copyObj.locationX) + 50
copyObj.locationY = Number(copyObj.locationY) + 50 copyObj.locationY = Number(copyObj.locationY) + 50
allMapPointInfo.value.push(copyObj) state.allMapPointInfo.push(copyObj)
addEditHistory() addEditHistory()
break break
case 'delete': case 'delete':
// //
if (currentItemIndex.value !== -1) { if (state.currentItemIndex !== -1) {
allMapPointInfo.value.splice(currentItemIndex.value, 1) state.allMapPointInfo.splice(state.currentItemIndex, 1)
addEditHistory() state.currentItemIndex = -1
} }
if (state.currentDragTarget.index !== null) { if (state.currentDragTarget.index !== null) {
state.mapRouteList.splice(state.currentDragTarget.index, 1) state.mapRouteList.splice(state.currentDragTarget.index, 1)
state.currentDragTarget.index = null
} }
addEditHistory()
break break
case 'tools': case 'tools':
// //
@ -1256,7 +1260,7 @@ const toolbarClick = (item) => {
case 'larger': case 'larger':
// //
if (state.imageChangeMultiple < 3) { if (state.imageChangeMultiple < 3) {
state.imageChangeMultiple *= 1.2 state.imageChangeMultiple += 0.1
} else { } else {
message.warning('不能在放大了') message.warning('不能在放大了')
} }
@ -1264,7 +1268,7 @@ const toolbarClick = (item) => {
case 'smaller': case 'smaller':
// //
if (state.imageChangeMultiple > 0.3) { if (state.imageChangeMultiple > 0.3) {
state.imageChangeMultiple *= 0.8 state.imageChangeMultiple -= 0.1
} else { } else {
message.warning('不能在缩小了') message.warning('不能在缩小了')
} }
@ -1291,7 +1295,7 @@ const toolbarClick = (item) => {
break break
case 'equipment': case 'equipment':
// //
let equipmentList = allHistoryList.value[currentIndex.value].filter((item) => { let equipmentList = state.allMapPointInfo.filter((item) => {
return item.type === 3 return item.type === 3
}) })
equipmentToolDialogRef.value.open(equipmentList) equipmentToolDialogRef.value.open(equipmentList)
@ -1301,25 +1305,35 @@ const toolbarClick = (item) => {
// //
const moveFormSubmit = () => { const moveFormSubmit = () => {
allHistoryList.value[currentIndex.value][currentItemIndex.value].locationX = state.allMapPointInfo[state.currentItemIndex].locationX = Number(state.moveForm.locationX)
state.moveForm.locationX state.allMapPointInfo[state.currentItemIndex].locationY = Number(state.moveForm.locationY)
allHistoryList.value[currentIndex.value][currentItemIndex.value].locationY = addEditHistory()
state.moveForm.locationY
} }
// //
const rotationFormSubmit = () => { const rotationFormSubmit = () => {
allHistoryList.value[currentIndex.value][currentItemIndex.value].angle = state.rotationForm.angle state.allMapPointInfo[state.currentItemIndex].angle = state.rotationForm.angle
addEditHistory()
} }
// //
// //
const startFromPoint = (index, event) => { const startFromPoint = (index, event) => {
let list = allHistoryList.value[currentIndex.value] let list = state.allMapPointInfo
const point = list[index] const point = list[index]
if (point.id) {
state.startDrawPoint = point // state.startDrawPoint = point //
state.startDrawPointIndex = index state.startDrawPointIndex = index
state.isDrawing = true state.isDrawing = true
event.preventDefault() // event.preventDefault() //
} else {
message.warning('选择的节点未保存')
//
state.startDrawPointIndex = -1 //
state.startDrawPoint = null
state.isDrawing = false
state.currentDrawX = 0
state.currentDrawY = 0
}
} }
// //
const startDrawSelection = (event) => { const startDrawSelection = (event) => {
@ -1396,8 +1410,19 @@ const endDrawSelection = (event) => {
// //
const endPointIndex = findClosestPoint(state.currentDrawX, state.currentDrawY) 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) { if (endPointIndex !== null && endPointIndex !== state.startDrawPointIndex) {
let list = allHistoryList.value[currentIndex.value] let list = state.allMapPointInfo
const endPoint = list[endPointIndex] const endPoint = list[endPointIndex]
const newLine = { const newLine = {
startPointX: state.startDrawPoint.locationX, startPointX: state.startDrawPoint.locationX,
@ -1455,6 +1480,7 @@ const endDrawSelection = (event) => {
endWidth: endPoint.locationWide, // endWidth: endPoint.locationWide, //
endHigh: endPoint.locationDeep // endHigh: endPoint.locationDeep //
}) })
addEditHistory()
} }
} }
// //
@ -1473,7 +1499,7 @@ const endDrawSelection = (event) => {
const findClosestPoint = (x, y) => { const findClosestPoint = (x, y) => {
let minDistance = Infinity let minDistance = Infinity
let closestIndex = null let closestIndex = null
let list = allHistoryList.value[currentIndex.value] let list = state.allMapPointInfo
list.forEach((point, index) => { list.forEach((point, index) => {
const distance = Math.sqrt((point.locationX - x) ** 2 + (point.locationY - y) ** 2) const distance = Math.sqrt((point.locationX - x) ** 2 + (point.locationY - y) ** 2)
if (distance < minDistance && distance < point.locationWide) { if (distance < minDistance && distance < point.locationWide) {
@ -1484,10 +1510,9 @@ const findClosestPoint = (x, y) => {
}) })
return closestIndex return closestIndex
} }
// //
const clickDrawSelectionArea = () => { const clickDrawSelectionArea = () => {
let points = allHistoryList.value[currentIndex.value] let points = state.allMapPointInfo
state.drawSelectionPointList = [] state.drawSelectionPointList = []
state.allDrawSelectionAreaBox.forEach((box) => { state.allDrawSelectionAreaBox.forEach((box) => {
@ -1511,8 +1536,6 @@ const clickDrawSelectionArea = () => {
// let routeList = state.drawSelectionPointList.filter((item) => item.type === 1) // let routeList = state.drawSelectionPointList.filter((item) => item.type === 1)
let routeList = state.drawSelectionPointList let routeList = state.drawSelectionPointList
console.log(routeList)
let isHaveId = binLocation.every((item) => { let isHaveId = binLocation.every((item) => {
item.id item.id
}) })
@ -1600,6 +1623,7 @@ const clickDrawSelectionArea = () => {
} }
state.selectedCurve = curve state.selectedCurve = curve
state.mapRouteList.push(curve) state.mapRouteList.push(curve)
addEditHistory()
} }
} }
//线 //线
@ -1680,6 +1704,8 @@ const endDrag = (event) => {
curve.actualEndControlX = actualEndControl.actualLocationX curve.actualEndControlX = actualEndControl.actualLocationX
curve.actualEndControlY = actualEndControl.actualLocationY curve.actualEndControlY = actualEndControl.actualLocationY
addEditHistory()
state.currentDragTarget = { index: null, type: null } state.currentDragTarget = { index: null, type: null }
window.removeEventListener('mousemove', handleDrag) window.removeEventListener('mousemove', handleDrag)
window.removeEventListener('mouseup', endDrag) window.removeEventListener('mouseup', endDrag)
@ -1710,7 +1736,7 @@ const handleChooseRoute = (item, index) => {
state.selectedCurve = item state.selectedCurve = item
state.currentDragTarget.index = index state.currentDragTarget.index = index
// //
currentItemIndex.value = -1 state.currentItemIndex = -1
} }
//线 //线
const editMapRouteDialogSubmit = (form) => { const editMapRouteDialogSubmit = (form) => {
@ -1735,7 +1761,7 @@ const editMapRouteDialogSubmit = (form) => {
item.actualEndPointY = disposeEventPoint(form.endPointX, form.endPointY).actualLocationY item.actualEndPointY = disposeEventPoint(form.endPointX, form.endPointY).actualLocationY
} }
}) })
allMapPointInfo.value.forEach((item) => { state.allMapPointInfo.forEach((item) => {
if (item.id === form.startingPointId) { if (item.id === form.startingPointId) {
item.locationX = form.startPointX item.locationX = form.startPointX
item.locationY = form.startPointY item.locationY = form.startPointY
@ -1749,7 +1775,8 @@ const editMapRouteDialogSubmit = (form) => {
item.actualLocationY = disposeEventPoint(form.endPointX, form.endPointY).actualLocationX item.actualLocationY = disposeEventPoint(form.endPointX, form.endPointY).actualLocationX
} }
}) })
allHistoryList.value[currentIndex.value] = JSON.parse(JSON.stringify(allMapPointInfo.value)) //
addEditHistory()
} }
// //
@ -1855,9 +1882,9 @@ const getAllNodeList = async () => {
let list = await MapApi.getPositionMapItemList({ let list = await MapApi.getPositionMapItemList({
positionMapId: imgBgObj.positionMapId positionMapId: imgBgObj.positionMapId
}) })
allMapPointInfo.value = [] state.allMapPointInfo = []
allHistoryList.value = [] state.allHistoryList = []
currentIndex.value = 0 state.currentIndex = 0
list.forEach((item) => { list.forEach((item) => {
item.layerSelectionShow = true // item.layerSelectionShow = true //
item.locationX = Number(item.locationX) item.locationX = Number(item.locationX)
@ -1922,13 +1949,16 @@ const getAllNodeList = async () => {
item.rotatable = true item.rotatable = true
item.lockAspectRatio = true item.lockAspectRatio = true
} }
allMapPointInfo.value.push(item) state.allMapPointInfo.push(item)
}) })
allHistoryList.value[0] = JSON.parse(JSON.stringify(allMapPointInfo.value))
} }
//线 //线
const getAllMapRoute = async () => { const getAllMapRoute = async () => {
state.mapRouteList = await MapApi.getPositionMapLineByPositionMapId(imgBgObj.positionMapId) state.mapRouteList = await MapApi.getPositionMapLineByPositionMapId(imgBgObj.positionMapId)
state.allHistoryList[0] = {
allMapPointInfo: JSON.parse(JSON.stringify(state.allMapPointInfo)),
mapRouteList: JSON.parse(JSON.stringify(state.mapRouteList))
}
} }
// //
const saveMap = async () => { const saveMap = async () => {
@ -1954,7 +1984,7 @@ const saveMap = async () => {
} }
// //
const saveNodeList = async () => { const saveNodeList = async () => {
let list = allHistoryList.value[currentIndex.value] let list = state.allMapPointInfo
list.forEach((item) => { list.forEach((item) => {
if (item.type === 7) { if (item.type === 7) {
item.dataObj.positionMapId = imgBgObj.positionMapId item.dataObj.positionMapId = imgBgObj.positionMapId
@ -1976,7 +2006,7 @@ const saveMapRoute = async () => {
} }
// //
const layerSelectionSuccess = (typeList) => { const layerSelectionSuccess = (typeList) => {
allHistoryList.value[currentIndex.value].forEach((item) => { state.allMapPointInfo.forEach((item) => {
// type layerSelectionShow false // type layerSelectionShow false
if (typeList.includes(item.type)) { if (typeList.includes(item.type)) {
item.layerSelectionShow = false item.layerSelectionShow = false
@ -2013,7 +2043,6 @@ const disposeEventPoint = (x, y) => {
const actualLocationX = Number(imgBgObj.origin[0]) + Number(x) * Number(imgBgObj.resolution) const actualLocationX = Number(imgBgObj.origin[0]) + Number(x) * Number(imgBgObj.resolution)
const actualLocationY = const actualLocationY =
Number(imgBgObj.origin[1]) + (Number(imgBgObj.height) - Number(y)) * Number(imgBgObj.resolution) Number(imgBgObj.origin[1]) + (Number(imgBgObj.height) - Number(y)) * Number(imgBgObj.resolution)
return { return {
actualLocationX, actualLocationX,
actualLocationY actualLocationY
@ -2027,7 +2056,7 @@ document.onmousedown = function (e) {
state.mapRouteList[state.currentDragTarget.index].isSelected = false state.mapRouteList[state.currentDragTarget.index].isSelected = false
state.currentDragTarget = { index: null, type: null } state.currentDragTarget = { index: null, type: null }
} }
currentItemIndex.value = -1 state.currentItemIndex = -1
} }
} }
// //
@ -2035,8 +2064,57 @@ window.document.oncontextmenu = function () {
return false return false
} }
//
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('复制成功')
} 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()
} else if (event.key === 'z') {
//
backPreviousStep()
}
}
}
onMounted(() => { onMounted(() => {
getMapList() getMapList()
window.addEventListener('keydown', handleKeyDown)
})
onUnmounted(() => {
window.removeEventListener('keydown', handleKeyDown)
}) })
</script> </script>