This commit is contained in:
xhf 2025-03-18 17:24:55 +08:00
commit 12b13dfee9
5 changed files with 65 additions and 186 deletions

View File

@ -6,7 +6,7 @@ VITE_DEV=true
# 请求路径 # 请求路径
# VITE_BASE_URL='http://192.168.0.66:48080' # VITE_BASE_URL='http://192.168.0.66:48080'
# VITE_BASE_URL='http://192.168.0.189:48080' # VITE_BASE_URL='http://192.168.0.189:48080'
VITE_BASE_URL='http://127.0.0.1:48080' VITE_BASE_URL='http://192.168.0.45:48080'
# 文件上传类型server - 后端上传, client - 前端直连上传仅支持S3服务 # 文件上传类型server - 后端上传, client - 前端直连上传仅支持S3服务
VITE_UPLOAD_TYPE=server VITE_UPLOAD_TYPE=server

View File

@ -4,8 +4,9 @@ NODE_ENV=development
VITE_DEV=true VITE_DEV=true
# 请求路径 # 请求路径
VITE_BASE_URL='http://192.168.0.74:48080' # VITE_BASE_URL='http://192.168.0.74:48080'
# VITE_BASE_URL='http://192.168.0.189:48080' # VITE_BASE_URL='http://192.168.0.189:48080'
VITE_BASE_URL='http://192.168.0.45:48080'
# 文件上传类型server - 后端上传, client - 前端直连上传,仅支持 S3 服务 # 文件上传类型server - 后端上传, client - 前端直连上传,仅支持 S3 服务
VITE_UPLOAD_TYPE=server VITE_UPLOAD_TYPE=server

View File

@ -1,151 +0,0 @@
<template>
<div class="map-container" ref="mapContainer">
<!-- 地图 -->
<div
class="map"
:style="{
backgroundImage: `url(${mapImage})`,
transform: `scale(${scale})`,
transformOrigin: '0 0',
width: `${mapWidth}px`,
height: `${mapHeight}px`
}"
@click="addLocation"
>
<!-- 库位 -->
<div
v-for="(location, index) in locations"
:key="index"
class="location"
:style="{
left: `${location.projectX}px`,
top: `${location.projectY}px`,
transform: `scale(${scale})` //
}"
>
<img src="@/assets/location-icon.png" alt="库位" />
</div>
</div>
<!-- 放大缩小按钮 -->
<div class="controls">
<button @click="zoomIn">放大</button>
<button @click="zoomOut">缩小</button>
<button @click="saveLocations">保存</button>
</div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import mapImage from '@/assets/warehouse-map.png' //
import locationIcon from '@/assets/location-icon.png' //
const origin = [-54.4, -34.2]
const resolution = 0.05
const mapContainer = ref(null) //
const scale = ref(1) //
const locations = ref([]) //
const mapWidth = ref(0) //
const mapHeight = ref(0) //
//
onMounted(() => {
const img = new Image()
img.src = mapImage
img.onload = () => {
mapWidth.value = img.width
mapHeight.value = img.height
}
})
//
const addLocation = (event) => {
const rect = mapContainer.value.getBoundingClientRect()
const scrollLeft = mapContainer.value.scrollLeft //
const scrollTop = mapContainer.value.scrollTop //
const devicePixelRatio = window.devicePixelRatio || 1
//
const projectX = (event.clientX - rect.left + scrollLeft) / scale.value / devicePixelRatio
const projectY = (event.clientY - rect.top + scrollTop) / scale.value / devicePixelRatio
//
const actualX = (projectX - origin[0]) / resolution
const actualY = (projectY - origin[1]) / resolution
//
locations.value.push({
projectX,
projectY,
actualX,
actualY
})
}
//
const zoomIn = () => {
scale.value *= 1.2
}
//
const zoomOut = () => {
scale.value /= 1.2
}
//
const saveLocations = () => {
console.log(
'项目点位坐标:',
locations.value.map((loc) => ({ x: loc.projectX, y: loc.projectY }))
)
console.log(
'实际现场点位坐标:',
locations.value.map((loc) => ({ x: loc.actualX, y: loc.actualY }))
)
alert('点位坐标已保存,请查看控制台输出。')
}
</script>
<style scoped>
.map-container {
position: relative;
width: 100%;
height: 80vh;
overflow: auto;
border: 1px solid #ccc;
}
.map {
background-size: contain;
background-repeat: no-repeat;
position: relative;
}
.location {
position: absolute;
width: 20px;
height: 20px;
cursor: pointer;
}
.location img {
width: 100%;
height: 100%;
}
.controls {
position: fixed;
top: 110px;
right: 110px;
display: flex;
gap: 10px;
}
.controls button {
padding: 5px 10px;
font-size: 14px;
cursor: pointer;
}
</style>

View File

