diff --git a/src/views/inspection/map/index.vue b/src/views/inspection/map/index.vue index 2576ca7..d8fec87 100644 --- a/src/views/inspection/map/index.vue +++ b/src/views/inspection/map/index.vue @@ -52,7 +52,8 @@ - @@ -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; } - \ No newline at end of file +