2025-09-08 11:44:28 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div class="robot-menu">
|
|
|
|
|
<div v-if="robotInfo" class="robot-info-section">
|
|
|
|
|
<!-- 机器人基本信息 -->
|
|
|
|
|
<div class="robot-header">
|
|
|
|
|
<div class="robot-name">{{ robotInfo.name }}</div>
|
|
|
|
|
<div class="robot-status" :style="{ color: getStatusColor(robotInfo.status) }">
|
|
|
|
|
{{ getStatusText(robotInfo.status) }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 机器人详细信息 -->
|
|
|
|
|
<div class="robot-details">
|
|
|
|
|
<div v-if="robotInfo.batteryLevel !== undefined" class="detail-item">
|
|
|
|
|
<span class="detail-label">电量:</span>
|
|
|
|
|
<div class="battery-container">
|
|
|
|
|
<div class="battery-bar">
|
|
|
|
|
<div
|
|
|
|
|
class="battery-fill"
|
|
|
|
|
:style="{ width: `${robotInfo.batteryLevel}%` }"
|
|
|
|
|
:class="getBatteryClass(robotInfo.batteryLevel)"
|
|
|
|
|
></div>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="battery-text">{{ robotInfo.batteryLevel }}%</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="robotInfo.currentTask" class="detail-item">
|
|
|
|
|
<span class="detail-label">当前任务:</span>
|
|
|
|
|
<span class="detail-value">{{ robotInfo.currentTask }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 机器人操作菜单 -->
|
|
|
|
|
<div class="robot-actions">
|
|
|
|
|
<div class="action-group">
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<div class="action-group-title">控制权限</div>
|
|
|
|
|
<div class="action-item" @click="handleRobotAction('seize_control', '抢占控制权')">
|
|
|
|
|
<span class="action-icon">🎮</span>
|
|
|
|
|
<span>抢占控制权</span>
|
2025-09-08 11:44:28 +08:00
|
|
|
|
</div>
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<div class="action-item" @click="handleRobotAction('enable_orders', '可接单')">
|
|
|
|
|
<span class="action-icon">✅</span>
|
|
|
|
|
<span>可接单</span>
|
2025-09-08 11:44:28 +08:00
|
|
|
|
</div>
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<div class="action-item" @click="handleRobotAction('disable_orders', '不可接单')">
|
|
|
|
|
<span class="action-icon">❌</span>
|
|
|
|
|
<span>不可接单</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="action-group">
|
|
|
|
|
<div class="action-group-title">运行控制</div>
|
2025-09-08 11:44:28 +08:00
|
|
|
|
<div class="action-item" @click="handleRobotAction('pause', '暂停')">
|
|
|
|
|
<span class="action-icon">⏸️</span>
|
|
|
|
|
<span>暂停</span>
|
|
|
|
|
</div>
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<div class="action-item" @click="handleRobotAction('resume', '继续')">
|
2025-09-08 11:44:28 +08:00
|
|
|
|
<span class="action-icon">▶️</span>
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<span>继续</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="action-item" @click="handleRobotAction('start', '启动')">
|
|
|
|
|
<span class="action-icon">🚀</span>
|
|
|
|
|
<span>启动</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="action-item" @click="handleRobotAction('stop', '停止')">
|
|
|
|
|
<span class="action-icon">⏹️</span>
|
|
|
|
|
<span>停止</span>
|
2025-09-08 11:44:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="action-group">
|
|
|
|
|
<div class="action-group-title">导航控制</div>
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<div class="action-item" @click="handleRobotAction('go_charge', '前往充电')">
|
2025-09-08 11:44:28 +08:00
|
|
|
|
<span class="action-icon">🔋</span>
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<span>前往充电</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="action-item" @click="handleRobotAction('go_dock', '前往停靠')">
|
|
|
|
|
<span class="action-icon">🏠</span>
|
|
|
|
|
<span>前往停靠</span>
|
2025-09-08 11:44:28 +08:00
|
|
|
|
</div>
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<div class="action-item" @click="handleRobotAction('navigate', '路径导航')">
|
|
|
|
|
<span class="action-icon">🧭</span>
|
|
|
|
|
<span>路径导航</span>
|
2025-09-08 11:44:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="action-group">
|
2025-09-09 17:12:30 +08:00
|
|
|
|
<div class="action-group-title">系统管理</div>
|
2025-09-08 11:44:28 +08:00
|
|
|
|
<div class="action-item" @click="handleRobotAction('reset', '重置')">
|
|
|
|
|
<span class="action-icon">🔄</span>
|
|
|
|
|
<span>重置</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="action-item" @click="handleRobotAction('diagnose', '诊断')">
|
|
|
|
|
<span class="action-icon">🔧</span>
|
|
|
|
|
<span>诊断</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="action-item" @click="handleRobotAction('update', '更新')">
|
|
|
|
|
<span class="action-icon">📱</span>
|
|
|
|
|
<span>更新</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { computed } from 'vue';
|
2025-09-09 17:12:30 +08:00
|
|
|
|
|
|
|
|
|
import type { RobotAction,RobotInfo } from '../../services/context-menu/robot-menu.service';
|
|
|
|
|
import {
|
|
|
|
|
executeRobotAction,
|
|
|
|
|
getRobotActionIcon,
|
|
|
|
|
getRobotActionText,
|
|
|
|
|
getRobotStatusColor,
|
|
|
|
|
getRobotStatusText} from '../../services/context-menu/robot-menu.service';
|
2025-09-08 11:44:28 +08:00
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
robotInfo?: RobotInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Emits {
|
2025-09-09 17:12:30 +08:00
|
|
|
|
(e: 'actionComplete', data: { action: RobotAction; robot: RobotInfo; success: boolean }): void;
|
2025-09-08 11:44:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const props = defineProps<Props>();
|
|
|
|
|
const emit = defineEmits<Emits>();
|
|
|
|
|
|
|
|
|
|
// 定义组件名称
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: 'RobotMenu',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 获取状态显示文本
|
|
|
|
|
const getStatusText = (status: string): string => {
|
|
|
|
|
return getRobotStatusText(status);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 获取状态颜色
|
|
|
|
|
const getStatusColor = (status: string): string => {
|
|
|
|
|
return getRobotStatusColor(status);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 获取电量条样式类
|
|
|
|
|
const getBatteryClass = (batteryLevel: number) => {
|
|
|
|
|
if (batteryLevel > 50) return 'battery-high';
|
|
|
|
|
if (batteryLevel > 20) return 'battery-medium';
|
|
|
|
|
return 'battery-low';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 处理机器人操作
|
2025-09-09 17:12:30 +08:00
|
|
|
|
const handleRobotAction = async (action: RobotAction, actionName: string) => {
|
2025-09-08 11:44:28 +08:00
|
|
|
|
if (!props.robotInfo) return;
|
|
|
|
|
|
|
|
|
|
try {
|
2025-09-09 17:12:30 +08:00
|
|
|
|
console.log(`执行机器人操作: ${action} (${actionName})`, props.robotInfo);
|
|
|
|
|
|
|
|
|
|
// 使用服务函数执行操作
|
|
|
|
|
const result = await executeRobotAction(action, props.robotInfo);
|
2025-09-08 11:44:28 +08:00
|
|
|
|
|
2025-09-09 17:12:30 +08:00
|
|
|
|
console.log('机器人操作结果:', result);
|
2025-09-08 11:44:28 +08:00
|
|
|
|
|
|
|
|
|
// 发送操作完成事件
|
|
|
|
|
emit('actionComplete', {
|
|
|
|
|
action,
|
|
|
|
|
robot: props.robotInfo,
|
2025-09-09 17:12:30 +08:00
|
|
|
|
success: result.success
|
2025-09-08 11:44:28 +08:00
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(`机器人${actionName}操作失败:`, error);
|
|
|
|
|
|
|
|
|
|
// 发送操作失败事件
|
|
|
|
|
emit('actionComplete', {
|
|
|
|
|
action,
|
|
|
|
|
robot: props.robotInfo,
|
|
|
|
|
success: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.robot-menu {
|
|
|
|
|
width: 100%;
|
|
|
|
|
min-width: 200px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 机器人信息区域 */
|
|
|
|
|
.robot-info-section {
|
|
|
|
|
padding: 12px;
|
|
|
|
|
background-color: #f8f9fa;
|
|
|
|
|
border-bottom: 1px solid #e9ecef;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.robot-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.robot-name {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
color: #000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.robot-status {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
padding: 2px 8px;
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.05);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.robot-details {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.detail-item {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.detail-label {
|
|
|
|
|
color: #666;
|
|
|
|
|
min-width: 60px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.detail-value {
|
|
|
|
|
color: #000;
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 电量条样式 */
|
|
|
|
|
.battery-container {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
flex: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.battery-bar {
|
|
|
|
|
flex: 1;
|
|
|
|
|
height: 6px;
|
|
|
|
|
background-color: #e9ecef;
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.battery-fill {
|
|
|
|
|
height: 100%;
|
|
|
|
|
transition: width 0.3s ease;
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.battery-fill.battery-high {
|
|
|
|
|
background-color: #52c41a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.battery-fill.battery-medium {
|
|
|
|
|
background-color: #faad14;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.battery-fill.battery-low {
|
|
|
|
|
background-color: #ff4d4f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.battery-text {
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
color: #666;
|
|
|
|
|
min-width: 30px;
|
|
|
|
|
text-align: right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 操作区域 */
|
|
|
|
|
.robot-actions {
|
|
|
|
|
padding: 8px 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-group {
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-group:last-child {
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-group-title {
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
color: #666;
|
|
|
|
|
padding: 4px 12px;
|
|
|
|
|
text-transform: uppercase;
|
|
|
|
|
letter-spacing: 0.5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-item {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: background-color 0.2s;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
color: #000;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-item:hover {
|
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-icon {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
width: 16px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
</style>
|