This commit is contained in:
mmc
2026-05-11 11:59:17 +08:00
parent 8c877b3ee2
commit 0bd1fc42d3
3 changed files with 918 additions and 1087 deletions

View File

@@ -60,11 +60,9 @@ const logs = [
// 设备总览组件
export default function DeviceOverviewPage({ devices, planedevices, devicesAll }) {
console.log(devicesAll)
const [activeTab, setActiveTab] = useState('drone');
const [selectedDevice, setSelectedDevice] = useState('');
const [currentDevice, setCurrentDevice] = useState(null);
const controlTabs = [
{ key: 'airport', label: '无人机机场' },
@@ -79,11 +77,31 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
const handleReturn = () => message.info('返航指令已下发');
const handleRecharge = () => message.info('回充指令已下发');
const handleEmergencyStop = () => message.error('已触发急停!');
// 数字保留两位小数
const fix2 = (val) => {
if (val === null || val === undefined || isNaN(val)) return '-';
return Number(val).toFixed(2);
};
// 安全取值
const getVal = (val) => val == "no_rain" ? "无" : '-';
// 默认选中第一个
useEffect(() => {
if (devicesAll.length > 0) {
setSelectedDevice(devicesAll[0].device_sn);
if (devicesAll && devicesAll.length > 0) {
const first = devicesAll[0];
setSelectedDevice(first.device_sn);
setCurrentDevice(first);
}
}, [devicesAll])
}, [devicesAll]);
// 切换设备
const handleDeviceChange = (sn) => {
setSelectedDevice(sn);
const target = devicesAll.find(item => item.device_sn === sn);
setCurrentDevice(target);
};
return (
<Content style={{ maxWidth: 1800, margin: '0 auto', }}>
@@ -108,11 +126,10 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
<Row gutter={16}>
<Col xs={24} lg={14}>
{/* 装备协同态势图 */}
<Card title={<><EnvironmentOutlined /> 装备协同态势图</>} extra={<Button type="text" icon={<SettingOutlined />} />} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }} bodyStyle={{ padding: 0 }}>
<div style={{ width: '100%', height: 400, background: '#e6f7ff url(https://picsum.photos/seed/solarfarm/1600/800) center/cover', borderRadius: 12, position: 'relative', overflow: 'hidden' }}>
<div style={{ position: 'absolute', top: 16, left: 16, background: 'rgba(255,255,255,0.95)', borderRadius: 8, padding: 12 }}>
<div style={{ fontSize: 12, fontWeight: 600, marginBottom: 8 }}>图例说明</div>
<div style={{ fontSize: 12, fontWeight: 60, marginBottom: 8 }}>图例说明</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, fontSize: 11 }}>
<div><span style={{ color: '#1890ff' }}>———</span> 巡检航线</div>
<div><span style={{ color: '#fa8c16' }}>———</span> 机器人路径</div>
@@ -142,85 +159,142 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
scroll={{ x: 'max-content' }}
/>
</Card>
<Card title={<><SettingOutlined /> <span style={{ color: '#1890ff' }}>控制日志 / 告警记录</span></>} bordered={false} style={{ borderRadius: 12 }} extra={<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><Button size="small" style={{ borderRadius: 8, border: '1px solid #d9d9d9' }}>全部级别 ▼</Button></div>}>
<Table rowKey="time" size="small" pagination={false} dataSource={logs} scroll={{ x: 'max-content' }}
columns={[
{ title: '时间', dataIndex: 'time', width: 100, render: t => <span style={{ fontSize: 14 }}>{t}</span> },
{ title: '设备', dataIndex: 'device', width: 120, render: t => <span style={{ fontSize: 14 }}>{t}</span> },
{ title: '类型', dataIndex: 'type', width: 80, render: t => { let c = '#52c41a'; if (t === '告警') c = '#fa8c16'; if (t === '事件') c = '#1890ff'; return <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}><span style={{ width: 12, height: 12, borderRadius: 2, background: c }} /><span style={{ fontSize: 14 }}>{t}</span></div> } },
{ title: '类型', dataIndex: 'type', width: 80, 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: 12, height: 12, borderRadius: 2, background: c }} /><span style={{ fontSize: 14 }}>{t}</span></div> } },
{ title: '描述', dataIndex: 'desc', render: t => <span style={{ fontSize: 14 }}>{t}</span> },
{ title: '', width: 80, render: (_, r) => r.level ? <Tag color="red" style={{ fontSize: 12 }}>{r.level}</Tag> : null }
]}
/>
<div style={{ textAlign: 'center', marginTop: 12 }}><Button type="link" style={{ fontSize: 16, color: '#1890ff' }}>查看更多日志</Button></div>
</Card>
</Col>
<Col xs={24} lg={10}>
<Card title={<> 设备控制面板</>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }} bodyStyle={{ padding: 16, paddingBottom: 0 }}>
<Select style={{ width: 180, marginBottom: 4 }}
options={devicesAll.map((item) => {
return {
value: item.device_sn,
label: item.drone_callsign
}
})}
value={selectedDevice} // 必须加
onChange={setSelectedDevice}// 必须加
<Select
style={{ width: 180, marginBottom: 10 }}
placeholder="请选择设备"
value={selectedDevice}
onChange={handleDeviceChange}
options={devicesAll.map(item => ({
value: item.device_sn,
label: item.callsign || '未知设备'
}))}
/>
<Row gutter={16}>
<Col span={12}>
<div style={{ marginBottom: 24 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 16 }}>
<span style={{ fontSize: 24, color: '#1890ff' }}><RocketOutlined /></span>
<span style={{ fontSize: 16, fontWeight: 600 }}>清洗无人机 UAV-C01</span>
<Tag color="success" size="small">作业中</Tag>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<span style={{ color: '#52c41a' }}><ThunderboltOutlined /></span>
<span style={{ fontSize: 12 }}>电量 72%</span>
{currentDevice && (
<Row gutter={16}>
<Col span={12}>
<div style={{ marginBottom: 24 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 16 }}>
<span style={{ fontSize: 24, color: '#1890ff' }}><RocketOutlined /></span>
<span style={{ fontSize: 16, fontWeight: 600 }}>{currentDevice.drone_callsign || currentDevice.callsign}</span>
<Tag color={currentDevice.onlineStatus === 1 ? "success" : "default"} size="small">
{currentDevice.onlineStatus == 1 ? "在线" : "离线"}
</Tag>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<span style={{ fontSize: 12 }}>信号强度</span>
<span style={{ color: '#52c41a' }}>强</span>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<span style={{ color: '#52c41a' }}><ThunderboltOutlined /></span>
<span style={{ fontSize: 12 }}>电量 {fix2(currentDevice.capacity_percent)}%</span>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<span style={{ fontSize: 12 }}>温度</span>
<span style={{ color: '#faad14' }}>{fix2(currentDevice.environment_temperature)}℃</span>
</div>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 12, maxHeight: "100px", overflow: "auto", scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>机场编号</span>
<span style={{ fontSize: 12 }}>{getVal(currentDevice.gateway_sn)}</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>设备SN</span>
<span style={{ fontSize: 12 }}>{getVal(currentDevice.device_sn)}</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>高度</span>
<span style={{ fontSize: 12 }}>{fix2(currentDevice.height)} m</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>风速</span>
<span style={{ fontSize: 12 }}>{fix2(currentDevice.wind_speed)} m/s</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>离家距离</span>
<span style={{ fontSize: 12 }}>{fix2(currentDevice.home_distance)} m</span>
</div>
{/* 经纬度 */}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>经纬度</span>
<span style={{ fontSize: 12 }}>{(fix2(currentDevice.longitude), fix2(currentDevice.latitude))}</span>
</div>
{/* 无人机状态 */}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>信号</span>
<span style={{ fontSize: 12 }}>
{currentDevice.network_state?.quality === 'good' ? '好' : currentDevice.network_state?.quality === 'better' ? '较好' : currentDevice.network_state?.quality === 'moderate' ? '一般' : currentDevice.network_state?.quality === 'poor' ? '较差' : currentDevice.network_state?.quality === 'too_pool' ? '差' : '无信号'}
</span>
</div>
{/* RTK 信息 */}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#1890ff', fontSize: 12 }}>RTK 状态</span>
<span style={{ fontSize: 12 }}>
{currentDevice.position_state?.is_fixed === 'fixing_successful' ? '固定' : '未固定'}
</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>GPS卫星</span>
<span style={{ fontSize: 12 }}>{getVal(currentDevice.position_state?.gps_number)}</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span style={{ color: '#666', fontSize: 12 }}>RTK卫星</span>
<span style={{ fontSize: 12 }}>{getVal(currentDevice.position_state?.rtk_number)}</span>
</div>
</div>
<div style={{ display: 'flex', justifyContent: "space-between", flexWrap: 'wrap', gap: 6 }}>
<Button type="primary" size="large" style={{ borderRadius: 8, flex: 1 }} onClick={handleStart}>启动任务</Button>
<Button style={{ borderRadius: 8, flex: 1 }} size="large" onClick={handlePause}>暂停</Button>
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} size="large" onClick={handleReturn}>返航</Button>
<Button style={{ background: '#52c41a', borderColor: '#52c41a', color: "#fff", borderRadius: 8, flex: 1 }} size="large" onClick={handleRecharge}>回充</Button>
</div>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 24 }}>
<div style={{ display: 'flex', justifyContent: 'space-between' }}><span style={{ color: '#666', fontSize: 12 }}>当前模式</span><span style={{ fontSize: 12 }}>自主清洗模式</span></div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}><span style={{ color: '#666', fontSize: 12 }}>当前位置</span><span style={{ fontSize: 12 }}>清洗区域 C-05</span></div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}><span style={{ color: '#666', fontSize: 12 }}>当前任务</span><span style={{ fontSize: 12 }}>清洗航线 C-05</span></div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}><span style={{ color: '#666', fontSize: 12 }}>预计剩余时间</span><span style={{ fontSize: 12, fontWeight: 600 }}>00:18:36</span></div>
</div>
<div style={{ display: 'flex', justifyContent: "space-between", flexWrap: 'wrap' }}>
<Button type="primary" size="large" style={{ borderRadius: 8, padding: "0 10px", fontSize: "14px" }} onClick={handleStart}>启动任务</Button>
<Button style={{ borderRadius: 8, padding: "0 10px", fontSize: "14px" }} size="large" onClick={handlePause}>暂停</Button>
<Button style={{ borderRadius: 8, padding: "0 10px", fontSize: "14px" }} type="primary" size="large" onClick={handleReturn}>返航</Button>
<Button style={{ background: '#52c41a', padding: "0 10px", fontSize: "14px", borderColor: '#52c41a', borderRadius: 8, color: "#fff" }} size="large" onClick={handleRecharge}>回充</Button>
</div>
</div>
</Col>
<Col span={12}>
<div style={{ marginBottom: 16 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
<span style={{ fontSize: 14, fontWeight: 500, color: "#666" }}>实时画面</span>
<span style={{ fontSize: 13, color: '#999' }}>2025-05-24 10:24:18</span>
</div>
<div style={{ width: '100%', height: 160, background: '#000 url(https://picsum.photos/seed/droneview/800/400) center/cover', borderRadius: 8, position: 'relative', overflow: 'hidden' }}>
<div style={{ position: 'absolute', bottom: 0, left: 0, right: 0, background: 'rgba(0,0,0,0.6)', color: '#fff', display: 'flex', justifyContent: 'space-between', padding: '8px 12px', fontSize: 14 }}>
<span>高度 12.5m</span><span>速度 4.2m/s</span><span>距离 86m</span>
</Col>
<Col span={12}>
<div style={{ marginBottom: 16 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
<span style={{ fontSize: 14, fontWeight: 500, color: "#666" }}>实时画面</span>
<span style={{ fontSize: 13, color: '#999' }}>实时监控</span>
</div>
<div style={{ width: '100%', height: 160, background: '#000 url(https://picsum.photos/seed/droneview/800/400) center/cover', borderRadius: 8, position: 'relative', overflow: 'hidden' }}>
<div style={{ position: 'absolute', bottom: 0, left: 0, right: 0, background: 'rgba(0,0,0,0.6)', color: '#fff', display: 'flex', justifyContent: 'space-between', padding: '8px 12px', fontSize: 14 }}>
<span>高度 {fix2(currentDevice.height)}m</span>
<span>风速 {fix2(currentDevice.wind_speed)}m/s</span>
</div>
</div>
</div>
</div>
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
<Button size="large" style={{ flex: 1, borderRadius: 8, padding: "0 10px", fontSize: "14px" }}>切换手动</Button>
<Button danger size="large" style={{ flex: 1, borderRadius: 8, padding: "0 10px", fontSize: "14px", backgroundColor: "#ff4d4f", borderColor: "#ff4d4f", color: "#fff" }} onClick={handleEmergencyStop}>急停</Button>
</div>
</Col>
</Row>
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
<Button size="large" style={{ flex: 1, borderRadius: 8 }}>切换手动</Button>
<Button danger size="large" style={{ flex: 1, borderRadius: 8 }} onClick={handleEmergencyStop}>急停</Button>
</div>
</Col>
</Row>
)}
</Card>
<Card title={<><ApiOutlined /> AI分析与操作建议</>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
@@ -256,20 +330,19 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
<Card title="环境与飞行条件" bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
<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 }}>2.6 m/s</div><div style={{ fontSize: 11, color: '#666', fontWeight: 600, marginTop: 2 }}>轻风</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 }}>28.7℃</div><div style={{ fontSize: 11, color: '#52c41a', fontWeight: 600, marginTop: 2 }}>适宜</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 }}>812W/m²</div><div style={{ fontSize: 11, color: '#fa8c16', fontWeight: 600, marginTop: 2 }}>较高</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 }}>10%</div><div style={{ fontSize: 11, color: '#52c41a', fontWeight: 600, marginTop: 2 }}>低</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 }}>GNSS状态</div><div style={{ fontSize: 14, fontWeight: 700, color: '#52c41a', marginTop: 2 }}>正常</div><div style={{ fontSize: 11, color: '#666', fontWeight: 600, marginTop: 2 }}>定位稳定</div></div>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>禁飞状态</div><div style={{ fontSize: 14, fontWeight: 700, color: '#52c41a', marginTop: 2 }}>未禁飞</div><div style={{ fontSize: 11, color: '#666', fontWeight: 600, marginTop: 2 }}>可执行</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(currentDevice?.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(currentDevice?.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(currentDevice?.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 }}>{currentDevice?.position_state?.is_fixed === 'fixing_successful' ? '固定' : '未固定'}</div></div>
</div>
<div style={{ width: 110, padding: '12px 8px', borderRadius: 8, background: '#f6ffed', border: '1px solid #b7eb8f', textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4 }}>
<div style={{ fontSize: 14, fontWeight: 700, color: '#52c41a' }}>适宜执行</div>
<div style={{ width: 18, height: 18, borderRadius: '50%', background: '#52c41a', display: 'flex', alignItems: 'center', justifyContent: 'center' }}><CheckCircleOutlined style={{ fontSize: 12, color: '#fff' }} /></div>
<div style={{ fontSize: 11, color: '#666' }}>可正常开展作业</div>
<div style={{ fontSize: 11, color: '#666' }}>可正常作业</div>
</div>
</div>
</Card>
<Card title={<><ClockCircleOutlined /> 任务执行时间线</>} bordered={false} style={{ borderRadius: 12 }} extra={<div style={{ fontSize: 12, color: '#666' }}>今天 2025-05-24</div>}>
<Timeline mode="left">
{taskTimeline.map((item, idx) => (
@@ -281,8 +354,6 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll }
</Timeline>
<div style={{ textAlign: 'center', marginTop: 12 }}><Button type="link">查看更多</Button></div>
</Card>
</Col>
</Row>
</Content>