路径编辑

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 message = useMessage() //
const props = defineProps({ const props = defineProps({
positionMapId: { imgBgObj: {
type: String, type: Object,
default: () => '' default: () => {}
} }
}) })
@ -212,6 +212,34 @@ const submitForm = async (formEl) => {
if (!formEl) return if (!formEl) return
await formEl.validate(async (valid, fields) => { await formEl.validate(async (valid, fields) => {
if (valid) { 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) emit('editMapRouteDialogSubmit', form.value)
dialogFormVisible.value = false 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 defineExpose({ open }) // open
</script> </script>

View File

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