创建编辑删除仓库点位地图连线

This commit is contained in:
yyy 2025-02-18 11:36:00 +08:00
parent cf90d2c457
commit 87bd656625
3 changed files with 97 additions and 90 deletions

View File

@ -1,6 +1,6 @@
import request from '@/config/axios' import request from '@/config/axios'
//获得任务号 //获得获得库位
export const getHouseLocation = async (id: number) => { export const getHouseLocation = async (id: number) => {
return await request.get({ url: `/system/ware/house-location/get?id=` + id }) return await request.get({ url: `/system/ware/house-location/get?id=` + id })
} }

View File

@ -95,3 +95,18 @@ export const houseLocationGetByMapItemId = async (params) => {
export const updateHouseLocation = async (data) => { export const updateHouseLocation = async (data) => {
return await request.put({ url: `/system/ware/house-location/update`, data }) return await request.put({ url: `/system/ware/house-location/update`, data })
} }
//创建编辑删除仓库点位地图连线
export const createOrEditOrDelPositionMapLine = async (positionMapId, data) => {
return await request.post({
url: `/system/position-map-line/createOrEditOrDel?positionMapId=${positionMapId}`,
data
})
}
// 获得仓库点位地图连线
export const getPositionMapLineById = async (id: number) => {
return await request.get({ url: `/system/position-map-line/get?id=` + id })
}
// 通过地图id获取连线列表
export const getPositionMapLineByPositionMapId = async (positionMapId: number) => {
return await request.get({ url: `/system/position-map-line/list?positionMapId=` + positionMapId })
}

View File

@ -249,33 +249,39 @@
<svg <svg
:width="imgBgObj.width" :width="imgBgObj.width"
:height="imgBgObj.height" :height="imgBgObj.height"
style="position: absolute; top: 0; left: 0" style="position: absolute; top: 0; left: 0; z-index: 9"
> >
<path <path
v-for="(curve, index) in state.mapRouteList" v-for="(curve, index) in state.mapRouteList"
:key="index" :key="index"
:d="getCurvePath(curve)" :d="getCurvePath(curve)"
:stroke="curve.isSelected ? 'red' : 'blue'" :stroke="curve.isSelected ? '#f48924' : '#00329F'"
stroke-width="2" stroke-width="3"
fill="none" fill="none"
@mousedown="handleEditRoute(curve)" @click="handleEditRoute(curve, index)"
/> />
<line <line
:x1="state.selectedCurve.startPointX" v-for="(curve, index) in state.mapRouteList"
:y1="state.selectedCurve.startPointY" :key="'start-' + index"
:x2="state.selectedCurve.beginControlX" :x1="curve.startPointX"
:y2="state.selectedCurve.beginControlY" :y1="curve.startPointY"
stroke="gray" :x2="curve.beginControlX"
:y2="curve.beginControlY"
:stroke="curve.isSelected ? '#f48924' : '#00329F'"
stroke-dasharray="4" stroke-dasharray="4"
stroke-width="2"
/> />
<!-- 第二条控制线 --> <!-- 第二条控制线 -->
<line <line
:x1="state.selectedCurve.endPointX" v-for="(curve, index) in state.mapRouteList"
:y1="state.selectedCurve.endPointY" :key="'end-' + index"
:x2="state.selectedCurve.endControlX" :x1="curve.endPointX"
:y2="state.selectedCurve.endControlY" :y1="curve.endPointY"
stroke="gray" :x2="curve.endControlX"
:y2="curve.endControlY"
:stroke="curve.isSelected ? '#f48924' : '#00329F'"
stroke-dasharray="4" stroke-dasharray="4"
stroke-width="2"
/> />
<circle <circle
v-for="(curve, index) in state.mapRouteList" v-for="(curve, index) in state.mapRouteList"
@ -283,8 +289,8 @@
:cx="curve.beginControlX" :cx="curve.beginControlX"
:cy="curve.beginControlY" :cy="curve.beginControlY"
r="5" r="5"
fill="green" :fill="curve.isSelected ? '#f48924' : '#00329F'"
@mousedown="startDrag(index, 'start')" @mousedown="startDrag(curve, index, 'start')"
/> />
<circle <circle
v-for="(curve, index) in state.mapRouteList" v-for="(curve, index) in state.mapRouteList"
@ -292,8 +298,8 @@
:cx="curve.endControlX" :cx="curve.endControlX"
:cy="curve.endControlY" :cy="curve.endControlY"
r="5" r="5"
fill="green" :fill="curve.isSelected ? '#f48924' : '#00329F'"
@mousedown="startDrag(index, 'end')" @mousedown="startDrag(curve, index, 'end')"
/> />
</svg> </svg>
</div> </div>
@ -414,6 +420,7 @@
<script setup> <script setup>
import JSONBigInt from 'json-bigint' import JSONBigInt from 'json-bigint'
import { ElLoading } from 'element-plus'
import { ref, defineComponent, reactive, nextTick, onMounted } from 'vue' import { ref, defineComponent, reactive, nextTick, onMounted } from 'vue'
import editNodeProperties from './components-tool/editNodeProperties.vue' import editNodeProperties from './components-tool/editNodeProperties.vue'
import textFormToolDialog from './components-tool/textFormToolDialog.vue' import textFormToolDialog from './components-tool/textFormToolDialog.vue'
@ -435,7 +442,6 @@ const mapBackgroundRef = ref()
const inputBoxRef = ref() // const inputBoxRef = ref() //
const message = useMessage() // const message = useMessage() //
const formLoading = ref(false)
const allHistoryList = ref([]) // const allHistoryList = ref([]) //
const currentIndex = ref(0) // const currentIndex = ref(0) //
@ -457,7 +463,6 @@ const resizeEnd = (x, y, w, h, item, index) => {
} }
// //
const dragEnd = (x, y, item, index) => { const dragEnd = (x, y, item, index) => {
console.log('拖拽')
if (x === item.locationX && y === item.locationY) return if (x === item.locationX && y === item.locationY) return
allMapPointInfo.value[index].locationX = x allMapPointInfo.value[index].locationX = x
allMapPointInfo.value[index].locationY = y allMapPointInfo.value[index].locationY = y
@ -497,7 +502,6 @@ const addEditHistory = () => {
currentIndex.value++ currentIndex.value++
} }
interfaceRefreshed.value = true interfaceRefreshed.value = true
console.log(allHistoryList.value, 'allHistoryList')
} }
// //
@ -505,7 +509,6 @@ const backPreviousStep = () => {
if (currentIndex.value > 0) { if (currentIndex.value > 0) {
currentIndex.value-- currentIndex.value--
allMapPointInfo.value = allHistoryList.value[currentIndex.value] allMapPointInfo.value = allHistoryList.value[currentIndex.value]
console.log('撤销', allHistoryList.value[currentIndex.value])
} else { } else {
message.warning('没了老铁') message.warning('没了老铁')
} }
@ -515,7 +518,6 @@ const backNextStep = () => {
if (currentIndex.value < allHistoryList.value.length - 1) { if (currentIndex.value < allHistoryList.value.length - 1) {
currentIndex.value++ currentIndex.value++
allMapPointInfo.value = allHistoryList.value[currentIndex.value] allMapPointInfo.value = allHistoryList.value[currentIndex.value]
console.log('重做', allHistoryList.value[currentIndex.value])
} else { } else {
message.warning('没了老铁') message.warning('没了老铁')
} }
@ -544,8 +546,7 @@ const mapClick = (e) => {
dataList: [], // dataList: [], //
dataObj: {} // dataObj: {} //
}) })
currentIndex.value++ addEditHistory()
allHistoryList.value.push(JSON.parse(JSON.stringify(allMapPointInfo.value)))
} }
// //
if (toolbarSwitchType.value === 'text') { if (toolbarSwitchType.value === 'text') {
@ -800,9 +801,12 @@ const state = reactive({
imageChangeMultiple: 1, // imageChangeMultiple: 1, //
prohibitedOperation: false, // prohibitedOperation: false, //
mapRouteList: [], //线 mapRouteList: [], //线
isDragging: false, // currentDragTarget: {
currentDragTarget: '', // index: null,
selectedCurve: '' // 线 type: null
}, //
selectedCurve: '', // 线
svgZIndex: 9999
}) })
const toolbarClick = (item) => { const toolbarClick = (item) => {
let type = item.switchType let type = item.switchType
@ -1143,6 +1147,9 @@ const clickDrawSelectionArea = () => {
} }
let curve = { let curve = {
isSelected: false, //
startingPointId: routeList[0].id,
endPointId: routeList[1].id,
startPointX: routeList[0].locationX + routeList[0].locationWide / 2, // startPointX: routeList[0].locationX + routeList[0].locationWide / 2, //
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, //
@ -1157,13 +1164,12 @@ const clickDrawSelectionArea = () => {
expansionZoneRight: 0, // expansionZoneRight: 0, //
method: 0, // 0.线 1.线2.线3.线 4.线 method: 0, // 0.线 1.线2.线3.线 4.线
direction: 2, // 1. 2., direction: 2, // 1. 2.,
forwardSpeedLimit: '1.5', // forwardSpeedLimit: 1.5, //
reverseSpeedLimit: '0.4' // reverseSpeedLimit: 0.4, //
toward: 0
} }
state.selectedCurve = curve state.selectedCurve = curve
state.mapRouteList.push(curve) state.mapRouteList.push(curve)
state.currentDragTarget = 'end'
state.isDragging = true
} }
} }
//线 //线
@ -1206,70 +1212,45 @@ const isStraightLine = (binLocation) => {
} }
//线 //线
// //
const dragging = ref() const startDrag = (item, index, type) => {
const startDrag = (index, type) => { handleEditRoute(item, index)
dragging.value = { index, type } state.currentDragTarget = { index, type }
window.addEventListener('mousemove', handleDrag) window.addEventListener('mousemove', handleDrag)
window.addEventListener('mouseup', endDrag) window.addEventListener('mouseup', endDrag)
} }
// //
const handleDrag = (event) => { const handleDrag = (event) => {
if (dragging.value.index !== null) { const x = disposeEventPoints(event).x
const curve = state.mapRouteList[dragging.value.index] const y = disposeEventPoints(event).y
if (dragging.value.type === 'start') {
curve.beginControlX = event.offsetX if (state.currentDragTarget.index !== null) {
curve.beginControlY = event.offsetY const curve = state.mapRouteList[state.currentDragTarget.index]
if (state.currentDragTarget.type === 'start') {
curve.beginControlX = x
curve.beginControlY = y
} else { } else {
curve.endControlX = event.offsetX curve.endControlX = x
curve.endControlY = event.offsetY curve.endControlY = y
} }
} }
} }
// //
const endDrag = () => { const endDrag = () => {
dragging.value = { 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)
} }
//
const handleMouseDown = (event) => {}
//
const handleMouseMove = (event) => {
if (!state.isDragging || !state.selectedCurve) return
const mousePos = disposeEventPoints(event)
//
if (state.currentDragTarget === 'start') {
state.selectedCurve.startPointX = mousePos.x
state.selectedCurve.startPointY = mousePos.y
} else if (state.currentDragTarget === 'end') {
state.selectedCurve.endPointX = mousePos.x
state.selectedCurve.endPointY = mousePos.y
} else if (state.currentDragTarget === 'control1') {
state.selectedCurve.beginControlX = mousePos.x
state.selectedCurve.beginControlY = mousePos.y
} else if (state.currentDragTarget === 'control2') {
state.selectedCurve.endControlX = mousePos.x
state.selectedCurve.endControlY = mousePos.y
}
}
//
const handleMouseUp = (event) => {
state.isDragging = false
state.currentDragTarget = null
}
// 线 // 线
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) => { const handleEditRoute = (item, index) => {
console.log('Selected curve:', item) state.mapRouteList.forEach((curve, i) => {
curve.isSelected = i === index
})
state.selectedCurve = item
console.log('选中路线', item)
} }
// //
@ -1334,8 +1315,7 @@ const imgBgObj = reactive({
floor: '', floor: '',
area: '', area: '',
resolution: 0.05, resolution: 0.05,
// origin: [-54.4, -34.2] origin: [-54.4, -34.2]
origin: [-10.4, 9.1]
}) })
// //
const { query } = useRoute() // const { query } = useRoute() //
@ -1366,6 +1346,7 @@ const getMapData = async (mapInfo) => {
imgBgObj.height = img.naturalHeight imgBgObj.height = img.naturalHeight
console.log(img.naturalWidth, img.naturalHeight) console.log(img.naturalWidth, img.naturalHeight)
getAllNodeList() getAllNodeList()
getAllMapRoute()
} }
// //
img.onerror = () => { img.onerror = () => {
@ -1377,6 +1358,7 @@ const getAllNodeList = async () => {
let list = await MapApi.getPositionMapItemList({ let list = await MapApi.getPositionMapItemList({
positionMapId: imgBgObj.positionMapId positionMapId: imgBgObj.positionMapId
}) })
allMapPointInfo.value = []
list.forEach((item) => { list.forEach((item) => {
item.layerSelectionShow = true // item.layerSelectionShow = true //
item.locationX = Number(item.locationX) item.locationX = Number(item.locationX)
@ -1434,18 +1416,30 @@ const getAllNodeList = async () => {
}) })
allHistoryList.value[0] = JSON.parse(JSON.stringify(allMapPointInfo.value)) allHistoryList.value[0] = JSON.parse(JSON.stringify(allMapPointInfo.value))
} }
//线
const getAllMapRoute = async () => {
state.mapRouteList = await MapApi.getPositionMapLineByPositionMapId(imgBgObj.positionMapId)
}
// //
const saveMap = async () => { const saveMap = async () => {
const loading = ElLoading.service({
lock: true,
text: '保存中',
background: 'rgba(255, 255, 255, 0.7)'
})
// //
await saveNodeList() await saveNodeList()
//线 //线
await saveMapRoute()
//loading
loading.close()
message.success('保存成功')
await getAllNodeList()
} }
// //
const saveNodeList = async () => { const saveNodeList = async () => {
formLoading.value = true
let list = allHistoryList.value[currentIndex.value] let list = allHistoryList.value[currentIndex.value]
list.forEach((item) => { list.forEach((item) => {
if (item.type === 7) { if (item.type === 7) {
item.dataObj.positionMapId = imgBgObj.positionMapId item.dataObj.positionMapId = imgBgObj.positionMapId
@ -1459,13 +1453,11 @@ const saveNodeList = async () => {
item.dataJson = JSON.stringify(item.dataObj) item.dataJson = JSON.stringify(item.dataObj)
} }
}) })
try {
await MapApi.batchSaveOrEditOrDelMapItem(imgBgObj.positionMapId, list) await MapApi.batchSaveOrEditOrDelMapItem(imgBgObj.positionMapId, list)
message.success('创建成功') }
} finally { //线
formLoading.value = false const saveMapRoute = async () => {
} await MapApi.createOrEditOrDelPositionMapLine(imgBgObj.positionMapId, state.mapRouteList)
} }
// //