feat: 根据机械臂的数量来判断机器人的类型
This commit is contained in:
parent
92bd36c705
commit
7bfff64737
2
components.d.ts
vendored
2
components.d.ts
vendored
@ -13,8 +13,6 @@ declare module 'vue' {
|
|||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
ElButton: typeof import('element-plus/es')['ElButton']
|
ElButton: typeof import('element-plus/es')['ElButton']
|
||||||
ElContainer: typeof import('element-plus/es')['ElContainer']
|
ElContainer: typeof import('element-plus/es')['ElContainer']
|
||||||
ElForm: typeof import('element-plus/es')['ElForm']
|
|
||||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
|
||||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||||
ElInput: typeof import('element-plus/es')['ElInput']
|
ElInput: typeof import('element-plus/es')['ElInput']
|
||||||
|
|||||||
@ -27,14 +27,6 @@
|
|||||||
<el-table-column prop="deviceId" label="设备 ID" />
|
<el-table-column prop="deviceId" label="设备 ID" />
|
||||||
<el-table-column prop="health" label="健康状态" width="190" />
|
<el-table-column prop="health" label="健康状态" width="190" />
|
||||||
</el-table>
|
</el-table>
|
||||||
<el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="auto">
|
|
||||||
<el-form-item label="机器人类型" prop="robotType">
|
|
||||||
<el-select v-model="ruleForm.robotType" placeholder="请选择机器人类型">
|
|
||||||
<el-option label="巡检机器人" value="inspection"></el-option>
|
|
||||||
<el-option label="讲解机器人" value="explanation"></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<el-button :loading="loading" @click="testConnect" class="connect">进入上位机控制页面</el-button>
|
<el-button :loading="loading" @click="testConnect" class="connect">进入上位机控制页面</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="error-tips">连接异常排查:检查机器人状态、局域网联通、设备ID调谐是否匹配</div>
|
<div class="error-tips">连接异常排查:检查机器人状态、局域网联通、设备ID调谐是否匹配</div>
|
||||||
@ -62,23 +54,33 @@ const selectedDevices = computed(() => Object.entries(selectedRobot.value?.devic
|
|||||||
([kind, devices]) => devices.map(device => ({ kind, ...device }))
|
([kind, devices]) => devices.map(device => ({ kind, ...device }))
|
||||||
))
|
))
|
||||||
let refreshTimer
|
let refreshTimer
|
||||||
const ruleFormRef = ref()
|
|
||||||
const ruleForm = ref({
|
|
||||||
robotType: 'inspection',
|
|
||||||
})
|
|
||||||
|
|
||||||
const rules = ref({
|
/**
|
||||||
robotType: [
|
* 通过机械臂数量判断机器人类型
|
||||||
{ required: true, message: '请选择机器人类型', trigger: 'blur' }
|
* 1 个机械臂为巡检机器人,2 个机械臂为讲解机器人
|
||||||
],
|
* @param robot
|
||||||
})
|
*/
|
||||||
|
const getRobotType = (robot) => {
|
||||||
|
const armCount = robot?.devices?.arm?.length || 0
|
||||||
|
if (armCount === 1) return 'inspection'
|
||||||
|
if (armCount === 2) return 'explanation'
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选择机器人并且设置机器人类型
|
||||||
|
*/
|
||||||
const selectRobot = () => {
|
const selectRobot = () => {
|
||||||
const robot = selectedRobot.value
|
const robot = selectedRobot.value
|
||||||
if (!robot) return
|
if (!robot) return
|
||||||
robotStore.setRobotId(robot.robotId)
|
robotStore.setRobotId(robot.robotId)
|
||||||
|
const robotType = getRobotType(robot)
|
||||||
|
if (robotType) robotStore.setRobotType(robotType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载机器人列表
|
||||||
|
*/
|
||||||
const loadRobots = async () => {
|
const loadRobots = async () => {
|
||||||
robotListLoading.value = true
|
robotListLoading.value = true
|
||||||
try {
|
try {
|
||||||
@ -101,32 +103,34 @@ const testConnect = async () => {
|
|||||||
ElMessage.warning('请先选择已连接机器人')
|
ElMessage.warning('请先选择已连接机器人')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const valid = await ruleFormRef.value.validate();
|
const robotType = getRobotType(selectedRobot.value)
|
||||||
if (valid) {
|
if (!robotType) {
|
||||||
loading.value = true
|
ElMessage.warning('机器人机械臂数量异常,无法判断机器人类型')
|
||||||
robotStore.setRobotId(selectedRobot.value.robotId)
|
return
|
||||||
robotStore.setRobotType(ruleForm.value.robotType)
|
}
|
||||||
selectRobot()
|
|
||||||
|
loading.value = true
|
||||||
try {
|
robotStore.setRobotId(selectedRobot.value.robotId)
|
||||||
const result = await getRuntimeState()
|
robotStore.setRobotType(robotType)
|
||||||
loading.value = false
|
|
||||||
if (result.code === 200) {
|
try {
|
||||||
robotStore.setPosition(result.data.pose)
|
const result = await getRuntimeState()
|
||||||
robotStore.setBattery(result.data.battery)
|
loading.value = false
|
||||||
robotStore.setCurrentMap(result.data.current_map)
|
if (result.code === 200) {
|
||||||
router.push({
|
robotStore.setPosition(result.data.pose)
|
||||||
path: '/home'
|
robotStore.setBattery(result.data.battery)
|
||||||
})
|
robotStore.setCurrentMap(result.data.current_map)
|
||||||
} else {
|
router.push({
|
||||||
ElMessage.error(result?.message || result?.error || '连接服务错误')
|
path: '/home'
|
||||||
}
|
})
|
||||||
}
|
} else {
|
||||||
catch (error) {
|
ElMessage.error(result?.message || result?.error || '连接服务错误')
|
||||||
loading.value = false
|
|
||||||
ElMessage.error(error?.message || '连接服务错误')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
loading.value = false
|
||||||
|
ElMessage.error(error?.message || '连接服务错误')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -174,11 +178,6 @@ const testConnect = async () => {
|
|||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-form-item__label) {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.el-input__inner) {
|
:deep(.el-input__inner) {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
// 避免 iPad Safari 聚焦小字号输入框时自动缩放页面。
|
// 避免 iPad Safari 聚焦小字号输入框时自动缩放页面。
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user