bug修改

This commit is contained in:
yyy 2025-03-20 08:59:13 +08:00
parent 0896a1bda3
commit e742405735
4 changed files with 260 additions and 99 deletions

View File

@ -1,8 +1,8 @@
<template> <template>
<Dialog <Dialog
v-model="dialogFormVisible" v-model="dialogFormVisible"
title="区域管理" title="物料区域管理"
width="600" width="660"
class="item-area-management-dialog" class="item-area-management-dialog"
@close="dialogClose" @close="dialogClose"
> >
@ -12,11 +12,12 @@
:header-cell-style="{ backgroundColor: '#EBF1FF', color: '#0D162A', padding: '13px 0' }" :header-cell-style="{ backgroundColor: '#EBF1FF', color: '#0D162A', padding: '13px 0' }"
v-loading="loading" v-loading="loading"
> >
<el-table-column type="index" width="50" align="center" /> <el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column prop="areaName" label="库区名称" align="center" /> <el-table-column prop="skuInfo" label="物料区域名称" align="center" />
<el-table-column prop="skuInfo" label="库区说明" align="center" /> <el-table-column prop="areaName" label="物料名称" align="center" />
<el-table-column label="操作" align="center" width="100"> <el-table-column label="操作" align="center" width="140">
<template #default="scope"> <template #default="scope">
<el-button size="small" type="primary" @click="handleEdit(scope.row)"> 编辑 </el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.row.id)"> <el-button size="small" type="danger" @click="handleDelete(scope.row.id)">
删除 删除
</el-button> </el-button>
@ -34,6 +35,23 @@
/> />
</div> </div>
</Dialog> </Dialog>
<el-dialog v-model="editDialogFormVisible" title="编辑" width="400">
<el-form :model="editForm" label-width="110" :rules="editRules" ref="editFormEl">
<el-form-item label="物料区域名称" prop="skuInfo" required>
<el-input v-model="editForm.skuInfo" />
</el-form-item>
<el-form-item label="物料名称" prop="areaName" required>
<el-input v-model="editForm.areaName" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="editDialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="editSubmit"> 确定 </el-button>
</div>
</template>
</el-dialog>
</template> </template>
<script setup> <script setup>
@ -93,6 +111,32 @@ const handleDelete = async (id) => {
} catch {} } catch {}
} }
//
const editForm = ref({
skuInfo: '',
areaName: ''
})
const editDialogFormVisible = ref(false)
const handleEdit = (row) => {
editDialogFormVisible.value = true
editForm.value = row
}
const editRules = reactive({
skuInfo: [{ required: true, message: '请输入物料区域名称', trigger: 'blur' }],
areaName: [{ required: true, message: '请输入物料名称', trigger: 'blur' }]
})
const editFormEl = ref()
const editSubmit = async () => {
await editFormEl.value.validate(async (valid, fields) => {
if (valid) {
await MapApi.createOrEditOrDelHouseArea(editForm.value)
await getWareHouseList()
editDialogFormVisible.value = false
message.success('编辑成功')
}
})
}
defineExpose({ open }) // open defineExpose({ open }) // open
</script> </script>

View File

