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 {
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
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']
|
||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||
ElInput: typeof import('element-plus/es')['ElInput']
|
||||
|
||||
@ -27,14 +27,6 @@
|
||||
<el-table-column prop="deviceId" label="设备 ID" />
|
||||
<el-table-column prop="health" label="健康状态" width="190" />
|
||||
</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>
|
||||
</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 }))
|
||||
))
|
||||
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 robot = selectedRobot.value
|
||||
if (!robot) return
|
||||
robotStore.setRobotId(robot.robotId)
|
||||
const robotType = getRobotType(robot)
|
||||
if (robotType) robotStore.setRobotType(robotType)
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载机器人列表
|
||||
*/
|
||||
const loadRobots = async () => {
|
||||
robotListLoading.value = true
|
||||
try {
|
||||
@ -101,32 +103,34 @@ const testConnect = async () => {
|
||||
ElMessage.warning('请先选择已连接机器人')
|
||||
return
|
||||
}
|
||||
const valid = await ruleFormRef.value.validate();
|
||||
if (valid) {
|
||||
loading.value = true
|
||||
robotStore.setRobotId(selectedRobot.value.robotId)
|
||||
robotStore.setRobotType(ruleForm.value.robotType)
|
||||
selectRobot()
|
||||
const robotType = getRobotType(selectedRobot.value)
|
||||
if (!robotType) {
|
||||
ElMessage.warning('机器人机械臂数量异常,无法判断机器人类型')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await getRuntimeState()
|
||||
loading.value = false
|
||||
if (result.code === 200) {
|
||||
robotStore.setPosition(result.data.pose)
|
||||
robotStore.setBattery(result.data.battery)
|
||||
robotStore.setCurrentMap(result.data.current_map)
|
||||
router.push({
|
||||
path: '/home'
|
||||
})
|
||||
} else {
|
||||
ElMessage.error(result?.message || result?.error || '连接服务错误')
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
loading.value = false
|
||||
ElMessage.error(error?.message || '连接服务错误')
|
||||
loading.value = true
|
||||
robotStore.setRobotId(selectedRobot.value.robotId)
|
||||
robotStore.setRobotType(robotType)
|
||||
|
||||
try {
|
||||
const result = await getRuntimeState()
|
||||
loading.value = false
|
||||
if (result.code === 200) {
|
||||
robotStore.setPosition(result.data.pose)
|
||||
robotStore.setBattery(result.data.battery)
|
||||
robotStore.setCurrentMap(result.data.current_map)
|
||||
router.push({
|
||||
path: '/home'
|
||||
})
|
||||
} else {
|
||||
ElMessage.error(result?.message || result?.error || '连接服务错误')
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
loading.value = false
|
||||
ElMessage.error(error?.message || '连接服务错误')
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -174,11 +178,6 @@ const testConnect = async () => {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
font-size: 16px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
:deep(.el-input__inner) {
|
||||
height: 40px;
|
||||
// 避免 iPad Safari 聚焦小字号输入框时自动缩放页面。
|
||||
|
||||
Loading…
Reference in New Issue
Block a user