中英文切换 初始化
This commit is contained in:
@@ -35,6 +35,7 @@ import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/store';
|
||||
import envConfig from '../../../env';
|
||||
import utils from '@/lib/utils.ts';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { Content } = Layout;
|
||||
const { Text, Title } = Typography;
|
||||
@@ -48,16 +49,9 @@ const taskTimeline = [
|
||||
{ time: '09:58:10', color: 'green', text: 'RBT-02 完成巡检航线 P-01', status: '任务完成' },
|
||||
];
|
||||
|
||||
const logs = [
|
||||
{ time: '10:24:35', device: 'UAV-C01', type: '命令', desc: '起飞指令下发,开始作业' },
|
||||
{ time: '10:21:40', device: 'RBT-01', type: '命令', desc: '开始巡检任务 P-02' },
|
||||
{ time: '10:20:11', device: 'UAV-C02', type: '命令', desc: '转入待命状态' },
|
||||
{ time: '10:18:05', device: 'GR-02', type: '命令', desc: '除草作业开始 G-01' },
|
||||
{ time: '10:12:35', device: 'UAV-C01', type: '告警', desc: '返航补水' },
|
||||
{ time: '10:05:22', device: 'RBT-01', type: '事件', desc: '电量较低,建议回充', level: '低电量' },
|
||||
];
|
||||
|
||||
export default function DeviceOverviewPage() {
|
||||
const { t } = useTranslation();
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const { stationId, currentStation } = useSelector((state: RootState) => state.station);
|
||||
|
||||
@@ -87,6 +81,16 @@ export default function DeviceOverviewPage() {
|
||||
const navigate = useNavigate();
|
||||
const [robotPlayActive, setRobotPlayActive] = useState<boolean>(false);
|
||||
|
||||
const logs = [
|
||||
{ time: '10:24:35', device: 'UAV-C01', type: '命令', desc: '起飞指令下发,开始作业' },
|
||||
{ time: '10:21:40', device: 'RBT-01', type: '命令', desc: '开始巡检任务 P-02' },
|
||||
{ time: '10:20:11', device: 'UAV-C02', type: '命令', desc: '转入待命状态' },
|
||||
{ time: '10:18:05', device: 'GR-02', type: '命令', desc: '除草作业开始 G-01' },
|
||||
{ time: '10:12:35', device: 'UAV-C01', type: t('constants.sourceAlert'), desc: '返航补水' },
|
||||
{ time: '10:05:22', device: 'RBT-01', type: '事件', desc: '电量较低,建议回充', level: '低电量' },
|
||||
];
|
||||
|
||||
|
||||
|
||||
// 获取数据
|
||||
const fetchAllData = async () => {
|
||||
@@ -113,7 +117,7 @@ export default function DeviceOverviewPage() {
|
||||
latitude: item.latitude || 0,
|
||||
},
|
||||
deviceAlias: item.drone_callsign || item.device_sn
|
||||
|| '无人机',
|
||||
|| t('constants.uav'),
|
||||
|
||||
}));
|
||||
|
||||
@@ -447,12 +451,12 @@ export default function DeviceOverviewPage() {
|
||||
const totalDrones = planedevices?.length || 0;
|
||||
const onlineDrones = planedevices?.filter(d => d.onlineStatus === 1).length || 0;
|
||||
const totalRobots = 1;
|
||||
//const totalRobots = devicesAll?.filter(d => d.productName?.includes('巡检')).length || 0;
|
||||
//const totalRobots = devicesAll?.filter(d => d.productName?.includes(t('constants.inspection'))).length || 0;
|
||||
|
||||
//key 0 有任务 1 无任务
|
||||
const activeRobots = 0;
|
||||
const totalMowers = 1;
|
||||
//const totalMowers = devicesAll?.filter(d => d.productName?.includes('割草机')).length || 0;
|
||||
//const totalMowers = devicesAll?.filter(d => d.productName?.includes(t('constants.mower'))).length || 0;
|
||||
const activeMowers = devices?.filter(d => d.feStatus == 1).length || 0; // 作业中状态数量
|
||||
const washDroneStandby = planedevices?.[0]?.modeStatistics?.["0"] || 0;
|
||||
//key 设备状态:{"0":"空闲中","1":"现场调试","2":"远程调试","3":"固件升级中","4":"作业中"}
|
||||
@@ -474,7 +478,7 @@ export default function DeviceOverviewPage() {
|
||||
iconBg: '#E8F3FF'
|
||||
},
|
||||
{
|
||||
title: '巡检机器人',
|
||||
title: t('home.inspectionRobot'),
|
||||
icon: <RobotOutlined style={{ color: '#13c2c2', fontSize: 24 }} />,
|
||||
value: `${totalRobots} 台`,
|
||||
sub: `执行中 ${activeRobots}`,
|
||||
@@ -522,9 +526,9 @@ export default function DeviceOverviewPage() {
|
||||
...d,
|
||||
id: d.deviceId || index,
|
||||
name: d.deviceAlias || d.deviceName || d.callsign || '未知设备',
|
||||
type: d.productName || '无人机',
|
||||
status: d.onlineStatus === 1 ? '在线' : '离线',
|
||||
mode: d.feStatus == 1 ? '作业中' : d.feStatus == 2 ? '空闲' : d.mode_code == 0 ? '空闲' : d.mode_code == 1 ? '现场调试' : d.mode_code == 2 ? '远程调试' : d.mode_code == 3 ? '固件升级中' : '作业中',
|
||||
type: d.productName || t('constants.uav'),
|
||||
status: d.onlineStatus === 1 ? t('devices.online') : t('devices.offline'),
|
||||
mode: d.feStatus == 1 ? '作业中' : d.feStatus == 2 ? t('devices.idle') : d.mode_code == 0 ? t('devices.idle') : d.mode_code == 1 ? '现场调试' : d.mode_code == 2 ? '远程调试' : d.mode_code == 3 ? '固件升级中' : '作业中',
|
||||
capacity_percent: d.capacity_percent || 100,
|
||||
position: d.position || '站内',
|
||||
task: d.status === 4 ? '待命' : '作业中',
|
||||
@@ -644,13 +648,13 @@ export default function DeviceOverviewPage() {
|
||||
<Table rowKey={(record) => record.id || record.serialNumber || record.device_sn} size="small" pagination={false}
|
||||
columns={[
|
||||
{ title: '装备名称', dataIndex: 'name', width: 140 },
|
||||
{ title: '类型', dataIndex: 'type', width: 90 },
|
||||
{ title: t('common.type'), dataIndex: 'type', width: 90 },
|
||||
{
|
||||
title: '当前状态',
|
||||
title: t('workOrder.currentStatus'),
|
||||
dataIndex: 'onlineStatus',
|
||||
width: 70,
|
||||
render: (s) => {
|
||||
const text = s === 1 ? '在线' : '离线';
|
||||
const text = s === 1 ? t('devices.online') : t('devices.offline');
|
||||
const color = s === 1 ? 'success' : 'default';
|
||||
return <Tag color={color} style={{ margin: 0 }}>{text}</Tag>;
|
||||
}
|
||||
@@ -658,7 +662,7 @@ export default function DeviceOverviewPage() {
|
||||
title: '模式', dataIndex: 'mode', width: 70, render: (text) => {
|
||||
let color = 'default';
|
||||
if (text === '作业中') color = 'processing';
|
||||
if (text === '空闲') color = 'success';
|
||||
if (text === t('devices.idle')) color = 'success';
|
||||
if (text === '空闲中') color = 'success';
|
||||
if (text === '现场调试') color = 'warning';
|
||||
if (text === '远程调试') color = 'warning';
|
||||
@@ -667,7 +671,7 @@ export default function DeviceOverviewPage() {
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电量',
|
||||
title: t('devices.batteryLevel'),
|
||||
dataIndex: 'lastRunningStatus',
|
||||
width: 70,
|
||||
render: (lastRunningStatus) => {
|
||||
@@ -678,11 +682,11 @@ export default function DeviceOverviewPage() {
|
||||
status={v < 40 ? 'exception' : 'active'}
|
||||
/>;
|
||||
}
|
||||
}, { title: '位置', dataIndex: 'position', width: 90 },
|
||||
}, { title: t('aiAnalysis.location'), dataIndex: 'position', width: 90 },
|
||||
//{ title: '当前任务', dataIndex: 'task', width: 100 },
|
||||
{ title: '通讯状态', dataIndex: 'comm', width: 100, render: v => <Badge status={v.includes('-') ? 'warning' : 'success'} text={v} /> },
|
||||
{
|
||||
title: '操作',
|
||||
title: t('roles.actions'),
|
||||
key: 'action',
|
||||
width: 150,
|
||||
//fixed: 'right',
|
||||
@@ -694,7 +698,7 @@ export default function DeviceOverviewPage() {
|
||||
type="text"
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => openEditRobotModal(record)}
|
||||
title="编辑"
|
||||
title={t('roles.edit')}
|
||||
/>
|
||||
<Tooltip title="设备参数设置">
|
||||
<Button
|
||||
@@ -718,10 +722,10 @@ export default function DeviceOverviewPage() {
|
||||
<Card title={<><SettingOutlined /> <span >控制日志 / 告警记录</span></>} bordered={false} style={{ borderRadius: 8 }} extra={<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><Button size="small" style={{ borderRadius: 4, border: '1px solid #d9d9d9' }}>全部级别 ▼</Button></div>}>
|
||||
<Table rowKey="time" size="small" pagination={false} dataSource={logs} scroll={{ x: 'max-content' }}
|
||||
columns={[
|
||||
{ title: '时间', dataIndex: 'time', width: 90, render: t => <span style={{ fontSize: 13 }}>{t}</span> },
|
||||
{ title: t('common.time'), dataIndex: 'time', width: 90, render: t => <span style={{ fontSize: 13 }}>{t}</span> },
|
||||
{ title: '设备', dataIndex: 'device', width: 100, render: t => <span style={{ fontSize: 13 }}>{t}</span> },
|
||||
{ title: '类型', dataIndex: 'type', width: 70, render: t => { let c = '#52c41a'; if (t === '告警') c = '#fa8c16'; if (t === 'events') c = '#1890ff'; return <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}><span style={{ width: 10, height: 10, borderRadius: 2, background: c }} /><span style={{ fontSize: 13 }}>{t}</span></div> } },
|
||||
{ title: '描述', dataIndex: 'desc', render: t => <span style={{ fontSize: 13 }}>{t}</span> },
|
||||
{ title: t('common.type'), dataIndex: 'type', width: 70, render: r => { let c = '#52c41a'; if (r === t('constants.sourceAlert')) c = '#fa8c16'; if (t === 'events') c = '#1890ff'; return <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}><span style={{ width: 10, height: 10, borderRadius: 2, background: c }} /><span style={{ fontSize: 13 }}>{t}</span></div> } },
|
||||
{ title: t('common.description'), dataIndex: 'desc', render: t => <span style={{ fontSize: 13 }}>{t}</span> },
|
||||
{ title: '', width: 70, render: (_, r) => r.level ? <Tag color="red" style={{ fontSize: 11, margin: 0 }}>{r.level}</Tag> : null }
|
||||
]}
|
||||
/>
|
||||
@@ -745,8 +749,8 @@ export default function DeviceOverviewPage() {
|
||||
String(option?.label || "").toLowerCase().includes(input.toLowerCase())
|
||||
}
|
||||
options={[
|
||||
{ label: <span>机器人</span>, options: devices.map(item => ({ value: item.device_sn || item.serialNumber, label: item.deviceAlias || item.deviceName || '未知设备' })) },
|
||||
{ label: <span>无人机</span>, options: planedevices.map(item => ({ value: item.device_sn, label: item.drone_callsign || item.callsign || '未知设备' })) },
|
||||
{ label: <span>devices.robot</span>, options: devices.map(item => ({ value: item.device_sn || item.serialNumber, label: item.deviceAlias || item.deviceName || '未知设备' })) },
|
||||
{ label: <span>constants.uav</span>, options: planedevices.map(item => ({ value: item.device_sn, label: item.drone_callsign || item.callsign || '未知设备' })) },
|
||||
]}
|
||||
/>
|
||||
|
||||
@@ -755,14 +759,14 @@ export default function DeviceOverviewPage() {
|
||||
<Col span={12}>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 12, flexWrap: "wrap" }}>
|
||||
{selectedDevice.deviceType === 'drone' || selectedDevice.deviceName?.includes('无人机') || selectedDevice.drone_callsign ? (
|
||||
{selectedDevice.deviceType === 'drone' || selectedDevice.deviceName?.includes(t('constants.uav')) || selectedDevice.drone_callsign ? (
|
||||
<span style={{ fontSize: 20, color: '#1890ff' }}><RocketOutlined /></span>
|
||||
) : (
|
||||
<span style={{ fontSize: 20, color: '#1890ff' }}><CarOutlined /></span>
|
||||
)}
|
||||
<span style={{ fontSize: 14, fontWeight: 600 }}>{selectedDevice.deviceAlias || selectedDevice.drone_callsign || selectedDevice.callsign || selectedDevice.deviceName}</span>
|
||||
<Tag color={selectedDevice.onlineStatus === 1 ? "success" : "default"} size="small" style={{ margin: 0 }}>
|
||||
{selectedDevice.onlineStatus == 1 ? "在线" : "离线"}
|
||||
{selectedDevice.onlineStatus == 1 ? t('devices.online') : t('devices.offline')}
|
||||
</Tag>
|
||||
<Button
|
||||
type="primary" size="small" ghost icon={<InfoCircleOutlined />}
|
||||
@@ -778,7 +782,7 @@ export default function DeviceOverviewPage() {
|
||||
</div>
|
||||
{realtimeDevice?.environment_temperature && (
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||
<span style={{ fontSize: 12 }}>温度</span>
|
||||
<span style={{ fontSize: 12 }}>{t('home.temperature')}</span>
|
||||
<span style={{ color: '#faad14' }}>{fix2(realtimeDevice.environment_temperature || 25)}℃</span>
|
||||
</div>
|
||||
)}
|
||||
@@ -809,7 +813,7 @@ export default function DeviceOverviewPage() {
|
||||
<span style={{ fontSize: 12 }}>v{selectedDevice.firmwareVersion}</span>
|
||||
</div>
|
||||
)}
|
||||
{(selectedDevice.productName?.includes('无人机') || selectedDevice.device_sn) && (
|
||||
{(selectedDevice.productName?.includes(t('constants.uav')) || selectedDevice.device_sn) && (
|
||||
<>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
<span style={{ color: '#666', fontSize: 12 }}>飞行高度</span>
|
||||
@@ -835,8 +839,8 @@ export default function DeviceOverviewPage() {
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: "space-between", flexWrap: 'wrap', gap: 6 }}>
|
||||
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} onClick={handleStart}>启动</Button>
|
||||
<Button style={{ borderRadius: 8, flex: 1 }} onClick={handlePause}>暂停</Button>
|
||||
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} onClick={handleReturn}>返航</Button>
|
||||
<Button style={{ borderRadius: 8, flex: 1 }} onClick={handlePause}>{t('video.pause')}</Button>
|
||||
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} onClick={handleReturn}>{t('devices.returnHome')}</Button>
|
||||
<Button style={{ flex: 1, background: '#52c41a', borderColor: '#52c41a', color: "#fff", borderRadius: 8, }} onClick={handleRecharge}>回充</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -973,12 +977,12 @@ export default function DeviceOverviewPage() {
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
{(selectedDevice?.productName?.includes('无人机') || selectedDevice?.device_sn) && (
|
||||
{(selectedDevice?.productName?.includes(t('constants.uav')) || selectedDevice?.device_sn) && (
|
||||
<Card title="环境与飞行条件" bordered={false} style={{ borderRadius: 12, marginBottom: 8 }}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", gap: 12, alignItems: "center" }}>
|
||||
<div style={{ display: "flex", border: "1px solid #e8e8e8", borderRadius: 12, overflow: "hidden", flex: 1 }}>
|
||||
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>风速</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(realtimeDevice?.wind_speed)} m/s</div></div>
|
||||
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>温度</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(realtimeDevice?.environment_temperature)}℃</div></div>
|
||||
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>{t('home.temperature')}</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(realtimeDevice?.environment_temperature)}℃</div></div>
|
||||
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>降雨</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{getVal(realtimeDevice?.rainfall)}</div></div>
|
||||
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>RTK</div><div style={{ fontSize: 14, fontWeight: 700, color: '#52c41a', marginTop: 2 }}>{realtimeDevice?.position_state?.is_fixed === 'fixing_successful' ? '固定' : '未固定'}</div></div>
|
||||
</div>
|
||||
@@ -993,7 +997,7 @@ export default function DeviceOverviewPage() {
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{(!selectedDevice?.productName?.includes('无人机') && !selectedDevice?.device_sn) && (
|
||||
{(!selectedDevice?.productName?.includes(t('constants.uav')) && !selectedDevice?.device_sn) && (
|
||||
<Card title={<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}><RobotOutlined style={{ color: '#165DFF' }} />机器人作业状态</div>} bordered={false} style={{ borderRadius: 12, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}>
|
||||
<Row gutter={16} style={{ alignItems: 'center' }}>
|
||||
<Col span={8}>
|
||||
@@ -1090,7 +1094,7 @@ export default function DeviceOverviewPage() {
|
||||
</div>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<Typography.Text strong>设备类型:</Typography.Text>
|
||||
<Typography.Text>{currentEditRobot.productName || '未知'}</Typography.Text>
|
||||
<Typography.Text>{currentEditRobot.productName || t('constants.locationUnknown')}</Typography.Text>
|
||||
</div>
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<Typography.Text strong>设备别名 <span style={{ color: 'red' }}>*</span></Typography.Text>
|
||||
|
||||
Reference in New Issue
Block a user