路径编辑

This commit is contained in:
yyy 2025-02-18 17:32:30 +08:00
parent 06ede04e13
commit 8a7518777a
2 changed files with 130 additions and 30 deletions

View File

@ -170,9 +170,9 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
const message = useMessage() //
const props = defineProps({
positionMapId: {
type: String,
default: () => ''
imgBgObj: {
type: Object,
default: () => {}
}
})
@ -212,6 +212,34 @@ const submitForm = async (formEl) => {
if (!formEl) return
await formEl.validate(async (valid, fields) => {
if (valid) {
let actualStartPoint = disposeEventPoint(form.value.startPointX, form.value.startPointY)
let actualEndPoint = disposeEventPoint(form.value.endPointX, form.value.endPointY)
form.value.actualStartPointX = actualStartPoint.actualLocationX //x
form.value.actualStartPointY = actualStartPoint.actualLocationY //y
form.value.actualEndPointX = actualEndPoint.actualLocationX //x
form.value.actualEndPointY = actualEndPoint.actualLocationY //y
if (form.value.method === 1) {
let actualBeginControl = disposeEventPoint(
form.value.beginControlX,
form.value.beginControlY
)
let actualEndControl = disposeEventPoint(form.value.endControlX, form.value.endControlY)
form.value.actualBeginControlX = actualBeginControl.actualLocationX //x
form.value.actualBeginControlY = actualBeginControl.actualLocationX //y
form.value.actualEndControlX = actualEndControl.actualLocationX //x
form.value.actualEndControlY = actualEndControl.actualLocationX //y
} else {
form.value.beginControlX = 0
form.value.beginControlY = 0
form.value.endControlX = 0
form.value.endControlY = 0
form.value.actualBeginControlX = 0
form.value.actualBeginControlY = 0
form.value.actualEndControlX = 0
form.value.actualEndControlY = 0
}
emit('editMapRouteDialogSubmit', form.value)
dialogFormVisible.value = false
}
@ -232,6 +260,20 @@ const methodChange = (e) => {
}
}
//x y
const disposeEventPoint = (x, y) => {
const actualLocationX =
Number(props.imgBgObj.origin[0]) + Number(x) * Number(props.imgBgObj.resolution)
const actualLocationY =
Number(props.imgBgObj.origin[1]) +
(Number(props.imgBgObj.height) - Number(y)) * Number(props.imgBgObj.resolution)
return {
actualLocationX,
actualLocationY
}
}
defineExpose({ open }) // open
</script>

View File

@ -161,9 +161,8 @@
:style="{
width: item.locationWide + 'px',
height: item.locationDeep + 'px',
border: ' 1px dashed #000',
backgroundColor: currentItemIndex === index ? '#f48924' : '#000',
borderRadius: '50%',
backgroundColor: '#000',
zIndex: 999
}"
>
@ -251,17 +250,19 @@
:x2="curve.endPointX"
:y2="curve.endPointY"
:stroke="curve.isSelected ? '#f48924' : '#00329F'"
stroke-width="4"
@click="handleEditRoute(curve, index)"
stroke-width="5"
@click="handleChooseRoute(curve, index)"
@dblclick="handleEditRoute(curve, index)"
/>
<template v-else>
<path
:d="getCurvePath(curve)"
:stroke="curve.isSelected ? '#f48924' : '#00329F'"
stroke-width="4"
stroke-width="5"
fill="none"
@click="handleEditRoute(curve, index)"
@click="handleChooseRoute(curve, index)"
@dblclick="handleEditRoute(curve, index)"
/>
<line
:x1="curve.startPointX"
@ -417,6 +418,7 @@
<editMapRouteDialog
ref="editMapRouteDialogRef"
@editMapRouteDialogSubmit="editMapRouteDialogSubmit"
:imgBgObj="imgBgObj"
/>
</template>
@ -530,6 +532,9 @@ const backNextStep = () => {
const mapClick = (e) => {
const x = disposeEventPoints(e).x
const y = disposeEventPoints(e).y
const actualLocationX = disposeEventPoints(e).actualLocationX
const actualLocationY = disposeEventPoints(e).actualLocationY
//
if (toolbarSwitchType.value === 'drawNodes') {
allMapPointInfo.value.push({
@ -537,6 +542,8 @@ const mapClick = (e) => {
layerSelectionShow: true,
locationX: x,
locationY: y,
actualLocationX: actualLocationX,
actualLocationY: actualLocationY,
locationDeep: 10,
locationWide: 10,
angle: 0,
@ -556,6 +563,8 @@ const mapClick = (e) => {
state.showInputBox = true
state.inputBoxStyle.locationX = x
state.inputBoxStyle.locationY = y
state.inputBoxStyle.actualLocationX = actualLocationX
state.inputBoxStyle.actualLocationY = actualLocationY
//
setTimeout(() => {
@ -569,11 +578,9 @@ const mapClick = (e) => {
}
//
const textFormSuccess = (form) => {
state.inputBoxStyle = {
fontSize: `${form.fontSize}`,
fontFamily: `${form.fontFamily}`,
fontColor: `${form.fontColor}`
}
state.inputBoxStyle.fontSize = `${form.fontSize}`
state.inputBoxStyle.fontFamily = `${form.fontFamily}`
state.inputBoxStyle.fontColor = `${form.fontColor}`
}
//
const handleInputEnd = () => {
@ -584,6 +591,8 @@ const handleInputEnd = () => {
positionMapId: imgBgObj.positionMapId, //id
locationX: state.inputBoxStyle.locationX, //x
locationY: state.inputBoxStyle.locationY, //y
actualLocationX: state.inputBoxStyle.actualLocationX,
actualLocationY: state.inputBoxStyle.actualLocationY,
locationDeep: '', //h
locationWide: '', //w
angle: 0, //
@ -795,7 +804,9 @@ const state = reactive({
fontSize: '14',
fontColor: '#000000',
locationX: 0,
locationY: 0
locationY: 0,
actualLocationX: 0,
actualLocationY: 0
}, //
inputBoxValue: '', //
isShowLayer: false, //
@ -1119,7 +1130,12 @@ const clickDrawSelectionArea = () => {
//
let binLocation = state.drawSelectionPointList.filter((item) => item.type === 2)
//
let routeList = state.drawSelectionPointList.filter((item) => item.type === 1)
// let routeList = state.drawSelectionPointList.filter((item) => item.type === 1)
let routeList = state.drawSelectionPointList
let isHaveId = binLocation.every((item) => {
item.id
})
if (toolbarSwitchType.value === 'lineLibrary') {
//线
@ -1131,24 +1147,44 @@ const clickDrawSelectionArea = () => {
message.warning('您选择的库位不在一条直线上')
return
}
let isHaveId = binLocation.every((item) => {
return item.id
})
if (!isHaveId) {
message.warning('您选择的库位存在未保存的')
return
}
lineLibrarySettingDialogRef.value.open(binLocation)
}
//
if (toolbarSwitchType.value === 'region') {
//
if (binLocation.length < 1) {
message.warning('至少选择两个库位')
} else {
itemAreaSettingDialogRef.value.open(binLocation)
return
}
let isHaveId = binLocation.every((item) => {
return item.id
})
if (!isHaveId) {
message.warning('您选择的库位存在未保存的')
return
}
itemAreaSettingDialogRef.value.open(binLocation)
}
if (toolbarSwitchType.value === 'drawRoute') {
//
if (routeList.length !== 2) {
message.warning('只能选择两个路径点')
return
}
let isHaveId = routeList.every((item) => {
return item.id
})
if (!isHaveId) {
message.warning('您选择的路径点存在未保存的')
return
}
console.log(routeList)
let curve = {
isSelected: false, //
startingPointId: routeList[0].id,
@ -1157,6 +1193,14 @@ const clickDrawSelectionArea = () => {
startPointY: routeList[0].locationY + routeList[0].locationDeep / 2, //
endPointX: routeList[1].locationX + routeList[1].locationWide / 2, //
endPointY: routeList[1].locationY + routeList[1].locationWide / 2, //
actualStartPointX: routeList[0].actualLocationX, //x
actualStartPointY: routeList[0].actualLocationY, //y
actualEndPointX: routeList[1].actualLocationX, //x
actualEndPointY: routeList[1].actualLocationY, //y
actualBeginControlX: '', //x
actualBeginControlY: '', //y
actualEndControlX: '', //x
actualEndControlY: '', //y
beginControlX: 0, //x
beginControlY: 0, //y
endControlX: 0, //x
@ -1246,7 +1290,7 @@ const endDrag = () => {
const getCurvePath = (curve) => {
return `M ${curve.startPointX} ${curve.startPointY} C ${curve.beginControlX} ${curve.beginControlY}, ${curve.endControlX} ${curve.endControlY}, ${curve.endPointX} ${curve.endPointY}`
}
//线
//线
const handleEditRoute = (item, index) => {
state.mapRouteList.forEach((curve, i) => {
curve.isSelected = i === index
@ -1255,6 +1299,14 @@ const handleEditRoute = (item, index) => {
state.selectedCurve = item
editMapRouteDialogRef.value.open(JSON.parse(JSON.stringify(item)))
}
//
const handleChooseRoute = (item, index) => {
state.mapRouteList.forEach((curve, i) => {
curve.isSelected = i === index
})
state.selectedCurve = item
state.currentDragTarget.index = index
}
//线
const editMapRouteDialogSubmit = (item) => {
state.mapRouteList[state.currentDragTarget.index] = item
@ -1435,14 +1487,20 @@ const saveMap = async () => {
text: '保存中',
background: 'rgba(255, 255, 255, 0.7)'
})
//
await saveNodeList()
//线
await saveMapRoute()
//loading
loading.close()
message.success('保存成功')
await getAllNodeList()
try {
//
await saveNodeList()
//线
await saveMapRoute()
//
await getAllNodeList()
await getAllMapRoute()
//loading
loading.close()
message.success('保存成功')
} catch (error) {
loading.close()
}
}
//
const saveNodeList = async () => {