feat(inspection): 更新地图页面机器人选择功能

- 优化机器人下拉选择器,添加过滤和加载状态显示
- 新增连接AGV设备的机器人筛选逻辑
- 集成机器人设备API获取AGV设备信息
- 改进机器人列表数据显示格式,显示设备ID
- 添加加载状态指示器提升用户体验
- 修复机器人数据获取逻辑确保仅显示已连接AGV的机器人
This commit is contained in:
lixiaolong 2026-08-05 11:51:31 +08:00
parent b2593bf857
commit 22e69b79ae

View File

@ -52,7 +52,8 @@
<el-form-item label="选择机器人地图">
<el-col :span="11">
<el-form-item prop="mapSourceRobotId">
<el-select v-model="form.mapSourceRobotId" placeholder="请选择机器人" clearable style="width: 100%"
<el-select v-model="form.mapSourceRobotId" placeholder="请选择已连接AGV的机器人" clearable
filterable :loading="robotLoading" no-data-text="暂无已连接AGV的机器人" style="width: 100%"
@change="robotChange">
<el-option v-for="robot in robotList" :key="robot.value" :label="robot.label" :value="robot.value" />
</el-select>
@ -88,7 +89,7 @@
import { useContainerHeight } from "@/hooks/tableHeight";
import { addMap, updateMap, deleteMap, getMapList } from "../../../api/inspection/map";
import { getRobotList, getMapByRobot, getMapJson } from "../../../api/inspection/robot";
import { getRobotList, getMapByRobot, getMapJson, getRobotDevicesByRobotId } from "../../../api/inspection/robot";
import { onMounted } from "vue";
import {
@ -202,6 +203,7 @@ function resetQuery() {
/** 新增按钮操作 */
function handleAdd() {
getRobotArr();
open.value = true;
isNew.value = true;
title.value = "添加地图";
@ -212,6 +214,7 @@ function handleAdd() {
/** 修改按钮操作 */
function handleUpdate(row) {
getRobotArr();
form.value = { ...row };
isNew.value = false;
open.value = true;
@ -518,17 +521,33 @@ function renderFrame(timestamp) {
const robotList = ref([])
const mapList = ref([])
const robotLoading = ref(false)
const getRobotArr = () => {
getRobotList({
const getRobotArr = async () => {
robotLoading.value = true
try {
const response = await getRobotList({
pageNum: 1,
pageSize: 10000,
}).then((response) => {
robotList.value = response.rows.map(item => ({
label: item.robotName,
value: item.id
}));
});
connectStatus: '1'
})
const candidates = (response.rows || []).filter(item => item.robotId)
const resolved = await Promise.allSettled(candidates.map(async item => {
const deviceResponse = await getRobotDevicesByRobotId(item.robotId, { deviceKind: 1 })
const agvDevices = Array.isArray(deviceResponse.data) ? deviceResponse.data : []
if (!agvDevices.length) return null
const deviceIds = agvDevices.map(device => device.deviceId).join(' / ')
return {
label: `${item.robotName || item.robotId} (${item.robotId}) · AGV: ${deviceIds}`,
value: item.id
}
}))
robotList.value = resolved
.filter(result => result.status === 'fulfilled' && result.value)
.map(result => result.value)
} finally {
robotLoading.value = false
}
}
const getMapArr = async (robotId) => {
@ -577,4 +596,4 @@ onMounted(() => {
height: 300px;
border: 1px solid #ccc;
}
</style>
</style>