右击菜单 库位生成检测点

This commit is contained in:
yyy 2025-06-26 10:49:33 +08:00
parent b1fbcb09f2
commit cd75476893
2 changed files with 153 additions and 4 deletions

View File

@ -442,7 +442,7 @@ const clearCar = (robotNo) => {
.then(() => {
CarApi.cleanTrafficManagement({ robotNo }).then((res) => {
getCarList()
getRobotInformationStatistics()
fetchData()
message.success('清除成功')
})
})
@ -459,7 +459,7 @@ const recoveryTask = (robotNo) => {
.then(() => {
CarApi.doTaskContinue({ robotNo }).then((res) => {
getCarList()
getRobotInformationStatistics()
fetchData()
message.success('恢复成功')
})
})

View File

@ -540,7 +540,7 @@
</div>
</div>
</template>
<div>
<div @contextmenu="handleContextMenu(item, index, $event)">
<div
v-if="
item.type === 1 &&
@ -957,6 +957,21 @@
:imgBgObj="imgBgObj"
@submit-batch-copying-form-success="submitBatchCopyingFormSuccess"
/>
<div
v-if="state.contextMenu.visible"
class="context-menu"
:style="{ left: state.contextMenu.x + 'px', top: state.contextMenu.y + 'px' }"
@click.stop
>
<div class="context-menu-item" @click="deleteSingleNode">删除</div>
<div
class="context-menu-item"
@click="generateDetectionPoint"
v-if="state.contextMenu.currentItem.type === 2"
>生成检测点</div
>
</div>
</div>
</template>
@ -1716,7 +1731,15 @@ const state = reactive({
vLine: [],
hLine: [],
svgRouteZIndex: 9,
isCurveDisplay: true
isCurveDisplay: true,
//
contextMenu: {
visible: false, //
x: 0, // x
y: 0, // y
currentItem: null, //
currentIndex: -1 //
}
})
const getRefLineParams = (params) => {
@ -2083,6 +2106,93 @@ const toolbarClick = async (item) => {
}
}
//
const handleContextMenu = (item, index, event) => {
//
event.preventDefault()
//
state.contextMenu.visible = true
state.contextMenu.x = event.clientX
state.contextMenu.y = event.clientY
state.contextMenu.currentItem = item
state.contextMenu.currentIndex = index
}
//
const hideContextMenu = () => {
state.contextMenu.visible = false
state.contextMenu.currentIndex = -1
}
//
const deleteSingleNode = () => {
if (state.contextMenu.currentIndex !== -1) {
let deleteId = state.allMapPointInfo[state.contextMenu.currentIndex].id
// 线
state.mapRouteList = state.mapRouteList.filter(
(item) => item.startingPointId !== deleteId && item.endPointId !== deleteId
)
state.allMapPointInfo.splice(state.contextMenu.currentIndex, 1)
//index
state.contextMenu.currentIndex = -1
message.success('删除成功')
addEditHistory()
//
hideContextMenu()
}
}
//
const generateDetectionPoint = () => {
if (state.contextMenu.currentIndex === -1) return
const { locationX, locationY } = state.contextMenu.currentItem
const radian = 1.57 //
const distance = 1 / Number(imgBgObj.resolution) //
// 使
const angle = radian * (180 / Math.PI)
//
// 090西180-90
const newX = Number((Number(locationX) + distance * Math.cos(radian)).toFixed(2))
const newY = Number((Number(locationY) - distance * Math.sin(radian)).toFixed(2))
let actualPoint = disposeEventPoint(newX, newY)
let pointItem = {
positionMapId: imgBgObj.positionMapId,
layerSelectionShow: true,
locationX: newX,
locationY: newY,
actualLocationX: actualPoint.actualLocationX,
actualLocationY: actualPoint.actualLocationY,
locationDeep: 40,
locationWide: 40,
locationDeepPx: 8,
locationWidePx: 8,
angle: 0,
draggable: true,
resizable: true,
rotatable: false,
lockAspectRatio: false,
mapImageUrl: '',
locationYaw: 0,
type: 1,
dataList: [],
dataObj: {}
}
//
state.allMapPointInfo.push(pointItem)
addEditHistory()
//
hideContextMenu()
}
//
const replicationNode = () => {
let copyMapItem = state.allMapPointInfo[state.currentItemIndex]
@ -3971,6 +4081,15 @@ const searchSelectChange = (sortNum) => {
}
document.onmousedown = function (e) {
//
if (state.contextMenu.visible) {
//
const contextMenu = document.querySelector('.context-menu')
if (contextMenu && !contextMenu.contains(e.target)) {
state.contextMenu.visible = false
}
}
//
if (e.button == 2) {
state.selectedCurve = ''
@ -4408,4 +4527,34 @@ const findClosestPoint = (x, y) => {
.h-line {
height: 1px;
}
//
.context-menu {
position: fixed;
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 99999;
min-width: 120px;
padding: 4px 0;
.context-menu-item {
z-index: 99999;
padding: 8px 16px;
cursor: pointer;
font-size: 14px;
color: #606266;
transition: background-color 0.2s;
&:hover {
background-color: #f5f7fa;
color: #409eff;
}
&:not(:last-child) {
border-bottom: 1px solid #f0f0f0;
}
}
}
</style>