增加地图编辑界面,该界面支持增删改查 返航点,一个机器对应一个返航点,增删改查场站分区,将原本机器状态界面的 路径规划功能移植到该页面,地图上支持显示 返航点和分区,点击分区和返航点,地图支持定位和高亮,等待测试
机器状态界面返航 功能接口对接,还未对接实机测试
This commit is contained in:
@@ -154,6 +154,7 @@ import { useUnitFormatter } from '@/lib/units';
|
||||
import { PauseOutlined, PlayCircleOutlined } from '@ant-design/icons';
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { backToRestPointCommand } from '@/api/mapEdit';
|
||||
|
||||
|
||||
|
||||
@@ -1498,19 +1499,19 @@ export default function DeviceStatusPage() {
|
||||
|
||||
// 无控制权限时:不发送消息,且只发起一次权限申请(避免手柄/方向盘高频更新刷屏)
|
||||
|
||||
//if (!isControlled) {
|
||||
if (!isControlled) {
|
||||
|
||||
// //if (!hasRequestedControlRef.current && !connecting) {
|
||||
//if (!hasRequestedControlRef.current && !connecting) {
|
||||
|
||||
// // hasRequestedControlRef.current = true;
|
||||
// hasRequestedControlRef.current = true;
|
||||
|
||||
// // handleControlModal();
|
||||
// handleControlModal();
|
||||
|
||||
// //}
|
||||
//}
|
||||
|
||||
// return;
|
||||
return;
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
console.log('Gamepad state updated:', state);
|
||||
|
||||
@@ -1658,6 +1659,22 @@ export default function DeviceStatusPage() {
|
||||
return Number(val).toFixed(2);
|
||||
|
||||
};
|
||||
const handleAutoBack = () => {
|
||||
const payload = {
|
||||
deviceId: selectedSn,
|
||||
|
||||
|
||||
|
||||
orgId: currentStation?.orgId,
|
||||
|
||||
siteId: stationId,
|
||||
|
||||
}
|
||||
backToRestPointCommand(payload).then(res => { }).catch(err => {
|
||||
|
||||
console.error('返回休息点失败', err);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1920,9 +1937,9 @@ export default function DeviceStatusPage() {
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
* 修改handleComplete:计算完成后 return路径对象;失败返回null
|
||||
|
||||
|
||||
*/
|
||||
|
||||
const handleComplete = async () => {
|
||||
@@ -2159,7 +2176,7 @@ export default function DeviceStatusPage() {
|
||||
|
||||
{/* 页面顶部按钮区域 */}
|
||||
|
||||
{!isUAV && (
|
||||
{/*{!isUAV && (
|
||||
|
||||
<div
|
||||
|
||||
@@ -2269,7 +2286,7 @@ export default function DeviceStatusPage() {
|
||||
|
||||
</Button>*/}
|
||||
|
||||
<Button
|
||||
{/*<Button
|
||||
|
||||
type="primary"
|
||||
|
||||
@@ -2287,7 +2304,7 @@ export default function DeviceStatusPage() {
|
||||
|
||||
</div>
|
||||
|
||||
)}
|
||||
)}}*/}
|
||||
|
||||
|
||||
|
||||
@@ -3114,6 +3131,7 @@ export default function DeviceStatusPage() {
|
||||
onToggle={(feature, enabled) => { console.log('[DeviceStatusPage] Feature toggled: ' + feature + ' = ' + enabled); }}
|
||||
|
||||
sendFindCar={() => handleFindCar()}
|
||||
sendAutoBack={() => handleAutoBack()}
|
||||
|
||||
/>
|
||||
|
||||
|
||||
1375
src/components/devices/MapEditorPage.tsx
Normal file
1375
src/components/devices/MapEditorPage.tsx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -49,7 +49,8 @@ interface RobotFeatureButtonsProps {
|
||||
onToggle?: (feature: RobotFeature, enabled: boolean) => void;
|
||||
className?: string;
|
||||
showEmergencyStop?: boolean;
|
||||
sendFindCar: () => {}
|
||||
sendFindCar: () => {};
|
||||
sendAutoBack?: () => {};
|
||||
}
|
||||
|
||||
const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
@@ -58,6 +59,7 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
className = '',
|
||||
showEmergencyStop = true,
|
||||
sendFindCar,
|
||||
sendAutoBack
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
@@ -76,6 +78,9 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
if (feature === 'findCar') {
|
||||
sendFindCar?.();
|
||||
}
|
||||
if (feature === 'autoback') {
|
||||
sendAutoBack?.();
|
||||
}
|
||||
const next = !active.has(feature);
|
||||
const nextSet = new Set(active);
|
||||
if (next) nextSet.add(feature);
|
||||
@@ -100,6 +105,7 @@ const RobotFeatureButtons: React.FC<RobotFeatureButtonsProps> = ({
|
||||
backgroundColor: isActive ? `${f.activeColor}1a` : '#fafafa',
|
||||
borderColor: isActive ? f.activeColor : '#e5e7eb',
|
||||
boxShadow: isActive ? `0 0 12px ${f.activeColor}33` : 'none',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
title={t(`devices.features.${f.key}`)}
|
||||
>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import {
|
||||
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
|
||||
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
|
||||
@@ -1767,22 +1767,11 @@ export default function RobotTaskPage() {
|
||||
{route.workName || route.name || t('devices.unnamedRoute')}
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: '#86909C', marginTop: 4 }}>
|
||||
ID: {route.id}
|
||||
{t('devices.rtMode')}: {route.mode == "coverage" ? t('devices.coverageMode') : t('devices.singleMode')}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{/* 删除按钮 */}
|
||||
<Tooltip title={t('devices.deleteRoute')}>
|
||||
<Button
|
||||
type="text"
|
||||
icon={<DeleteOutlined style={{ color: '#F53F3F', fontSize: 20 }} />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setSelectedPathWork(route);
|
||||
// 替换为你的删除处理函数
|
||||
handleDeleteRoute(route);
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title={t('devices.createTask')}>
|
||||
<Button
|
||||
type="text"
|
||||
@@ -2048,6 +2037,22 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
|
||||
|
||||
}, [selectedPathWork]);
|
||||
|
||||
// ====================== Tab / 返航任务 ======================
|
||||
const [activeTab, setActiveTab] = useState('scheduled');
|
||||
const [returnRoute, setReturnRoute] = useState(null);
|
||||
const [returnDevice, setReturnDevice] = useState(null);
|
||||
|
||||
// 预设路径:仅保留单次任务路径
|
||||
const singleRouteList = useMemo(
|
||||
() => (routeList || []).filter(route => route.mode == 'single_point'),
|
||||
[routeList]
|
||||
);
|
||||
|
||||
const handleSaveReturnTask = () => {
|
||||
// TODO: 返航任务保存接口待接入,暂时打印
|
||||
console.log('新建返航任务', { route: returnRoute, device: returnDevice });
|
||||
};
|
||||
|
||||
// ====================== 周/月选择 ======================
|
||||
const weekDays = [
|
||||
{ label: t('devices.wdSun'), value: 'SUNDAY' },
|
||||
@@ -2170,144 +2175,208 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
|
||||
>
|
||||
<div className="space-y-4">
|
||||
|
||||
{/* 任务名称 */}
|
||||
<div>
|
||||
<label className="block mb-2 font-medium">{t('devices.taskName')}</label>
|
||||
<Input
|
||||
value={formData.planName}
|
||||
onChange={(e) => setFormData({ ...formData, planName: e.target.value })}
|
||||
placeholder={t('devices.inputTaskName')}
|
||||
/>
|
||||
</div>
|
||||
{/*<Tabs
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{ key: 'scheduled', label: t('devices.scheduledTaskTab') },
|
||||
{ key: 'return', label: t('devices.returnTaskTab') },
|
||||
]}
|
||||
/>*/}
|
||||
|
||||
{/* 执行路线 */}
|
||||
<div>
|
||||
<label className="block mb-2 font-medium">{t('devices.executeRouteLabel')}</label>
|
||||
<Select
|
||||
className="w-full"
|
||||
placeholder={t('devices.selectRoute')}
|
||||
onSelect={(_, option) => {
|
||||
const route = routeList.find(r => r.id === option.value);
|
||||
setFormData(prev => ({ ...prev, path: route }));
|
||||
}}
|
||||
value={formData.path?.id}
|
||||
>
|
||||
{routeList.map(route => (
|
||||
<Select.Option
|
||||
key={route.id}
|
||||
value={route.id}
|
||||
>
|
||||
{route.workName || route.name}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 选择设备 */}
|
||||
<div className="relative">
|
||||
<label className="block mb-2 font-medium">{t('video.selectDevice')}</label>
|
||||
<Select
|
||||
className="w-full"
|
||||
placeholder={t('video.selectDevice')}
|
||||
onSelect={(_, option) => {
|
||||
const robot = robots.find(r => r.serialNumber === option.value);
|
||||
setFormData(prev => ({ ...prev, device: robot }));
|
||||
}}
|
||||
value={formData.device?.serialNumber}
|
||||
>
|
||||
{robots.map(robot => (
|
||||
<Select.Option
|
||||
key={robot.serialNumber}
|
||||
value={robot.serialNumber}
|
||||
>
|
||||
{robot.deviceAlias} ({robot.serialNumber})
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 重复计划 */}
|
||||
<div>
|
||||
<label className="block mb-2 font-medium">{t('devices.repeatPlan')}</label>
|
||||
<Select
|
||||
value={formData.repeatPlan}
|
||||
onChange={(val) => setFormData({ ...formData, repeatPlan: val })}
|
||||
className="w-full"
|
||||
>
|
||||
<Select.Option value="DAY">{t('devices.day')}</Select.Option>
|
||||
<Select.Option value="WEEK">{t('devices.week')}</Select.Option>
|
||||
<Select.Option value="MONTH">{t('devices.month')}</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 周选择 */}
|
||||
{formData.repeatPlan === 'WEEK' && (
|
||||
<div className="flex gap-1 flex-wrap">
|
||||
{weekDays.map(day => (
|
||||
<Button
|
||||
key={day.value}
|
||||
type={formData.days.includes(day.value) ? 'primary' : 'default'}
|
||||
onClick={() => handleToggleDay(day.value)}
|
||||
size="small"
|
||||
shape="circle"
|
||||
>
|
||||
{day.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 月选择 */}
|
||||
{formData.repeatPlan === 'MONTH' && (
|
||||
<div className="grid grid-cols-7 gap-1">
|
||||
{monthDays.map(day => (
|
||||
<Button
|
||||
key={day}
|
||||
type={formData.dayOfMonth.includes(day) ? 'primary' : 'default'}
|
||||
onClick={() => handleToggleMonthDay(day)}
|
||||
size="small"
|
||||
>
|
||||
{day}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 按天:选择日期 */}
|
||||
{formData.repeatPlan === 'DAY' && (
|
||||
{activeTab === 'scheduled' ? (
|
||||
<>
|
||||
<label className="block mb-2 font-medium">{t('devices.execDate')}</label>
|
||||
<DatePicker
|
||||
onChange={handleDateChange}
|
||||
|
||||
{/* 任务名称 */}
|
||||
<div>
|
||||
<label className="block mb-2 font-medium">{t('devices.taskName')}</label>
|
||||
<Input
|
||||
value={formData.planName}
|
||||
onChange={(e) => setFormData({ ...formData, planName: e.target.value })}
|
||||
placeholder={t('devices.inputTaskName')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 执行路线 */}
|
||||
<div>
|
||||
<label className="block mb-2 font-medium">{t('devices.executeRouteLabel')}</label>
|
||||
<Select
|
||||
className="w-full"
|
||||
placeholder={t('devices.selectRoute')}
|
||||
onSelect={(_, option) => {
|
||||
const route = routeList.find(r => r.id === option.value);
|
||||
setFormData(prev => ({ ...prev, path: route }));
|
||||
}}
|
||||
value={formData.path?.id}
|
||||
>
|
||||
{routeList.map(route => (
|
||||
<Select.Option
|
||||
key={route.id}
|
||||
value={route.id}
|
||||
>
|
||||
{route.workName || route.name}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 选择设备 */}
|
||||
<div className="relative">
|
||||
<label className="block mb-2 font-medium">{t('video.selectDevice')}</label>
|
||||
<Select
|
||||
className="w-full"
|
||||
placeholder={t('video.selectDevice')}
|
||||
onSelect={(_, option) => {
|
||||
const robot = robots.find(r => r.serialNumber === option.value);
|
||||
setFormData(prev => ({ ...prev, device: robot }));
|
||||
}}
|
||||
value={formData.device?.serialNumber}
|
||||
>
|
||||
{robots.map(robot => (
|
||||
<Select.Option
|
||||
key={robot.serialNumber}
|
||||
value={robot.serialNumber}
|
||||
>
|
||||
{robot.deviceAlias} ({robot.serialNumber})
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 重复计划 */}
|
||||
<div>
|
||||
<label className="block mb-2 font-medium">{t('devices.repeatPlan')}</label>
|
||||
<Select
|
||||
value={formData.repeatPlan}
|
||||
onChange={(val) => setFormData({ ...formData, repeatPlan: val })}
|
||||
className="w-full"
|
||||
>
|
||||
<Select.Option value="DAY">{t('devices.day')}</Select.Option>
|
||||
<Select.Option value="WEEK">{t('devices.week')}</Select.Option>
|
||||
<Select.Option value="MONTH">{t('devices.month')}</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 周选择 */}
|
||||
{formData.repeatPlan === 'WEEK' && (
|
||||
<div className="flex gap-1 flex-wrap">
|
||||
{weekDays.map(day => (
|
||||
<Button
|
||||
key={day.value}
|
||||
type={formData.days.includes(day.value) ? 'primary' : 'default'}
|
||||
onClick={() => handleToggleDay(day.value)}
|
||||
size="small"
|
||||
shape="circle"
|
||||
>
|
||||
{day.label}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 月选择 */}
|
||||
{formData.repeatPlan === 'MONTH' && (
|
||||
<div className="grid grid-cols-7 gap-1">
|
||||
{monthDays.map(day => (
|
||||
<Button
|
||||
key={day}
|
||||
type={formData.dayOfMonth.includes(day) ? 'primary' : 'default'}
|
||||
onClick={() => handleToggleMonthDay(day)}
|
||||
size="small"
|
||||
>
|
||||
{day}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 按天:选择日期 */}
|
||||
{formData.repeatPlan === 'DAY' && (
|
||||
<>
|
||||
<label className="block mb-2 font-medium">{t('devices.execDate')}</label>
|
||||
<DatePicker
|
||||
onChange={handleDateChange}
|
||||
className="w-full"
|
||||
placeholder={t('devices.selectExecDate')}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 时间 */}
|
||||
<label className="block mb-2 font-medium">{t('devices.execTime')}</label>
|
||||
<TimePicker
|
||||
format="HH:mm:ss"
|
||||
onChange={handleTimeChange}
|
||||
className="w-full"
|
||||
placeholder={t('devices.selectExecDate')}
|
||||
placeholder={t('devices.selectExecTime')}
|
||||
/>
|
||||
|
||||
{/* 执行周期 */}
|
||||
<label className="block mb-2 font-medium">{t('devices.executionCycle')}</label>
|
||||
<RangePicker
|
||||
onChange={handleCycleChange}
|
||||
className="w-full"
|
||||
placeholder={[t('devices.startDate'), t('devices.endDate')]}
|
||||
showTime
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
|
||||
</>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{/* 预设路径列表 */}
|
||||
<div>
|
||||
<label className="block mb-2 font-medium">{t('devices.presetRoutes')}</label>
|
||||
<div className="max-h-64 overflow-y-auto space-y-2 pr-1">
|
||||
{singleRouteList.length === 0 ? (
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t('devices.noReturnRoute')} />
|
||||
) : (
|
||||
singleRouteList.map(route => {
|
||||
const selected = returnRoute?.id === route.id;
|
||||
return (
|
||||
<div
|
||||
key={route.id}
|
||||
onClick={() => setReturnRoute(route)}
|
||||
className={`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${selected ? 'border-blue-500 bg-blue-50' : 'border-gray-200 hover:border-blue-300'}`}
|
||||
>
|
||||
<div className="w-10 h-10 rounded overflow-hidden bg-gray-100 flex items-center justify-center shrink-0">
|
||||
{route.imgUrl ? (
|
||||
<img src={route.imgUrl} alt="" className="w-full h-full object-cover" />
|
||||
) : (
|
||||
<EyeOutlined className="text-gray-400" />
|
||||
)}
|
||||
</div>
|
||||
<div className="flex-1 min-w-0 font-medium truncate">{route.workName || route.name}</div>
|
||||
{selected && <CheckCircle2 size={18} className="text-blue-500 shrink-0" />}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 选择机器 */}
|
||||
<div>
|
||||
<label className="block mb-2 font-medium">{t('video.selectDevice')}</label>
|
||||
<Select
|
||||
className="w-full"
|
||||
placeholder={t('video.selectDevice')}
|
||||
allowClear
|
||||
value={returnDevice?.serialNumber}
|
||||
onChange={(val) => setReturnDevice((robots || []).find(r => r.serialNumber === val) || null)}
|
||||
options={(robots || []).map(robot => ({
|
||||
value: robot.serialNumber,
|
||||
label: `${robot.deviceAlias ?? ''} ${robot.serialNumber}`,
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 时间 */}
|
||||
<label className="block mb-2 font-medium">{t('devices.execTime')}</label>
|
||||
<TimePicker
|
||||
format="HH:mm:ss"
|
||||
onChange={handleTimeChange}
|
||||
className="w-full"
|
||||
placeholder={t('devices.selectExecTime')}
|
||||
/>
|
||||
|
||||
{/* 执行周期 */}
|
||||
<label className="block mb-2 font-medium">{t('devices.executionCycle')}</label>
|
||||
<RangePicker
|
||||
onChange={handleCycleChange}
|
||||
className="w-full"
|
||||
placeholder={[t('devices.startDate'), t('devices.endDate')]}
|
||||
showTime
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<div className="flex justify-end gap-2 mt-6">
|
||||
<Button onClick={onClose}>{t('common.cancel')}</Button>
|
||||
<Button type="primary" onClick={handleSave}>{t('devices.saveTask')}</Button>
|
||||
<Button type="primary" onClick={activeTab === 'scheduled' ? handleSave : handleSaveReturnTask}>{t('devices.saveTask')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user