@ -2,7 +2,7 @@
<Dialog <Dialog
v-model="dialogFormVisible" v-model="dialogFormVisible"
title="线库管理" title="线库管理"
width="600" width="660"
class="line-library-management-dialog" class="line-library-management-dialog"
@close="dialogClose" @close="dialogClose"
> >
@ -12,10 +12,11 @@
:header-cell-style="{ backgroundColor: '#EBF1FF', color: '#0D162A', padding: '13px 0' }" :header-cell-style="{ backgroundColor: '#EBF1FF', color: '#0D162A', padding: '13px 0' }"
v-loading="loading" v-loading="loading"
> >
<el-table-column type="index" width="50" align="center" /> <el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column prop="laneName" label="巷道名称" align="center" /> <el-table-column prop="laneName" label="线库名称" align="center" />
<el-table-column label="操作" align="center"> <el-table-column label="操作" align="center">
<template #default="scope"> <template #default="scope">
<el-button size="small" type="primary" @click="handleEdit(scope.row)"> 编辑 </el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.row.id)"> <el-button size="small" type="danger" @click="handleDelete(scope.row.id)">
删除 删除
</el-button> </el-button>
@ -33,6 +34,20 @@
/> />
</div> </div>
</Dialog> </Dialog>
<el-dialog v-model="editDialogFormVisible" title="编辑" width="400">
<el-form :model="editForm" :rules="editRules" ref="editFormEl">
<el-form-item label="线库名称" prop="laneName" required>
<el-input v-model="editForm.laneName" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="editDialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="editSubmit"> 确定 </el-button>
</div>
</template>
</el-dialog>
</template> </template>
<script setup> <script setup>
@ -83,7 +98,7 @@ const getLineLibraryList = async () => {
const handleDelete = async (id) => { const handleDelete = async (id) => {
try { try {
// //
await message.delConfirm('请确认是否删除该物料区域') await message.delConfirm('请确认是否删除该线库')
// //
await MapApi.deleteWareLaneArea(id) await MapApi.deleteWareLaneArea(id)
message.success('删除成功') message.success('删除成功')
@ -92,6 +107,30 @@ const handleDelete = async (id) => {
} catch {} } catch {}
} }
//
const editForm = ref({
laneName: ''
})
const editDialogFormVisible = ref(false)
const handleEdit = (row) => {
editDialogFormVisible.value = true
editForm.value = row
}
const editRules = reactive({
laneName: [{ required: true, message: '请输入线库名称', trigger: 'blur' }]
})
const editFormEl = ref()
const editSubmit = async () => {
await editFormEl.value.validate(async (valid, fields) => {
if (valid) {
await MapApi.createOrEditOrDelHouseLane(editForm.value)
await getLineLibraryList()
editDialogFormVisible.value = false
message.success('编辑成功')
}
})
}
defineExpose({ open }) // open defineExpose({ open }) // open
</script> </script>

View File

@ -605,35 +605,18 @@
<!-- 测距 绘制点和连线 --> <!-- 测距 绘制点和连线 -->
<template v-if="state.measureDistancesPoints.length > 0"> <template v-if="state.measureDistancesPoints.length > 0">
<!-- 测距的线 -->
<div v-if="state.measureDistancesPoints.length === 2" :style="rangingLineStyle"></div>
<!-- 显示距离信息 -->
<div v-if="state.measureDistancesNum !== null" :style="rangingTextStyle">
{{ state.measureDistancesNum.toFixed(2) }}
</div>
<!-- 测距的点 -->
<div <div
v-for="(point, index) in state.measureDistancesPoints" v-for="(point, index) in state.measureDistancesPoints"
:key="index" :key="index"
:style="{ :style="getRangingPointStyle(point)"
position: 'absolute',
left: `${point.x - 3}px`,
top: `${point.y - 3}px`,
width: '6px',
height: '6px',
backgroundColor: '#00329F',
borderRadius: '50%'
}"
></div> ></div>
<div
v-if="state.measureDistancesPoints.length === 2"
:style="{
position: 'absolute',
left: `${state.measureDistancesPoints[0].x}px`,
top: `${state.measureDistancesPoints[0].y}px`,
width: `${computedLineWidth}px`,
height: '2px',
backgroundColor: '#00329F',
transform: `rotate(${computedLineAngle}deg)`,
transformOrigin: '0 0',
textAlign: 'center'
}"
>
距离{{ state.measureDistancesNum.toFixed(2) }}</div
>
</template> </template>
<!-- 文字输入区域 --> <!-- 文字输入区域 -->
@ -2318,28 +2301,68 @@ const editMapRouteDialogSubmit = (form) => {
addEditHistory() // addEditHistory() //
} }
// //
// // 线
const calculateDistance = (point1, point2) => { const rangingLineStyle = computed(() => {
const dx = point2.x - point1.x
const dy = point2.y - point1.y
return Math.sqrt(dx * dx + dy * dy)
}
// 线
const computedLineAngle = computed(() => {
if (state.measureDistancesPoints.length === 2) { if (state.measureDistancesPoints.length === 2) {
const dx = state.measureDistancesPoints[1].x - state.measureDistancesPoints[0].x const [point1, point2] = state.measureDistancesPoints
const dy = state.measureDistancesPoints[1].y - state.measureDistancesPoints[0].y const length = Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2))
return Math.atan2(dy, dx) * (180 / Math.PI) const angle = (Math.atan2(point2.y - point1.y, point2.x - point1.x) * 180) / Math.PI
return {
position: 'absolute',
left: `${point1.x}px`,
top: `${point1.y}px`,
width: `${length}px`,
height: '2px',
backgroundColor: 'red',
transform: `rotate(${angle}deg)`,
transformOrigin: '0 0'
}
} }
return 0 return {}
}) })
// 线 // 线
const computedLineWidth = computed(() => { const rangingTextStyle = computed(() => {
if (state.measureDistancesPoints.length === 2) { if (state.measureDistancesPoints.length === 2) {
return calculateDistance(state.measureDistancesPoints[0], state.measureDistancesPoints[1]) const [point1, point2] = state.measureDistancesPoints
const midX = (point1.x + point2.x) / 2
const midY = (point1.y + point2.y) / 2
const angle = (Math.atan2(point2.y - point1.y, point2.x - point1.x) * 180) / Math.PI
// 使
let textRotation = 0
if (angle > 90 || angle < -90) {
textRotation = angle + 180 //
} else {
textRotation = angle
}
return {
position: 'absolute',
left: `${midX}px`,
top: `${midY}px`,
transform: `translate(-50%, -50%) rotate(${textRotation}deg)`,
backgroundColor: 'rgba(255, 255, 255, 0.8)',
padding: '2px',
borderRadius: '4px',
fontSize: '12px',
color: 'black',
whiteSpace: 'nowrap', //
pointerEvents: 'none' //
}
} }
return 0 return {}
})
//
const getRangingPointStyle = (point) => ({
position: 'absolute',
left: `${point.x - 4}px`,
top: `${point.y - 4}px`,
width: '8px',
height: '8px',
backgroundColor: 'blue',
borderRadius: '50%'
}) })
//线 //线
@ -2411,9 +2434,9 @@ const measureDistancesClick = (event) => {
state.measureDistancesPoints.push({ x: offsetX, y: offsetY }) state.measureDistancesPoints.push({ x: offsetX, y: offsetY })
if (state.measureDistancesPoints.length === 2) { if (state.measureDistancesPoints.length === 2) {
// //
let distancesNum = calculateDistance( const [point1, point2] = state.measureDistancesPoints
state.measureDistancesPoints[0], let distancesNum = Math.sqrt(
state.measureDistancesPoints[1] Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2)
) )
state.measureDistancesNum = distancesNum * Number(imgBgObj.resolution) state.measureDistancesNum = distancesNum * Number(imgBgObj.resolution)
} }

