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>

View File

@@ -1,581 +1,411 @@
import React, { useState } from 'react';
import {
Card, Row, Col, Tabs, Button, Space, Select, Table, Statistic,
DatePicker, message, Tag, Empty,
Typography
DatePicker, message, Tag, Typography,
Radio, Checkbox, Divider
} from 'antd';
import {
CloudOutlined, BarChartOutlined, BellOutlined,
CalendarOutlined, LinkOutlined, FileTextOutlined,
DownloadOutlined
CalendarOutlined, FileTextOutlined,
DownloadOutlined, ArrowUpOutlined, CheckCircleOutlined,
ClockCircleOutlined, WarningOutlined, FileExcelOutlined,
FilePdfOutlined, MailOutlined, SendOutlined, SettingOutlined,
RobotOutlined
} from '@ant-design/icons';
import { Line, Pie } from '@ant-design/charts';
import { Line, Bar, Pie } from '@ant-design/charts';
import dayjs from 'dayjs';
const { TabPane } = Tabs;
const { RangePicker } = DatePicker;
const { Option } = Select;
const { Text, Title } = Typography;
// 模拟数据
const overviewData = {
powerToday: 69302.3,
currentPower: 89343.1,
currentAlarm: 5,
processingOrder: 2,
deviceOnlineRate: 92.3,
generatedReport: 4
};
// 发电报表模拟数据
const powerTrendData = [
{ date: '2026-04-28', avgPower: 40.33, dailyPower: 4580.6 }
];
const powerDetailData = [
{ date: '2026-04-28', avgPower: 40.33, dailyPower: 4580.6, totalPower: 182345.7 }
// 模拟数据(完全匹配参考图)
const overviewCards = [
{ title: '本月发电量', value: '138.6', unit: 'MWh', rate: '+6.2%', rateUp: true, color: '#52c41a' },
{ title: 'PR均值', value: '82.8', unit: '%', rate: '+1.1%', rateUp: true, color: '#1890ff' },
{ title: '运维工单完成率', value: '93.4', unit: '%', desc: '本月累计 126 单', color: '#1890ff' },
{ title: '告警闭环率', value: '94.2', unit: '%', desc: '严重告警 8 条', color: '#faad14' },
{ title: '清洗收益提升', value: '+7.6', unit: '%', desc: '预估增发 12,850 kWh', color: '#52c41a' },
{ title: '自动生成报告', value: '24', unit: '份', desc: '本月累计', color: '#722ed1' },
];
// 告警报表模拟数据
const alarmLevelData = [
{ type: 'MAJOR', value: 2 },
{ type: 'INFO', value: 2 },
{ type: 'MINOR', value: 1 }
];
const alarmStatusData = [
{ type: 'PENDING', value: 3 },
{ type: 'PROCESSING', value: 2 }
];
const alarmTrendData = [
{ date: '2026-04-28', count: 5 }
];
const deviceAlarmRankData = [
{ device: 'INV-A02', count: 2 },
{ device: 'CAM-02', count: 2 },
{ device: 'CMB-A01', count: 1 }
const monthlyPowerData = [
{ date: '05-01', generation: 6, predicted: 8, pr: 105 },
{ date: '05-06', generation: 7, predicted: 9, pr: 108 },
{ date: '05-11', generation: 3, predicted: 7, pr: 102 },
{ date: '05-16', generation: 8, predicted: 10, pr: 112 },
{ date: '05-21', generation: 9, predicted: 10, pr: 110 },
{ date: '05-26', generation: 7, predicted: 9, pr: 108 },
{ date: '05-31', generation: 5, predicted: 7, pr: 105 },
];
// 工单报表模拟数据
const orderStatusData = [
{ type: 'DISPATCHED', value: 1 },
{ type: 'PENDING', value: 1 },
{ type: 'PROCESSING', value: 1 }
];
const orderPriorityData = [
{ type: 'LOW', value: 1 },
{ type: 'MEDIUM', value: 1 },
{ type: 'HIGH', value: 1 }
];
const orderSourceData = [
{ type: 'ALARM', value: 2 },
{ type: 'MANUAL', value: 1 }
];
const orderTrendData = [
{ date: '2026-04-28', newOrder: 3, completed: 0 }
];
const orderEfficiencyData = {
avgProcessHour: 0.00,
completionRate: '0.0%',
newOrderToday: 0
};
// 设备健康模拟数据
const deviceHealthList = [
{ deviceCode: 'CAM-02', deviceName: '摄像头 CAM-02', type: 'CAMERA', online: 'OFFLINE', run: 'FAULT', temp: 0, power: 0, healthScore: 40, healthStatus: 'OFFLINE' },
{ deviceCode: 'INV-A02', deviceName: '逆变器 INV-A02', type: 'INVERTER', online: 'ONLINE', run: 'WARNING', temp: 82.5, power: 54.2, healthScore: 70, healthStatus: 'WARNING' },
{ deviceCode: 'CMB-A01', deviceName: '汇流箱 CMB-A01', type: 'COMBINER_BOX', online: 'ONLINE', run: 'WARNING', temp: 46.3, power: 0, healthScore: 70, healthStatus: 'WARNING' },
{ deviceCode: 'INV-A01', deviceName: '逆变器 INV-A01', type: 'INVERTER', online: 'ONLINE', run: 'NORMAL', temp: 46, power: 66.8, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'INV-B01', deviceName: '逆变器 INV-B01', type: 'INVERTER', online: 'ONLINE', run: 'NORMAL', temp: 43.8, power: 22410.8, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'CMB-A02', deviceName: '汇流箱 CMB-A02', type: 'COMBINER_BOX', online: 'ONLINE', run: 'NORMAL', temp: 41.1, power: 0, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'MET-01', deviceName: '气象站 MET-01', type: 'WEATHER_STATION', online: 'ONLINE', run: 'NORMAL', temp: 28.4, power: 0, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'METER-01', deviceName: '电表 METER-01', type: 'METER', online: 'ONLINE', run: 'NORMAL', temp: 39.2, power: 66811.3, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'CAM-01', deviceName: '摄像头 CAM-01', type: 'CAMERA', online: 'ONLINE', run: 'NORMAL', temp: 35.2, power: 0, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'CAM-03', deviceName: '摄像头 CAM-03', type: 'CAMERA', online: 'ONLINE', run: 'NORMAL', temp: 33.9, power: 0, healthScore: 92, healthStatus: 'HEALTHY' }
const powerMeteorologyData = [
{ date: '05-05-05', generation: 70, irradiance: 60, temp: 20 },
{ date: '05-12-05', generation: 60, irradiance: 50, temp: 22 },
{ date: '05-19-05', generation: 65, irradiance: 65, temp: 25 },
{ date: '05-26-05', generation: 55, irradiance: 55, temp: 23 },
];
const orderAlarmData = [
{ date: '05-05-05', newOrder: 80, completed: 60, alarmCount: 10, closedRate: 80 },
{ date: '05-12-05', newOrder: 100, completed: 80, alarmCount: 20, closedRate: 85 },
{ date: '05-19-05', newOrder: 70, completed: 50, alarmCount: 15, closedRate: 90 },
{ date: '05-26-05', newOrder: 90, completed: 70, alarmCount: 18, closedRate: 92 },
];
const aiAnalysisData = [
{ type: '热斑识别', value: 36 },
{ type: '异常组串', value: 8 },
{ type: '推荐清洗区块', value: 8 },
{ type: '视频异常事件', value: 6 },
];
// 报表文件模拟数据
const reportFileList = [
{ id: 'RPT-ALARM_STAT-20260429092501', name: '告警统计报表', type: 'ALARM_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:25:03+08:00' },
{ id: 'RPT-DEMO-WORKORDER-001', name: '西北荒漠一号光伏电站工单效率统计', type: 'WORK_ORDER_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' },
{ id: 'RPT-DEMO-ALARM-001', name: '西北荒漠一号光伏电站告警统计', type: 'ALARM_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' },
{ id: 'RPT-DEMO-POWER-001', name: '西北荒漠一号光伏电站发电日报', type: 'POWER_DAILY', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' }
{ name: '电站月报', date: '2025年05月', type: '发电报表', status: '已生成', operator: '张运维', time: '2025-05-31 08:15' },
{ name: '周运维总结', date: '2025年05月', type: '运维报表', status: '已生成', operator: '系统自动', time: '2025-05-26 09:10' },
{ name: 'AI诊断日报', date: '2025年05月', type: 'AI分析报告', status: '生成中', operator: '系统自动', time: '2025-05-31 07:30' },
{ name: '告警闭环周报', date: '2025年05月', type: '告警报表', status: '已生成', operator: '李工程师', time: '2025-05-31 09:00' },
{ name: '清洗效果报告', date: '2025年05月', type: '运维报表', status: '已生成', operator: '王运维', time: '2025-05-28 10:20' },
];
const reportTemplates = [
{ name: '月度经营报告', desc: '综合经营分析与收益评估模板', icon: <BarChartOutlined />, color: '#1890ff' },
{ name: '设备健康分析报告', desc: '设备健康与故障分析模板', icon: <WarningOutlined />, color: '#faad14' },
{ name: '清洗优化效果报告', desc: '清洗前后对比与收益分析模板', icon: <CloudOutlined />, color: '#52c41a' },
{ name: '巡检与机器人作业报告', desc: '巡检与机器人作业统计模板', icon: <RobotOutlined />, color: '#722ed1' },
];
export default function ReportCenterPage() {
const [activeTab, setActiveTab] = useState('power');
const [timeType, setTimeType] = useState('day');
const [dateRange, setDateRange] = useState([dayjs().subtract(7, 'day'), dayjs()]);
// 顶部概览卡片
const OverviewCards = () => (
< div
style={{
display: 'flex',
flexWrap: 'wrap', // 自动换行
gap: '16px', // 卡片间距
marginBottom: '20px'
}
}
>
{/* 今日发电量 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '110px', // 固定高度
flexShrink: 0 // 不压缩
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="今日发电量"
value={overviewData.powerToday}
precision={1}
suffix="kWh"
valueStyle={{ color: '#52c41a', fontSize: 24, fontWeight: 700 }}
prefix={<CloudOutlined style={{ fontSize: 32, color: '#52c41a' }} />}
/>
<div style={{ fontSize: 12, color: '#666', marginTop: 4 }}>遥测与 latest 聚合</div>
</Card>
</div >
{/* 当前功率 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '110px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="当前功率"
value={overviewData.currentPower}
precision={1}
suffix="kW"
valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 700 }}
prefix={<BarChartOutlined style={{ fontSize: 32, color: '#1890ff' }} />}
/>
<div style={{ fontSize: 12, color: '#666', marginTop: 4 }}>实时功率汇总</div>
</Card>
</div >
{/* 当前告警 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '110px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="当前告警"
value={overviewData.currentAlarm}
suffix="条"
valueStyle={{ color: '#ff4d4f', fontSize: 24, fontWeight: 700 }}
prefix={<BellOutlined style={{ fontSize: 32, color: '#ff4d4f' }} />}
/>
<div style={{ fontSize: 12, color: '#666', marginTop: 4 }}>累计 5 条</div>
</Card>
</div >
{/* 处理中工单 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '110px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="处理中工单"
value={overviewData.processingOrder}
suffix="单"
valueStyle={{ color: '#faad14', fontSize: 24, fontWeight: 700 }}
prefix={<CalendarOutlined style={{ fontSize: 32, color: '#faad14' }} />}
/>
<div style={{ fontSize: 12, color: '#666', marginTop: 4 }}>全部 3 单</div>
</Card>
</div >
{/* 设备在线率 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '110px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="设备在线率"
value={overviewData.deviceOnlineRate}
precision={1}
suffix="%"
valueStyle={{ color: '#52c41a', fontSize: 24, fontWeight: 700 }}
prefix={<LinkOutlined style={{ fontSize: 32, color: '#52c41a' }} />}
/>
<div style={{ fontSize: 12, color: '#666', marginTop: 4 }}>来自设备主数据</div>
</Card>
</div >
{/* 已生成报表 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '110px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="已生成报表"
value={overviewData.generatedReport}
suffix="份"
valueStyle={{ color: '#722ed1', fontSize: 24, fontWeight: 700 }}
prefix={<FileTextOutlined style={{ fontSize: 32, color: '#722ed1' }} />}
/>
<div style={{ fontSize: 12, color: '#666', marginTop: 4 }}>SUCCESS 文件记录</div>
</Card>
</div >
</div >
);
// 发电报表
const PowerReportTab = () => (
<div>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16, gap: 16 }}>
<RangePicker
value={dateRange}
onChange={setDateRange}
style={{ flex: 1 }}
/>
<Space>
<Button size="small" onClick={() => setTimeType('hour')}>小时</Button>
<Button size="small" type={timeType === 'day' ? 'primary' : 'default'} onClick={() => setTimeType('day')}>日</Button>
<Button size="small" onClick={() => setTimeType('month')}>月</Button>
</Space>
<Button type="primary">查询</Button>
</div>
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title="发电趋势">
<Line
data={powerTrendData}
xField="date"
yField={['avgPower', 'dailyPower']}
seriesField="type"
color={['#1890ff', '#52c41a']}
point={{ size: 5 }}
legend={{ position: 'top-right' }}
yAxis={{
label: { formatter: (v) => `${v}` },
}}
/>
</Card>
<Card bordered={false} style={{ borderRadius: 8 }} title="发电趋势明细">
<Table
rowKey="date"
columns={[
{ title: '时间', dataIndex: 'date' },
{ title: '平均功率(kW)', dataIndex: 'avgPower' },
{ title: '日发电量(kWh)', dataIndex: 'dailyPower' },
{ title: '累计发电量(kWh)', dataIndex: 'totalPower' }
]}
dataSource={powerDetailData}
pagination={false}
/>
</Card>
</div>
);
// 告警报表
const AlarmReportTab = () => (
<div>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警等级分布">
<Pie
data={alarmLevelData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#faad14']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警状态分布">
<Pie
data={alarmStatusData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警日趋势">
<Line
data={alarmTrendData}
xField="date"
yField="count"
color="#1890ff"
point={{ size: 5 }}
legend={{ position: 'top-right' }}
/>
</Card>
</Col>
</Row>
<Card bordered={false} style={{ borderRadius: 8 }} title="设备告警排行">
<Table
rowKey="device"
columns={[
{ title: '设备编码', dataIndex: 'device' },
{ title: '告警数', dataIndex: 'count' }
]}
dataSource={deviceAlarmRankData}
pagination={false}
/>
</Card>
</div>
);
// 工单报表
const WorkOrderReportTab = () => (
<div>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="工单状态分布">
<Pie
data={orderStatusData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#faad14']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="优先级分布">
<Pie
data={orderPriorityData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#faad14']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="来源分布">
<Pie
data={orderSourceData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
</Row>
<Row gutter={16}>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }} title="处理效率">
<div style={{ display: 'flex', gap: 16 }}>
<div>
<Statistic
value={orderEfficiencyData.avgProcessHour}
precision={2}
valueStyle={{ color: '#1890ff', fontSize: 24 }}
/>
<div style={{ fontSize: 12, color: '#666' }}>平均处理小时</div>
</div>
<div>
<Statistic
value={0}
suffix="%"
valueStyle={{ color: '#1890ff', fontSize: 24 }}
formatter={() => orderEfficiencyData.completionRate}
/>
<div style={{ fontSize: 12, color: '#666' }}>完成率</div>
</div>
<div>
<Statistic
value={orderEfficiencyData.newOrderToday}
valueStyle={{ color: '#1890ff', fontSize: 24 }}
/>
<div style={{ fontSize: 12, color: '#666' }}>今日新增</div>
</div>
</div>
</Card>
</Col>
<Col span={18}>
<Card bordered={false} style={{ borderRadius: 8 }} title="工单日趋势">
<Table
rowKey="date"
columns={[
{ title: '日期', dataIndex: 'date' },
{ title: '新增', dataIndex: 'newOrder' },
{ title: '完成', dataIndex: 'completed' }
]}
dataSource={orderTrendData}
pagination={false}
/>
</Card>
</Col>
</Row>
</div>
);
// 设备健康报表
const DeviceHealthTab = () => (
<div>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="设备在线率"
value={92.3}
precision={1}
suffix="%"
valueStyle={{ color: '#52c41a', fontSize: 24, fontWeight: 700 }}
prefix={<LinkOutlined style={{ fontSize: 28, color: '#52c41a' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>来自 pv_device</div>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="离线设备"
value={1}
suffix="台"
valueStyle={{ color: '#faad14', fontSize: 24, fontWeight: 700 }}
prefix={<BellOutlined style={{ fontSize: 28, color: '#faad14' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>在线状态统计</div>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="异常设备"
value={3}
suffix="台"
valueStyle={{ color: '#ff4d4f', fontSize: 24, fontWeight: 700 }}
prefix={<BellOutlined style={{ fontSize: 28, color: '#ff4d4f' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>运行状态统计</div>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="平均温度"
value={38.4}
precision={1}
suffix="℃"
valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 700 }}
prefix={<BarChartOutlined style={{ fontSize: 28, color: '#1890ff' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>来自 device_latest</div>
</Card>
</Col>
</Row>
<Card bordered={false} style={{ borderRadius: 8 }} title="设备健康列表">
<Table
rowKey="deviceCode"
columns={[
{ title: '设备编码', dataIndex: 'deviceCode' },
{ title: '设备名称', dataIndex: 'deviceName' },
{ title: '类型', dataIndex: 'type' },
{ title: '在线', dataIndex: 'online', render: (v) => <Tag color={v === 'ONLINE' ? 'green' : 'red'}>{v}</Tag> },
{ title: '运行', dataIndex: 'run', render: (v) => <Tag color={v === 'NORMAL' ? 'green' : v === 'WARNING' ? 'orange' : 'red'}>{v}</Tag> },
{ title: '温度', dataIndex: 'temp' },
{ title: '功率', dataIndex: 'power' },
{ title: '健康分', dataIndex: 'healthScore' },
{ title: '健康状态', dataIndex: 'healthStatus', render: (v) => <Tag color={v === 'HEALTHY' ? 'green' : v === 'WARNING' ? 'orange' : 'red'}>{v}</Tag> }
]}
dataSource={deviceHealthList}
pagination={false}
scroll={{ x: 'max-content' }}
/>
</Card>
</div>
);
// 报表文件
const ReportFileTab = () => (
<div>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16, gap: 16 }}>
<Select placeholder="报表类型" style={{ width: 150 }} allowClear>
<Option value="POWER_DAILY">发电日报</Option>
<Option value="ALARM_STAT">告警统计</Option>
<Option value="WORK_ORDER_STAT">工单统计</Option>
</Select>
<Select placeholder="生成状态" style={{ width: 150 }} allowClear>
<Option value="SUCCESS">成功</Option>
<Option value="FAILED">失败</Option>
</Select>
<Button type="primary">查询</Button>
<Button type="primary" onClick={() => message.success('报表生成任务已提交')}>生成报表</Button>
</div>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Table
rowKey="id"
columns={[
{ title: '报表编码', dataIndex: 'id' },
{ title: '报表名称', dataIndex: 'name' },
{ title: '类型', dataIndex: 'type' },
{ title: '格式', dataIndex: 'format' },
{ title: '状态', dataIndex: 'status', render: (v) => <Tag color={v === 'SUCCESS' ? 'green' : 'red'}>{v}</Tag> },
{ title: '生成时间', dataIndex: 'time' },
{ title: '操作', render: () => <Button type="link" icon={<DownloadOutlined />}>下载</Button> }
]}
dataSource={reportFileList}
pagination={{ total: 4, pageSize: 10, showSizeChanger: true, showTotal: (total) => `共 ${total} 条` }}
/>
</Card>
</div>
);
const [activeTab, setActiveTab] = useState('overview');
const [reportCycle, setReportCycle] = useState('month');
const [reportType, setReportType] = useState('all');
const [dateRange, setDateRange] = useState([dayjs('2025-05-01'), dayjs('2025-05-31')]);
return (
<div style={{ padding: 20, background: '#f5f7fa', minHeight: '100vh' }}>
{/* 页面头部 */}
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 20 }}>
<div>
<Typography.Title level={4} style={{ margin: 0 }}>报表中心</Typography.Title>
<p style={{ color: '#666', margin: '4px 0 0' }}>发电、告警、工单效率、设备健康与报表文件统一分析</p>
</div>
<Button type="primary" size="large">生成报表</Button>
{/* 页面头部标签 */}
<Tabs activeKey={activeTab} onChange={setActiveTab} style={{ marginBottom: 20 }}>
<TabPane tab="报表总览" key="overview" />
<TabPane tab="发电报表" key="power" />
<TabPane tab="运维报表" key="operation" />
<TabPane tab="告警报表" key="alarm" />
<TabPane tab="AI分析报告" key="ai" />
</Tabs>
{/* 顶部统计卡片 */}
<Row gutter={16} style={{ marginBottom: 20 }}>
{overviewCards.map((card, idx) => (
<Col span={4} key={idx}>
<Card bordered={false} style={{ borderRadius: 8, height: 120 }}>
<Statistic
title={card.title}
value={card.value}
precision={card.title === 'PR均值' ? 1 : 1}
suffix={card.unit}
valueStyle={{ color: card.color, fontSize: 28, fontWeight: 700 }}
/>
{card.rate && (
<Text type="secondary" style={{ fontSize: 12 }}>
环比 <span style={{ color: card.rateUp ? '#52c41a' : '#ff4d4f' }}>{card.rate}</span>
</Text>
)}
{card.desc && (
<Text type="secondary" style={{ fontSize: 12, display: 'block' }}>
{card.desc}
</Text>
)}
</Card>
</Col>
))}
</Row>
{/* 筛选栏 */}
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 20, gap: 16, flexWrap: 'wrap' }}>
<Select value={reportCycle} onChange={setReportCycle} style={{ width: 120 }}>
<Option value="day">日报</Option>
<Option value="week">周报</Option>
<Option value="month">月报</Option>
</Select>
<Select value={reportType} onChange={setReportType} style={{ width: 120 }}>
<Option value="all">全部</Option>
<Option value="power">发电报表</Option>
<Option value="operation">运维报表</Option>
<Option value="alarm">告警报表</Option>
<Option value="ai">AI分析报告</Option>
</Select>
<RangePicker
value={dateRange}
onChange={setDateRange}
style={{ flex: 1, maxWidth: 300 }}
/>
<Space>
<Button type="primary" icon={<FileTextOutlined />}>生成报表</Button>
<Button icon={<FilePdfOutlined />}>导出PDF</Button>
<Button icon={<FileExcelOutlined />}>导出Excel</Button>
</Space>
</div>
{/* 顶部概览卡片 */}
<OverviewCards />
<Row gutter={16}>
{/* 左侧主内容区 */}
<Col span={16}>
{/* 月度综合经营分析 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title="月度综合经营分析">
<Line
data={monthlyPowerData}
xField="date"
yField={['generation', 'predicted', 'pr']}
seriesField="type"
color={['#52c41a', '#1890ff', '#fa8c16']}
lineStyle={(datum) => {
if (datum.type === 'pr') return { lineDash: [4, 4] };
return {};
}}
tooltip={{
formatter: (datum) => {
return {
name: datum.date,
data: [
{ name: '发电量(MWh)', value: datum.generation },
{ name: '预测发电(MWh)', value: datum.predicted },
{ name: 'PR(%)', value: datum.pr }
]
};
}
}}
legend={{
items: [
{ name: '发电量(MWh)', marker: { symbol: 'line', style: { stroke: '#52c41a' } } },
{ name: '预测发电(MWh)', marker: { symbol: 'line', style: { stroke: '#1890ff', lineDash: [4, 4] } } },
{ name: 'PR(%)', marker: { symbol: 'line', style: { stroke: '#fa8c16' } } },
]
}}
yAxis={[
{
label: { formatter: (v) => `${v}` },
name: '发电量',
},
{
label: { formatter: (v) => `${v}%` },
name: 'PR',
position: 'right',
}
]}
height={200}
/>
<Row gutter={16} style={{ marginTop: 16 }}>
<Col span={6}>
<Statistic title="本月累计发电量" value={138.6} suffix="MWh" />
</Col>
<Col span={6}>
<Statistic title="理论发电量" value={166.8} suffix="MWh" />
</Col>
<Col span={6}>
<Statistic title="PR均值" value={82.8} suffix="%" />
</Col>
<Col span={6}>
<Statistic title="发电偏差" value={-3.4} suffix="%" valueStyle={{ color: '#ff4d4f' }} />
</Col>
<Col span={6}>
<Statistic title="平均辐照度" value={5.3} suffix="kWh/㎡/天" />
</Col>
</Row>
</Card>
{/* 标签页 */}
<Tabs activeKey={activeTab} onChange={setActiveTab}>
<TabPane tab="发电报表" key="power">{PowerReportTab()}</TabPane>
<TabPane tab="告警报表" key="alarm">{AlarmReportTab()}</TabPane>
<TabPane tab="工单报表" key="order">{WorkOrderReportTab()}</TabPane>
<TabPane tab="设备健康" key="device">{DeviceHealthTab()}</TabPane>
<TabPane tab="报表文件" key="file">{ReportFileTab()}</TabPane>
</Tabs>
{/* 发电与气象 + 工单与告警 */}
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={12}>
<Card bordered={false} style={{ borderRadius: 8 }} title="发电与气象统计">
<Bar
data={powerMeteorologyData}
xField="date"
yField={['generation', 'irradiance', 'temp']}
color={['#1890ff', '#52c41a', '#fa8c16']}
legend={{ position: 'top' }}
height={180}
/>
</Card>
</Col>
<Col span={12}>
<Card bordered={false} style={{ borderRadius: 8 }} title="工单与告警闭环分析">
<Bar
data={orderAlarmData}
xField="date"
yField={['newOrder', 'completed', 'alarmCount', 'closedRate']}
color={['#1890ff', '#52c41a', '#fa8c16', '#722ed1']}
legend={{ position: 'top' }}
height={180}
/>
</Card>
</Col>
</Row>
{/* AI分析成果统计 */}
<Card bordered={false} style={{ borderRadius: 8 }} title="AI分析成果统计">
<Row gutter={16}>
<Col span={8}>
<Pie
data={aiAnalysisData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#fa8c16', '#722ed1']}
radius={0.7}
innerRadius={0.6}
height={180}
/>
</Col>
<Col span={16}>
<Row gutter={16}>
{aiAnalysisData.map((item, idx) => (
<Col span={12} key={idx}>
<Statistic title={item.type} value={item.value} suffix="个" />
</Col>
))}
</Row>
</Col>
</Row>
</Card>
</Col>
{/* 右侧边栏 */}
<Col span={8}>
{/* 报表目录 / 快捷下载 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title={
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>报表目录 / 快捷下载</span>
<Button type="link">更多 </Button>
</div>
}>
<Table
rowKey="name"
columns={[
{ title: '报表名称', dataIndex: 'name' },
{
title: '状态', dataIndex: 'status', render: (v) => (
<Tag color={v === '已生成' ? 'green' : v === '生成中' ? 'orange' : 'default'}>{v}</Tag>
)
},
{
title: '操作', render: () => (
<Space>
<Button type="link" size="small">查看</Button>
<Button type="link" size="small">下载</Button>
</Space>
)
}
]}
dataSource={reportFileList.slice(0, 4)}
pagination={false}
size="small"
/>
</Card>
{/* 模板中心 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title={
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>模板中心</span>
<Button type="link">更多 </Button>
</div>
}>
<Row gutter={16}>
{reportTemplates.map((tpl, idx) => (
<Col span={12} key={idx}>
<Card bordered={false} size="small" style={{ background: '#fafafa', borderRadius: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<div style={{ width: 32, height: 32, borderRadius: 4, background: `${tpl.color}15`, color: tpl.color, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{tpl.icon}
</div>
<div>
<div style={{ fontSize: 13, fontWeight: 500 }}>{tpl.name}</div>
<div style={{ fontSize: 11, color: '#666' }}>{tpl.desc}</div>
</div>
</div>
</Card>
</Col>
))}
</Row>
</Card>
{/* 报表生成记录 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title={
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>报表生成记录</span>
<Button type="link">更多 </Button>
</div>
}>
<Table
rowKey="name"
columns={[
{ title: '报表名称', dataIndex: 'name' },
{ title: '生成时间', dataIndex: 'time' },
{ title: '生成人', dataIndex: 'operator' },
{ title: '类型', dataIndex: 'type' },
{
title: '状态', dataIndex: 'status', render: (v) => (
<Tag color={v === '已生成' ? 'green' : v === '生成中' ? 'orange' : 'default'}>{v}</Tag>
)
},
{
title: '操作', render: () => (
<Space>
<Button type="link" size="small">查看</Button>
<Button type="link" size="small">下载</Button>
</Space>
)
}
]}
dataSource={reportFileList}
pagination={false}
size="small"
/>
</Card>
{/* 订阅与分发 */}
<Card bordered={false} style={{ borderRadius: 8 }} title="订阅与分发">
<div style={{ marginBottom: 16 }}>
<Text strong>订阅人员</Text>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
{['张运维', '李工程师', '王运维', '陈经理'].map((name, idx) => (
<div key={idx} style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<div style={{ width: 32, height: 32, borderRadius: '50%', background: '#e6f7ff', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{name.charAt(0)}
</div>
<Text style={{ fontSize: 12 }}>{name}</Text>
</div>
))}
<Text type="secondary">+2</Text>
</div>
</div>
<Divider style={{ margin: '12px 0' }} />
<div style={{ marginBottom: 16 }}>
<Text strong>分发渠道(可多选)</Text>
<div style={{ display: 'flex', gap: 16, marginTop: 8 }}>
<Checkbox checked>
<MailOutlined style={{ marginRight: 4 }} /> 邮件
</Checkbox>
<Checkbox checked>
<SendOutlined style={{ marginRight: 4 }} /> Telegram
</Checkbox>
<Checkbox checked>
<BellOutlined style={{ marginRight: 4 }} /> 系统通知
</Checkbox>
</div>
</div>
<Divider style={{ margin: '12px 0' }} />
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Text strong>发送计划</Text>
<Button type="link" icon={<SettingOutlined />}>编辑</Button>
</div>
<Card size="small" style={{ marginTop: 8, background: '#f6ffed', borderColor: '#b7eb8f' }}>
<Text>每周一 09:00 自动发送</Text>
</Card>
</Card>
</Col>
</Row>
</div>
);
}

View File

@@ -1,71 +1,101 @@
import React, { useState } from 'react';
import {
Layout, Card, Row, Col, Button, Table, Tag, Select, Input, Typography, Space,
Statistic, Modal, message, Empty, Drawer, Descriptions, Timeline, Divider, Form
Statistic, message, Drawer, Descriptions, Timeline, Divider, Form, Modal
} from 'antd';
import {
CheckOutlined, ClockCircleOutlined, ControlOutlined,
BarChartOutlined, RiseOutlined, ArrowUpOutlined,
SearchOutlined, PlusOutlined, EditOutlined, DeleteOutlined,
EyeOutlined, CommentOutlined, PauseOutlined, FormOutlined
PlusOutlined, SearchOutlined, EditOutlined, EyeOutlined,
ClockCircleOutlined, CheckCircleOutlined, PlayCircleOutlined,
CloseCircleOutlined, ThunderboltOutlined, SettingOutlined,
SendOutlined, PauseOutlined, ArrowRightOutlined, FileDoneOutlined,
RobotOutlined, CloudOutlined, RiseOutlined,
BranchesOutlined
} from '@ant-design/icons';
import { Pie, Bar } from '@ant-design/charts';
import { Pie, Line, Bar } from '@ant-design/charts';
import dayjs from 'dayjs';
const { Option } = Select;
const { Search } = Input;
const { Text, Title } = Typography;
// 模拟数据
const workOrderData = [
// 模拟数据(完全匹配参考图)
const workOrderList = [
{
id: 'WO-20260428-003',
title: 'A区组件例行巡检',
source: '人工创建',
device: 'INV-A01',
deviceName: '逆变器 INV-A01',
type: '巡检',
priority: 'low',
status: 'dispatched',
handler: '李工程师',
createTime: '2026-04-28 19:55:18',
desc: '结合日常运维计划执行 A 区逆变器和汇流箱巡检。'
},
{
id: 'WO-20260428-002',
title: 'CAM-02 离线排查',
source: '告警',
device: 'CAM-02',
deviceName: '摄像头 CAM-02',
type: '故障排查',
priority: 'medium',
status: 'pending',
handler: '',
createTime: '2026-04-28 19:55:18',
desc: ''
},
{
id: 'WO-20260428-001',
title: 'INV-A02 温度过高现场检查',
source: '告警',
device: 'INV-A02',
deviceName: '逆变器 INV-A02',
type: '故障排查',
id: 'WO20250524001',
title: '逆变器 INV-05 告警排查',
source: 'AI诊断',
type: '检修',
priority: 'high',
handler: '李工',
deadline: '2025-05-24 14:30',
status: 'pending',
description: ''
},
{
id: 'WO20250524002',
title: '区块 B-12 热斑复检',
source: '无人机巡检',
type: '巡检',
priority: 'high',
handler: '王工',
deadline: '2025-05-24 15:00',
status: 'processing',
description: '对AI识别热斑区域进行复检与红外复核,确认是否需要更换组件。'
},
{
id: 'WO20250524003',
title: '组件清洗任务 C-05',
source: '清洗优化',
type: '清洗',
priority: 'medium',
handler: '赵工',
deadline: '2025-05-24 16:00',
status: 'dispatched',
description: ''
},
{
id: 'WO20250524004',
title: '周界摄像头 CAM-08 离线修复',
source: '视频监控',
type: '维修',
priority: 'medium',
handler: '陈工',
deadline: '2025-05-24 17:30',
status: 'processing',
description: ''
},
{
id: 'WO20250524005',
title: '除草机器人补给',
source: '装备控制',
type: '运维',
priority: 'low',
handler: '刘工',
deadline: '2025-05-24 18:00',
status: 'pending',
description: ''
},
{
id: 'WO20250524006',
title: '逆变器室夜间巡检',
source: '人工创建',
type: '巡检',
priority: 'medium',
handler: '张运维',
createTime: '2026-04-28 19:55:18',
desc: ''
deadline: '2025-05-24 21:00',
status: 'completed',
description: ''
}
];
// 工单状态配置
const statusConfig = {
pending: { label: '待处理', color: '#faad14', icon: <ClockCircleOutlined /> },
dispatched: { label: '已派发', color: '#1890ff', icon: <ControlOutlined /> },
processing: { label: '处理中', color: '#2f54eb', icon: <BarChartOutlined /> },
pending: { label: '待处理', color: '#1890ff', icon: <ClockCircleOutlined /> },
dispatched: { label: '已派发', color: '#52c41a', icon: <SendOutlined /> },
processing: { label: '执行中', color: '#2f54eb', icon: <PlayCircleOutlined /> },
suspended: { label: '挂起', color: '#faad14', icon: <PauseOutlined /> },
completed: { label: '已完成', color: '#52c41a', icon: <CheckOutlined /> },
closed: { label: '已关闭', color: '#8c8c8c', icon: <CheckOutlined /> }
completed: { label: '已完成', color: '#52c41a', icon: <CheckCircleOutlined /> },
closed: { label: '已关闭', color: '#8c8c8c', icon: <CloseCircleOutlined /> }
};
// 优先级配置
@@ -76,347 +106,351 @@ const priorityConfig = {
urgent: { label: '紧急', color: '#f5222d' }
};
const WorkOrderPage = () => {
const [searchParams, setSearchParams] = useState({ orderNo: '', status: '' });
const [drawerVisible, setDrawerVisible] = useState(false);
const [currentOrder, setCurrentOrder] = useState(null);
// 统计卡片数据
const overviewCards = [
{ title: '今日新增工单', value: 18, suffix: '单', desc: '较昨日 +3', color: '#1890ff', icon: <FileDoneOutlined /> },
{ title: '待处理工单', value: 12, suffix: '单', desc: '高优先级 5', color: '#ff4d4f', icon: <ClockCircleOutlined /> },
{ title: '执行中工单', value: 9, suffix: '单', desc: '按时率 92%', color: '#52c41a', icon: <PlayCircleOutlined /> },
{ title: '已完成工单', value: 126, suffix: '单', desc: '本月累计', color: '#52c41a', icon: <CheckCircleOutlined /> },
{ title: '平均处理时长', value: 4.3, suffix: '小时', desc: '较上周 -12% ↓', color: '#1890ff', icon: <ClockCircleOutlined /> },
{ title: 'AI建议生成', value: 7, suffix: '单', desc: '今日自动生成', color: '#722ed1', icon: <RobotOutlined /> }
];
// 👇 新增:编辑工单弹窗状态
// 任务排班数据
const scheduleData = [
{ handler: '李工', tasks: [{ title: 'INV-05 告警排查', time: '08:30 - 12:00', type: 'alarm' }] },
{ handler: '王工', tasks: [{ title: 'B-12 热斑复检', time: '13:30 - 15:00', type: 'inspect' }] },
{ handler: '赵工', tasks: [{ title: '组件清洗 C-05', time: '09:00 - 12:00', type: 'clean' }, { title: '清洗效果复检', time: '15:00 - 17:00', type: 'clean' }] },
{ handler: '陈工', tasks: [{ title: '周界摄像头修复', time: '10:00 - 12:30', type: 'repair' }, { title: '设备巡检', time: '15:30 - 17:30', type: 'inspect' }] }
];
// 告警趋势数据
const alarmTrendData = [
{ date: '05-18', count: 5 },
{ date: '05-19', count: 10 },
{ date: '05-20', count: 5 },
{ date: '05-21', count: 5 },
{ date: '05-22', count: 12 },
{ date: '05-23', count: 10 },
{ date: '05-24', count: 12 }
];
// 告警列表数据
const alarmList = [
{ name: 'INV-05 逆变器告警', time: '05-24 10:24' },
{ name: 'B-12 区块热斑告警', time: '05-24 09:56' },
{ name: 'B-12 组件温度异常', time: '05-24 09:32' }
];
export default function WorkOrderPage() {
const [selectedOrder, setSelectedOrder] = useState(workOrderList[1]); // 默认选中执行中的工单
const [drawerVisible, setDrawerVisible] = useState(false);
const [editModalVisible, setEditModalVisible] = useState(false);
const [editingOrder, setEditingOrder] = useState(null);
const [editForm] = Form.useForm();
// 打开编辑弹窗
const openEditModal = (record) => {
setEditingOrder(record);
editForm.setFieldsValue({
title: record.title,
source: record.source,
type: record.type,
priority: record.priority,
handler: record.handler,
deviceCode: record.device,
deviceName: record.deviceName,
desc: record.desc
});
setEditModalVisible(true);
};
// 提交编辑
const handleEditSubmit = () => {
editForm.validateFields().then(values => {
console.log('保存工单:', { ...editingOrder, ...values });
message.success('工单保存成功');
setEditModalVisible(false);
});
};
// 表格列定义
const columns = [
{
title: '工单编号',
dataIndex: 'id',
key: 'id',
width: 140
},
{
title: '标题',
dataIndex: 'title',
key: 'title'
},
{
title: '来源',
dataIndex: 'source',
key: 'source',
width: 100
},
{
title: '设备',
dataIndex: 'device',
key: 'device',
width: 100
},
{ title: '工单编号', dataIndex: 'id', key: 'id', width: 140 },
{ title: '工单标题', dataIndex: 'title', key: 'title' },
{ title: '来源', dataIndex: 'source', key: 'source', width: 100 },
{ title: '类型', dataIndex: 'type', key: 'type', width: 80 },
{
title: '优先级',
dataIndex: 'priority',
key: 'priority',
width: 80,
render: (priority) => (
<Tag color={priorityConfig[priority]?.color} style={{ borderRadius: 12, padding: '0 8px' }}>
<Tag color={priorityConfig[priority]?.color} style={{ borderRadius: 4 }}>
{priorityConfig[priority]?.label}
</Tag>
)
},
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 80 },
{ title: '截止时间', dataIndex: 'deadline', key: 'deadline', width: 160 },
{
title: '状态',
dataIndex: 'status',
key: 'status',
width: 100,
render: (status) => (
<Tag color={statusConfig[status]?.color}>
<Tag color={statusConfig[status]?.color} style={{ borderRadius: 4 }}>
{statusConfig[status]?.label}
</Tag>
)
},
{
title: '处理人',
dataIndex: 'handler',
key: 'handler',
width: 100,
render: (handler) => handler || '—'
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
width: 160
},
{
title: '操作',
key: 'action',
width: 320,
fixed: 'right',
width: 80,
render: (_, record) => (
<Space size="small" wrap>
<Button
type="link"
size="small"
icon={<EyeOutlined />}
onClick={() => {
setCurrentOrder(record);
setDrawerVisible(true);
}}
>
详情
</Button>
<Button
type="link"
size="small"
icon={<EditOutlined />}
onClick={() => openEditModal(record)}
>
编辑
</Button>
<Button type="link" size="small" onClick={() => message.info('派发工单')}>派发</Button>
<Button type="link" size="small" style={{ color: '#52c41a' }}>开始</Button>
<Button type="link" size="small" style={{ color: '#faad14' }}>挂起</Button>
<Button type="link" size="small" style={{ color: '#1890ff' }}>恢复</Button>
<Button type="link" size="small" style={{ color: '#52c41a' }}>完成</Button>
<Button type="link" size="small" danger>关闭</Button>
<Button type="link" size="small" icon={<CommentOutlined />}>评论</Button>
</Space>
<Button type="link" size="small" onClick={() => { setSelectedOrder(record); setDrawerVisible(true); }}>
查看
</Button>
)
}
];
// 饼图数据
// 工单状态分布饼图数据
const pieData = [
{ type: '待处理', value: 1, color: '#1890ff' },
{ type: '已派发', value: 1, color: '#52c41a' },
{ type: '处理中', value: 1, color: '#faad14' }
];
// 柱状图数据
const barData = [
{ priority: '紧急', count: 0 },
{ priority: '高', count: 1 },
{ priority: '中', count: 1 },
{ priority: '低', count: 1 }
{ type: '待处理', value: 12, color: '#1890ff' },
{ type: '执行中', value: 9, color: '#2f54eb' },
{ type: '已完成', value: 126, color: '#52c41a' },
{ type: '已挂起', value: 4, color: '#faad14' }
];
return (
<div style={{ padding: 20, background: '#f5f7fa', minHeight: '100vh' }}>
{/* 顶部标题和搜索 */}
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 20 }}>
<div>
<Typography.Title level={4} style={{ margin: 0 }}>工单管理</Typography.Title>
<Text type="secondary">告警转工单、派发处理、流转记录与事件联动闭环</Text>
</div>
{/* 顶部统计卡片 */}
<Row gutter={16} style={{ marginBottom: 20 }}>
{overviewCards.map((card, idx) => (
<Col span={4} key={idx}>
<Card bordered={false} style={{ borderRadius: 8, height: 120 }}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<div>
<div style={{ fontSize: 14, color: '#666' }}>{card.title}</div>
<div style={{ fontSize: 28, fontWeight: 700, color: card.color, margin: '8px 0' }}>
{card.value} <span style={{ fontSize: 14, fontWeight: 400 }}>{card.suffix}</span>
</div>
<div style={{ fontSize: 12, color: '#999' }}>{card.desc}</div>
</div>
<div style={{ width: 48, height: 48, borderRadius: '50%', background: `${card.color}15`, display: 'flex', alignItems: 'center', justifyContent: 'center', color: card.color, fontSize: 20 }}>
{card.icon}
</div>
</div>
</Card>
</Col>
))}
</Row>
{/* 筛选栏 */}
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 20, gap: 16, flexWrap: 'wrap' }}>
<Select placeholder="工单类型" style={{ width: 120 }} defaultValue="all">
<Option value="all">全部</Option>
<Option value="inspect">巡检</Option>
<Option value="repair">维修</Option>
<Option value="clean">清洗</Option>
</Select>
<Select placeholder="优先级" style={{ width: 120 }} defaultValue="all">
<Option value="all">全部</Option>
<Option value="high">高</Option>
<Option value="medium">中</Option>
<Option value="low">低</Option>
</Select>
<Select placeholder="负责人" style={{ width: 120 }} defaultValue="all">
<Option value="all">全部</Option>
<Option value="李工">李工</Option>
<Option value="王工">王工</Option>
<Option value="赵工">赵工</Option>
</Select>
<Space>
<Input
placeholder="请输入工单编号"
prefix={<SearchOutlined />}
style={{ width: 220 }}
value={searchParams.orderNo}
onChange={(e) => setSearchParams({ ...searchParams, orderNo: e.target.value })}
/>
<Select
placeholder="状态"
style={{ width: 120 }}
allowClear
onChange={(val) => setSearchParams({ ...searchParams, status: val })}
>
<Option value="pending">待处理</Option>
<Option value="dispatched">已派发</Option>
<Option value="processing">处理中</Option>
<Option value="suspended">挂起</Option>
</Select>
<Button type="primary" icon={<SearchOutlined />}>查询</Button>
<Button icon={<PlusOutlined />}>新建工单</Button>
<span>时间范围</span>
<Input style={{ width: 180 }} value="2025-05-24 ~ 2025-05-24" readOnly />
</Space>
<Select placeholder="状态" style={{ width: 120 }} defaultValue="all">
<Option value="all">全部</Option>
<Option value="pending">待处理</Option>
<Option value="processing">执行中</Option>
<Option value="completed">已完成</Option>
</Select>
<Input placeholder="请输入工单编号/标题" style={{ width: 240 }} prefix={<SearchOutlined />} />
<Space>
<Button>重置</Button>
<Button type="primary">查询</Button>
</Space>
</div>
{/* 统计卡片 */}
<Row gutter={16} style={{ marginBottom: 20 }}>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="全部工单"
value={3}
suffix="单"
prefix={<CheckOutlined style={{ color: '#1890ff', fontSize: 24 }} />}
valueStyle={{ fontSize: 28, fontWeight: 700 }}
/>
<Text type="secondary" style={{ fontSize: 12 }}>当前电站</Text>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="待处理"
value={1}
suffix="单"
prefix={<ClockCircleOutlined style={{ color: '#faad14', fontSize: 24 }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }}
/>
<Text type="secondary" style={{ fontSize: 12 }}>PENDING</Text>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="已派发"
value={1}
suffix="单"
prefix={<ControlOutlined style={{ color: '#1890ff', fontSize: 24 }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }}
/>
<Text type="secondary" style={{ fontSize: 12 }}>DISPATCHED</Text>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="处理中"
value={1}
suffix="单"
prefix={<BarChartOutlined style={{ color: '#2f54eb', fontSize: 24 }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#2f54eb' }}
/>
<Text type="secondary" style={{ fontSize: 12 }}>PROCESSING</Text>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="挂起"
value={0}
suffix="单"
prefix={<PauseOutlined style={{ color: '#faad14', fontSize: 24 }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }}
/>
<Text type="secondary" style={{ fontSize: 12 }}>SUSPENDED</Text>
</Card>
</Col>
<Col span={4}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="今日新增"
value={0}
suffix="单"
prefix={<RiseOutlined style={{ color: '#52c41a', fontSize: 24 }} />}
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }}
/>
<Text type="secondary" style={{ fontSize: 12 }}>逾期 0 单</Text>
</Card>
</Col>
</Row>
{/* 工单列表 */}
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 20 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}>
<div>
<Typography.Title level={5} style={{ margin: 0, color: "#0837A8" }}>工单列表</Typography.Title>
<Text type="secondary" style={{ fontSize: 12 }}>工单状态变化会写入流转记录和事件中心</Text>
</div>
<Space>
<Select placeholder="优先级" style={{ width: 120 }} allowClear>
<Option value="low">低</Option>
<Option value="medium">中</Option>
<Option value="high">高</Option>
</Select>
<Select placeholder="来源" style={{ width: 120 }} allowClear>
<Option value="manual">人工创建</Option>
<Option value="alarm">告警</Option>
</Select>
<Input placeholder="设备编码" style={{ width: 150 }} />
</Space>
</div>
<Table
rowKey="id"
columns={columns}
dataSource={workOrderData}
pagination={false}
scroll={{ x: 'max-content' }}
size="middle"
/>
</Card>
{/* 底部图表区域:降低卡片高度 */}
<Row gutter={16}>
<Col span={8}>
<Card
bordered={false}
style={{ borderRadius: 8, height: 280 }}
title="工单状态分布"
>
<Pie
data={pieData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#faad14']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
interactions={[{ type: 'pie-legend-active' }, { type: 'element-active' }]}
height={200}
{/* 左侧工单列表 */}
<Col span={14}>
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 20 }} title="工单列表(共 147 条)">
<Table
rowKey="id"
columns={columns}
dataSource={workOrderList}
pagination={{ pageSize: 15, showSizeChanger: true, showTotal: (total) => `共 ${total} 条` }}
scroll={{ x: 'max-content' }}
rowClassName={(record) => record.id === selectedOrder?.id ? 'selected-row' : ''}
onRow={(record) => ({ onClick: () => setSelectedOrder(record) })}
/>
<style>{`
.selected-row { background-color: #e6f7ff !important; }
`}</style>
</Card>
{/* 工单状态分布 + 任务排班 */}
<Row gutter={16}>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="工单状态分布">
<Pie
data={pieData}
angleField="value"
colorField="type"
color={['#1890ff', '#2f54eb', '#52c41a', '#faad14']}
radius={0.8}
innerRadius={0.6}
height={180}
label={{
formatter: (datum) => `${datum.value} (${((datum.value / 147) * 100).toFixed(2)}%)`
}}
interactions={[{ type: 'pie-legend-active' }]}
/>
<div style={{ textAlign: 'center', marginTop: -120 }}>
<div style={{ fontSize: 16, fontWeight: 600 }}>总数</div>
<div style={{ fontSize: 24, fontWeight: 700 }}>147</div>
</div>
</Card>
</Col>
<Col span={16}>
<Card bordered={false} style={{ borderRadius: 8 }} title={<div style={{ display: 'flex', justifyContent: 'space-between' }}><span>任务排班 / 日历视图</span><Button type="link">更多 </Button></div>}>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16 }}>
<Button type="text" icon={<ArrowRightOutlined style={{ transform: 'rotate(180deg)' }} />} />
<span style={{ margin: '0 16px' }}>2025-05-24 (今天)</span>
<Button type="text" icon={<ArrowRightOutlined />} />
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{scheduleData.map((item, idx) => (
<div key={idx} style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<div style={{ width: 60, textAlign: 'right' }}>{item.handler}</div>
<div style={{ flex: 1, display: 'flex', gap: 16, height: 40, alignItems: 'center', position: 'relative' }}>
<div style={{ position: 'absolute', left: 0, right: 0, height: 1, background: '#e8e8e8', zIndex: 0 }} />
{item.tasks.map((task, i) => (
<div key={i} style={{
background: task.type === 'alarm' ? '#e6ffed' : task.type === 'inspect' ? '#e6f7ff' : task.type === 'clean' ? '#f9f0ff' : '#fff7e6',
border: '1px solid #d9d9d9',
borderRadius: 4,
padding: '4px 8px',
fontSize: 12,
zIndex: 1
}}>
<div>{task.title}</div>
<div style={{ color: '#666' }}>{task.time}</div>
</div>
))}
</div>
</div>
))}
</div>
</Card>
</Col>
</Row>
</Col>
<Col span={8}>
<Card
bordered={false}
style={{ borderRadius: 8, height: 280 }}
title="工单优先级结构"
>
<Bar
data={barData}
xField="priority"
yField="count"
color="#1890ff"
barWidthRatio={0.5}
label={{ position: 'middle', style: { fill: '#fff' } }}
xAxis={{ label: { autoRotate: false } }}
legend={false}
height={200}
/>
</Card>
</Col>
<Col span={8}>
<Card
bordered={false}
style={{ borderRadius: 8, height: 280 }}
title="闭环说明"
>
<Space wrap style={{ marginBottom: 16 }}>
<Tag color="blue">告警转工单</Tag>
<Tag color="blue">流转记录</Tag>
<Tag color="blue">事件中心</Tag>
<Tag color="blue">WebSocket刷新</Tag>
</Space>
<div style={{ height: 140, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Empty description="流程说明区域" />
{/* 右侧工单详情面板 */}
<Col span={10}>
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title={
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<Title level={5} style={{ margin: 0 }}>{selectedOrder?.title}</Title>
<Tag color="red" size="small">高优先级</Tag>
</div>
<Text type="secondary">工单编号: {selectedOrder?.id}</Text>
</div>
}>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={12}><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>来源:</span><span>{selectedOrder?.source}</span></div></Col>
<Col span={12}><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>工单类型:</span><span>{selectedOrder?.type}</span></div></Col>
<Col span={12}><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>负责人:</span><span>{selectedOrder?.handler}</span></div></Col>
<Col span={12}><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>协同人员:</span><span>无人机A01 / 张运维</span></div></Col>
<Col span={12}><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>计划时间:</span><span>2025-05-24 13:30 ~ 15:00</span></div></Col>
<Col span={12}><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>关联区域:</span><span>B-12</span></div></Col>
<Col span={12}><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>关联设备:</span><span>UAV-A01</span></div></Col>
<Col span={12}><div style={{ display: 'flex', justifyContent: 'space-between' }}><span>当前状态:</span><Tag color="blue">执行中</Tag></div></Col>
</Row>
<div style={{ marginBottom: 16 }}>
<div style={{ fontSize: 14, fontWeight: 500, marginBottom: 8 }}>任务描述</div>
<div style={{ fontSize: 13, color: '#666', background: '#fafafa', padding: 12, borderRadius: 4 }}>
{selectedOrder?.description}
</div>
</div>
{/* 流程步骤 */}
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24, padding: '0 20px' }}>
{['已创建', '已派发', '执行中', '已完成'].map((step, idx) => (
<div key={idx} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<div style={{
width: 24, height: 24, borderRadius: '50%', background: idx < 3 ? '#1890ff' : '#d9d9d9',
display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff', fontSize: 12
}}>
{idx + 1}
</div>
<div style={{ fontSize: 12, marginTop: 4 }}>{step}</div>
</div>
))}
<div style={{ position: 'absolute', width: 'calc(100% - 120px)', height: 2, background: '#e8e8e8', left: 60, top: 100, zIndex: 0 }} />
</div>
{/* 操作按钮 */}
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
<Button type="primary">派发文单</Button>
<Button>转派</Button>
<Button>挂起</Button>
<Button type="primary" style={{ background: '#52c41a', borderColor: '#52c41a' }}>完成工单</Button>
</div>
</Card>
{/* AI建议与关联信息 */}
<Card bordered={false} style={{ borderRadius: 8 }} title="AI建议与关联信息">
<div style={{ display: 'flex', gap: 16, marginBottom: 16 }}>
<div style={{ flex: 1, background: '#f0f5ff', padding: 12, borderRadius: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 8 }}>
<div style={{ width: 32, height: 32, borderRadius: 4, background: '#e6f7ff', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#1890ff' }}>
<CloudOutlined />
</div>
<div style={{ fontSize: 13, fontWeight: 500 }}>建议携带红外热像设备</div>
</div>
</div>
<div style={{ flex: 1, background: '#f6ffed', padding: 12, borderRadius: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 8 }}>
<div style={{ width: 32, height: 32, borderRadius: 4, background: '#e6ffed', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#52c41a' }}>
<BranchesOutlined />
</div>
<div style={{ fontSize: 13, fontWeight: 500 }}>优先复检组件 B-12-03 / B-12-05</div>
</div>
</div>
<div style={{ flex: 1, background: '#fff7e6', padding: 12, borderRadius: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 8 }}>
<div style={{ width: 32, height: 32, borderRadius: 4, background: '#fff7e6', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fa8c16' }}>
<ThunderboltOutlined />
</div>
<div style={{ fontSize: 13, fontWeight: 500 }}>预计影响发电 2.1%</div>
</div>
</div>
</div>
<Row gutter={16}>
<Col span={12}>
<div style={{ fontSize: 14, fontWeight: 500, marginBottom: 8 }}>关联告警趋势(近7天)</div>
<Line
data={alarmTrendData}
xField="date"
yField="count"
color="#1890ff"
point={{ size: 4 }}
height={120}
legend={false}
smooth
/>
</Col>
<Col span={12}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8 }}>
<span style={{ fontSize: 14, fontWeight: 500 }}>关联告警列表(近3条)</span>
<Button type="link" size="small">查看全部 </Button>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{alarmList.map((alarm, idx) => (
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '4px 8px', background: '#fafafa', borderRadius: 4 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<div style={{ width: 8, height: 8, borderRadius: '50%', background: idx === 0 ? '#ff4d4f' : idx === 1 ? '#fa8c16' : '#faad14' }} />
<span style={{ fontSize: 13 }}>{alarm.name}</span>
</div>
<span style={{ fontSize: 12, color: '#999' }}>{alarm.time}</span>
</div>
))}
</div>
</Col>
</Row>
</Card>
</Col>
</Row>
@@ -430,153 +464,49 @@ const WorkOrderPage = () => {
open={drawerVisible}
destroyOnClose
>
{currentOrder && (
{selectedOrder && (
<div>
<Title level={5}>基础信息</Title>
<Descriptions column={2} bordered size="small">
<Descriptions.Item label="工单编号">{currentOrder.id}</Descriptions.Item>
<Descriptions.Item label="状态">{statusConfig[currentOrder.status]?.label}</Descriptions.Item>
<Descriptions.Item label="标题">{currentOrder.title}</Descriptions.Item>
<Descriptions column={2} bordered size="small" title="基础信息">
<Descriptions.Item label="工单编号">{selectedOrder.id}</Descriptions.Item>
<Descriptions.Item label="状态">{statusConfig[selectedOrder.status]?.label}</Descriptions.Item>
<Descriptions.Item label="标题">{selectedOrder.title}</Descriptions.Item>
<Descriptions.Item label="优先级">
<Tag color={priorityConfig[currentOrder.priority]?.color}>
{priorityConfig[currentOrder.priority]?.label}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="来源">{currentOrder.source}</Descriptions.Item>
<Descriptions.Item label="设备">{currentOrder.device}</Descriptions.Item>
<Descriptions.Item label="处理人">{currentOrder.handler || '—'}</Descriptions.Item>
<Descriptions.Item label="创建时间">{currentOrder.createTime}</Descriptions.Item>
<Descriptions.Item label="描述" span={2}>
{currentOrder.desc || '—'}
<Tag color={priorityConfig[selectedOrder.priority]?.color}>{priorityConfig[selectedOrder.priority]?.label}</Tag>
</Descriptions.Item>
<Descriptions.Item label="来源">{selectedOrder.source}</Descriptions.Item>
<Descriptions.Item label="类型">{selectedOrder.type}</Descriptions.Item>
<Descriptions.Item label="负责人">{selectedOrder.handler || '—'}</Descriptions.Item>
<Descriptions.Item label="截止时间">{selectedOrder.deadline}</Descriptions.Item>
<Descriptions.Item label="描述" span={2}>{selectedOrder.description || '—'}</Descriptions.Item>
</Descriptions>
<Divider />
<Title level={5}>关联告警</Title>
<Descriptions column={2} bordered size="small">
<Descriptions.Item label="告警编号">-</Descriptions.Item>
<Descriptions.Item label="告警状态">-</Descriptions.Item>
<Descriptions.Item label="告警名称" span={2}>-</Descriptions.Item>
</Descriptions>
<Divider />
<Title level={5}>流转时间线</Title>
<Timeline mode="left">
<Timeline.Item label={currentOrder.createTime}>
创建 --&gt; 已派发
<div style={{ color: '#666', fontSize: 12, marginTop: 4 }}>
阶段4B演示工单初始化
<br />
system
</div>
</Timeline.Item>
</Timeline>
<Divider />
<Title level={5}>评论</Title>
<Table
columns={[
{ title: '时间', dataIndex: 'time', width: 150 },
{ title: '操作人', dataIndex: 'operator', width: 100 },
{ title: '内容', dataIndex: 'content' }
]}
dataSource={[]}
pagination={false}
size="small"
locale={{ emptyText: '暂无评论' }}
/>
<Divider />
<Title level={5}>附件元数据</Title>
<Table
columns={[
{ title: '文件名', dataIndex: 'name' },
{ title: '类型', dataIndex: 'type', width: 100 },
{ title: '上传人', dataIndex: 'uploader', width: 100 },
{ title: '时间', dataIndex: 'time', width: 150 }
]}
dataSource={[]}
pagination={false}
size="small"
locale={{ emptyText: '暂无附件' }}
/>
</div>
)}
</Drawer>
{/* 👇 编辑工单弹窗 */}
{/* 编辑工单弹窗 */}
<Modal
title="编辑工单"
open={editModalVisible}
onCancel={() => setEditModalVisible(false)}
onOk={handleEditSubmit}
onOk={() => { editForm.validateFields().then(values => { message.success('工单保存成功'); setEditModalVisible(false); }); }}
okText="保存"
cancelText="取消"
width={600}
destroyOnClose
>
<Form form={editForm} layout="vertical" initialValues={{ priority: 'low', source: '人工创建', type: '巡检' }}>
<Form.Item label="标题" name="title" rules={[{ required: true, message: '请输入标题' }]}>
<Input />
</Form.Item>
<Form.Item label="标题" name="title" rules={[{ required: true, message: '请输入标题' }]}><Input /></Form.Item>
<Row gutter={16}>
<Col span={12}>
<Form.Item label="来源" name="source">
<Select>
<Option value="人工创建">人工创建</Option>
<Option value="告警">告警</Option>
</Select>
</Form.Item>
</Col>
<Col span={12}>
<Form.Item label="类型" name="type">
<Select>
<Option value="巡检">巡检</Option>
<Option value="故障排查">故障排查</Option>
<Option value="维护">维护</Option>
</Select>
</Form.Item>
</Col>
<Col span={12}><Form.Item label="来源" name="source"><Select><Option value="人工创建">人工创建</Option><Option value="告警">告警</Option><Option value="AI诊断">AI诊断</Option></Select></Form.Item></Col>
<Col span={12}><Form.Item label="类型" name="type"><Select><Option value="巡检">巡检</Option><Option value="故障排查">故障排查</Option><Option value="维护">维护</Option><Option value="清洗">清洗</Option></Select></Form.Item></Col>
</Row>
<Row gutter={16}>
<Col span={12}>
<Form.Item label="优先级" name="priority">
<Select>
<Option value="low">低</Option>
<Option value="medium">中</Option>
<Option value="high">高</Option>
</Select>
</Form.Item>
</Col>
<Col span={12}>
<Form.Item label="处理人" name="handler">
<Input />
</Form.Item>
</Col>
<Col span={12}><Form.Item label="优先级" name="priority"><Select><Option value="low">低</Option><Option value="medium">中</Option><Option value="high">高</Option></Select></Form.Item></Col>
<Col span={12}><Form.Item label="负责人" name="handler"><Input /></Form.Item></Col>
</Row>
<Row gutter={16}>
<Col span={12}>
<Form.Item label="设备编码" name="deviceCode">
<Input disabled />
</Form.Item>
</Col>
<Col span={12}>
<Form.Item label="设备名称" name="deviceName">
<Input disabled />
</Form.Item>
</Col>
</Row>
<Form.Item label="描述" name="desc">
<Input.TextArea rows={4} />
</Form.Item>
<Form.Item label="描述" name="description"><Input.TextArea rows={4} /></Form.Item>
</Form>
</Modal>
</div>
);
};
export default WorkOrderPage;
}