@ -8,7 +8,7 @@
: width = "170"
trigger = "click"
v - if = "item.switchType === 'move' || item.switchType === 'revolve'"
: disabled = " currentItemIndex === -1"
: disabled = " state. currentItemIndex === -1"
>
< template # reference >
< div
@ -32,7 +32,7 @@
< el -input v -model = " state.moveForm.locationX " placeholder = "请输入" / >
< / e l - f o r m - i t e m >
< el -form -item label = "Y" >
< el -input v -model = " state.moveForm. y " placeholder = "请输入" / >
< el -input v -model = " state.moveForm. locationY " placeholder = "请输入" / >
< / e l - f o r m - i t e m >
< div style = "text-align: right" >
< el -button
@ -203,14 +203,6 @@
< / div >
< 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
class = "map-bg"
: style = " {
@ -236,7 +228,7 @@
v - if = "interfaceRefreshed"
>
< VueDragResizeRotate
v - for = "(item, index) in allHistoryList[currentIndex] "
v - for = "(item, index) in state.allMapPointInfo "
: key = "item.locationX"
: parent = "true"
: x = "Number(item.locationX) - Number(item.locationWide) / 2"
@ -263,7 +255,7 @@
: style = " {
width : item . locationWide + 'px' ,
height : item . locationDeep + 'px' ,
backgroundColor : currentItemIndex === index ? '#f48924' : '#000' ,
backgroundColor : state . currentItemIndex === index ? '#f48924' : '#000' ,
borderRadius : '50%' ,
zIndex : 999
} "
@ -277,7 +269,7 @@
: style = " {
width : item . locationWide + 'px' ,
height : item . locationDeep + 'px' ,
border : currentItemIndex === index ? '1px dashed #000' : 'none'
border : state . currentItemIndex === index ? '1px dashed #000' : 'none'
} "
/ >
<!-- 3 设备点 -- >
@ -291,7 +283,7 @@
: style = " {
width : item . locationWide + 'px' ,
height : item . locationDeep + 'px' ,
border : currentItemIndex === index ? '1px dashed #000' : 'none'
border : state . currentItemIndex === index ? '1px dashed #000' : 'none'
} "
/ >
<!-- 4 停车点 -- >
@ -302,7 +294,7 @@
: style = " {
width : item . locationWide + 'px' ,
height : item . locationDeep + 'px' ,
border : currentItemIndex === index ? '1px dashed #000' : 'none'
border : state . currentItemIndex === index ? '1px dashed #000' : 'none'
} "
/ >
<!-- 5 区域变更点 -- >
@ -313,7 +305,7 @@
: style = " {
width : item . locationWidee + 'px' ,
height : item . locationDeep + 'px' ,
border : currentItemIndex === index ? '1px dashed #000' : 'none'
border : state . currentItemIndex === index ? '1px dashed #000' : 'none'
} "
/ >
<!-- 6 等待点 -- >
@ -324,7 +316,7 @@
: style = " {
width : item . locationWide + 'px' ,
height : item . locationDeep + 'px' ,
border : currentItemIndex === index ? '1px dashed #000' : 'none'
border : state . currentItemIndex === index ? '1px dashed #000' : 'none'
} "
/ >
< div
@ -333,7 +325,7 @@
color : item . fontColor ,
fontSize : item . fontSize + 'px' ,
fontFamily : item . fontFamily ,
border : currentItemIndex === index ? '1px dashed #000' : 'none'
border : state . currentItemIndex === index ? '1px dashed #000' : 'none'
} "
>
{ { item . text } }
@ -348,7 +340,6 @@
style = "position: absolute; top: 0; left: 0; z-index: 9"
id = "svgId"
>
< template v-for ="(curve, index) in state.mapRouteList" :key ="index" >
<!-- 实时绘制当前直线 -- >
< line
v - if = "state.isDrawing && toolbarSwitchType === 'clickDrawRoute'"
@ -359,7 +350,8 @@
stroke = "#00329F"
stroke - width = "5"
/ >
< template v-if ="state.mapRouteList.length > 0" >
< template v-for ="(curve, index) in state.mapRouteList" :key ="index" >
<!-- 直线 -- >
< line
v - if = "curve.method === 0"
@ -384,6 +376,7 @@
/ >
<!-- 第一条控制线 -- >
< line
v - if = "state.currentDragTarget.index == index"
: x1 = "Number(curve.startPointX)"
: y1 = "Number(curve.startPointY)"
: x2 = "curve.beginControlX"
@ -394,6 +387,7 @@
/ >
<!-- 第二条控制线 -- >
< line
v - if = "state.currentDragTarget.index == index"
: x1 = "Number(curve.endPointX)"
: y1 = "Number(curve.endPointY)"
: x2 = "curve.endControlX"
@ -403,6 +397,7 @@
stroke - width = "2"
/ >
< circle
v - if = "state.currentDragTarget.index == index"
id = "startCircle"
: cx = "curve.beginControlX"
: cy = "curve.beginControlY"
@ -411,6 +406,7 @@
@ mousedown = "startDrag(curve, index, 'start')"
/ >
< circle
v - if = "state.currentDragTarget.index == index"
id = "endCircle"
: cx = "curve.endControlX"
: cy = "curve.endControlY"
@ -420,6 +416,7 @@
/ >
< / template >
< / template >
< / template >
< / svg >
< / div >
< / div >
@ -505,7 +502,6 @@
class = "input-box-class"
/ >
< / div >
< / m a p - s c a l e - t o o l >
< / div >
<!-- 节点编辑 -- >
@ -587,16 +583,6 @@ const inputBoxRef = ref() //文字输入框
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 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 y = Number ( locationY ) + Number ( item . locationDeep ) / 2
allMapPointInfo. value [ index ] . locationX = x
allMapPointInfo. value [ index ] . locationY = y
allMapPointInfo. value [ index ] . locationWide = w
allMapPointInfo. value [ index ] . locationDeep = h
state. allMapPointInfo[ index ] . locationX = x
state. allMapPointInfo[ index ] . locationY = y
state. allMapPointInfo[ index ] . locationWide = w
state. allMapPointInfo[ index ] . locationDeep = h
addEditHistory ( )
state . mapRouteList . forEach ( ( route ) => {
@ -631,6 +617,7 @@ const resizeEnd = (locationX, locationY, w, h, item, index) => {
} )
} )
}
/ / 拖 拽 停 止
const dragEnd = ( locationX , locationY , item , index ) => {
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
let actualPoint = disposeEventPoint ( x , y )
allMapPointInfo. value [ index ] . locationX = x
allMapPointInfo. value [ index ] . locationY = y
allMapPointInfo. value [ index ] . actualStartPointX = actualPoint . actualLocationX
allMapPointInfo. value [ index ] . actualStartPointY = actualPoint . actualLocationY
state. allMapPointInfo[ index ] . locationX = x
state. allMapPointInfo[ index ] . locationY = y
state. allMapPointInfo[ index ] . actualStartPointX = actualPoint . actualLocationX
state. allMapPointInfo[ index ] . actualStartPointY = actualPoint . actualLocationY
addEditHistory ( )
/ / 更 改 路 线 里 的
state . mapRouteList . forEach ( ( route ) => {
@ -665,26 +652,26 @@ const dragEnd = (locationX, locationY, item, index) => {
}
/ / 旋 转
const rotateEnd = ( angle , item , index ) => {
allMapPointInfo. value [ index ] . angle = angle
state. allMapPointInfo[ index ] . angle = angle
addEditHistory ( )
}
/ / 节 点 选 中
const editNodePropertiesRef = ref ( )
const activatedHandle = ( item , index ) => {
currentItemIndex. value = index
state. currentItemIndex = index
/ / 让 路 线 不 选 中
state . selectedCurve = ''
if ( state . currentDragTarget. index !== null ) {
if ( state . mapRouteList. length > 0 && state . currentDragTarget. index !== null ) {
state . mapRouteList [ state . currentDragTarget . index ] . isSelected = false
state . currentDragTarget = { index : null , type : null }
}
/ / 节 点 编 辑
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 )
}
}
@ -694,31 +681,42 @@ const deactivatedHandle = () => {}
/ / 添 加 历 史 记 录
const addEditHistory = ( ) => {
/ / 要 判 断 是 不 是 在 最 新 的 记 录 上 修 改 如 果 不 是 要 把 c u r r e n t I n d e x 之 后 的 记 录 都 删 掉 保 持 当 前 修 改 是 最 新 的
if ( currentIndex . value !== allHistoryList . value . length - 1 ) {
allHistoryList . value = allHistoryList . value . splice ( 0 , currentIndex . value )
currentIndex . value = allHistoryList . value . length
allHistoryList . value . push ( JSON . parse ( JSON . stringify ( allMapPointInfo . value ) ) )
if ( state . currentIndex !== state . allHistoryList . length - 1 ) {
state . allHistoryList = state . allHistoryList . splice ( 0 , state . currentIndex )
state . currentIndex = state . allHistoryList . length
state . allHistoryList . push ( {
allMapPointInfo : JSON . parse ( JSON . stringify ( state . allMapPointInfo ) ) ,
mapRouteList : JSON . parse ( JSON . stringify ( state . mapRouteList ) )
} )
} else {
allHistoryList . value . push ( JSON . parse ( JSON . stringify ( allMapPointInfo . value ) ) )
currentIndex . value ++
state . allHistoryList . push ( {
allMapPointInfo : JSON . parse ( JSON . stringify ( state . allMapPointInfo ) ) ,
mapRouteList : JSON . parse ( JSON . stringify ( state . mapRouteList ) )
} )
state . currentIndex ++
}
interfaceRefreshed . value = true
}
/ / 上 一 步
const backPreviousStep = ( ) => {
if ( currentIndex . value > 0 ) {
currentIndex . value --
allMapPointInfo . value = allHistoryList . value [ currentIndex . value ]
console . log ( state . currentIndex )
console . log ( state . allMapPointInfo )
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 {
message . warning ( '没了老铁' )
}
}
/ / 下 一 步
const backNextStep = ( ) => {
if ( currentIndex . value < allHistoryList . value . length - 1 ) {
currentIndex . value ++
allMapPointInfo . value = allHistoryList . value [ currentIndex . value ]
if ( state . currentIndex < state . allHistoryList . length - 1 ) {
state . currentIndex ++
state . allMapPointInfo = state . allHistoryList [ state . currentIndex ] ? . allMapPointInfo || [ ]
state . mapRouteList = state . allHistoryList [ state . currentIndex ] ? . mapRouteList || [ ]
} else {
message . warning ( '没了老铁' )
}
@ -733,7 +731,7 @@ const mapClick = (e) => {
/ / 绘 制 节 点
if ( toolbarSwitchType . value === 'drawNodes' ) {
allMapPointInfo. value . push ( {
state. allMapPointInfo. push ( {
positionMapId : imgBgObj . positionMapId , / / 地 图 的 i d
layerSelectionShow : true ,
locationX : x ,
@ -782,7 +780,7 @@ const textFormSuccess = (form) => {
const handleInputEnd = ( ) => {
if ( state . inputBoxValue ) {
state . showInputBox = false
allMapPointInfo. value . push ( {
state. allMapPointInfo. push ( {
type : 7 , / / 类 型 7 文 字
positionMapId : imgBgObj . positionMapId , / / 地 图 的 i d
locationX : state . inputBoxStyle . locationX , / / x
@ -810,9 +808,7 @@ const handleInputEnd = () => {
}
/ / 编 辑 节 点 成 功
const submitNodeSuccess = ( form ) => {
allMapPointInfo . value [ currentItemIndex . value ] = form
allHistoryList . value [ currentIndex . value ] [ currentItemIndex . value ] = form
state . allMapPointInfo [ state . currentItemIndex ] = form
/ / 节 点 位 置 改 变 通 知 路 径 里 面 的 节 点 也 改 变
state . mapRouteList . forEach ( ( item ) => {
if ( form . id === item . startingPointId ) {
@ -832,6 +828,7 @@ const submitNodeSuccess = (form) => {
item . actualEndPointY = disposeEventPoint ( form . locationX , form . locationY ) . actualLocationY
}
} )
addEditHistory ( )
}
/ / 工 具 栏 点 击
@ -1036,21 +1033,26 @@ const state = reactive({
measureDistancesNum : 0 , / / 存 储 两 点 之 间 的 距 离
imageChangeMultiple : 1 , / / 图 片 放 大 缩 小 的 倍 数
prohibitedOperation : false , / / 禁 止 操 作 在 框 选 测 距 等 操 作 时 , 禁 止 所 有 拖 动 等 操 作
mapRouteList : [ ] , / / 仓 库 点 位 地 图 连 线
currentDragTarget : {
index : null ,
type : null
} , / / 当 前 拖 拽 的 目 标 ( 起 点 、 终 点 、 控 制 点 )
selectedCurve : '' , / / 当 前 选 中 的 曲 线
startDrawPointIndex : - 1 , / / 起 始 点 的 索 引
startDrawPoint : null ,
isDrawing : false ,
currentDrawX : 0 ,
currentDrawY : 0
startDrawPoint : null , / / 绘 制 路 线 开 始 的 点
isDrawing : false , / / 正 在 绘 制
currentDrawX : 0 , / / 正 在 绘 制 的 x 轴 坐 标
currentDrawY : 0 , / / 正 在 绘 制 的 y 轴 坐 标
allHistoryList : [ ] , / / 所 有 的 历 史 记 录 [ { a l l M a p P o i n t I n f o : [ ] , m a p R o u t e L i s t : [ ] } ]
allMapPointInfo : [ ] , / / 当 前 页 面 上 的 所 有 节 点 的 列 表
mapRouteList : [ ] , / / 当 前 页 面 上 所 有 路 线 的 列 表
currentIndex : 0 , / / 当 前 处 在 哪 条 历 史 记 录
currentItemIndex : - 1 / / 当 前 处 在 哪 个 工 具
} )
const toolbarClick = ( item ) => {
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 ( '请先选择要操作的对象' )
return
}
@ -1058,7 +1060,7 @@ const toolbarClick = (item) => {
if (
type === 'delete' &&
state . currentDragTarget . index === null &&
currentItemIndex. value === - 1
state. currentItemIndex === - 1
) {
message . warning ( '请先选择要操作的对象' )
return
@ -1125,7 +1127,7 @@ const toolbarClick = (item) => {
break
case 'saveAs' :
/ / 另 存 为 存 为 j s o n 文 件 无 法 直 接 访 问 用 户 的 文 件 系 统 不 能 选 择 存 在 那 个 文 件 夹 里 面
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 url = URL . createObjectURL ( blob )
@ -1149,7 +1151,7 @@ const toolbarClick = (item) => {
break
case 'copy' :
/ / 复 制
let copyMapItem = allHistoryList. value [ currentIndex . value ] [ currentItemIndex . value ]
let copyMapItem = state. allMapPointInfo [ state . currentItemIndex ]
state . copyMapItem = {
positionMapId : copyMapItem . positionMapId ,
locationX : copyMapItem . locationX ,
@ -1172,18 +1174,20 @@ const toolbarClick = (item) => {
let copyObj = JSON . parse ( JSON . stringify ( state . copyMapItem ) )
copyObj . locationX = Number ( copyObj . locationX ) + 50
copyObj . locationY = Number ( copyObj . locationY ) + 50
allMapPointInfo. value . push ( copyObj )
state. allMapPointInfo. push ( copyObj )
addEditHistory ( )
break
case 'delete' :
/ / 删 除
if ( currentItemIndex. value !== - 1 ) {
allMapPointInfo. value . splice ( currentItemIndex . value , 1 )
addEditHistory( )
if ( state. currentItemIndex !== - 1 ) {
state. allMapPointInfo . splice ( state . currentItemIndex , 1 )
state. currentItemIndex = - 1
}
if ( state . currentDragTarget . index !== null ) {
state . mapRouteList . splice ( state . currentDragTarget . index , 1 )
state . currentDragTarget . index = null
}
addEditHistory ( )
break
case 'tools' :
/ / 工 具
@ -1256,7 +1260,7 @@ const toolbarClick = (item) => {
case 'larger' :
/ / 放 大
if ( state . imageChangeMultiple < 3 ) {
state . imageChangeMultiple *= 1.2
state . imageChangeMultiple += 0.1
} else {
message . warning ( '不能在放大了' )
}
@ -1264,7 +1268,7 @@ const toolbarClick = (item) => {
case 'smaller' :
/ / 缩 小
if ( state . imageChangeMultiple > 0.3 ) {
state . imageChangeMultiple *= 0.8
state . imageChangeMultiple -= 0.1
} else {
message . warning ( '不能在缩小了' )
}
@ -1291,7 +1295,7 @@ const toolbarClick = (item) => {
break
case 'equipment' :
/ / 设 备
let equipmentList = allHistoryList. value [ currentIndex . value ] . filter ( ( item ) => {
let equipmentList = state. allMapPointInfo . filter ( ( item ) => {
return item . type === 3
} )
equipmentToolDialogRef . value . open ( equipmentList )
@ -1301,25 +1305,35 @@ const toolbarClick = (item) => {
/ / 移 动 工 具 表 单 提 交
const moveFormSubmit = ( ) => {
allHistoryList . value [ currentIndex . value ] [ currentItemIndex . value ] . locationX =
state . moveForm . locationX
allHistoryList . value [ currentIndex . value ] [ currentItemIndex . value ] . locationY =
state . moveForm . locationY
state . allMapPointInfo [ state . currentItemIndex ] . locationX = Number ( state . moveForm . locationX )
state . allMapPointInfo [ state . currentItemIndex ] . locationY = Number ( state . moveForm . locationY )
addEditHistory ( )
}
/ / 旋 转 工 具 表 单 提 交
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 ) => {
let list = allHistoryList. value [ currentIndex . value ]
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
}
}
/ / 开 始 框 选 绘 制
const startDrawSelection = ( event ) => {
@ -1396,8 +1410,19 @@ 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 = allHistoryList . value [ currentIndex . value ]
let list = state. allMapPointInfo
const endPoint = list [ endPointIndex ]
const newLine = {
startPointX : state . startDrawPoint . locationX ,
@ -1455,6 +1480,7 @@ const endDrawSelection = (event) => {
endWidth : endPoint . locationWide , / / 终 点 宽
endHigh : endPoint . locationDeep / / 终 点 高
} )
addEditHistory ( )
}
}
/ / 重 置 状 态
@ -1473,7 +1499,7 @@ const endDrawSelection = (event) => {
const findClosestPoint = ( x , y ) => {
let minDistance = Infinity
let closestIndex = null
let list = allHistoryList. value [ currentIndex . value ]
let list = state. allMapPointInfo
list . forEach ( ( point , index ) => {
const distance = Math . sqrt ( ( point . locationX - x ) * * 2 + ( point . locationY - y ) * * 2 )
if ( distance < minDistance && distance < point . locationWide ) {
@ -1484,10 +1510,9 @@ const findClosestPoint = (x, y) => {
} )
return closestIndex
}
/ / 点 击 区 域
const clickDrawSelectionArea = ( ) => {
let points = allHistoryList. value [ currentIndex . value ]
let points = state. allMapPointInfo
state . drawSelectionPointList = [ ]
state . allDrawSelectionAreaBox . forEach ( ( box ) => {
@ -1511,8 +1536,6 @@ const clickDrawSelectionArea = () => {
/ / l e t r o u t e L i s t = s t a t e . d r a w S e l e c t i o n P o i n t L i s t . f i l t e r ( ( i t e m ) = > i t e m . t y p e = = = 1 )
let routeList = state . drawSelectionPointList
console . log ( routeList )
let isHaveId = binLocation . every ( ( item ) => {
item . id
} )
@ -1600,6 +1623,7 @@ const clickDrawSelectionArea = () => {
}
state . selectedCurve = curve
state . mapRouteList . push ( curve )
addEditHistory ( )
}
}
/ / 计 算 是 不 是 在 同 一 条 直 线 的
@ -1680,6 +1704,8 @@ const endDrag = (event) => {
curve . actualEndControlX = actualEndControl . actualLocationX
curve . actualEndControlY = actualEndControl . actualLocationY
addEditHistory ( )
state . currentDragTarget = { index : null , type : null }
window . removeEventListener ( 'mousemove' , handleDrag )
window . removeEventListener ( 'mouseup' , endDrag )
@ -1710,7 +1736,7 @@ const handleChooseRoute = (item, index) => {
state . selectedCurve = item
state . currentDragTarget . index = index
/ / 让 节 点 不 选 中
currentItemIndex. value = - 1
state. currentItemIndex = - 1
}
/ / 编 辑 路 线 成 功
const editMapRouteDialogSubmit = ( form ) => {
@ -1735,7 +1761,7 @@ const editMapRouteDialogSubmit = (form) => {
item . actualEndPointY = disposeEventPoint ( form . endPointX , form . endPointY ) . actualLocationY
}
} )
allMapPointInfo. value . forEach ( ( item ) => {
state. allMapPointInfo. forEach ( ( item ) => {
if ( item . id === form . startingPointId ) {
item . locationX = form . startPointX
item . locationY = form . startPointY
@ -1749,7 +1775,8 @@ const editMapRouteDialogSubmit = (form) => {
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 ( {
positionMapId : imgBgObj . positionMapId
} )
allMapPointInfo. value = [ ]
allHistoryList. value = [ ]
currentIndex. value = 0
state. allMapPointInfo = [ ]
state. allHistoryList = [ ]
state. currentIndex = 0
list . forEach ( ( item ) => {
item . layerSelectionShow = true / / 用 于 图 层
item . locationX = Number ( item . locationX )
@ -1922,13 +1949,16 @@ const getAllNodeList = async () => {
item . rotatable = true
item . lockAspectRatio = true
}
allMapPointInfo. value . push ( item )
state. allMapPointInfo. push ( item )
} )
allHistoryList . value [ 0 ] = JSON . parse ( JSON . stringify ( allMapPointInfo . value ) )
}
/ / 获 取 所 有 的 路 线
const getAllMapRoute = async ( ) => {
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 ( ) => {
@ -1954,7 +1984,7 @@ const saveMap = async () => {
}
/ / 节 点 的 保 存
const saveNodeList = async ( ) => {
let list = allHistoryList. value [ currentIndex . value ]
let list = state. allMapPointInfo
list . forEach ( ( item ) => {
if ( item . type === 7 ) {
item . dataObj . positionMapId = imgBgObj . positionMapId
@ -1976,7 +2006,7 @@ const saveMapRoute = async () => {
}
/ / 筛 选 图 层
const layerSelectionSuccess = ( typeList ) => {
allHistoryList. value [ currentIndex . value ] . forEach ( ( item ) => {
state. allMapPointInfo . forEach ( ( item ) => {
/ / 如 果 t y p e 存 在 于 第 一 个 数 组 中 , 则 将 l a y e r S e l e c t i o n S h o w 设 置 为 f a l s e
if ( typeList . includes ( item . type ) ) {
item . layerSelectionShow = false
@ -2013,7 +2043,6 @@ const disposeEventPoint = (x, y) => {
const actualLocationX = Number ( imgBgObj . origin [ 0 ] ) + Number ( x ) * Number ( imgBgObj . resolution )
const actualLocationY =
Number ( imgBgObj . origin [ 1 ] ) + ( Number ( imgBgObj . height ) - Number ( y ) ) * Number ( imgBgObj . resolution )
return {
actualLocationX ,
actualLocationY
@ -2027,7 +2056,7 @@ document.onmousedown = function (e) {
state . mapRouteList [ state . currentDragTarget . index ] . isSelected = false
state . currentDragTarget = { index : null , type : null }
}
currentItemIndex. value = - 1
state. currentItemIndex = - 1
}
}
/ / 阻 止 默 认 菜 单 弹 出
@ -2035,8 +2064,57 @@ window.document.oncontextmenu = function () {
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 ( ( ) => {
getMapList ( )
window . addEventListener ( 'keydown' , handleKeyDown )
} )
onUnmounted ( ( ) => {
window . removeEventListener ( 'keydown' , handleKeyDown )
} )
< / script >