@ -23,8 +23,8 @@
<!-- 新增设备 --> <!-- 新增设备 -->
<Dialog v-model="addDeviceVisible" title="设备" width="586" class="equipment-form-dialog"> <Dialog v-model="addDeviceVisible" title="设备" width="586" class="equipment-form-dialog">
<el-form :model="deviceInfo" label-width="90"> <el-form :model="deviceInfo" label-width="90" ref="ruleFormRef" :rules="rules">
<el-form-item label="设备类型" required> <el-form-item prop="deviceType" label="设备类型" required>
<el-select <el-select
v-model="deviceInfo.deviceType" v-model="deviceInfo.deviceType"
class="!w-400px" class="!w-400px"
@ -40,7 +40,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="设备编号" required> <el-form-item prop="deviceInfoId" label="设备编号" required>
<el-select <el-select
v-model="deviceInfo.deviceInfoId" v-model="deviceInfo.deviceInfoId"
class="!w-400px" class="!w-400px"
@ -127,6 +127,7 @@ const addDevice = () => {
} }
// //
const deviceTypeChange = async () => { const deviceTypeChange = async () => {
deviceInfo.value.deviceInfoId = ''
getAllDeviceList() getAllDeviceList()
} }
const getAllDeviceList = async () => { const getAllDeviceList = async () => {
@ -136,12 +137,20 @@ const getAllDeviceList = async () => {
}) })
} }
// //
const ruleFormRef = ref()
const rules = reactive({
deviceType: [{ required: true, message: '请选择设备类型', trigger: 'change' }],
deviceInfoId: [{ required: true, message: '请选择设备类型', trigger: 'change' }]
})
const submitAddForm = async () => { const submitAddForm = async () => {
deviceInfo.value.positionMapId = props.positionMapId await ruleFormRef.value.validate(async (valid, fields) => {
await MapApi.mapBindDeviceInfo(deviceInfo.value) if (!valid) return
message.success('新增成功') deviceInfo.value.positionMapId = props.positionMapId
addDeviceVisible.value = false await MapApi.mapBindDeviceInfo(deviceInfo.value)
getDeviceList() message.success('新增成功')
addDeviceVisible.value = false
getDeviceList()
})
} }
const equipmentList = ref([]) const equipmentList = ref([])
@ -159,7 +168,7 @@ const dialogClose = () => {
const initAddForm = () => { const initAddForm = () => {
deviceInfo.value.deviceInfoId = '' deviceInfo.value.deviceInfoId = ''
deviceInfo.value.deviceType = '' deviceInfo.value.deviceType = ''
getAllDeviceList() allDeviceList.value = []
} }
defineExpose({ open }) // open defineExpose({ open }) // open

View File

@ -395,8 +395,6 @@
v-if="item.type === 7 && item.layerSelectionShow" v-if="item.type === 7 && item.layerSelectionShow"
:style="{ :style="{
position: 'absolute', position: 'absolute',
left: item.locationX + 'px',
top: item.locationY + 'px',
color: item.fontColor, color: item.fontColor,
fontSize: item.fontSize + 'px', fontSize: item.fontSize + 'px',
fontFamily: item.fontFamily, fontFamily: item.fontFamily,
@ -760,10 +758,15 @@ const resizeEnd = (locationX, locationY, w, h, item, index) => {
nextTick(() => { nextTick(() => {
let x = Number(locationX) + Number(item.locationWidePx) / 2 let x = Number(locationX) + Number(item.locationWidePx) / 2
let y = Number(locationY) + Number(item.locationDeepPx) / 2 let y = Number(locationY) + Number(item.locationDeepPx) / 2
let width = Number(w) * imgBgObj.resolution * 100 //cm
let height = Number(h) * imgBgObj.resolution * 100
let actualPoint = disposeEventPoint(x, y) let actualPoint = disposeEventPoint(x, y)
state.allMapPointInfo[index].locationX = x state.allMapPointInfo[index].locationX = x
state.allMapPointInfo[index].locationY = y state.allMapPointInfo[index].locationY = y
state.allMapPointInfo[index].locationWide = width
state.allMapPointInfo[index].locationDeep = height
state.allMapPointInfo[index].locationWidePx = w state.allMapPointInfo[index].locationWidePx = w
state.allMapPointInfo[index].locationDeepPx = h state.allMapPointInfo[index].locationDeepPx = h
state.allMapPointInfo[index].actualLocationX = actualPoint.actualLocationX state.allMapPointInfo[index].actualLocationX = actualPoint.actualLocationX
@ -781,8 +784,8 @@ const resizeEnd = (locationX, locationY, w, h, item, index) => {
if (item.id === route.endPointId) { if (item.id === route.endPointId) {
route.endPointX = x route.endPointX = x
route.endPointY = y route.endPointY = y
route.endHigh = Number(item.locationDeep) route.endHigh = Number(item.locationDeepPx)
route.endWidth = Number(item.locationDeep) route.endWidth = Number(item.locationWidePx)
route.actualEndPointX = actualPoint.actualLocationX route.actualEndPointX = actualPoint.actualLocationX
route.actualEndPointY = actualPoint.actualLocationY route.actualEndPointY = actualPoint.actualLocationY
} }
@ -984,7 +987,11 @@ const handleInputEnd = () => {
fontFamily: state.inputBoxStyle.fontFamily, // fontFamily: state.inputBoxStyle.fontFamily, //
fontSize: state.inputBoxStyle.fontSize, fontSize: state.inputBoxStyle.fontSize,
dataObj: {}, // dataObj: {}, //
layerSelectionShow: true layerSelectionShow: true,
locationDeep: 20,
locationWide: 20,
locationDeepPx: 4,
locationWidePx: 4
}) })
addEditHistory() addEditHistory()
state.inputBoxValue = '' state.inputBoxValue = ''
@ -1347,6 +1354,7 @@ const toolbarClick = async (item) => {
break break
case 'move': case 'move':
// //
console.log(state.allMapPointInfo[state.currentItemIndex])
state.moveForm.locationX = Number(state.allMapPointInfo[state.currentItemIndex].locationX) state.moveForm.locationX = Number(state.allMapPointInfo[state.currentItemIndex].locationX)
state.moveForm.locationY = Number(state.allMapPointInfo[state.currentItemIndex].locationY) state.moveForm.locationY = Number(state.allMapPointInfo[state.currentItemIndex].locationY)
break break
@ -1696,25 +1704,24 @@ const startFromPoint = (index, event) => {
// //
const startDrawSelection = (event) => { const startDrawSelection = (event) => {
if ( if (
toolbarSwitchType.value !== 'createLineLibrary' && toolbarSwitchType.value === 'createLineLibrary' ||
toolbarSwitchType.value !== 'createRegion' && toolbarSwitchType.value === 'createRegion' ||
toolbarSwitchType.value !== 'drawRoute' && toolbarSwitchType.value === 'drawRoute' ||
toolbarSwitchType.value !== 'generateLine' toolbarSwitchType.value == 'generateLine'
) ) {
return const backgroundRect = mapBackgroundRef.value.getBoundingClientRect()
const backgroundRect = mapBackgroundRef.value.getBoundingClientRect() const x = disposeEventPoints(event).x
const y = disposeEventPoints(event).y
const x = disposeEventPoints(event).x //
const y = disposeEventPoints(event).y if (x >= 0 && x <= backgroundRect.width && y >= 0 && y <= backgroundRect.height) {
state.drawSelectionAreaShow = true
// state.drawSelectionStartPoint = { x: x, y: y }
if (x >= 0 && x <= backgroundRect.width && y >= 0 && y <= backgroundRect.height) { state.drawSelectionAreaBox = { x: x, y: y, width: 0, height: 0 }
state.drawSelectionAreaShow = true }
state.drawSelectionStartPoint = { x: x, y: y } event.preventDefault() //
state.drawSelectionAreaBox = { x: x, y: y, width: 0, height: 0 }
} }
event.preventDefault() //
} }
// //
const updateDrawSelection = (event) => { const updateDrawSelection = (event) => {
@ -1736,7 +1743,6 @@ const updateDrawSelection = (event) => {
} }
} }
event.preventDefault() // event.preventDefault() //
return
} }
if (toolbarSwitchType.value === 'clickDrawRoute') { if (toolbarSwitchType.value === 'clickDrawRoute') {
// //
@ -1748,7 +1754,6 @@ const updateDrawSelection = (event) => {
state.currentDrawY = y state.currentDrawY = y
} }
event.preventDefault() // event.preventDefault() //
return
} }
} }
// //
@ -2468,6 +2473,8 @@ const getAllNodeList = async () => {
item.resizable = false item.resizable = false
item.rotatable = true item.rotatable = true
item.lockAspectRatio = true item.lockAspectRatio = true
item.locationDeep = 20
item.locationWide = 20
} }
//cmpx //cmpx
@ -2515,7 +2522,20 @@ const saveMap = async () => {
const saveNodeList = async () => { const saveNodeList = async () => {
let list = state.allMapPointInfo let list = state.allMapPointInfo
list.forEach((item) => { list.forEach((item) => {
if (item.type === 7) { if (item.type === 2) {
//
item.dataList.forEach((node) => {
node.locationDeep = item.locationDeep
node.locationWide = item.locationWide
})
item.dataJson = JSON.stringify(item.dataList)
} else if (item.type === 3 || item.type === 4) {
//
item.dataObj.locationWide = item.locationWide
item.dataObj.locationDeep = item.locationDeep
item.dataJson = JSON.stringify(item.dataObj)
} else if (item.type === 7) {
//
item.dataObj.positionMapId = imgBgObj.positionMapId item.dataObj.positionMapId = imgBgObj.positionMapId
item.dataObj.text = item.text item.dataObj.text = item.text
item.dataObj.fontColor = item.fontColor item.dataObj.fontColor = item.fontColor