This commit is contained in:
BianLzhaoMin 2025-07-25 16:09:45 +08:00
parent 57d636ba91
commit 381404fbdb
3 changed files with 216 additions and 37 deletions

View File

@ -77,28 +77,24 @@
class="arrow-top hand-direction" class="arrow-top hand-direction"
@mousedown="handleChangeCamera('up')" @mousedown="handleChangeCamera('up')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-right hand-direction" class="arrow-right hand-direction"
@mousedown="handleChangeCamera('right')" @mousedown="handleChangeCamera('right')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-bottom hand-direction" class="arrow-bottom hand-direction"
@mousedown="handleChangeCamera('down')" @mousedown="handleChangeCamera('down')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-left hand-direction" class="arrow-left hand-direction"
@mousedown="handleChangeCamera('left')" @mousedown="handleChangeCamera('left')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
@ -118,11 +114,13 @@
<span>缩放</span> <span>缩放</span>
<img <img
style="margin-bottom: 2px" style="margin-bottom: 2px"
@click="handleChangeZoomCamera('ZoomIn')" @mousedown="handleChangeZoomCamera('ZoomIn')"
@mouseup="handleStopDeviceCameraZoom()"
src="@/assets/home-imgs/control-2-add.png" src="@/assets/home-imgs/control-2-add.png"
/> />
<img <img
@click="handleChangeZoomCamera('ZoomOut')" @mousedown="handleChangeZoomCamera('ZoomOut')"
@mouseup="handleStopDeviceCameraZoom()"
src="@/assets/home-imgs/control-2-reduce.png" src="@/assets/home-imgs/control-2-reduce.png"
/> />
</div> </div>
@ -146,28 +144,24 @@
class="arrow-top" class="arrow-top"
@mousedown="handleChangeRobot('5')" @mousedown="handleChangeRobot('5')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-right" class="arrow-right"
@mousedown="handleChangeRobot('8')" @mousedown="handleChangeRobot('8')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-bottom" class="arrow-bottom"
@mousedown="handleChangeRobot('6')" @mousedown="handleChangeRobot('6')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-left" class="arrow-left"
@mousedown="handleChangeRobot('7')" @mousedown="handleChangeRobot('7')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
@ -457,6 +451,43 @@ const beforeUpload = ({ file }) => {
return true return true
} }
//
const handleInspection = async () => {
if (robotBaseInfo.value.type.includes('巡检')) {
return new Promise((resolve) => {
dialog.warning({
title: '提示',
content: '当前机器人正在巡检中,可暂停巡检后再进行操作',
positiveText: '暂停巡检',
negativeText: '取消',
onPositiveClick: async () => {
try {
const { data: res } = await handleRobotActionApi({
puId: robotData.robotInfo?.puId,
type: '15',
})
if (res.code == 200) {
message.success('已暂停巡检')
getRobotBaseInfo()
resolve(false) // false
} else {
message.error('暂停巡检失败' + res.message)
resolve(true) //
}
} catch (error) {
message.error('暂停巡检出错')
resolve(true) //
}
},
onNegativeClick: () => {
resolve(true) //
},
})
})
}
return false // ""false
}
// //
const handleChangeUpload = async (e) => { const handleChangeUpload = async (e) => {
const file = e.file const file = e.file
@ -598,11 +629,16 @@ const handleStopDeviceCameraZoom = async () => {
puid: '201115200268437643', puid: '201115200268437643',
}) })
console.log(res, '停止位置---') isStopLeft.value = true
console.log(res, '停止缩放')
} }
// //
const handleChangeCamera = debounce(async (motion) => { const handleChangeCamera = debounce(async (motion) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
if (motion === 'stop' && isZoom.value) { if (motion === 'stop' && isZoom.value) {
isStopLeft.value = true isStopLeft.value = true
handleStopDeviceCameraZoom() handleStopDeviceCameraZoom()
@ -629,6 +665,10 @@ const handleChangeCamera = debounce(async (motion) => {
// //
const handleChangeZoomCamera = async (motion) => { const handleChangeZoomCamera = async (motion) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
isStopLeft.value = false isStopLeft.value = false
isZoom.value = true isZoom.value = true
if (motion === 'ZoomIn') { if (motion === 'ZoomIn') {
@ -648,7 +688,18 @@ const handleChangeZoomCamera = async (motion) => {
// //
const handleChangeRobot = debounce(async (type) => { const handleChangeRobot = debounce(async (type) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
// type 5 6 退 7 8 // type 5 6 退 7 8
const typeMap = {
5: '前进', //
6: '后退', // 退
7: '左转', //
8: '右转', //
9: '停止', //
}
if (!robotData.robotInfo?.puId) { if (!robotData.robotInfo?.puId) {
message.error('当前机器人未连接', { message.error('当前机器人未连接', {
duration: 1000, duration: 1000,
@ -661,10 +712,10 @@ const handleChangeRobot = debounce(async (type) => {
type, type,
} }
console.log(params, 'params---') console.log(params, '机器人操控参数' + typeMap[type])
const res = await handleRobotActionApi(params) const { data: res } = await handleRobotActionApi(params)
console.log(res, '操控机器人---') console.log(res, '机器人操控结果')
if (res.code == 200 && type != 9) { if (res.code == 200 && type != 9) {
isStopRight.value = true isStopRight.value = true
} }

View File

@ -77,28 +77,24 @@
class="arrow-top hand-direction" class="arrow-top hand-direction"
@mousedown="handleChangeCamera('up')" @mousedown="handleChangeCamera('up')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-right hand-direction" class="arrow-right hand-direction"
@mousedown="handleChangeCamera('right')" @mousedown="handleChangeCamera('right')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-bottom hand-direction" class="arrow-bottom hand-direction"
@mousedown="handleChangeCamera('down')" @mousedown="handleChangeCamera('down')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-left hand-direction" class="arrow-left hand-direction"
@mousedown="handleChangeCamera('left')" @mousedown="handleChangeCamera('left')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
@ -118,11 +114,13 @@
<span>缩放</span> <span>缩放</span>
<img <img
style="margin-bottom: 2px" style="margin-bottom: 2px"
@click="handleChangeZoomCamera('ZoomIn')" @mousedown="handleChangeZoomCamera('ZoomIn')"
@mouseup="handleStopDeviceCameraZoom()"
src="@/assets/home-imgs/control-2-add.png" src="@/assets/home-imgs/control-2-add.png"
/> />
<img <img
@click="handleChangeZoomCamera('ZoomOut')" @mousedown="handleChangeZoomCamera('ZoomOut')"
@mouseup="handleStopDeviceCameraZoom()"
src="@/assets/home-imgs/control-2-reduce.png" src="@/assets/home-imgs/control-2-reduce.png"
/> />
</div> </div>
@ -146,28 +144,24 @@
class="arrow-top" class="arrow-top"
@mousedown="handleChangeRobot('5')" @mousedown="handleChangeRobot('5')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-right" class="arrow-right"
@mousedown="handleChangeRobot('8')" @mousedown="handleChangeRobot('8')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-bottom" class="arrow-bottom"
@mousedown="handleChangeRobot('6')" @mousedown="handleChangeRobot('6')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
<img <img
class="arrow-left" class="arrow-left"
@mousedown="handleChangeRobot('7')" @mousedown="handleChangeRobot('7')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
/> />
@ -457,6 +451,68 @@ const beforeUpload = ({ file }) => {
return true return true
} }
//
const handleInspection = async () => {
// if (robotBaseInfo.value.type.includes('')) {
// //
// dialog.warning({
// title: '',
// content: '',
// positiveText: '',
// negativeText: '',
// onPositiveClick: async () => {
// const { data: res } = await handleRobotActionApi({
// puId: robotData.robotInfo?.puId,
// type: '15',
// })
// if (res.code == 200) {
// message.success('')
// getRobotBaseInfo()
// } else {
// message.error('' + res.message)
// }
// },
// onNegativeClick: () => {
// return
// },
// })
// }
if (robotBaseInfo.value.type.includes('巡检')) {
return new Promise((resolve) => {
dialog.warning({
title: '提示',
content: '当前机器人正在巡检中,可暂停巡检后再进行操作',
positiveText: '暂停巡检',
negativeText: '取消',
onPositiveClick: async () => {
try {
const { data: res } = await handleRobotActionApi({
puId: robotData.robotInfo?.puId,
type: '15',
})
if (res.code == 200) {
message.success('已暂停巡检')
getRobotBaseInfo()
resolve(false) // false
} else {
message.error('暂停巡检失败' + res.message)
resolve(true) //
}
} catch (error) {
message.error('暂停巡检出错')
resolve(true) //
}
},
onNegativeClick: () => {
resolve(true) //
},
})
})
}
return false // ""false
}
// //
const handleChangeUpload = async (e) => { const handleChangeUpload = async (e) => {
const file = e.file const file = e.file
@ -598,11 +654,16 @@ const handleStopDeviceCameraZoom = async () => {
puid: '201115200268437643', puid: '201115200268437643',
}) })
isStopLeft.value = true
console.log(res, '停止位置---') console.log(res, '停止位置---')
} }
// //
const handleChangeCamera = debounce(async (motion) => { const handleChangeCamera = debounce(async (motion) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
if (motion === 'stop' && isZoom.value) { if (motion === 'stop' && isZoom.value) {
isStopLeft.value = true isStopLeft.value = true
handleStopDeviceCameraZoom() handleStopDeviceCameraZoom()
@ -629,6 +690,10 @@ const handleChangeCamera = debounce(async (motion) => {
// //
const handleChangeZoomCamera = async (motion) => { const handleChangeZoomCamera = async (motion) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
isStopLeft.value = false isStopLeft.value = false
isZoom.value = true isZoom.value = true
if (motion === 'ZoomIn') { if (motion === 'ZoomIn') {
@ -648,6 +713,10 @@ const handleChangeZoomCamera = async (motion) => {
// //
const handleChangeRobot = debounce(async (type) => { const handleChangeRobot = debounce(async (type) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
// type 5 6 退 7 8 // type 5 6 退 7 8
if (!robotData.robotInfo?.puId) { if (!robotData.robotInfo?.puId) {
message.error('当前机器人未连接', { message.error('当前机器人未连接', {
@ -708,7 +777,6 @@ const handlePlayAudio = async () => {
} }
// //
const handleChangeVolume = debounce(async (value) => { const handleChangeVolume = debounce(async (value) => {
const { data: res } = await handleRobotActionApi({ const { data: res } = await handleRobotActionApi({
puId: robotData.robotInfo?.puId, puId: robotData.robotInfo?.puId,

View File

@ -12,7 +12,6 @@
alt="" alt=""
@mousedown="handleChangeCamera('up')" @mousedown="handleChangeCamera('up')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
/> />
<img <img
class="arrow-right hand-direction" class="arrow-right hand-direction"
@ -20,7 +19,6 @@
alt="" alt=""
@mousedown="handleChangeCamera('right')" @mousedown="handleChangeCamera('right')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
/> />
<img <img
class="arrow-bottom hand-direction" class="arrow-bottom hand-direction"
@ -28,7 +26,6 @@
alt="" alt=""
@mousedown="handleChangeCamera('down')" @mousedown="handleChangeCamera('down')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
/> />
<img <img
class="arrow-left hand-direction" class="arrow-left hand-direction"
@ -36,7 +33,6 @@
alt="" alt=""
@mousedown="handleChangeCamera('left')" @mousedown="handleChangeCamera('left')"
@mouseup="handleChangeCamera('stop')" @mouseup="handleChangeCamera('stop')"
@mouseleave="handleChangeCamera('stop')"
/> />
<!-- 中间的按钮 --> <!-- 中间的按钮 -->
@ -56,12 +52,14 @@
<img <img
style="margin-left: 20px; transform: rotate(-90deg)" style="margin-left: 20px; transform: rotate(-90deg)"
src="@/assets/home-imgs/control-2-add.png" src="@/assets/home-imgs/control-2-add.png"
@click="handleChangeZoomCamera('ZoomIn')" @mousedown="handleChangeZoomCamera('ZoomIn')"
@mouseup="handleStopDeviceCameraZoom()"
/> />
<img <img
style="margin-left: 50px; transform: rotate(-90deg)" style="margin-left: 50px; transform: rotate(-90deg)"
src="@/assets/home-imgs/control-2-reduce.png" src="@/assets/home-imgs/control-2-reduce.png"
@click="handleChangeZoomCamera('ZoomOut')" @mousedown="handleChangeZoomCamera('ZoomOut')"
@mouseup="handleStopDeviceCameraZoom()"
/> />
</div> </div>
</div> </div>
@ -73,7 +71,6 @@
<img <img
@mousedown="handleChangeRobot('5')" @mousedown="handleChangeRobot('5')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
class="arrow-top" class="arrow-top"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
alt="" alt=""
@ -81,7 +78,6 @@
<img <img
@mousedown="handleChangeRobot('8')" @mousedown="handleChangeRobot('8')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
class="arrow-right" class="arrow-right"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
alt="" alt=""
@ -89,7 +85,6 @@
<img <img
@mousedown="handleChangeRobot('6')" @mousedown="handleChangeRobot('6')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
class="arrow-bottom" class="arrow-bottom"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
alt="" alt=""
@ -97,7 +92,6 @@
<img <img
@mousedown="handleChangeRobot('7')" @mousedown="handleChangeRobot('7')"
@mouseup="handleChangeRobot(9)" @mouseup="handleChangeRobot(9)"
@mouseleave="handleChangeRobot(9)"
class="arrow-left" class="arrow-left"
src="@/assets/home-imgs/control-2-arrow.png" src="@/assets/home-imgs/control-2-arrow.png"
alt="" alt=""
@ -138,6 +132,7 @@ const message = useMessage()
const isStopLeft = ref(false) const isStopLeft = ref(false)
const isStopRight = ref(false) const isStopRight = ref(false)
const isZoom = ref(false) const isZoom = ref(false)
const robotBaseInfo = ref({})
const props = defineProps({ const props = defineProps({
deviceToken: { deviceToken: {
@ -149,8 +144,59 @@ const props = defineProps({
default: () => {}, default: () => {},
}, },
}) })
//
const getRobotBaseInfo = async () => {
const { data: res } = await handleRobotActionApi({
puId: deviceInfo.value?.puId,
type: '1',
})
robotBaseInfo.value = res.data
}
//
const handleInspection = async () => {
if (robotBaseInfo.value.type.includes('巡检')) {
return new Promise((resolve) => {
dialog.warning({
title: '提示',
content: '当前机器人正在巡检中,可暂停巡检后再进行操作',
positiveText: '暂停巡检',
negativeText: '取消',
onPositiveClick: async () => {
try {
const { data: res } = await handleRobotActionApi({
puId: robotData.robotInfo?.puId,
type: '15',
})
if (res.code == 200) {
message.success('已暂停巡检')
getRobotBaseInfo()
resolve(false) // false
} else {
message.error('暂停巡检失败' + res.message)
resolve(true) //
}
} catch (error) {
message.error('暂停巡检出错')
resolve(true) //
}
},
onNegativeClick: () => {
resolve(true) //
},
})
})
}
return false // ""false
}
// //
const handleStopDeviceCameraZoom = async () => { const handleStopDeviceCameraZoom = async () => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
isZoom.value = false isZoom.value = false
const res = await stopDeviceCameraZoomApi({ const res = await stopDeviceCameraZoomApi({
token: props.deviceToken, token: props.deviceToken,
@ -158,15 +204,19 @@ const handleStopDeviceCameraZoom = async () => {
idx: 0, idx: 0,
}) })
isStopLeft.value = true
console.log(res, '停止位置---') console.log(res, '停止位置---')
} }
// //
const handleChangeCamera = debounce(async (motion) => { const handleChangeCamera = debounce(async (motion) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
if (motion === 'stop' && isZoom.value) { if (motion === 'stop' && isZoom.value) {
isStopLeft.value = true isStopLeft.value = true
handleStopDeviceCameraZoom() handleStopDeviceCameraZoom()
return return
} }
if (motion === 'stop') { if (motion === 'stop') {
@ -190,6 +240,10 @@ const handleChangeCamera = debounce(async (motion) => {
// //
const handleChangeZoomCamera = async (motion) => { const handleChangeZoomCamera = async (motion) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
isStopLeft.value = false isStopLeft.value = false
isZoom.value = true isZoom.value = true
if (motion === 'ZoomIn') { if (motion === 'ZoomIn') {
@ -209,6 +263,10 @@ const handleChangeZoomCamera = async (motion) => {
// //
const handleChangeRobot = debounce(async (type) => { const handleChangeRobot = debounce(async (type) => {
const isInspection = await handleInspection()
if (isInspection) {
return
}
// type 5 6 退 7 8 9 // type 5 6 退 7 8 9
if (!robotData.robotInfo?.puId) { if (!robotData.robotInfo?.puId) {
message.error('当前机器人未连接', { message.error('当前机器人未连接', {
@ -231,7 +289,9 @@ const handleChangeRobot = debounce(async (type) => {
} }
}, 600) }, 600)
onMounted(async () => {}) onMounted(async () => {
getRobotBaseInfo()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.control-deck { .control-deck {