中英文切换 初始化

This commit is contained in:
mmc
2026-08-12 11:29:44 +08:00
parent 541e16f742
commit a8af55a856
76 changed files with 5847 additions and 1962 deletions

View File

@@ -48,11 +48,13 @@ import DeviceController from './DeviceController';
import Draggable, { DraggableData, DraggableEvent } from 'react-draggable';
import { MowerAllView } from './mowerAllView.jsx';
import { useWebRTCPlayer } from '../useWebRTCStream.js';
import { useTranslation } from 'react-i18next';
const { Text, Title } = Typography;
const { RangePicker } = DatePicker;
export default function RobotTaskPage() {
const { t } = useTranslation();
const { userInfo } = useSelector((state: RootState) => state.user);
const { stationId, currentStation } = useSelector((state: RootState) => state.station);
const [excuteStatus, setExcuteStatus] = useState("stop"); //"stop" "running" "pause"
@@ -186,7 +188,7 @@ export default function RobotTaskPage() {
content: `确定要删除航线「${route.workName}」吗?删除后数据无法恢复!`,
icon: <ExclamationCircleOutlined style={{ color: '#FF7D00' }} />,
okText: '确定删除',
cancelText: '取消',
cancelText: t('common.cancel'),
okButtonProps: { danger: true, loading: deleteLoading },
onOk: async () => {
setDeleteLoading(true);
@@ -481,12 +483,12 @@ export default function RobotTaskPage() {
deleteDeviceTask({ id }).then(res => {
if (res.code == 200) {
utils.message.success('删除成功');
utils.message.success(t('common.deleteSuccess'));
} else {
utils.message.error(res.msg);
}
}).catch(() => message.error('删除失败')).finally(() => {
}).catch(() => message.error(t('common.deleteFail'))).finally(() => {
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
@@ -757,14 +759,14 @@ export default function RobotTaskPage() {
const taskColumns = [
{
title: '任务名称',
title: t('devices.taskName'),
dataIndex: 'planName',
width: 160,
ellipsis: true,
fixed: "left"
},
{
title: '设备',
title: t('devices.device'),
dataIndex: 'deviceAlias',
width: 320,
render: (_, record) => {
@@ -773,20 +775,20 @@ export default function RobotTaskPage() {
},
{
title: '创建者',
title: t('devices.creator'),
dataIndex: 'createBy',
width: 100,
render: (text) => text
},
{
title: '创建时间',
title: t('common.createTime'),
dataIndex: 'createTime',
width: 170,
render: t => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
},
// 执行计划 + 周期时间
{
title: '执行计划',
title: t('devices.executionPlan'),
width: 280,
render: (_, record) => {
const rule = record.deviceTaskPlanRules || {};
@@ -794,65 +796,65 @@ export default function RobotTaskPage() {
// 周映射
const weekMap = {
SUNDAY: '周日',
MONDAY: '周一',
TUESDAY: '周二',
WEDNESDAY: '周三',
THURSDAY: '周四',
FRIDAY: '周五',
SATURDAY: '周六'
SUNDAY: t('devices.sun'),
MONDAY: t('devices.mon'),
TUESDAY: t('devices.tue'),
WEDNESDAY: t('devices.wed'),
THURSDAY: t('devices.thu'),
FRIDAY: t('devices.fri'),
SATURDAY: t('devices.sat')
};
switch (type) {
case 'DAY':
return `按天 | 开始日期${startDate || ''} ${dayTime || ''}`;
return t('devices.planByDay', { startDate: startDate || '', dayTime: dayTime || '' });
case 'WEEK':
const weekText = (days || []).map(d => weekMap[d]).join('、');
return `按周 | ${weekText} ${dayTime || ''}`;
return t('devices.planByWeek', { weekText, dayTime: dayTime || '' });
case 'MONTH':
const monthText = (dayOfMonth || []).map(d => `${d}日`).join('、');
return `按月 | ${monthText} ${dayTime || ''}`;
const monthText = (dayOfMonth || []).map(d => t('devices.daySuffix', { day: d })).join('、');
return t('devices.planByMonth', { monthText, dayTime: dayTime || '' });
default:
return '未知计划';
return t('devices.unknownPlan');
}
}
},
{
title: '执行周期',
title: t('devices.executionCycle'),
width: 320,
render: (_, record) => {
return `${record.startTime || ''} - ${record.finishTime || ''}`;
}
},
{
title: '状态',
title: t('roles.status'),
dataIndex: 'taskStaus',
width: 100,
render: (status, record) => {
const statusMap = {
'NEW': { color: 'default', text: '新建' },
'EXECUTING': { color: 'processing', text: '执行中' },
'PAUSE': { color: 'warning', text: '暂停中' },
'FINISH': { color: 'success', text: '执行成功' },
'FAILED': { color: 'error', text: '执行失败' }
'NEW': { color: 'default', text: t('devices.statusNew') },
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
'FINISH': { color: 'success', text: t('devices.statusFinished') },
'FAILED': { color: 'error', text: t('devices.statusFailed') }
};
const item = statusMap[status] || { color: 'default', text: record.taskStausTranslate || '未知' };
const item = statusMap[status] || { color: 'default', text: record.taskStausTranslate || t('constants.locationUnknown') };
return <Tag color={item.color}>{item.text}</Tag>;
}
},
{
title: '操作',
title: t('roles.actions'),
width: 300,
fixed: 'right',
render: (_, record) => (
<Space size="small">
<Popconfirm
title="确定要删除该任务吗?"
title={t('devices.confirmDeleteTask')}
onConfirm={() => handleDelete(record.id)}
okText="确定"
cancelText="取消"
okText={t('common.ok')}
cancelText={t('common.cancel')}
>
<Button
type="text"
@@ -860,7 +862,7 @@ export default function RobotTaskPage() {
size="small"
icon={<DeleteOutlined />}
>
删除
{t('common.delete')}
</Button>
</Popconfirm>
@@ -873,33 +875,33 @@ export default function RobotTaskPage() {
const taskPoolColumns = [
{
title: '设备',
title: t('devices.device'),
dataIndex: 'deviceId',
width: 320,
},
{
title: '状态',
title: t('roles.status'),
dataIndex: 'taskStaus',
width: 100,
render: (status, record) => {
const statusMap = {
'NEW': { color: 'default', text: '新建' },
'EXECUTING': { color: 'processing', text: '执行中' },
'PAUSE': { color: 'warning', text: '暂停中' },
'FINISH': { color: 'success', text: '执行成功' },
'FAILED': { color: 'error', text: '执行失败' }
'NEW': { color: 'default', text: t('devices.statusNew') },
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
'FINISH': { color: 'success', text: t('devices.statusFinished') },
'FAILED': { color: 'error', text: t('devices.statusFailed') }
};
const item = statusMap[status] || { color: 'default', text: '未知' };
const item = statusMap[status] || { color: 'default', text: t('constants.locationUnknown') };
return <Tag color={item.color}>{item.text}</Tag>;
}
},
{
title: '创建时间',
title: t('common.createTime'),
dataIndex: 'createTime',
width: 170,
},
{
title: '操作',
title: t('roles.actions'),
width: 100, // 加宽一点
fixed: 'right',
render: (_, record) => (
@@ -907,35 +909,38 @@ export default function RobotTaskPage() {
<>
{/*{record.taskStaus === 'NEW' && (*/}
<Popconfirm
title="确定要取消该任务吗?"
onConfirm={() => handleCancelTask(record)}
okText="确定" cancelText="取消"
>
<Button type="text" size="small" danger icon={<CloseOutlined />} onClick={(e) => e.stopPropagation()}
>取消</Button>
</Popconfirm>
<Popconfirm
title={t('devices.confirmCancelTask')}
onConfirm={() => handleCancelTask(record)}
okText={t('common.ok')} cancelText={t('common.cancel')}
>
<Button type="text" size="small" danger icon={<CloseOutlined />} onClick={(e) => e.stopPropagation()}>
{t('common.cancel')}
</Button>
</Popconfirm>
{/*//)}*/}
{/*{record.taskStaus === 'EXECUTING' && (*/}
<Popconfirm
title="确定要暂停该任务吗?"
onConfirm={() => handlePauseTask(record)}
okText="确定" cancelText="取消"
>
<Button type="text" size="small" style={{ color: '#FF9500' }} onClick={(e) => e.stopPropagation()}
>暂停</Button>
</Popconfirm>
<Popconfirm
title={t('devices.confirmPauseTask')}
onConfirm={() => handlePauseTask(record)}
okText={t('common.ok')} cancelText={t('common.cancel')}
>
<Button type="text" size="small" style={{ color: '#FF9500' }} onClick={(e) => e.stopPropagation()}>
{t('video.pause')}
</Button>
</Popconfirm>
{/*)}/*/}
{record.taskStaus === 'PAUSE' && (
<Popconfirm
title="确定要恢复该任务吗?"
title={t('devices.confirmResumeTask')}
onConfirm={() => handleRecoverTask(record)}
okText="确定" cancelText="取消"
okText={t('common.ok')} cancelText={t('common.cancel')}
>
<Button type="text" size="small" style={{ color: '#00B42A' }} onClick={(e) => e.stopPropagation()}
>恢复</Button>
<Button type="text" size="small" style={{ color: '#00B42A' }} onClick={(e) => e.stopPropagation()}>
{t('devices.recover')}
</Button>
</Popconfirm>
)}
</>
@@ -949,12 +954,12 @@ export default function RobotTaskPage() {
const taskHistoryColumns = [
{
title: '设备',
title: t('devices.device'),
dataIndex: 'deviceId',
width: 320,
},
{
title: '状态',
title: t('roles.status'),
dataIndex: 'taskStausTranslate',
width: 100,
render: (text, record) => {
@@ -972,16 +977,16 @@ export default function RobotTaskPage() {
},
{
title: '开始时间',
title: t('devices.startTime'),
dataIndex: 'startTime',
width: 170,
},
{
title: '结束时间',
title: t('devices.endTime'),
dataIndex: 'finishTime',
width: 170,
}, {
title: '创建时间',
title: t('common.createTime'),
dataIndex: 'createTime',
width: 170,
}
@@ -1015,16 +1020,16 @@ export default function RobotTaskPage() {
const topCards = [
{ title: '今日机器人计划', value: taskList.length, unit: '条', desc: '进行中', icon: <LayoutGrid size={22} />, color: '#165DFF' },
{ title: '作业中机器人', value: taskPoolList?.filter(item => ['EXECUTING', 'PAUSE'].includes(item.taskStaus))?.length, unit: '台', desc: '作业中', icon: <Car size={22} />, color: '#165DFF' },
{ title: '累计作业里程', value: '12.5', unit: 'km', trend: '较昨日 +1.2', trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
{ title: '任务完成率', value: successfulTaskList.length ? Math.round((successfulTaskList.length / taskHistoryList.length) * 100) : 0, unit: '%', trend: '较昨日 +5%', trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
{ title: '异常告警', value: '0', unit: '次', trend: '较昨日 -1', trendColor: '#00B42A', icon: <AlertCircle size={22} />, color: '#F53F3F' },
{ title: t('devices.statTodayPlan'), value: taskList.length, unit: t('devices.unitPlan'), desc: t('devices.statInProgress'), icon: <LayoutGrid size={22} />, color: '#165DFF' },
{ title: t('devices.statWorkingRobots'), value: taskPoolList?.filter(item => ['EXECUTING', 'PAUSE'].includes(item.taskStaus))?.length, unit: t('devices.unitRobot'), desc: t('devices.statWorking'), icon: <Car size={22} />, color: '#165DFF' },
{ title: t('devices.statTotalDistance'), value: '12.5', unit: 'km', trend: t('devices.vsYesterday', { value: '+1.2' }), trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
{ title: t('devices.statCompletionRate'), value: successfulTaskList.length ? Math.round((successfulTaskList.length / taskHistoryList.length) * 100) : 0, unit: '%', trend: t('devices.vsYesterday', { value: '+5%' }), trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
{ title: t('devices.statAlerts'), value: '0', unit: t('devices.unitTimes'), trend: t('devices.vsYesterday', { value: '-1' }), trendColor: '#00B42A', icon: <AlertCircle size={22} />, color: '#F53F3F' },
{
title: '在线率',
title: t('devices.statOnlineRate'),
value: `${devices?.length ? Math.round((devices.filter(d => d.onlineStatus == 1).length / devices.length) * 100) : 0}`,
unit: '%',
desc: '良好',
desc: t('devices.good'),
icon: <Satellite size={22} />,
color: '#165DFF'
}];
@@ -1032,7 +1037,7 @@ export default function RobotTaskPage() {
return (
<div className="normal-spacing" style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0px', paddingTop: 0 }}>
<div style={{ padding: '4px 0px 8px' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>机器人任务</Typography.Title>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>{t('devices.robotTask')}</Typography.Title>
</div>
<Row gutter={[16, 16]} style={{ marginBottom: 8 }}>
{topCards.map((item, index) => (
@@ -1121,7 +1126,7 @@ export default function RobotTaskPage() {
}}
>
<span style={{ fontSize: fontNormal, fontWeight: 700 }}>
机器人路径规划与监控
{t('devices.robotRouteMonitor')}
</span>
@@ -1130,12 +1135,12 @@ export default function RobotTaskPage() {
size="small"
extra={
<Space size={4} wrap> {/* Space开启自动换行,小屏按钮自动折行 */}
<Button size="small" icon={<DeleteOutlined />} type="primary" style={{ borderRadius: 4 }} onClick={() => setClearNavLine(v => v + 1)}>清空实时轨迹</Button>
<Button size="small" icon={<DeleteOutlined />} danger style={{ borderRadius: 4 }} onClick={() => { setPoints([]); setClearPlanLine(v => v + 1); }}>清空规划航线</Button>
{/*<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>新增</Button>
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>导入</Button>
<Button size="small" icon={<DeleteOutlined />} type="primary" style={{ borderRadius: 4 }} onClick={() => setClearNavLine(v => v + 1)}>{t('devices.clearRealtimeTrack')}</Button>
<Button size="small" icon={<DeleteOutlined />} danger style={{ borderRadius: 4 }} onClick={() => { setPoints([]); setClearPlanLine(v => v + 1); }}>{t('devices.clearPlanRoute')}</Button>
{/*<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>{t('common.addNew')}</Button>
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>{t('common.import')}</Button>
<Button size="small" icon={<NodeIndexOutlined />} style={{ borderRadius: 4 }}>优化</Button>
<Button size="small" icon={<SaveOutlined />} style={{ borderRadius: 4 }}>保存</Button>*/}
<Button size="small" icon={<SaveOutlined />} style={{ borderRadius: 4 }}>{t('common.save')}</Button>*/}
{/*<Button size="small" icon={<Maximize2 size={12} />} />*/}
</Space>
}
@@ -1185,25 +1190,25 @@ export default function RobotTaskPage() {
</span>
<span>
控制模式:
{t('devices.controlMode')}
{robotRealtimePosition?.controlMode == '1' ? (
<span style={{ color: '#ff6f6f' }}>本地</span>
<span style={{ color: '#ff6f6f' }}>{t('devices.localMode')}</span>
) : (
<span style={{ color: '#9eff9e' }}>远程</span>
<span style={{ color: '#9eff9e' }}>{t('devices.remoteMode')}</span>
)}
</span>
<span>
航向:
{t('devices.heading')}
{robotRealtimePosition?.headingStatus == '1' ? (
<span style={{ color: '#9eff9e' }}>已初始化</span>
<span style={{ color: '#9eff9e' }}>{t('devices.initialized')}</span>
) : (
<span style={{ color: '#ff6f6f' }}>未初始化</span>
<span style={{ color: '#ff6f6f' }}>{t('devices.uninitialized')}</span>
)}
</span>
<span>
定位:
{t('devices.location')}
{(() => {
const qual = robotRealtimePosition?.qual;
const info = getLocationQuality(qual);
@@ -1213,7 +1218,7 @@ export default function RobotTaskPage() {
{/* 视频开关 */}
<span style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
视频:
{t('devices.video')}
<Switch
size="small"
checked={showVideo}
@@ -1244,16 +1249,16 @@ export default function RobotTaskPage() {
items={[
{
key: 'pool',
label: '任务池',
label: t('devices.taskPool'),
},
{
key: 'task',
label: '任务执行计划',
label: t('devices.taskExecutionPlan'),
},
{
key: 'history',
label: '历史任务',
label: t('devices.taskHistory'),
}
]}
tabBarExtraContent={
@@ -1263,7 +1268,7 @@ export default function RobotTaskPage() {
fetchTaskPoolList();
fetchTaskHistoryList();
}} />
<Tooltip title="创建任务">
<Tooltip title={t('devices.createTask')}>
<PlusOutlined
style={{ cursor: 'pointer', color: '#165DFF', fontSize: 14 }}
onClick={() => setIsTaskModalOpen(true)}
@@ -1282,7 +1287,7 @@ export default function RobotTaskPage() {
<RangePicker
size="small"
format="YYYY-MM-DD"
placeholder={['开始日期', '结束日期']}
placeholder={[t('devices.startDate'), t('devices.endDate')]}
value={filterForm.dateRange}
onChange={(dates) => {
setFilterForm(prev => ({ ...prev, dateRange: dates }));
@@ -1291,14 +1296,14 @@ export default function RobotTaskPage() {
<Select
style={{ width: 120 }}
size="small"
placeholder="状态"
placeholder={t('roles.status')}
allowClear
options={[
{ label: '新建', value: 'NEW' },
{ label: '执行中', value: 'EXECUTING' },
{ label: '暂停中', value: 'PAUSE' },
{ label: '执行成功', value: 'FINISH' },
{ label: '执行失败', value: 'FAILED' },
{ label: t('devices.statusNew'), value: 'NEW' },
{ label: t('workOrder.inProgress'), value: 'EXECUTING' },
{ label: t('devices.statusPaused'), value: 'PAUSE' },
{ label: t('devices.statusFinished'), value: 'FINISH' },
{ label: t('devices.statusFailed'), value: 'FAILED' },
]}
value={filterForm.taskStatus}
onChange={(val) => {
@@ -1308,7 +1313,7 @@ export default function RobotTaskPage() {
<Select
style={{ width: 140 }}
size="small"
placeholder="全部机器人"
placeholder={t('devices.allRobots')}
allowClear
options={devices?.map(item => ({
value: item.serialNumber,
@@ -1347,12 +1352,12 @@ export default function RobotTaskPage() {
<Select
style={{ width: 120 }}
size="small"
placeholder="状态"
placeholder={t('roles.status')}
allowClear
options={[
{ label: '新建', value: 'NEW' },
{ label: '执行中', value: 'EXECUTING' },
{ label: '暂停中', value: 'PAUSE' },
{ label: t('devices.statusNew'), value: 'NEW' },
{ label: t('workOrder.inProgress'), value: 'EXECUTING' },
{ label: t('devices.statusPaused'), value: 'PAUSE' },
]}
value={poolFilterForm.taskStatus}
onChange={(val) => {
@@ -1362,7 +1367,7 @@ export default function RobotTaskPage() {
<Select
style={{ width: 140 }}
size="small"
placeholder="全部机器人"
placeholder={t('devices.allRobots')}
allowClear
options={devices?.map(item => ({
value: item.serialNumber,
@@ -1404,7 +1409,7 @@ export default function RobotTaskPage() {
<RangePicker
size="small"
format="YYYY-MM-DD HH:mm:ss"
placeholder={['开始时间', '结束时间']}
placeholder={[t('devices.startTime'), t('devices.endTime')]}
value={historyFilterForm.dateRange}
onChange={(dates) => {
setHistoryFilterForm(prev => ({ ...prev, dateRange: dates }));
@@ -1414,12 +1419,12 @@ export default function RobotTaskPage() {
<Select
style={{ width: 120 }}
size="small"
placeholder="状态"
placeholder={t('roles.status')}
allowClear
options={[
{ label: '执行成功', value: 'FINISH' },
{ label: '执行失败', value: 'FAILED' },
{ label: '已取消', value: 'CANCELED' },
{ label: t('devices.statusFinished'), value: 'FINISH' },
{ label: t('devices.statusFailed'), value: 'FAILED' },
{ label: t('clean.cancelled'), value: 'CANCELED' },
]}
value={historyFilterForm.taskStatus}
onChange={(val) => {
@@ -1429,7 +1434,7 @@ export default function RobotTaskPage() {
<Select
style={{ width: 340 }}
size="small"
placeholder="全部机器人"
placeholder={t('devices.allRobots')}
allowClear
options={devices?.map(item => ({
value: item.serialNumber,
@@ -1462,30 +1467,30 @@ export default function RobotTaskPage() {
<Col xs={24} xl={10} style={{ display: "flex", flexDirection: "column" }} >
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>作业编排建议</span>}
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.operationSuggestion')}</span>}
bordered={false}
bodyStyle={{ padding: '12px 16px' }}
style={{ ...cardStyle, marginBottom: 8 }}
>
<Timeline mode="left">
<Timeline.Item label="09:30" color="green">
<Text strong>RBT-01 开始除草任务</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>预计耗时 2 小时,当前进度 45%</div>
<Text strong>{t('devices.timelineMow', { robot: 'RBT-01' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMowDetail')}</div>
</Timeline.Item>
<Timeline.Item label="11:00" color="blue">
<Text strong>RBT-02 预定巡检任务</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>待审批,建议执行区域 C</div>
<Text strong>{t('devices.timelineInspect', { robot: 'RBT-02' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineInspectDetail')}</div>
</Timeline.Item>
<Timeline.Item label="14:00" color="gray">
<Text strong>设备例行维护</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>所有割草机返回充电站</div>
<Text strong>{t('devices.timelineMaintenance')}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMaintenanceDetail')}</div>
</Timeline.Item>
</Timeline>
<Button type="primary" block style={{ marginTop: 16, borderRadius: 18 }}>智能生成今日计划</Button>
<Button type="primary" block style={{ marginTop: 16, borderRadius: 18 }}>{t('devices.autoGenerateTodayPlan')}</Button>
</Card>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>设备环境与状态</span>}
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.deviceEnvironment')}</span>}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ ...cardStyle, flex: 1 }}
@@ -1493,32 +1498,32 @@ export default function RobotTaskPage() {
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>当前温度</div>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.currentTemp')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>24.5 ℃</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>环境湿度</div>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.humidity')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>65 %</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>定位精度</div>
<div style={{ fontSize: 18, fontWeight: 700, color: '#00B42A' }}>RTK 固定</div>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.positionAccuracy')}</div>
<div style={{ fontSize: 18, fontWeight: 700, color: '#00B42A' }}>{t('devices.rtkFixed')}</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>网络延迟</div>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.networkLatency')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>45 ms</div>
</div>
</Col>
</Row>
<div style={{ marginTop: 8, padding: 12, background: 'rgba(255, 125, 0, 0.1)', borderRadius: 8, display: 'flex', alignItems: 'center', gap: 8 }}>
<AlertCircle size={16} style={{ color: '#FF7D00' }} />
<span style={{ fontSize: 13, color: '#FF7D00' }}>注意:区域 B 存在积水风险,建议避开</span>
<span style={{ fontSize: 13, color: '#FF7D00' }}>{t('devices.waterRiskWarning')}</span>
</div>
</Card>
</Col>
@@ -1529,9 +1534,9 @@ export default function RobotTaskPage() {
<Card
title={
<div className="flex justify-between items-center w-full">
<span style={{ fontSize: fontTitle, fontWeight: 700 }}>预设路线</span>
<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.presetRoutes')}</span>
<Input
placeholder="搜索..."
placeholder={t('devices.searchPlaceholder')}
size="small"
style={{ width: 200 }}
value={routeSearch}
@@ -1619,14 +1624,14 @@ export default function RobotTaskPage() {
{/* 路线信息 */}
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 600, fontSize: 14, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
{route.workName || route.name || '未命名路线'}
{route.workName || route.name || t('devices.unnamedRoute')}
</div>
<div style={{ fontSize: 12, color: '#86909C', marginTop: 4 }}>
ID: {route.id}
</div>
</div>
{/* 删除按钮 */}
<Tooltip title="删除航线">
<Tooltip title={t('devices.deleteRoute')}>
<Button
type="text"
icon={<DeleteOutlined style={{ color: '#F53F3F', fontSize: 20 }} />}
@@ -1638,7 +1643,7 @@ export default function RobotTaskPage() {
}}
/>
</Tooltip>
<Tooltip title="创建任务">
<Tooltip title={t('devices.createTask')}>
<Button
type="text"
icon={<PlusOutlined style={{ color: '#165DFF', fontSize: 20 }} />}
@@ -1651,7 +1656,7 @@ export default function RobotTaskPage() {
</Tooltip>
{/* 执行按钮 */}
<Tooltip title="执行航线">
<Tooltip title={t('devices.executeRoute')}>
<Button
type="text"
icon={<PlayCircleOutlined style={{ color: '#165DFF', fontSize: 28 }} />}
@@ -1670,7 +1675,7 @@ export default function RobotTaskPage() {
</Col>
<Col xs={24} xl={18}>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>任务看板</span>}
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.taskBoard')}</span>}
bordered={false}
bodyStyle={{ padding: '12px' }}
style={{ ...cardStyle, height: '100%' }}
@@ -1678,23 +1683,23 @@ export default function RobotTaskPage() {
<Row gutter={16}>
<Col span={8}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#86909C" text="待执行" /></Title>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#86909C" text={t('devices.pending')} /></Title>
{waitList.map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
<div style={{ fontWeight: 600 }}>{item.planName || item.workName}</div>
<div style={{ fontSize: 12, color: '#86909C' }}>设备: {item.deviceId}</div>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.device')}: {item.deviceId}</div>
</Card>
))}
</div>
</Col>
<Col span={8}>
<div style={{ background: '#E8F3FF', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#165DFF" text="进行中" /></Title>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#165DFF" text={t('devices.statInProgress')} /></Title>
{runList.map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
<div style={{ fontWeight: 600 }}>{item.planName || item.workName}</div>
<div style={{ fontSize: 12, color: '#165DFF' }}>
{item.taskStaus === 'EXECUTING' ? '正在执行...' : '已暂停'}
{item.taskStaus === 'EXECUTING' ? t('devices.executingEllipsis') : t('devices.paused')}
</div>
</Card>
))}
@@ -1702,12 +1707,12 @@ export default function RobotTaskPage() {
</Col>
<Col span={8}>
<div style={{ background: '#F6FFED', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#52C41A" text="已完成" /></Title>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#52C41A" text={t('workOrder.completed')} /></Title>
{finishList.slice(0, 3).map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
<div style={{ fontWeight: 600 }}>{item.planName || item.workName}</div>
<div style={{ fontSize: 12, color: item.taskStaus === 'FAILED' ? '#F53F3F' : '#52C41A' }}>
{item.taskStaus === 'FAILED' ? '执行失败' : '执行成功'}
{item.taskStaus === 'FAILED' ? t('devices.statusFailed') : t('devices.statusFinished')}
</div>
</Card>
))}
@@ -1733,26 +1738,26 @@ export default function RobotTaskPage() {
{/* 执行任务弹窗 */}
<Modal
title="执行路线任务"
title={t('devices.executeRouteTask')}
open={executeModalVisible}
onCancel={() => setExecuteModalVisible(false)}
onOk={handleExecuteConfirm}
okText="执行"
cancelText="取消"
okText={t('devices.execute')}
cancelText={t('common.cancel')}
>
<div style={{ padding: '10px 0' }}>
<div style={{ marginBottom: 16 }}>
<div style={{ marginBottom: 8, fontWeight: 500 }}>路线信息</div>
<div style={{ marginBottom: 8, fontWeight: 500 }}>{t('devices.routeInfo')}</div>
<div style={{ padding: 12, background: '#f5f7fa', borderRadius: 6 }}>
<div><strong>路线名称:</strong>{selectedRouteForExecute?.workName || selectedRouteForExecute?.name}</div>
<div><strong>{t('devices.routeName')}</strong>{selectedRouteForExecute?.workName || selectedRouteForExecute?.name}</div>
</div>
</div>
<div>
<div style={{ marginBottom: 8, fontWeight: 500 }}>选择执行设备</div>
<div style={{ marginBottom: 8, fontWeight: 500 }}>{t('workOrder.selectDevice')}</div>
<Select
style={{ width: '100%' }}
placeholder="请选择执行设备"
placeholder={t('devices.selectExecuteDevice')}
value={selectedRobotForExecute?.serialNumber}
onChange={(val) => {
const robot = devices.find(d => d.serialNumber === val);
@@ -1772,7 +1777,7 @@ export default function RobotTaskPage() {
{showVideo && executingRobot && execute && (
<DraggableBox
defaultPosition={{ x: 50, y: 50 }}
title={`机器人全景视频 - ${executingRobot.deviceAlias || executingRobot.serialNumber}`}
title={t('devices.robotPanoramaVideo', { robot: executingRobot.deviceAlias || executingRobot.serialNumber })}
onClose={() => setShowVideo(false)}
>
<div style={{ height: '100%', width: '100%' }}>
@@ -1790,6 +1795,7 @@ export default function RobotTaskPage() {
}
const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskList, routeList, stationId, onTaskCreated, userInfo }) => {
const { t } = useTranslation();
const [formData, setFormData] = useState({
path: selectedPathWork || null,
device: null,
@@ -1813,13 +1819,13 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
// ====================== 周/月选择 ======================
const weekDays = [
{ label: '日', value: 'SUNDAY' },
{ label: '一', value: 'MONDAY' },
{ label: '二', value: 'TUESDAY' },
{ label: '三', value: 'WEDNESDAY' },
{ label: '四', value: 'THURSDAY' },
{ label: '五', value: 'FRIDAY' },
{ label: '六', value: 'SATURDAY' },
{ label: t('devices.wdSun'), value: 'SUNDAY' },
{ label: t('devices.wdMon'), value: 'MONDAY' },
{ label: t('devices.wdTue'), value: 'TUESDAY' },
{ label: t('devices.wdWed'), value: 'WEDNESDAY' },
{ label: t('devices.wdThu'), value: 'THURSDAY' },
{ label: t('devices.wdFri'), value: 'FRIDAY' },
{ label: t('devices.wdSat'), value: 'SATURDAY' },
];
const monthDays = Array.from({ length: 31 }, (_, i) => (i + 1).toString());
@@ -1861,14 +1867,14 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
// ====================== 保存 ======================
const handleSave = () => {
const missingFields = [];
if (!formData.device?.serialNumber) missingFields.push('设备编号');
if (!formData.planName) missingFields.push('任务名称');
if (!formData.path?.id) missingFields.push('路线');
//if (!formData.excuteDayStartTime) missingFields.push('执行开始时间');
if (!formData.device?.serialNumber) missingFields.push(t('devices.deviceSerial'));
if (!formData.planName) missingFields.push(t('devices.taskName'));
if (!formData.path?.id) missingFields.push(t('devices.route'));
//if (!formData.excuteDayStartTime) missingFields.push(t('workOrder.execStartTime'));
//if (!formData.excuteDayEndTime) missingFields.push('执行结束时间');
if (missingFields.length > 0) {
utils.message.error({ title: '提示', content: `请填写:${missingFields.join('、')}` });
utils.message.error({ title: t('constants.info'), content: t('devices.fillRequired', { fields: missingFields.join('、') }) });
return;
}
@@ -1906,25 +1912,25 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
};
}
if (!finalData.deviceTaskPlanRules.dayTime) {
utils.message.error('请选择执行时间');
utils.message.error(t('devices.selectExecTime'));
return;
}
saveDeviceTask(finalData).then(res => {
if (res.code === 200) {
utils.message.success('任务创建成功');
utils.message.success(t('devices.taskCreated'));
onClose();
onTaskCreated();
} else {
utils.message.error(res.data.msg || '创建失败');
utils.message.error(res.data.msg || t('devices.createFailed'));
}
}).catch(() => utils.message.error('创建任务异常'));
}).catch(() => utils.message.error(t('devices.createTaskError')));
};
// ====================== 渲染 ======================
return (
<Modal
title="新建任务"
title={t('devices.newTask')}
open={isOpen}
onCancel={onClose}
width={500}
@@ -1935,20 +1941,20 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
{/* 任务名称 */}
<div>
<label className="block mb-2 font-medium">任务名称</label>
<label className="block mb-2 font-medium">{t('devices.taskName')}</label>
<Input
value={formData.planName}
onChange={(e) => setFormData({ ...formData, planName: e.target.value })}
placeholder="请输入任务名称"
placeholder={t('devices.inputTaskName')}
/>
</div>
{/* 执行路线 */}
<div>
<label className="block mb-2 font-medium">执行路线</label>
<label className="block mb-2 font-medium">{t('devices.executeRouteLabel')}</label>
<Select
className="w-full"
placeholder="选择路线"
placeholder={t('devices.selectRoute')}
onSelect={(_, option) => {
const route = routeList.find(r => r.id === option.value);
setFormData(prev => ({ ...prev, path: route }));
@@ -1968,10 +1974,10 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
{/* 选择设备 */}
<div className="relative">
<label className="block mb-2 font-medium">选择设备</label>
<label className="block mb-2 font-medium">{t('video.selectDevice')}</label>
<Select
className="w-full"
placeholder="选择设备"
placeholder={t('video.selectDevice')}
onSelect={(_, option) => {
const robot = robots.find(r => r.serialNumber === option.value);
setFormData(prev => ({ ...prev, device: robot }));
@@ -1991,15 +1997,15 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
{/* 重复计划 */}
<div>
<label className="block mb-2 font-medium">重复计划</label>
<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">天</Select.Option>
<Select.Option value="WEEK">周</Select.Option>
<Select.Option value="MONTH">月</Select.Option>
<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>
@@ -2039,38 +2045,38 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
{/* 按天:选择日期 */}
{formData.repeatPlan === 'DAY' && (
<>
<label className="block mb-2 font-medium">执行日期</label>
<label className="block mb-2 font-medium">{t('devices.execDate')}</label>
<DatePicker
onChange={handleDateChange}
className="w-full"
placeholder="选择执行日期"
placeholder={t('devices.selectExecDate')}
/>
</>
)}
{/* 时间 */}
<label className="block mb-2 font-medium">执行时间</label>
<label className="block mb-2 font-medium">{t('devices.execTime')}</label>
<TimePicker
format="HH:mm:ss"
onChange={handleTimeChange}
className="w-full"
placeholder="选择执行时间"
placeholder={t('devices.selectExecTime')}
/>
{/* 执行周期 */}
<label className="block mb-2 font-medium">执行周期</label>
<label className="block mb-2 font-medium">{t('devices.executionCycle')}</label>
<RangePicker
onChange={handleCycleChange}
className="w-full"
placeholder={['开始日期', '结束日期']}
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}>取消</Button>
<Button type="primary" onClick={handleSave}>保存任务</Button>
<Button onClick={onClose}>{t('common.cancel')}</Button>
<Button type="primary" onClick={handleSave}>{t('devices.saveTask')}</Button>
</div>
</div>
</Modal>