inspection-host-computer/src/views/Address.vue

149 lines
4.4 KiB
Vue
Raw Normal View History

2026-06-30 17:32:54 +08:00
<template>
<div class="page-container">
2026-07-06 10:32:35 +08:00
<div class="card">
<div class="title">设备连接登录</div>
<div class="secondaryTitle">填写设备通讯参数建立与AGV底盘和机械臂的连接</div>
<div class="tips">请操持设备与上位机在同一局域网内</div>
<div class="form">
<el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="auto">
<el-form-item label="IP和端口" prop="ip">
<el-input v-model="ruleForm.ip" placeholder="请输入IP和端口" />
</el-form-item>
<el-form-item label="底盘设备ID" prop="agvDeviceId">
<el-input v-model="ruleForm.agvDeviceId" placeholder="请输入底盘设备ID" />
</el-form-item>
<el-form-item label="机械臂设备ID" prop="almDeviceId">
<el-input v-model="ruleForm.almDeviceId" placeholder="请输入机械臂设备ID" />
</el-form-item>
</el-form>
<el-button :loading="loading" @click="testConnect" class="connect">进入上位机控制页面</el-button>
</div>
<div class="error-tips">连接异常排查检查机器人状态局域网联通设备ID调谐是否匹配</div>
2026-06-30 17:32:54 +08:00
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
2026-07-10 13:44:07 +08:00
import { getRuntimeState } from '@/api/agv.js'
2026-06-30 17:32:54 +08:00
import { useRobotStore } from '@/stores/robot'
2026-07-06 10:32:35 +08:00
import { ElMessage } from 'element-plus'
2026-06-30 17:32:54 +08:00
const router = useRouter()
const robotStore = useRobotStore()
2026-07-06 10:32:35 +08:00
const loading = ref(false)
2026-06-30 17:32:54 +08:00
const ruleFormRef = ref()
const ruleForm = ref({
2026-07-06 10:32:35 +08:00
ip: '',
agvDeviceId:'',
almDeviceId: ''
2026-06-30 17:32:54 +08:00
})
const rules = ref({
ip: [
{ required: true, message: '请输入机器人IP和端口', trigger: 'blur' }
],
2026-07-06 10:32:35 +08:00
agvDeviceId: [
{ required: true, message: '请输入底盘设备ID', trigger: 'blur' }
],
almDeviceId: [
{ required: true, message: '请输入机械臂设备ID', trigger: 'blur' }
],
2026-06-30 17:32:54 +08:00
})
const testConnect = async () => {
2026-07-06 10:32:35 +08:00
const valid = await ruleFormRef.value.validate();
if (valid) {
loading.value = true
robotStore.setIp(ruleForm.value.ip)
robotStore.setAgvDeviceId(ruleForm.value.agvDeviceId)
robotStore.setAlmDeviceId(ruleForm.value.almDeviceId)
2026-07-10 13:44:07 +08:00
const result = await getRuntimeState({
2026-07-06 10:32:35 +08:00
ip: robotStore.ip,
deviceId: ruleForm.value.agvDeviceId
})
loading.value = false
if (result.code === 200) {
2026-07-10 13:44:07 +08:00
robotStore.setPosition(result.data.pose)
robotStore.setBattery(result.data.battery)
robotStore.setCurrentMap(result.data.current_map)
2026-07-06 10:32:35 +08:00
router.push({
2026-07-10 13:44:07 +08:00
path: '/home'
2026-07-06 10:32:35 +08:00
})
} else {
ElMessage.error(result?.message || '连接服务错误')
2026-06-30 17:32:54 +08:00
}
2026-07-06 10:32:35 +08:00
}
2026-06-30 17:32:54 +08:00
}
</script>
<style lang="scss" scoped>
.page-container {
width: 100%;
height: 100%;
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 20px;
2026-07-06 10:32:35 +08:00
background-image: url(../assets/address.png);
background-repeat: no-repeat;
background-size: 100% 100%;
2026-06-30 17:32:54 +08:00
2026-07-06 10:32:35 +08:00
.card {
padding: 40px;
box-sizing: border-box;
background: #fff;
width: 600px;
border-radius: 20px;
.title {
font-size: 40px;
font-weight: bold;
color: #000;
margin-bottom: 12px;
}
.secondaryTitle {
font-size: 20px;
color: #8f8f8f;
margin-bottom: 8px;
}
.tips {
display: inline-block;
font-size: 14px;
padding: 4px 16px;
color: #003af7;
background: #b7c5f3;
border-radius: 12px;
margin-bottom: 12px;
}
:deep(.el-input__inner) {
height: 40px;
}
.connect {
width: 340px;
height: 50px;
display: inline-block;
padding: 4px 20px;
color: #fff;
background: #003af7;
border-radius: 12px;
margin-top: 20px;
}
2026-06-30 17:32:54 +08:00
2026-07-06 10:32:35 +08:00
.error-tips {
text-align: center;
font-size: 14px;
color: #8f8f8f;
margin-top: 10px;
}
2026-06-30 17:32:54 +08:00
}
}
</style>