From e18c4b88be4e14b8492bf5e19349962220edd41c Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Thu, 6 Aug 2026 11:23:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(inspection):=20=E7=BB=9F=E4=B8=80AGV?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=BA=E5=99=A8=E4=BA=BA=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将多个组件中的硬编码机器人状态映射替换为统一的 agvRuntimeStatus 工具函数 - 在手动接管和地图概览组件中实现5秒定时刷新机器人列表功能 - 添加 onUnmounted 钩子清理定时器避免内存泄漏 - 重构 MapCanvas 中的机器人位置解析逻辑并添加数据验证 - 为地图概览组件的状态显示添加动态CSS类名支持 --- .../components/ManualTakeover/index.vue | 27 +++++----- .../cockpit/components/MapCanvas.vue | 18 +++++-- .../cockpit/components/MapOverview.vue | 49 ++++++++++++++----- src/views/inspection/robot/index.vue | 5 +- 4 files changed, 70 insertions(+), 29 deletions(-) diff --git a/src/views/inspection/cockpit/components/ManualTakeover/index.vue b/src/views/inspection/cockpit/components/ManualTakeover/index.vue index fa40298..4cbb293 100644 --- a/src/views/inspection/cockpit/components/ManualTakeover/index.vue +++ b/src/views/inspection/cockpit/components/ManualTakeover/index.vue @@ -11,7 +11,7 @@
{{ item.robotName }}
-
{{ robotStatus[item.status] }}
+
{{ agvRuntimeStatusLabel(item.status) }}
@@ -122,7 +122,7 @@ @@ -224,6 +226,31 @@ onMounted(() => { background: #0f83; color: #0f8; } + + .unknown, + .offline, + .stopped { + background: rgba(148, 163, 184, 0.2); + color: #cbd5e1; + } + + .manual, + .running { + background: rgba(0, 212, 255, 0.18); + color: #00d4ff; + } + + .charging, + .paused { + background: rgba(255, 179, 0, 0.2); + color: #ffb300; + } + + .fault, + .emergency { + background: rgba(255, 77, 79, 0.2); + color: #ff6b6d; + } } .info-box { @@ -403,4 +430,4 @@ onMounted(() => { } } } - \ No newline at end of file + diff --git a/src/views/inspection/robot/index.vue b/src/views/inspection/robot/index.vue index 414f917..f48a64c 100644 --- a/src/views/inspection/robot/index.vue +++ b/src/views/inspection/robot/index.vue @@ -185,6 +185,7 @@ import { computed, getCurrentInstance, onBeforeUnmount, onMounted, reactive, ref import { ElMessage, ElMessageBox } from 'element-plus' import { addRobot, deleteRobot, getRobotDevices, getRobotList, getRobotStatus, updateRobot } from '@/api/inspection/robot' import { getMapList } from '@/api/inspection/map' +import { agvRuntimeStatusLabel, agvRuntimeStatusType } from '@/utils/agvRuntimeStatus' const { proxy } = getCurrentInstance() const { robot_type } = proxy.useDict('robot_type') @@ -256,8 +257,8 @@ async function loadDevices(showLoading = true) { try { const res = await getRobotDevices(activeRobot.value.id); devices.value = res.data || [] } finally { deviceLoading.value = false } } function endpointText(row) { return row.ipAddress && row.port ? `${row.ipAddress}:${row.port}` : '等待连接后自动获取' } -function runtimeStatusLabel(value) { return ({ 0: '在线', 1: '离线', 2: '充电中', 3: '巡检中' })[value] || '未知' } -function runtimeStatusType(value) { return ({ 0: 'success', 1: 'info', 2: 'warning', 3: 'primary' })[value] || 'info' } +const runtimeStatusLabel = agvRuntimeStatusLabel +const runtimeStatusType = agvRuntimeStatusType function hasBattery(row) { return row.batteryLevel !== null && row.batteryLevel !== undefined && row.batteryLevel !== '' } function normalizeBattery(value) { return Math.max(0, Math.min(100, Math.round(Number(value) || 0))) } function batteryColor(value) {