View File

@ -1,60 +1,115 @@
<template> <template>
<div> <div @click="handleClick" style="position: relative; width: 100%; height: 100vh">
<button @click="scale *= 1.1">放大</button> <!-- 画线 -->
<button @click="scale /= 1.1">缩小</button> <div v-if="state.measureDistancesPoints.length === 2" :style="rangingLineStyle"></div>
<div
ref="containerRef" <!-- 显示距离信息 -->
:style="{ transform: `scale(${scale})` }" <div v-if="state.measureDistancesNum !== null" :style="rangingTextStyle">
@mousemove="handleMouseMove" 距离: {{ state.measureDistancesNum.toFixed(2) }} 像素
class="scalable-container"
>
<div :style="{ left: `${mouseX}px`, top: `${mouseY}px` }" class="cursor"></div>
</div> </div>
<!-- 显示点 -->
<div
v-for="(point, index) in state.measureDistancesPoints"
:key="index"
:style="getRangingPointStyle(point)"
></div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue' import { ref, computed } from 'vue'
const containerRef = ref(null) const state = reactive({
const scale = ref(1) measureDistancesPoints: [],
const mouseX = ref(0) measureDistancesNum: null
const mouseY = ref(0) })
const handleMouseMove = (event) => { //
const rect = containerRef.value.getBoundingClientRect() const handleClick = (event) => {
const offsetX = event.clientX - rect.left if (state.measureDistancesPoints.length === 2) {
const offsetY = event.clientY - rect.top //
state.measureDistancesPoints = []
state.measureDistancesNum = null
} else {
//
state.measureDistancesPoints.push({ x: event.clientX, y: event.clientY })
// //
mouseX.value = offsetX / scale.value if (state.measureDistancesPoints.length === 2) {
mouseY.value = offsetY / scale.value const [point1, point2] = state.measureDistancesPoints
state.measureDistancesNum = Math.sqrt(
Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2)
)
}
}
} }
onMounted(() => { // 线
// const rangingLineStyle = computed(() => {
const rect = containerRef.value.getBoundingClientRect() if (state.measureDistancesPoints.length === 2) {
mouseX.value = rect.width / 2 const [point1, point2] = state.measureDistancesPoints
mouseY.value = rect.height / 2 const length = Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2))
const angle = (Math.atan2(point2.y - point1.y, point2.x - point1.x) * 180) / Math.PI
return {
position: 'absolute',
left: `${point1.x}px`,
top: `${point1.y}px`,
width: `${length}px`,
height: '2px',
backgroundColor: 'red',
transform: `rotate(${angle}deg)`,
transformOrigin: '0 0'
}
}
return {}
})
// 线
const rangingTextStyle = computed(() => {
if (state.measureDistancesPoints.length === 2) {
const [point1, point2] = state.measureDistancesPoints
const midX = (point1.x + point2.x) / 2
const midY = (point1.y + point2.y) / 2
const angle = (Math.atan2(point2.y - point1.y, point2.x - point1.x) * 180) / Math.PI
// 使
let textRotation = 0
if (angle > 90 || angle < -90) {
textRotation = angle + 180 //
} else {
textRotation = angle
}
return {
position: 'absolute',
left: `${midX}px`,
top: `${midY}px`,
transform: `translate(-50%, -50%) rotate(${textRotation}deg)`,
backgroundColor: 'rgba(255, 255, 255, 0.8)',
padding: '4px 8px',
borderRadius: '4px',
fontSize: '14px',
color: 'black',
whiteSpace: 'nowrap', //
pointerEvents: 'none' //
}
}
return {}
})
//
const getRangingPointStyle = (point) => ({
position: 'absolute',
left: `${point.x - 5}px`,
top: `${point.y - 5}px`,
width: '10px',
height: '10px',
backgroundColor: 'blue',
borderRadius: '50%'
}) })
</script> </script>
<style scoped> <style>
.scalable-container { /* 你可以在这里添加一些样式 */
position: relative;
width: 200px;
height: 200px;
border: 1px solid #ccc;
margin-top: 20px;
transform-origin: top left;
transition: transform 0.3s;
}
.cursor {
position: absolute;
width: 10px;
height: 10px;
background-color: red;
border-radius: 50%;
}
</style> </style>