Merge branch 'xhf' of http://git.znkjfw.com/ak/zn-admin-vue3-wcs into xhf
This commit is contained in:
commit
fa937ea0f0
@ -1,6 +1,6 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
//获得任务号
|
||||
//获得获得库位
|
||||
export const getHouseLocation = async (id: number) => {
|
||||
return await request.get({ url: `/system/ware/house-location/get?id=` + id })
|
||||
}
|
||||
|
@ -94,4 +94,19 @@ export const houseLocationGetByMapItemId = async (params) => {
|
||||
// 更新库位
|
||||
export const updateHouseLocation = async (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 })
|
||||
}
|
||||
|
@ -1,189 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- SVG 画布 -->
|
||||
<svg
|
||||
ref="svgRef"
|
||||
width="500"
|
||||
height="300"
|
||||
@mousedown="handleMouseDown"
|
||||
@mousemove="handleMouseMove"
|
||||
@mouseup="handleMouseUp"
|
||||
>
|
||||
<!-- 绘制所有曲线 -->
|
||||
<path
|
||||
v-for="(curve, index) in curveList"
|
||||
:key="index"
|
||||
:d="getCurvePath(curve)"
|
||||
stroke="#000"
|
||||
fill="none"
|
||||
stroke-width="2"
|
||||
:class="{ selected: selectedCurve === curve }"
|
||||
@click="svgClick(curve)"
|
||||
/>
|
||||
<!-- 绘制控制点和连线 -->
|
||||
<line
|
||||
v-if="selectedCurve"
|
||||
:x1="selectedCurve.start.x"
|
||||
:y1="selectedCurve.start.y"
|
||||
:x2="selectedCurve.control1.x"
|
||||
:y2="selectedCurve.control1.y"
|
||||
stroke="gray"
|
||||
stroke-dasharray="2"
|
||||
/>
|
||||
<line
|
||||
v-if="selectedCurve"
|
||||
:x1="selectedCurve.end.x"
|
||||
:y1="selectedCurve.end.y"
|
||||
:x2="selectedCurve.control2.x"
|
||||
:y2="selectedCurve.control2.y"
|
||||
stroke="gray"
|
||||
stroke-dasharray="2"
|
||||
/>
|
||||
<!-- 绘制起点、终点和控制点 -->
|
||||
<circle
|
||||
v-for="(curve, index) in curveList"
|
||||
:key="'start' + index"
|
||||
:cx="curve.start.x"
|
||||
:cy="curve.start.y"
|
||||
r="5"
|
||||
fill="red"
|
||||
@mousedown="startDrag($event, curve, 'start')"
|
||||
/>
|
||||
<circle
|
||||
v-for="(curve, index) in curveList"
|
||||
:key="'end' + index"
|
||||
:cx="curve.end.x"
|
||||
:cy="curve.end.y"
|
||||
r="5"
|
||||
fill="red"
|
||||
@mousedown="startDrag($event, curve, 'end')"
|
||||
/>
|
||||
<circle
|
||||
v-if="selectedCurve"
|
||||
:cx="selectedCurve.control1.x"
|
||||
:cy="selectedCurve.control1.y"
|
||||
r="5"
|
||||
fill="green"
|
||||
@mousedown="startDrag($event, selectedCurve, 'control1')"
|
||||
/>
|
||||
<circle
|
||||
v-if="selectedCurve"
|
||||
:cx="selectedCurve.control2.x"
|
||||
:cy="selectedCurve.control2.y"
|
||||
r="5"
|
||||
fill="green"
|
||||
@mousedown="startDrag($event, selectedCurve, 'control2')"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<!-- 显示控制点坐标 -->
|
||||
<div class="points" v-if="selectedCurve">
|
||||
<p>起点: ({{ selectedCurve.start.x }}, {{ selectedCurve.start.y }})</p>
|
||||
<p>控制点 1: ({{ selectedCurve.control1.x }}, {{ selectedCurve.control1.y }})</p>
|
||||
<p>控制点 2: ({{ selectedCurve.control2.x }}, {{ selectedCurve.control2.y }})</p>
|
||||
<p>终点: ({{ selectedCurve.end.x }}, {{ selectedCurve.end.y }})</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
mapRouteList: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
})
|
||||
|
||||
const svgRef = ref(null) // SVG 元素的引用
|
||||
|
||||
const curveList = computed(() => props.mapRouteList) // 存储所有曲线
|
||||
const selectedCurve = ref(null) // 当前选中的曲线
|
||||
const isDragging = ref(false) // 是否正在拖拽
|
||||
const dragTarget = ref(null) // 当前拖拽的目标(起点、终点、控制点)
|
||||
|
||||
// 获取鼠标位置
|
||||
const getMousePos = (event) => {
|
||||
const rect = svgRef.value.getBoundingClientRect()
|
||||
return {
|
||||
x: event.clientX - rect.left,
|
||||
y: event.clientY - rect.top
|
||||
}
|
||||
}
|
||||
|
||||
// 开始拖拽
|
||||
const startDrag = (event, curve, target) => {
|
||||
event.preventDefault()
|
||||
isDragging.value = true
|
||||
selectedCurve.value = curve
|
||||
dragTarget.value = target
|
||||
}
|
||||
|
||||
// 鼠标按下事件
|
||||
const handleMouseDown = (event) => {
|
||||
const mousePos = getMousePos(event)
|
||||
|
||||
// 如果没有选中任何点,则创建一条新的直线
|
||||
if (!isDragging.value && curveList.value.length === 0) {
|
||||
const newCurve = {
|
||||
start: mousePos,
|
||||
end: mousePos,
|
||||
control1: { x: mousePos.x + 50, y: mousePos.y - 50 },
|
||||
control2: { x: mousePos.x + 100, y: mousePos.y - 50 }
|
||||
}
|
||||
curveList.value.push(newCurve)
|
||||
selectedCurve.value = newCurve
|
||||
dragTarget.value = 'end'
|
||||
isDragging.value = true
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标移动事件
|
||||
const handleMouseMove = (event) => {
|
||||
if (!isDragging.value || !selectedCurve.value) return
|
||||
|
||||
const mousePos = getMousePos(event)
|
||||
|
||||
// 更新拖拽的目标点
|
||||
if (dragTarget.value === 'start') {
|
||||
selectedCurve.value.start = mousePos
|
||||
} else if (dragTarget.value === 'end') {
|
||||
selectedCurve.value.end = mousePos
|
||||
} else if (dragTarget.value === 'control1') {
|
||||
selectedCurve.value.control1 = mousePos
|
||||
} else if (dragTarget.value === 'control2') {
|
||||
selectedCurve.value.control2 = mousePos
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标松开事件
|
||||
const handleMouseUp = () => {
|
||||
isDragging.value = false
|
||||
dragTarget.value = null
|
||||
}
|
||||
|
||||
// 获取曲线的路径
|
||||
const getCurvePath = (curve) => {
|
||||
return `M ${curve.startPointX} ${curve.startPointY} C ${curve.beginControlX} ${curve.beginControlX}, ${curve.control2.x} ${curve.control2.y}, ${curve.endPointX} ${curve.endPointY}`
|
||||
}
|
||||
const svgClick = (item) => {
|
||||
console.log(item)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
svg {
|
||||
border: 1px solid #000;
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
path.selected {
|
||||
stroke: blue;
|
||||
}
|
||||
|
||||
.points {
|
||||
margin-top: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,289 @@
|
||||
<template>
|
||||
<!-- 新增设备 -->
|
||||
<Dialog v-model="dialogFormVisible" title="编辑路线" width="750" class="map-edit-route-dialog">
|
||||
<el-form :model="form" label-width="120" ref="ruleFormRef">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开始点位x轴" prop="startPointX" required>
|
||||
<el-input v-model="form.startPointX" placeholder="请输入开始点位x轴" type="number" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开始点位y轴" prop="startPointY" required>
|
||||
<el-input v-model="form.startPointY" placeholder="请输入开始点位y轴" type="number" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="结束点位x轴" prop="endPointX" required>
|
||||
<el-input v-model="form.endPointX" placeholder="请输入结束点位x轴" type="number" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="结束点位y轴" prop="endPointY" required>
|
||||
<el-input v-model="form.endPointY" placeholder="请输入结束点位y轴" type="number" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开始控制点x轴" prop="beginControlX" required>
|
||||
<el-input v-model="form.beginControlX" type="number" :disabled="true" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开始控制点y轴" prop="beginControlY" required>
|
||||
<el-input v-model="form.beginControlY" type="number" :disabled="true" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="结束控制点x轴" prop="endControlX" required>
|
||||
<el-input v-model="form.endControlX" type="number" :disabled="true" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label=" 结束控制点y轴" prop="endControlY" required>
|
||||
<el-input v-model="form.endControlY" type="number" :disabled="true" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="行走方法" prop="method" required>
|
||||
<el-select v-model="form.method" placeholder="请选择行走方法" @change="methodChange">
|
||||
<el-option label="直线" :value="0" />
|
||||
<el-option label="曲线" :value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="方向" prop="direction" required>
|
||||
<el-select v-model="form.direction" placeholder="请选择方向">
|
||||
<el-option label="单向" :value="1" />
|
||||
<el-option label="双向" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="膨胀区域前" prop="expansionZoneFront" required>
|
||||
<div>
|
||||
<el-input-number
|
||||
v-model="form.expansionZoneFront"
|
||||
placeholder="请输入膨胀区域前"
|
||||
:precision="2"
|
||||
class="!w-170px"
|
||||
/>
|
||||
<span class="ml-3">米</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="膨胀区域后" prop="expansionZoneAfter" required>
|
||||
<div>
|
||||
<el-input-number
|
||||
v-model="form.expansionZoneAfter"
|
||||
placeholder="请输入膨胀区域后"
|
||||
:precision="2"
|
||||
class="!w-170px"
|
||||
/>
|
||||
<span class="ml-3">米</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="膨胀区域左" prop="expansionZoneLeft" required>
|
||||
<div>
|
||||
<el-input-number
|
||||
v-model="form.expansionZoneLeft"
|
||||
placeholder="请输入膨胀区域左"
|
||||
:precision="2"
|
||||
class="!w-170px"
|
||||
/>
|
||||
<span class="ml-3">米</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="膨胀区域右" prop="expansionZoneRight" required>
|
||||
<div>
|
||||
<el-input-number
|
||||
v-model="form.expansionZoneRight"
|
||||
placeholder="请输入膨胀区域右"
|
||||
:precision="2"
|
||||
class="!w-170px"
|
||||
/>
|
||||
<span class="ml-3">米</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="正向限速" prop="forwardSpeedLimit" required>
|
||||
<el-input
|
||||
v-model="form.forwardSpeedLimit"
|
||||
type="number"
|
||||
placeholder="请输入正向限速"
|
||||
/> </el-form-item
|
||||
></el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="反向限速" prop="reverseSpeedLimit" required>
|
||||
<el-input
|
||||
v-model="form.reverseSpeedLimit"
|
||||
type="number"
|
||||
placeholder="请输入反向限速"
|
||||
/> </el-form-item
|
||||
></el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="车头朝向" prop="toward" required>
|
||||
<el-select v-model="form.toward" placeholder="请选择车头朝向">
|
||||
<el-option label="正正" :value="0" />
|
||||
<el-option label="正反" :value="1" />
|
||||
<el-option label="反正" :value="2" />
|
||||
<el-option label="反反" :value="3" />
|
||||
</el-select> </el-form-item
|
||||
></el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitForm(ruleFormRef)"> 确定 </el-button>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue'
|
||||
import * as MapApi from '@/api/map/map'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const props = defineProps({
|
||||
imgBgObj: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
})
|
||||
|
||||
const ruleFormRef = ref()
|
||||
const dialogFormVisible = ref(false) //列表的
|
||||
|
||||
const rules = reactive({
|
||||
skuInfo: [{ required: true, message: '请输入物料区域名称', trigger: 'blur' }],
|
||||
areaName: [{ required: true, message: '请输入物料名称', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
//新增
|
||||
const form = ref({
|
||||
positionMapId: '',
|
||||
startPointX: '', // 开始点位x轴
|
||||
startPointY: '', // 开始点位y轴
|
||||
endPointX: '', // 结束点位x轴
|
||||
endPointY: '', // 结束点位y轴
|
||||
expansionZoneFront: 0, //膨胀区域前
|
||||
expansionZoneAfter: 0, //膨胀区域后
|
||||
expansionZoneLeft: 0, // 膨胀区域左
|
||||
expansionZoneRight: 0, //膨胀区域右
|
||||
method: 0, // 行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线
|
||||
direction: 2, //方向 1.单向 2.双向
|
||||
forwardSpeedLimit: 1.5, //正向限速
|
||||
reverseSpeedLimit: 0.4, // 反向限速
|
||||
toward: 0 //车头朝向 0:正正 1:正反 2:反正 3:反反
|
||||
})
|
||||
|
||||
const open = (item) => {
|
||||
dialogFormVisible.value = true
|
||||
form.value = item
|
||||
}
|
||||
|
||||
const emit = defineEmits(['editMapRouteDialogSubmit'])
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const methodChange = (e) => {
|
||||
if (e === 0) {
|
||||
form.value.beginControlX = 0
|
||||
form.value.beginControlY = 0
|
||||
form.value.endControlX = 0
|
||||
form.value.endControlY = 0
|
||||
} else {
|
||||
form.value.beginControlX = form.value.startPointX + 50 //开始控制点x轴
|
||||
form.value.beginControlY = form.value.startPointY + 50 //开始控制点y轴
|
||||
form.value.endControlX = form.value.endPointX - 50 //结束控制点x轴
|
||||
form.value.endControlY = form.value.endPointY - 50 //结束控制点y轴
|
||||
}
|
||||
}
|
||||
|
||||
//传入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>
|
||||
|
||||
<style lang="scss">
|
||||
.map-edit-route-dialog {
|
||||
padding: 0px;
|
||||
|
||||
.el-dialog__footer {
|
||||
padding: 0px 20px 20px 0;
|
||||
border-top: none !important;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -46,15 +46,6 @@
|
||||
<el-button size="small" color="#00329F" @click="rotationFormSubmit">确认</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
<!-- 字体 -->
|
||||
<el-form :model="state.rotationForm" v-if="item.switchType === 'text'">
|
||||
<el-form-item label="角度">
|
||||
<el-input v-model="state.rotationForm.angle" placeholder="请输入" />
|
||||
</el-form-item>
|
||||
<div style="text-align: right">
|
||||
<el-button size="small" color="#00329F" @click="rotationFormSubmit">确认</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</el-popover>
|
||||
|
||||
<div
|
||||
@ -170,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
|
||||
}"
|
||||
>
|
||||
@ -249,52 +239,66 @@
|
||||
<svg
|
||||
:width="imgBgObj.width"
|
||||
:height="imgBgObj.height"
|
||||
style="position: absolute; top: 0; left: 0"
|
||||
style="position: absolute; top: 0; left: 0; z-index: 9"
|
||||
>
|
||||
<path
|
||||
v-for="(curve, index) in state.mapRouteList"
|
||||
:key="index"
|
||||
:d="getCurvePath(curve)"
|
||||
:stroke="curve.isSelected ? 'red' : 'blue'"
|
||||
stroke-width="2"
|
||||
fill="none"
|
||||
@mousedown="handleEditRoute(curve)"
|
||||
/>
|
||||
<line
|
||||
:x1="state.selectedCurve.startPointX"
|
||||
:y1="state.selectedCurve.startPointY"
|
||||
:x2="state.selectedCurve.beginControlX"
|
||||
:y2="state.selectedCurve.beginControlY"
|
||||
stroke="gray"
|
||||
stroke-dasharray="4"
|
||||
/>
|
||||
<!-- 第二条控制线 -->
|
||||
<line
|
||||
:x1="state.selectedCurve.endPointX"
|
||||
:y1="state.selectedCurve.endPointY"
|
||||
:x2="state.selectedCurve.endControlX"
|
||||
:y2="state.selectedCurve.endControlY"
|
||||
stroke="gray"
|
||||
stroke-dasharray="4"
|
||||
/>
|
||||
<circle
|
||||
v-for="(curve, index) in state.mapRouteList"
|
||||
:key="'start-' + index"
|
||||
:cx="curve.beginControlX"
|
||||
:cy="curve.beginControlY"
|
||||
r="5"
|
||||
fill="green"
|
||||
@mousedown="startDrag(index, 'start')"
|
||||
/>
|
||||
<circle
|
||||
v-for="(curve, index) in state.mapRouteList"
|
||||
:key="'end-' + index"
|
||||
:cx="curve.endControlX"
|
||||
:cy="curve.endControlY"
|
||||
r="5"
|
||||
fill="green"
|
||||
@mousedown="startDrag(index, 'end')"
|
||||
/>
|
||||
<template v-for="(curve, index) in state.mapRouteList" :key="index">
|
||||
<!-- 直线 -->
|
||||
<line
|
||||
v-if="curve.method === 0"
|
||||
:x1="curve.startPointX"
|
||||
:y1="curve.startPointY"
|
||||
:x2="curve.endPointX"
|
||||
:y2="curve.endPointY"
|
||||
:stroke="curve.isSelected ? '#f48924' : '#00329F'"
|
||||
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="5"
|
||||
fill="none"
|
||||
@click="handleChooseRoute(curve, index)"
|
||||
@dblclick="handleEditRoute(curve, index)"
|
||||
/>
|
||||
<line
|
||||
:x1="curve.startPointX"
|
||||
:y1="curve.startPointY"
|
||||
:x2="curve.beginControlX"
|
||||
:y2="curve.beginControlY"
|
||||
:stroke="curve.isSelected ? '#f48924' : '#00329F'"
|
||||
stroke-dasharray="4"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<!-- 第二条控制线 -->
|
||||
<line
|
||||
:x1="curve.endPointX"
|
||||
:y1="curve.endPointY"
|
||||
:x2="curve.endControlX"
|
||||
:y2="curve.endControlY"
|
||||
:stroke="curve.isSelected ? '#f48924' : '#00329F'"
|
||||
stroke-dasharray="4"
|
||||
stroke-width="2"
|
||||
/>
|
||||
<circle
|
||||
:cx="curve.beginControlX"
|
||||
:cy="curve.beginControlY"
|
||||
r="5"
|
||||
:fill="curve.isSelected ? '#f48924' : '#00329F'"
|
||||
@mousedown="startDrag(curve, index, 'start')"
|
||||
/>
|
||||
<circle
|
||||
:cx="curve.endControlX"
|
||||
:cy="curve.endControlY"
|
||||
r="5"
|
||||
:fill="curve.isSelected ? '#f48924' : '#00329F'"
|
||||
@mousedown="startDrag(curve, index, 'end')"
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
@ -410,10 +414,17 @@
|
||||
ref="lineLibrarySettingDialogRef"
|
||||
:positionMapId="imgBgObj.positionMapId"
|
||||
/>
|
||||
<!-- 编辑地图路线 -->
|
||||
<editMapRouteDialog
|
||||
ref="editMapRouteDialogRef"
|
||||
@editMapRouteDialogSubmit="editMapRouteDialogSubmit"
|
||||
:imgBgObj="imgBgObj"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import JSONBigInt from 'json-bigint'
|
||||
import { ElLoading } from 'element-plus'
|
||||
import { ref, defineComponent, reactive, nextTick, onMounted } from 'vue'
|
||||
import editNodeProperties from './components-tool/editNodeProperties.vue'
|
||||
import textFormToolDialog from './components-tool/textFormToolDialog.vue'
|
||||
@ -431,11 +442,11 @@ const lineLibrarySettingDialogRef = ref() //线库设置
|
||||
const itemAreaSettingDialogRef = ref() //物料区域设置
|
||||
const equipmentToolDialogRef = ref() //设备弹窗
|
||||
const textFormToolDialogRef = ref() //文字输入弹窗
|
||||
const editMapRouteDialogRef = ref() //编辑地图路线的弹窗
|
||||
const mapBackgroundRef = ref()
|
||||
const inputBoxRef = ref() //文字输入框
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const formLoading = ref(false)
|
||||
|
||||
const allHistoryList = ref([]) //全部的历史记录
|
||||
const currentIndex = ref(0) //用于记录是哪条历史记录的
|
||||
@ -457,7 +468,6 @@ const resizeEnd = (x, y, w, h, item, index) => {
|
||||
}
|
||||
// 拖拽停止
|
||||
const dragEnd = (x, y, item, index) => {
|
||||
console.log('拖拽')
|
||||
if (x === item.locationX && y === item.locationY) return
|
||||
allMapPointInfo.value[index].locationX = x
|
||||
allMapPointInfo.value[index].locationY = y
|
||||
@ -497,7 +507,6 @@ const addEditHistory = () => {
|
||||
currentIndex.value++
|
||||
}
|
||||
interfaceRefreshed.value = true
|
||||
console.log(allHistoryList.value, 'allHistoryList')
|
||||
}
|
||||
|
||||
//上一步
|
||||
@ -505,7 +514,6 @@ const backPreviousStep = () => {
|
||||
if (currentIndex.value > 0) {
|
||||
currentIndex.value--
|
||||
allMapPointInfo.value = allHistoryList.value[currentIndex.value]
|
||||
console.log('撤销', allHistoryList.value[currentIndex.value])
|
||||
} else {
|
||||
message.warning('没了老铁')
|
||||
}
|
||||
@ -515,7 +523,6 @@ const backNextStep = () => {
|
||||
if (currentIndex.value < allHistoryList.value.length - 1) {
|
||||
currentIndex.value++
|
||||
allMapPointInfo.value = allHistoryList.value[currentIndex.value]
|
||||
console.log('重做', allHistoryList.value[currentIndex.value])
|
||||
} else {
|
||||
message.warning('没了老铁')
|
||||
}
|
||||
@ -525,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({
|
||||
@ -532,6 +542,8 @@ const mapClick = (e) => {
|
||||
layerSelectionShow: true,
|
||||
locationX: x,
|
||||
locationY: y,
|
||||
actualLocationX: actualLocationX,
|
||||
actualLocationY: actualLocationY,
|
||||
locationDeep: 10,
|
||||
locationWide: 10,
|
||||
angle: 0,
|
||||
@ -544,14 +556,15 @@ const mapClick = (e) => {
|
||||
dataList: [], //存库位的
|
||||
dataObj: {} //存 设备点 停车点 文字
|
||||
})
|
||||
currentIndex.value++
|
||||
allHistoryList.value.push(JSON.parse(JSON.stringify(allMapPointInfo.value)))
|
||||
addEditHistory()
|
||||
}
|
||||
//文字输入
|
||||
if (toolbarSwitchType.value === 'text') {
|
||||
state.showInputBox = true
|
||||
state.inputBoxStyle.locationX = x
|
||||
state.inputBoxStyle.locationY = y
|
||||
state.inputBoxStyle.actualLocationX = actualLocationX
|
||||
state.inputBoxStyle.actualLocationY = actualLocationY
|
||||
|
||||
// 聚焦输入框
|
||||
setTimeout(() => {
|
||||
@ -565,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 = () => {
|
||||
@ -580,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, //旋转角度
|
||||
@ -791,7 +804,9 @@ const state = reactive({
|
||||
fontSize: '14',
|
||||
fontColor: '#000000',
|
||||
locationX: 0,
|
||||
locationY: 0
|
||||
locationY: 0,
|
||||
actualLocationX: 0,
|
||||
actualLocationY: 0
|
||||
}, //输入框的样式
|
||||
inputBoxValue: '', //输入的值
|
||||
isShowLayer: false, //图层显示
|
||||
@ -800,9 +815,12 @@ const state = reactive({
|
||||
imageChangeMultiple: 1, //图片放大缩小的倍数
|
||||
prohibitedOperation: false, //禁止操作 在框选测距等操作时,禁止所有拖动等操作
|
||||
mapRouteList: [], //仓库点位地图连线
|
||||
isDragging: false, // 是否正在拖拽
|
||||
currentDragTarget: '', //当前拖拽的目标(起点、终点、控制点)
|
||||
selectedCurve: '' // 当前选中的曲线
|
||||
currentDragTarget: {
|
||||
index: null,
|
||||
type: null
|
||||
}, //当前拖拽的目标(起点、终点、控制点)
|
||||
selectedCurve: '', // 当前选中的曲线
|
||||
svgZIndex: 9999
|
||||
})
|
||||
const toolbarClick = (item) => {
|
||||
let type = item.switchType
|
||||
@ -1112,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') {
|
||||
//线库
|
||||
@ -1124,46 +1147,76 @@ 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,
|
||||
endPointId: routeList[1].id,
|
||||
startPointX: routeList[0].locationX + routeList[0].locationWide / 2, //开始点
|
||||
startPointY: routeList[0].locationY + routeList[0].locationDeep / 2, //开始点
|
||||
endPointX: routeList[1].locationX + routeList[1].locationWide / 2, //结束点
|
||||
endPointY: routeList[1].locationY + routeList[1].locationWide / 2, //结束点
|
||||
beginControlX: routeList[0].locationX + routeList[0].locationWide / 2 + 50, //开始控制点x轴
|
||||
beginControlY: routeList[0].locationY + routeList[0].locationWide / 2 + 50, //开始控制点y轴
|
||||
endControlX: routeList[1].locationX + routeList[1].locationWide / 2 - 50, //结束控制点x轴
|
||||
endControlY: routeList[1].locationY + routeList[1].locationWide / 2 - 50, //结束控制点y轴
|
||||
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轴
|
||||
endControlY: 0, //结束控制点y轴
|
||||
expansionZoneFront: 0, //膨胀区域前
|
||||
expansionZoneAfter: 0, //膨胀区域后
|
||||
expansionZoneLeft: 0, // 膨胀区域左
|
||||
expansionZoneRight: 0, //膨胀区域右
|
||||
method: 0, //行走方法 0.直线 1.上左曲线2.上右曲线3.下左曲线 4.下右曲线
|
||||
direction: 2, //方向 1.单向 2.双向,
|
||||
forwardSpeedLimit: '1.5', //正向限速
|
||||
reverseSpeedLimit: '0.4' // 反向限速
|
||||
forwardSpeedLimit: 1.5, //正向限速
|
||||
reverseSpeedLimit: 0.4, // 反向限速
|
||||
toward: 0
|
||||
}
|
||||
state.selectedCurve = curve
|
||||
state.mapRouteList.push(curve)
|
||||
state.currentDragTarget = 'end'
|
||||
state.isDragging = true
|
||||
}
|
||||
}
|
||||
//计算是不是在同一条直线的
|
||||
@ -1206,70 +1259,57 @@ const isStraightLine = (binLocation) => {
|
||||
}
|
||||
//三阶贝塞尔曲线
|
||||
// 开始拖拽
|
||||
const dragging = ref()
|
||||
const startDrag = (index, type) => {
|
||||
dragging.value = { index, type }
|
||||
const startDrag = (item, index, type) => {
|
||||
state.currentDragTarget = { index, type }
|
||||
window.addEventListener('mousemove', handleDrag)
|
||||
window.addEventListener('mouseup', endDrag)
|
||||
}
|
||||
// 处理拖动事件
|
||||
const handleDrag = (event) => {
|
||||
if (dragging.value.index !== null) {
|
||||
const curve = state.mapRouteList[dragging.value.index]
|
||||
if (dragging.value.type === 'start') {
|
||||
curve.beginControlX = event.offsetX
|
||||
curve.beginControlY = event.offsetY
|
||||
const x = disposeEventPoints(event).x
|
||||
const y = disposeEventPoints(event).y
|
||||
|
||||
if (state.currentDragTarget.index !== null) {
|
||||
const curve = state.mapRouteList[state.currentDragTarget.index]
|
||||
if (state.currentDragTarget.type === 'start') {
|
||||
curve.beginControlX = x
|
||||
curve.beginControlY = y
|
||||
} else {
|
||||
curve.endControlX = event.offsetX
|
||||
curve.endControlY = event.offsetY
|
||||
curve.endControlX = x
|
||||
curve.endControlY = y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 结束拖动
|
||||
const endDrag = () => {
|
||||
dragging.value = { index: null, type: null }
|
||||
state.currentDragTarget = { index: null, type: null }
|
||||
window.removeEventListener('mousemove', handleDrag)
|
||||
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) => {
|
||||
return `M ${curve.startPointX} ${curve.startPointY} C ${curve.beginControlX} ${curve.beginControlY}, ${curve.endControlX} ${curve.endControlY}, ${curve.endPointX} ${curve.endPointY}`
|
||||
}
|
||||
//编辑路线
|
||||
const handleEditRoute = (item) => {
|
||||
console.log('Selected curve:', item)
|
||||
//编辑路线 双击
|
||||
const handleEditRoute = (item, index) => {
|
||||
state.mapRouteList.forEach((curve, i) => {
|
||||
curve.isSelected = i === index
|
||||
})
|
||||
state.currentDragTarget.index = 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
|
||||
}
|
||||
|
||||
//测距相关
|
||||
@ -1334,8 +1374,7 @@ const imgBgObj = reactive({
|
||||
floor: '',
|
||||
area: '',
|
||||
resolution: 0.05,
|
||||
// origin: [-54.4, -34.2]
|
||||
origin: [-10.4, 9.1]
|
||||
origin: [-54.4, -34.2]
|
||||
})
|
||||
//接收参数
|
||||
const { query } = useRoute() // 查询参数
|
||||
@ -1366,6 +1405,7 @@ const getMapData = async (mapInfo) => {
|
||||
imgBgObj.height = img.naturalHeight
|
||||
console.log(img.naturalWidth, img.naturalHeight)
|
||||
getAllNodeList()
|
||||
getAllMapRoute()
|
||||
}
|
||||
//加载图片失败
|
||||
img.onerror = () => {
|
||||
@ -1377,6 +1417,7 @@ const getAllNodeList = async () => {
|
||||
let list = await MapApi.getPositionMapItemList({
|
||||
positionMapId: imgBgObj.positionMapId
|
||||
})
|
||||
allMapPointInfo.value = []
|
||||
list.forEach((item) => {
|
||||
item.layerSelectionShow = true //用于图层
|
||||
item.locationX = Number(item.locationX)
|
||||
@ -1434,18 +1475,36 @@ const getAllNodeList = async () => {
|
||||
})
|
||||
allHistoryList.value[0] = JSON.parse(JSON.stringify(allMapPointInfo.value))
|
||||
}
|
||||
//获取所有的路线
|
||||
const getAllMapRoute = async () => {
|
||||
state.mapRouteList = await MapApi.getPositionMapLineByPositionMapId(imgBgObj.positionMapId)
|
||||
}
|
||||
|
||||
//保存地图按钮
|
||||
const saveMap = async () => {
|
||||
//节点的保存
|
||||
await saveNodeList()
|
||||
//路线的保存
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '保存中',
|
||||
background: 'rgba(255, 255, 255, 0.7)'
|
||||
})
|
||||
try {
|
||||
//节点的保存
|
||||
await saveNodeList()
|
||||
//路线的保存
|
||||
await saveMapRoute()
|
||||
//获取新的数据
|
||||
await getAllNodeList()
|
||||
await getAllMapRoute()
|
||||
//关闭loading
|
||||
loading.close()
|
||||
message.success('保存成功')
|
||||
} catch (error) {
|
||||
loading.close()
|
||||
}
|
||||
}
|
||||
//节点的保存
|
||||
const saveNodeList = async () => {
|
||||
formLoading.value = true
|
||||
let list = allHistoryList.value[currentIndex.value]
|
||||
|
||||
list.forEach((item) => {
|
||||
if (item.type === 7) {
|
||||
item.dataObj.positionMapId = imgBgObj.positionMapId
|
||||
@ -1459,13 +1518,11 @@ const saveNodeList = async () => {
|
||||
item.dataJson = JSON.stringify(item.dataObj)
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
await MapApi.batchSaveOrEditOrDelMapItem(imgBgObj.positionMapId, list)
|
||||
message.success('创建成功')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
await MapApi.batchSaveOrEditOrDelMapItem(imgBgObj.positionMapId, list)
|
||||
}
|
||||
//路线的保存
|
||||
const saveMapRoute = async () => {
|
||||
await MapApi.createOrEditOrDelPositionMapLine(imgBgObj.positionMapId, state.mapRouteList)
|
||||
}
|
||||
|
||||
//筛选图层
|
||||
|
Loading…
Reference in New Issue
Block a user