告警详情和 总览界面 修改 布局调整

This commit is contained in:
mmc
2026-04-28 11:01:54 +08:00
parent f5f27b7668
commit c08278190a
14 changed files with 2207 additions and 868 deletions

View File

@@ -5,7 +5,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="./src/assets/logo.png" /> <link rel="icon" type="image/x-icon" href="./src/assets/logo.png" />
<title>机器人智慧服务系统</title> <title>光伏电站智能监控与运维系统</title>
</head> </head>
<body> <body>

View File

@@ -1,5 +1,5 @@
{ {
"name": "机器人智慧服务系统", "name": "光伏电站智能监控与运维系统",
"description": "提供设备管理、视频监控、状态预警、警报处理及视频下载功能的一站式机器人智能管理平台。", "description": "提供设备管理、视频监控、状态预警、警报处理及视频下载功能的一站式机器人智能管理平台。",
"requestFramePermissions": [], "requestFramePermissions": [],
"majorCapabilities": [] "majorCapabilities": []

980
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,7 @@
"lint": "tsc --noEmit" "lint": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@ant-design/charts": "^2.6.7",
"@ant-design/icons": "^6.1.1", "@ant-design/icons": "^6.1.1",
"@reduxjs/toolkit": "^2.11.2", "@reduxjs/toolkit": "^2.11.2",
"@tailwindcss/vite": "^4.1.14", "@tailwindcss/vite": "^4.1.14",

View File

@@ -1,36 +1,20 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Outlet, useNavigate, useLocation } from 'react-router-dom'; import { Outlet, useNavigate, useLocation } from 'react-router-dom';
import { import {
Layout, Layout, Menu, Button, Space, ConfigProvider, theme,
Menu, Breadcrumb, Badge, message
Button,
Avatar,
Space,
ConfigProvider,
theme,
Breadcrumb,
Badge,
message
} from 'antd'; } from 'antd';
import { import {
DashboardOutlined, DashboardOutlined, ExperimentOutlined, VideoCameraOutlined,
ExperimentOutlined, BellOutlined, DownloadOutlined, UserOutlined, LogoutOutlined,
VideoCameraOutlined, MenuUnfoldOutlined, MenuFoldOutlined, TeamOutlined, MenuOutlined
BellOutlined,
DownloadOutlined,
UserOutlined,
LogoutOutlined,
MenuUnfoldOutlined,
MenuFoldOutlined,
GlobalOutlined,
TeamOutlined,
MenuOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import logo from '../assets/logo.png'; import logo from '../assets/logo.png';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { RootState, useAppDispatch } from '../store'; import { RootState, useAppDispatch } from '../store';
import { logout } from '../store/userSlice'; import { logout } from '../store/userSlice';
import { getMenuList } from '../api/mune'; import { getMenuList } from '../api/mune';
const { Header, Sider, Content } = Layout; const { Header, Sider, Content } = Layout;
export default function AppLayout() { export default function AppLayout() {
@@ -41,6 +25,7 @@ export default function AppLayout() {
const location = useLocation(); const location = useLocation();
const { userInfo } = useSelector((state: RootState) => state.user); const { userInfo } = useSelector((state: RootState) => state.user);
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const getMenu = () => { const getMenu = () => {
getMenuList().then(res => { getMenuList().then(res => {
if (res.code == 200) { if (res.code == 200) {
@@ -48,12 +33,6 @@ export default function AppLayout() {
} else { } else {
message.error("获取菜单失败:" + res.msg) message.error("获取菜单失败:" + res.msg)
} }
console.log("菜单列表:", res);
//if (res.code == 200) {
// setMenuList(res.data)
//} else {
// //message.error("获取菜单失败:"+res.msg)
//}
}) })
} }
@@ -66,105 +45,59 @@ export default function AppLayout() {
const handleLogout = async () => { const handleLogout = async () => {
await dispatch(logout()); await dispatch(logout());
navigate('/login', { replace: true }); navigate('/login', { replace: true });
}; };
const menuItems = [ const menuItems = [
{ key: '/', icon: <DashboardOutlined />, label: '概览控制台', roles: ['admin', 'operator', 'viewer'] }, { key: '/', icon: <DashboardOutlined />, label: '总览首页', roles: ['admin', 'operator', 'viewer'] },
{ key: '/devices', icon: <ExperimentOutlined />, label: '设备管理', roles: ['admin', 'operator'] }, { key: '/devices', icon: <ExperimentOutlined />, label: '设备管理', roles: ['admin', 'operator'] },
{ key: '/video', icon: <VideoCameraOutlined />, label: '在线视频', roles: ['admin', 'operator', 'viewer'] }, { key: '/video', icon: <VideoCameraOutlined />, label: '在线视频', roles: ['admin', 'operator', 'viewer'] },
{ key: '/alerts', icon: <BellOutlined />, label: '警报中心', roles: ['admin', 'operator'] }, { key: '/alerts', icon: <BellOutlined />, label: '告警中心', roles: ['admin', 'operator'] },
{ key: '/downloads', icon: <DownloadOutlined />, label: '视频下载', roles: ['admin', 'operator'] }, { key: '/downloads', icon: <DownloadOutlined />, label: '视频下载', roles: ['admin', 'operator'] },
{ key: '/serialNumGenerate', icon: <UserOutlined />, label: '序列号生成', roles: ['admin'] }, { key: '/serialNumGenerate', icon: <UserOutlined />, label: '序列号生成', roles: ['admin'] },
{ key: '/users', icon: <TeamOutlined />, label: '用户管理', roles: ['admin'] }, { key: '/users', icon: <TeamOutlined />, label: '用户管理', roles: ['admin'] },
{ key: '/roles', icon: <UserOutlined />, label: '角色管理', roles: ['admin'] }, { key: '/roles', icon: <UserOutlined />, label: '角色管理', roles: ['admin'] },
{ key: '/menuList', icon: <MenuOutlined />, label: '菜单管理', roles: ['admin'] },
{ { key: '/organization', icon: <MenuOutlined />, label: '组织管理', roles: ['admin'] },
key: '/menuList', { key: '/station', icon: <MenuOutlined />, label: '场站管理', roles: ['admin'] }
icon: <MenuOutlined />,
label: '菜单管理',
roles: ['admin']
},
{
key: '/organization',
icon: <MenuOutlined />,
label: '组织管理',
roles: ['admin']
},
{
key: '/station',
icon: <MenuOutlined />,
label: '场站管理',
roles: ['admin']
}
]; ];
const filteredMenu = menuItems const filteredMenu = menuItems;
//.filter(item => item.roles.includes(userInfo?.role)); const currentPathLabel = menuItems.find(i => i.key === location.pathname)?.label || '总览首页';
const currentPathLabel = menuItems.find(i => i.key === location.pathname)?.label || '概览控制台';
return ( return (
<ConfigProvider <ConfigProvider
theme={{ theme={{
algorithm: theme.defaultAlgorithm, algorithm: theme.defaultAlgorithm,
token: { token: { colorPrimary: '#1890ff', borderRadius: 2 },
colorPrimary: '#1890ff',
borderRadius: 2,
},
components: { components: {
Layout: { Layout: { headerBg: '#fff', siderBg: '#001529' },
headerBg: '#fff', Menu: { darkItemBg: '#001529', darkItemSelectedBg: '#1890ff' }
siderBg: '#001529',
},
Menu: {
darkItemBg: '#001529',
darkItemSelectedBg: '#1890ff',
}
} }
}} }}
> >
<Layout style={{ maxHeight: '100vh' }}>
<Layout style={{ minHeight: '100vh' }}> {/* 顶部通栏 */}
<Sider trigger={null} collapsible collapsed={collapsed} width={220} theme="dark"> <Header className=" px-6 flex items-center justify-between shadow-sm border-b border-gray-100 h-0 shrink-0 z-10" style={{
background: '#0837a8',
color: '#fff',
height: "50px"
}}>
<div className="h-16 flex items-center justify-center border-b border-white/10 overflow-hidden"> <div className="h-16 flex items-center justify-center border-b border-white/10 overflow-hidden">
<Space size="small" className="px-2"> <Space size="small" className="px-2">
<img src={logo} alt="Logo" style={{ width: "24px", height: "24px" }} /> <img src={logo} alt="Logo" style={{ width: "24px", height: "24px" }} />
{!collapsed && <span className="text-white font-bold text-lg whitespace-nowrap">机器人智慧服务系统</span>} {!collapsed && (
<span className="text-white font-bold text-lg whitespace-nowrap">
光伏电站智能监控与运维系统
</span>
)}
</Space> </Space>
</div> </div>
<Menu
theme="dark"
mode="inline"
selectedKeys={[location.pathname]}
items={filteredMenu}
onClick={({ key }) => navigate(key)}
/>
</Sider>
<Layout>
<Header className="px-6 flex items-center justify-between shadow-sm border-b border-gray-100 h-16 bg-white shrink-0 z-10">
<div className="flex items-center gap-4">
<Button
type="text"
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
onClick={() => setCollapsed(!collapsed)}
style={{ fontSize: '16px', width: 40, height: 40 }}
/>
<Breadcrumb
items={[
{ title: '系统首页' },
{ title: currentPathLabel }
]}
/>
</div>
<div className="flex items-center gap-6"> <div className="flex items-center gap-6">
<div className="flex items-center gap-3 pr-6 border-r border-gray-100"> <div className="flex items-center gap-3 pr-6 border-r border-gray-100">
<span className="text-gray-400 font-mono text-[13px]">{time}</span> <span className="text-gray-400 font-mono text-[13px]">{time}</span>
<Badge status="success" /> <Badge status="success" />
<span className="text-gray-800 font-medium">{userInfo?.username}</span> <span className="text-white font-medium">{userInfo?.username}</span>
</div> </div>
<Button <Button
type="text" type="text"
@@ -177,7 +110,38 @@ export default function AppLayout() {
</Button> </Button>
</div> </div>
</Header> </Header>
<Content className="p-4 overflow-y-auto bg-[#f4f7f9] min-h-0">
<Layout>
{/* 左侧:菜单 + 下部区域 */}
<Sider
trigger={null}
collapsible
collapsed={collapsed}
width={220}
theme="light"
style={{
overflow: 'auto', background: '#ffffff',
borderRight: '1px solid #e5e7eb',
}}
>
<Menu
theme="light"
mode="inline"
selectedKeys={[location.pathname]}
items={filteredMenu}
onClick={({ key }) => navigate(key)}
/>
{/* 左侧下方固定区域(你可以放任何内容) */}
<div className="p-3 text-white text-xs opacity-70 text-center mt-4">
{!collapsed && '快捷操作面板'}
</div>
</Sider>
{/* 右侧:主内容 */}
<Content className=" overflow-y-auto bg-[#f4f7f9] min-h-0">
<Outlet /> <Outlet />
</Content> </Content>
</Layout> </Layout>

View File

@@ -1,4 +1,4 @@
import React from 'react'; import React, { useState } from 'react';
import { import {
Table, Table,
Tag, Tag,
@@ -9,142 +9,314 @@ import {
Card, Card,
Typography, Typography,
Space, Space,
Statistic Statistic,
Select,
DatePicker,
List,
} from 'antd'; } from 'antd';
import { import {
BellOutlined, BellOutlined,
AlertOutlined, AlertOutlined,
InfoCircleOutlined, SyncOutlined,
SearchOutlined,
FilterOutlined,
CheckCircleOutlined, CheckCircleOutlined,
SyncOutlined ClockCircleOutlined,
RiseOutlined,
FallOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import { ALERTS } from '../constants'; import { ALERTS } from '../constants';
const { Text, Title } = Typography; const { Text, Title } = Typography;
const { RangePicker } = DatePicker;
export default function Alerts() { export default function Alerts() {
const columns = [ const [selectedAlert, setSelectedAlert] = useState<any>(null);
{ const AntdCard = Card as any;
title: '级别',
dataIndex: 'type',
key: 'type',
render: (type: string) => {
const config = {
critical: { color: 'error', text: '紧急', icon: <AlertOutlined /> },
warning: { color: 'warning', text: '警告', icon: <BellOutlined /> },
info: { color: 'processing', text: '提示', icon: <InfoCircleOutlined /> },
}[type] || { color: 'default', text: '其他', icon: <InfoCircleOutlined /> };
return ( // 模拟告警数据(和参考图一致)
<Tag color={config.color} icon={config.icon} bordered={false} style={{ fontWeight: 'bold' }}> const alertList = [
{config.text} {
</Tag> id: 'AL20250525001',
); content: '逆变器停机',
}, device: '逆变器 12 (组串式)',
width: 100, level: '严重',
time: '2025-05-25 09:18:32',
duration: '2小时18分',
status: '处理中',
handler: '张运维'
}, },
{ {
title: '设备来源', id: 'AL20250525002',
key: 'device', content: '发电量下降 > 15%',
render: (record: any) => ( device: '汇流箱 05',
<Space direction="vertical" size={0}> level: '重要',
<Text strong style={{ fontSize: 13 }}>{record.deviceName}</Text> time: '2025-05-25 08:46:11',
<Text type="secondary" style={{ fontSize: 10, fontFamily: 'monospace' }}>{record.deviceId}</Text> duration: '3小时50分',
</Space> status: '处理中',
), handler: '李工程师'
width: 180,
}, },
{ {
title: '内容描述', id: 'AL20250525003',
dataIndex: 'message', content: '逆变器温度过高',
key: 'message', device: '逆变器 07 (组串式)',
render: (text: string) => <Text ellipsis style={{ maxWidth: 300 }}>{text}</Text>, level: '重要',
time: '2025-05-25 07:32:45',
duration: '4小时24分',
status: '待处理',
handler: '-'
}, },
{ {
title: '发生时间', id: 'AL20250525004',
dataIndex: 'time', content: '通信中断',
key: 'time', device: '气象站 01',
render: (time: string) => <Text type="secondary" style={{ fontFamily: 'monospace', fontSize: 11 }}>{time}</Text>, level: '一般',
width: 160, time: '2025-05-25 06:51:20',
duration: '5小时05分',
status: '待处理',
handler: '王运维'
}, },
{ {
title: '状态', id: 'AL20250525005',
content: '数据异常',
device: '电表 01 (并网点)',
level: '提示',
time: '2025-05-25 06:20:18',
duration: '3小时36分',
status: '已关闭',
handler: '赵工程师'
},
];
const columns = [
{ title: '告警编号', dataIndex: 'id', key: 'id', width: 120 },
{ title: '告警内容', dataIndex: 'content', key: 'content' },
{ title: '来源设备', dataIndex: 'device', key: 'device', width: 140 },
{
title: '告警级别',
dataIndex: 'level',
key: 'level',
width: 80,
render: (level: string) => {
const colorMap: Record<string, string> = {
'严重': 'red',
'重要': 'orange',
'一般': 'gold',
'提示': 'blue'
};
return <Tag color={colorMap[level]}>{level}</Tag>;
}
},
{ title: '发生时间', dataIndex: 'time', key: 'time', width: 160 },
{ title: '持续时长', dataIndex: 'duration', key: 'duration', width: 100 },
{
title: '处理状态',
dataIndex: 'status',
key: 'status', key: 'status',
render: (record: any) => ( width: 100,
record.handled ? render: (status: string) => {
<Text type="success" italic style={{ fontSize: 11 }}><CheckCircleOutlined /> 已归档</Text> : const colorMap: Record<string, string> = {
<Text type="warning" strong style={{ fontSize: 11 }}><SyncOutlined spin /> 待处理</Text> '处理中': 'blue',
), '待处理': 'orange',
width: 120, '已关闭': 'green'
};
return <Tag color={colorMap[status]}>{status}</Tag>;
}
}, },
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 80 },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
align: 'right' as const, width: 60,
render: () => ( render: () => <Button type="link" size="small">查看</Button>
<Space>
<Button type="primary" size="small" style={{ borderRadius: 2 }}>处理</Button>
<Button type="default" size="small" style={{ borderRadius: 2 }}>忽略</Button>
</Space>
),
width: 140,
}, },
]; ];
const summary = [ // 顶部统计数据
{ label: '严重故障', count: ALERTS.filter(a => a.type === 'critical').length, color: '#f5222d', icon: <AlertOutlined />, bgColor: '#fff1f0', borderColor: '#ffa39e' }, const stats = [
{ label: '异常警告', count: ALERTS.filter(a => a.type === 'warning').length, color: '#faad14', icon: <BellOutlined />, bgColor: '#fffbe6', borderColor: '#ffe58f' }, { title: '今日告警总数', value: 36, suffix: '', change: '+28.6%', up: true, extra: '昨日 28', icon: <BellOutlined style={{ color: '#ff4d4f' }} /> },
{ label: '状态提示', count: ALERTS.filter(a => a.type === 'info').length, color: '#1890ff', icon: <InfoCircleOutlined />, bgColor: '#e6f7ff', borderColor: '#91d5ff' }, { title: '严重告警', value: 8, suffix: '', change: '+33.3%', up: true, extra: '昨日 6', icon: <AlertOutlined style={{ color: '#ff4d4f' }} /> },
{ title: '处理中', value: 12, suffix: '', change: '+20.0%', up: true, extra: '昨日 10', icon: <SyncOutlined style={{ color: '#fa8c16' }} /> },
{ title: '已关闭', value: 16, suffix: '', change: '+45.5%', up: true, extra: '昨日 11', icon: <CheckCircleOutlined style={{ color: '#52c41a' }} /> },
{ title: '平均响应时长', value: '18分32秒', suffix: '', change: '-12.6%', up: false, extra: '昨日 21分12秒', icon: <ClockCircleOutlined style={{ color: '#1890ff' }} /> },
]; ];
return ( return (
<div className="space-y-4"> <div style={{ padding: '16px', background: '#f4f7f9', minHeight: '100%' }}>
<div className="flex items-center justify-between"> <p className="text-lg font-semibold text-[#000] mb-2">
<Title level={5} style={{ margin: 0 }}>警报中心: 实时检索</Title> 告警中心
<Space> </p>
<Input {/* 顶部筛选栏 */}
prefix={<SearchOutlined style={{ color: 'rgba(0,0,0,0.25)' }} />} <AntdCard size="small" style={{ borderRadius: 8, marginBottom: 16 }}>
placeholder="搜索设备ID或警报内容..." <Row gutter={[16, 16]} align="middle">
style={{ width: 250, borderRadius: 2 }} <Col span={4}>
/> <Select placeholder="告警级别" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }, { label: '严重', value: 'critical' }, { label: '重要', value: 'important' }, { label: '一般', value: 'normal' }, { label: '提示', value: 'info' }]} />
<Button icon={<FilterOutlined />} style={{ borderRadius: 2 }}> </Col>
高级过滤 <Col span={4}>
</Button> <Select placeholder="告警类型" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }]} />
</Space> </Col>
</div> <Col span={4}>
<Select placeholder="设备类型" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }]} />
</Col>
<Col span={6}>
<RangePicker defaultValue={[null, null]} style={{ width: '100%' }} />
</Col>
<Col span={4}>
<Select placeholder="处理状态" defaultValue="全部" style={{ width: '100%' }} options={[{ label: '全部', value: 'all' }, { label: '处理中', value: 'processing' }, { label: '已关闭', value: 'closed' }]} />
</Col>
<Col span={24} style={{ display: 'flex', alignItems: 'center', gap: 8, marginTop: 8 }}>
<Input placeholder="请输入告警编号内容" style={{ width: 200 }} />
<Button>重置</Button>
<Button type="primary">查询</Button>
</Col>
</Row>
</AntdCard>
<Row gutter={16}> {/* 统计卡片 */}
{summary.map((item) => ( <Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
<Col span={8} key={item.label}> {stats.map((stat, idx) => (
<Card <Col xs={24} sm={12} md={8} lg={4} key={idx}>
size="small" <AntdCard size="small" style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}>
style={{
backgroundColor: item.bgColor,
borderColor: item.borderColor,
borderRadius: 4
}}
>
<Statistic <Statistic
title={<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase', opacity: 0.7 }}>{item.label}</Text>} title={<span style={{ fontSize: 13, color: '#666' }}>{stat.title}</span>}
value={item.count} value={stat.value}
valueStyle={{ color: item.color, fontWeight: 900, fontSize: 24 }} valueStyle={{ color: '#1f2329', fontWeight: 600, fontSize: 20 }}
prefix={React.cloneElement(item.icon, { style: { opacity: 0.4 } })} prefix={stat.icon}
suffix={stat.suffix}
/> />
</Card> <div style={{ marginTop: 4, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<Text type="secondary" style={{ fontSize: 12 }}>{stat.extra}</Text>
<Text style={{ fontSize: 12, color: stat.up ? '#ff4d4f' : '#52c41a' }}>
{stat.change} {stat.up ? <RiseOutlined /> : <FallOutlined />}
</Text>
</div>
</AntdCard>
</Col> </Col>
))} ))}
</Row> </Row>
<Card styles={{ body: { padding: 0 } }} className="overflow-hidden"> <Row gutter={[16, 16]}>
{/* 左侧主内容区 */}
<Col xs={24} lg={18}>
{/* 告警列表 */}
<AntdCard size="small" title={
<div style={{ display: 'flex', gap: 4, fontSize: 14, fontWeight: 600 }}>
<span style={{ color: '#165DFF' }}>告警列表</span>
<span style={{ color: '#1f2937' }}>(共36条)</span>
</div>
} style={{ borderRadius: 8, marginBottom: 16 }}>
<Table <Table
size="small" size="small"
columns={columns} columns={columns}
dataSource={ALERTS.map(a => ({ ...a, key: a.id }))} dataSource={alertList}
pagination={{ pageSize: 12, size: 'small' }} pagination={{ pageSize: 10, total: 36, showSizeChanger: true }}
rowKey="id"
onRow={(record) => ({ onClick: () => setSelectedAlert(record) })}
rowSelection={{ selectedRowKeys: selectedAlert ? [selectedAlert.id] : [], type: 'radio' }}
/> />
</Card> </AntdCard>
{/* 底部图表占位(和参考图结构一致) */}
<Row gutter={[16, 16]}>
<Col xs={24} lg={8}>
<AntdCard size="small" style={{ borderRadius: 8 }}>
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
趋势图占位
</div>
</AntdCard>
</Col>
<Col xs={24} lg={8}>
<AntdCard size="small" style={{ borderRadius: 8 }}>
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
占比图占位
</div>
</AntdCard>
</Col>
<Col xs={24} lg={8}>
<AntdCard size="small" style={{ borderRadius: 8 }}>
<div style={{ height: 150, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
分布图占位
</div>
</AntdCard>
</Col>
</Row>
</Col>
{/* 右侧告警详情面板 */}
<Col xs={24} lg={6}>
<AntdCard size="small" style={{ borderRadius: 8, height: '100%' }}>
{selectedAlert ? (
<div>
<div style={{ marginBottom: 16 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<BellOutlined style={{ color: '#ff4d4f', fontSize: 20 }} />
<Text strong style={{ fontSize: 16 }}>{selectedAlert.content}</Text>
<Tag color="red">{selectedAlert.level}</Tag>
</div>
<Text type="secondary" style={{ fontSize: 12 }}>告警编号 AL20250525001</Text>
</div>
<div style={{ fontSize: 12, color: '#666' }}>
<div>来源设备:{selectedAlert.device}(设备类型:逆变器)</div>
<div>发生时间:{selectedAlert.time} | 持续时长:{selectedAlert.duration}</div>
<div>处理状态:<Tag color="blue">{selectedAlert.status}</Tag> | 负责人:{selectedAlert.handler}</div>
<div>当前处理人:{selectedAlert.handler}({selectedAlert.time.split(' ')[0]} 接收)</div>
<div>告警描述:逆变器因内部故障自动停机,当前无功率输出。</div>
</div>
</div>
<div style={{ marginBottom: 16 }}>
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>根因分析建议</Text>
<List size="small" dataSource={[
'逆变器内部保护触发(IGBT/继电器故障)',
'交流侧电压异常或并网不稳定',
'散热风扇故障导致过温保护'
]} renderItem={(item) => <List.Item style={{ padding: '4px 0', fontSize: 12 }}>{item}</List.Item>} />
<Button type="primary" size="small" style={{ marginTop: 8 }}>AI 诊断分析</Button>
</div>
<div style={{ marginBottom: 16 }}>
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>相关趋势</Text>
<div style={{ height: 100, background: '#f5f7fa', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
趋势图占位
</div>
</div>
<div style={{ marginBottom: 16 }}>
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>推荐处理措施</Text>
<List size="small" dataSource={[
'现场检查逆变器告警记录及指示灯状态',
'检查散热风扇运行及通风条件',
'检查交流侧电压及并网条件',
'如无法恢复,建议联系厂家或更换模块'
]} renderItem={(item) => <List.Item style={{ padding: '4px 0', fontSize: 12 }}>{item}</List.Item>} />
<Button type="primary" size="small" style={{ marginTop: 8 }}>生成工单</Button>
</div>
<div style={{ marginBottom: 16 }}>
<Text strong style={{ fontSize: 13, marginBottom: 8, display: 'block' }}>通知与订阅</Text>
<Space direction="vertical" size="small" style={{ width: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span style={{ fontSize: 12 }}>短信</span>
<span style={{ fontSize: 12, color: '#1890ff' }}>已开启</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span style={{ fontSize: 12 }}>Telegram</span>
<span style={{ fontSize: 12, color: '#1890ff' }}>已开启</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<span style={{ fontSize: 12 }}>邮件</span>
<span style={{ fontSize: 12, color: '#888' }}>未开启</span>
</div>
</Space>
</div>
<Button type="primary" block>标记为已解决</Button>
</div>
) : (
<div style={{ textAlign: 'center', padding: '40px 0', color: '#888' }}>请选择一条告警查看详情</div>
)}
</AntdCard>
</Col>
</Row>
</div> </div>
); );
} }

View File

@@ -173,7 +173,7 @@ export default function Devices() {
</Text> </Text>
<Title level={4} style={{ margin: '4px 0' }}>{selectedDevice.name}</Title> <Title level={4} style={{ margin: '4px 0' }}>{selectedDevice.name}</Title>
<Space> <Space>
<Tag color="blue" bordered={false} style={{ fontSize: 10, fontWeight: 'bold' }}>{selectedDevice.type}</Tag> <Tag color="blue" variant={false} style={{ fontSize: 10, fontWeight: 'bold' }}>{selectedDevice.type}</Tag>
<Text type="secondary" style={{ fontSize: 11, fontFamily: 'monospace' }}>ID: {selectedDevice.id}</Text> <Text type="secondary" style={{ fontSize: 11, fontFamily: 'monospace' }}>ID: {selectedDevice.id}</Text>
</Space> </Space>
</div> </div>
@@ -194,7 +194,7 @@ export default function Devices() {
label: '基本信息', label: '基本信息',
children: ( children: (
<div className="space-y-6 pt-4 pb-4"> <div className="space-y-6 pt-4 pb-4">
<Descriptions column={1} size="small" bordered> <Descriptions column={1} size="small" variant>
<Descriptions.Item label="设备名称">{selectedDevice.name}</Descriptions.Item> <Descriptions.Item label="设备名称">{selectedDevice.name}</Descriptions.Item>
<Descriptions.Item label="设备 ID">{selectedDevice.id}</Descriptions.Item> <Descriptions.Item label="设备 ID">{selectedDevice.id}</Descriptions.Item>
<Descriptions.Item label="设备类型">{selectedDevice.type}</Descriptions.Item> <Descriptions.Item label="设备类型">{selectedDevice.type}</Descriptions.Item>
@@ -221,22 +221,22 @@ export default function Devices() {
<div className="space-y-6 pt-4 pb-4"> <div className="space-y-6 pt-4 pb-4">
<Row gutter={[12, 12]}> <Row gutter={[12, 12]}>
<Col span={12}> <Col span={12}>
<Card size="small" bordered styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}> <Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
<Statistic title={<Space><ClusterOutlined />负载率</Space>} value={selectedDevice.cpu} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace' }} /> <Statistic title={<Space><ClusterOutlined />负载率</Space>} value={selectedDevice.cpu} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace' }} />
</Card> </Card>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Card size="small" bordered styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}> <Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
<Statistic title={<Space><HeatMapOutlined />核心温度</Space>} value={selectedDevice.temp} suffix="°C" valueStyle={{ fontSize: 16, fontFamily: 'monospace', color: '#f5222d' }} /> <Statistic title={<Space><HeatMapOutlined />核心温度</Space>} value={selectedDevice.temp} suffix="°C" valueStyle={{ fontSize: 16, fontFamily: 'monospace', color: '#f5222d' }} />
</Card> </Card>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Card size="small" bordered styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}> <Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
<Statistic title={<Space><ThunderboltOutlined />剩余能量</Space>} value={selectedDevice.battery} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace', color: '#52c41a' }} /> <Statistic title={<Space><ThunderboltOutlined />剩余能量</Space>} value={selectedDevice.battery} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace', color: '#52c41a' }} />
</Card> </Card>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Card size="small" bordered styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}> <Card size="small" variant styles={{ body: { padding: 12 } }} style={{ backgroundColor: '#fafafa' }}>
<Statistic title={<Space><DashboardOutlined />系统健康</Space>} value={98.2} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace' }} /> <Statistic title={<Space><DashboardOutlined />系统健康</Space>} value={98.2} suffix="%" valueStyle={{ fontSize: 16, fontFamily: 'monospace' }} />
</Card> </Card>
</Col> </Col>

View File

@@ -22,6 +22,7 @@ import {
} from '@ant-design/icons'; } from '@ant-design/icons';
import { DEVICES, ALERTS } from '../constants'; import { DEVICES, ALERTS } from '../constants';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { Line, Column } from '@ant-design/charts';
const { Text, Title } = Typography; const { Text, Title } = Typography;
const AntdCard = Card as any; const AntdCard = Card as any;
@@ -29,188 +30,370 @@ const AntdCard = Card as any;
export default function Home() { export default function Home() {
const navigate = useNavigate(); const navigate = useNavigate();
const stats = [ // 顶部统计卡片数据(和参考图完全一致)
{ title: '芯片温度', value: 32.08, icon: <DashboardOutlined />, color: '#ff4d4f', suffix: '℃' }, const topStats = [
{ title: '设备电流', value: 0, icon: <ThunderboltOutlined />, color: '#1677ff', suffix: 'A' }, {
{ title: '设备电压', value: 0, icon: <DotChartOutlined />, color: '#fa8c16', suffix: 'V' }, title: '今日发电量',
{ title: '设备数量', value: DEVICES.length, icon: <RocketOutlined />, color: '#52c41a', suffix: '' }, value: 4752,
{ title: '告警数量', value: ALERTS.filter(a => !a.handled).length, icon: <BellOutlined />, color: '#ff4d4f', suffix: '' }, suffix: 'kWh',
{ title: '上报事件', value: 1, icon: <CloudUploadOutlined />, color: '#52c41a', suffix: '' }, extra: <span style={{ color: '#52c41a', fontSize: 12 }}>日目标 5,000 kWh</span>,
percent: 95,
color: '#52c41a'
},
{
title: '当前功率',
value: 812.6,
suffix: 'kW',
extra: <span style={{ color: '#888', fontSize: 12 }}>装机容量 1,000 kWp</span>,
color: '#1890ff'
},
{
title: 'Performance Ratio(PR)',
value: 82.6,
suffix: '%',
extra: <span style={{ color: '#888', fontSize: 12 }}>昨日 81.3% 环比 ↑1.3%</span>,
color: '#13c2c2'
},
{
title: '系统可用率',
value: 99.35,
suffix: '%',
extra: <span style={{ color: '#888', fontSize: 12 }}>昨日 99.12% 环比 ↑0.23%</span>,
color: '#52c41a'
},
{
title: '告警数量',
value: 8,
extra: <span style={{ color: '#888', fontSize: 12 }}>未处理 5 / 已处理 3</span>,
color: '#ff4d4f'
},
{
title: '节省运维成本',
value: 36540,
prefix: '¥',
extra: <span style={{ color: '#888', fontSize: 12 }}>本月累计节省</span>,
color: '#faad14'
},
]; ];
const columns = [ // 发电趋势图数据
{ const powerTrendData = [
title: 'Node / 标识', { time: '00:00', actual: 0, forecast: 0 },
dataIndex: 'name', { time: '06:00', actual: 200, forecast: 180 },
key: 'name', { time: '09:00', actual: 800, forecast: 750 },
render: (text: string, record: any) => ( { time: '12:00', actual: 1100, forecast: 1050 },
<Space direction="vertical" size={2}> { time: '15:00', actual: 900, forecast: 920 },
<Text strong style={{ fontSize: 13 }}>{text}</Text> { time: '18:00', actual: 300, forecast: 280 },
<Text type="secondary" style={{ fontSize: 11, fontFamily: 'monospace' }}>{record.id}</Text> { time: '24:00', actual: 0, forecast: 0 },
</Space> ];
),
}, // 辐照度与温度趋势数据
{ const irradianceData = [
title: 'Status / 状态', { time: '00:00', irradiance: 0, temp: 20 },
dataIndex: 'status', { time: '06:00', irradiance: 200, temp: 22 },
key: 'status', { time: '09:00', irradiance: 800, temp: 28 },
width: 110, { time: '12:00', irradiance: 1050, temp: 35 },
render: (status: string) => ( { time: '15:00', irradiance: 750, temp: 32 },
<Tag { time: '18:00', irradiance: 200, temp: 26 },
color={status === 'online' ? 'success' : status === 'alert' ? 'error' : 'default'} { time: '24:00', irradiance: 0, temp: 21 },
style={{ ];
borderRadius: 4,
fontSize: 11, // 逆变器效率数据
fontWeight: 600, const inverterData = [
padding: '2px 8px' { name: 'INV-01', value: 98.2 },
}} { name: 'INV-02', value: 97.6 },
> { name: 'INV-03', value: 98.9 },
{status.toUpperCase()} { name: 'INV-04', value: 97.1 },
</Tag> { name: 'INV-05', value: 98.0 },
), ];
},
{ // 告警列表数据
title: 'Batt / 电量', const alertList = [
dataIndex: 'battery', { key: 1, content: 'INV-03 逆变直流电压异常', level: '严重', time: '10:24:15' },
key: 'battery', { key: 2, content: '组串 String-07 绝缘电阻低', level: '重要', time: '10:18:42' },
width: 140, { key: 3, content: '汇流箱 Combiner-12 过温', level: '重要', time: '10:12:33' },
render: (percent: number) => ( { key: 4, content: '气象站辐照度传感器离线', level: '次要', time: '09:58:11' },
<Progress { key: 5, content: '组件温度异常偏高', level: '次要', time: '09:41:28' },
percent={percent} ];
size="small"
status={percent < 20 ? 'exception' : 'active'} // 巡检记录数据
strokeColor={percent < 20 ? '#ff4d4f' : '#52c41a'} const patrolData = [
/> { key: 1, type: '日常巡检', time: '2025-05-23 09:30', person: '张运维', status: '已完成' },
), { key: 2, type: '无人机巡检', time: '2025-05-22 14:15', person: '无人机01号', status: '已完成' },
}, { key: 3, type: '夜间巡检', time: '2025-05-21 20:45', person: '李班长', status: '已完成' },
{ { key: 4, type: '专项巡检', time: '2025-05-20 10:20', person: '王技术员', status: '已完成' },
title: 'Load / 负载', { key: 5, type: '日常巡检', time: '2025-05-19 09:25', person: '张运维', status: '已完成' },
dataIndex: 'cpu',
key: 'cpu',
width: 100,
render: (cpu: number) => (
<Text style={{ fontFamily: 'monospace', fontSize: 12 }}>{cpu}%</Text>
),
},
{
title: 'Ping / 延迟',
key: 'ping',
width: 100,
align: 'right',
render: () => <Text style={{ fontFamily: 'monospace', fontSize: 12 }}>12ms</Text>,
},
]; ];
return ( return (
<div style={{ padding: '16px' }}> <div style={{ padding: '16px', background: '#f4f7f9', minHeight: '100%' }}>
{/* 统计卡片 */} {/* 顶部统计卡片 */}
<Row gutter={[16, 16]}> <Row gutter={[16, 16]} style={{ marginBottom: 16 }}>
{stats.map((stat, idx) => ( {topStats.map((stat, idx) => (
<Col xs={12} sm={12} md={8} lg={4} xl={4} key={idx}> <Col xs={24} sm={12} md={8} lg={4} key={idx}>
<AntdCard <AntdCard
size="small" size="small"
bordered={false} variant={false}
hoverable style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
style={{
borderRadius: 10,
boxShadow: '0 2px 12px rgba(0,0,0,0.06)',
transition: 'all 0.3s',
}}
bodyStyle={{ padding: '16px 14px' }}
> >
<Statistic <Statistic
title={<span style={{ fontSize: 12, color: '#666', fontWeight: 500 }}>{stat.title}</span>} title={<span style={{ fontSize: 13, color: '#666' }}>{stat.title}</span>}
value={stat.value} value={stat.value}
precision={idx === 0 ? 2 : 0} precision={stat.value % 1 !== 0 ? 1 : 0}
valueStyle={{ valueStyle={{ color: '#1f2329', fontWeight: 600, fontSize: 20 }}
color: '#1f2329', prefix={stat.prefix}
fontWeight: 600, suffix={stat.suffix}
fontSize: 22,
marginTop: 4,
}}
prefix={React.cloneElement(stat.icon as React.ReactElement, {
style: { color: stat.color, fontSize: 16, marginRight: 6 },
})}
suffix={<span style={{ fontSize: 13, color: '#888' }}>{stat.suffix}</span>}
/> />
<div style={{ marginTop: 4, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
{stat.extra}
{stat.percent && <Progress percent={stat.percent} size="small" style={{ width: 60 }} />}
</div>
</AntdCard> </AntdCard>
</Col> </Col>
))} ))}
</Row> </Row>
<Row gutter={[16, 16]} style={{ marginTop: 4 }}> <Row gutter={[16, 16]}>
{/* 设备表格 */} {/* 左侧图表区域 */}
<Col xs={24} lg={16}> <Col xs={24} lg={6}>
{/* 发电趋势 */}
<AntdCard <AntdCard
title={<span style={{ fontSize: 14, fontWeight: 600 }}>核心节点实时清单</span>} size="small"
bordered={false} title={<span style={{ fontSize: 13 }}>今日发电功率趋势</span>}
style={{ borderRadius: 10, boxShadow: '0 2px 12px rgba(0,0,0,0.06)' }} variant={false}
bodyStyle={{ padding: 0 }} style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#52c41a' }}>■</span> 实际功率</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#1890ff' }}>■</span> 预测功率</span></Space>}
> >
<Table <Line
size="middle" data={powerTrendData}
columns={columns} xField="time"
dataSource={DEVICES.map(d => ({ ...d, key: d.id }))} yField="actual"
pagination={false} smooth
onRow={(record) => ({ color="#52c41a"
onClick: () => navigate('/devices'), style={{ height: 120 }}
style: { cursor: 'pointer' }, yAxis={{ min: 0, max: 1250 }}
})} />
rowHoverable </AntdCard>
{/* 辐照度与温度趋势 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>辐照度与温度趋势</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#fa8c16' }}>■</span> 辐照度(W/m²)</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#1890ff' }}>■</span> 环境温度(℃)</span></Space>}
>
<Line
data={irradianceData}
xField="time"
yField="irradiance"
smooth
color="#fa8c16"
style={{ height: 120 }}
yAxis={{ min: 0, max: 1250 }}
/>
</AntdCard>
{/* 逆变器效率对比 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>逆变器效率对比</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
>
<Column
data={inverterData}
xField="name"
yField="value"
color="#1890ff"
style={{ height: 120 }}
yAxis={{ min: 60, max: 100 }}
/> />
</AntdCard> </AntdCard>
</Col> </Col>
{/* 告警列表 */} {/* 中间:电站概览 */}
<Col xs={24} lg={8}> <Col xs={24} lg={12}>
<Card <AntdCard
title={<span style={{ fontSize: 14, fontWeight: 600 }}>当日重点警报</span>} size="small"
extra={ title={<span style={{ fontSize: 13 }}>电站概览</span>}
<Button type="text" danger size="small" style={{ fontWeight: 500 }}> variant={false}
一键清除 style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', height: '100%' }}
</Button> extra={<Space size="small"><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#52c41a' }}>●</span> 正常</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#ff4d4f' }}>●</span> 告警</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#888' }}>●</span> 离线</span><span style={{ fontSize: 11, color: '#888' }}><span style={{ color: '#faad14' }}>●</span> 维护中</span></Space>}
} >
bordered={false} {/* 这里替换成你的电站3D图 */}
style={{ borderRadius: 10, boxShadow: '0 2px 12px rgba(0,0,0,0.06)' }} <div style={{ width: '100%', height: 400, background: '#e6f7ff', borderRadius: 4, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#888' }}>
bodyStyle={{ padding: 0, height: 460, overflowY: 'auto' }} 电站3D概览图(可替换为你的图片/地图组件)
</div>
</AntdCard>
</Col>
{/* 右侧信息面板 */}
<Col xs={24} lg={6}>
{/* 实时告警 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>实时告警</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Button type="link" size="small">更多&gt;</Button>}
> >
<List <List
dataSource={ALERTS.slice(0, 10)} size="small"
renderItem={(alert) => ( dataSource={alertList}
<List.Item renderItem={(item) => (
style={{ <List.Item style={{ padding: '8px 0', borderBottom: '1px solid #f0f0f0' }}>
padding: '12px 16px', <div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
borderBottom: '1px solid #f5f5f5', <div>
cursor: 'pointer', <span style={{ fontSize: 12 }}>{item.content}</span>
}} </div>
hoverable <div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
> <Tag color={item.level === '严重' ? 'error' : item.level === '重要' ? 'warning' : 'default'} size="small" style={{ fontSize: 10 }}>{item.level}</Tag>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 6 }}> <span style={{ fontSize: 11, color: '#888' }}>{item.time}</span>
<Tag </div>
color={alert.type === 'critical' ? 'error' : alert.type === 'warning' ? 'warning' : 'processing'}
style={{
borderRadius: 4,
fontSize: 11,
fontWeight: 600,
padding: '0 6px',
}}
>
{alert.type}
</Tag>
<Text type="secondary" style={{ fontSize: 11 }}>
{alert.time.split(' ')[1]}
</Text>
</div> </div>
<Text style={{ fontSize: 13, fontWeight: 500, lineHeight: 1.4 }}>
{alert.message}
</Text>
<Text type="secondary" style={{ fontSize: 11, marginTop: 4, display: 'block' }}>
设备:{alert.deviceName}
</Text>
</List.Item> </List.Item>
)} )}
/> />
</Card> </AntdCard>
{/* 设备在线状态 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>设备在线状态</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 8 }}>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>组件阵列</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>320/320</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>逆变器</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>5/5</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>汇流箱</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>20/20</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>气象站</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>摄像头</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>12/12</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>环境传感器</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>8/8</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>无人机</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
<div style={{ textAlign: 'center' }}><span style={{ fontSize: 11 }}>巡检机器人</span><br /><span style={{ fontSize: 12, color: '#52c41a' }}>1/1</span></div>
</div>
</AntdCard>
{/* 天气信息 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>天气信息</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', marginBottom: 16 }}
extra={<Button type="link" size="small">详细&gt;</Button>}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<span style={{ fontSize: 32 }}>☀️</span>
<div>
<div style={{ fontSize: 24, fontWeight: 600 }}>28℃</div>
<div style={{ fontSize: 12, color: '#888' }}>晴</div>
</div>
<div style={{ fontSize: 11, color: '#888', marginLeft: 16 }}>
<div>辐照度: 815 W/m²</div>
<div>组件温度: 45.6℃</div>
<div>环境温度: 28.3℃</div>
<div>风速: 2.6 m/s</div>
<div>风向: 东南风</div>
<div>湿度: 56%</div>
</div>
</div>
</AntdCard>
{/* 清洗建议 */}
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>清洗建议</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<Progress percent={85} type="circle" size={60} strokeColor="#52c41a" />
<div>
<div style={{ fontSize: 12 }}>建议清洗时间: 3 天内</div>
<div style={{ fontSize: 12 }}>预计提升发电量: 2.6%</div>
<div style={{ fontSize: 12 }}>预计提升电量: 120 kWh/天</div>
<Button type="primary" size="small" style={{ marginTop: 8 }}>生成清洗工单</Button>
</div>
</div>
</AntdCard>
</Col>
</Row>
{/* 底部:运维任务/巡检记录/AI分析 */}
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
<Col xs={24} lg={6}>
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>运维任务进度</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<Progress percent={58} type="circle" size={80} strokeColor="#52c41a" successPercent={25} />
<div style={{ fontSize: 12 }}>
<div><span style={{ color: '#52c41a' }}>●</span> 已完成 7 (58%)</div>
<div><span style={{ color: '#faad14' }}>●</span> 进行中 3 (25%)</div>
<div><span style={{ color: '#1890ff' }}>●</span> 待开始 2 (17%)</div>
<div><span style={{ color: '#ff4d4f' }}>●</span> 已延期 0 (0%)</div>
</div>
</div>
</AntdCard>
</Col>
<Col xs={24} lg={12}>
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>近期巡检记录</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
extra={<Button type="link" size="small">更多&gt;</Button>}
>
<Table
size="small"
dataSource={patrolData}
pagination={false}
columns={[
{ title: '巡检类型', dataIndex: 'type', key: 'type', width: 80 },
{ title: '巡检时间', dataIndex: 'time', key: 'time', width: 120 },
{ title: '巡检人员', dataIndex: 'person', key: 'person', width: 100 },
{ title: '状态', dataIndex: 'status', key: 'status', render: (status) => <Tag color="success" size="small">{status}</Tag> },
]}
/>
</AntdCard>
</Col>
<Col xs={24} lg={6}>
<AntdCard
size="small"
title={<span style={{ fontSize: 13 }}>AI分析摘要</span>}
variant={false}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
>
<List
size="small"
dataSource={[
{ title: '热点检测', desc: '发现 2 处组件存在异常热斑', link: '查看详情' },
{ title: '组串异常', desc: '3 个组串存在发电异常', link: '查看详情' },
{ title: '发电偏差分析', desc: '整体发电偏差 -2.8%', link: '查看详情' },
]}
renderItem={(item) => (
<List.Item style={{ padding: '8px 0', borderBottom: '1px solid #f0f0f0' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
<div>
<div style={{ fontSize: 12, fontWeight: 500 }}>{item.title}</div>
<div style={{ fontSize: 11, color: '#888' }}>{item.desc}</div>
</div>
<Button type="link" size="small">{item.link}</Button>
</div>
</List.Item>
)}
/>
</AntdCard>
</Col> </Col>
</Row> </Row>
</div> </div>

View File

@@ -83,7 +83,7 @@ export default function Login() {
className="w-full max-w-5xl" className="w-full max-w-5xl"
> >
<Card <Card
bordered={false} variant={false}
className="shadow-xl overflow-hidden rounded-2xl" className="shadow-xl overflow-hidden rounded-2xl"
styles={{ body: { padding: 0 } }} styles={{ body: { padding: 0 } }}
> >
@@ -92,7 +92,7 @@ export default function Login() {
<div className="md:w-1/2 bg-white p-10 md:p-16 flex flex-col justify-center relative z-10"> <div className="md:w-1/2 bg-white p-10 md:p-16 flex flex-col justify-center relative z-10">
<motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: 0.2 }}> <motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} transition={{ delay: 0.2 }}>
<Title level={2} style={{ marginBottom: 40, color: '#111', fontWeight: 700 }}> <Title level={2} style={{ marginBottom: 40, color: '#111', fontWeight: 700 }}>
机器人智慧服务系统 光伏电站智能监控与运维系统
</Title> </Title>
<Form name="login" layout="vertical" onFinish={onFinish} autoComplete="off" size="large"> <Form name="login" layout="vertical" onFinish={onFinish} autoComplete="off" size="large">

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { import {
Table, Button, Typography, Space, Modal, Form, Tree, message, Table, Button, Typography, Space, Modal, Form, Tree, message,
Input, Popconfirm, Select Input, Popconfirm, Select
@@ -52,7 +52,7 @@ const roleList = [
{ name: '场站员工', key: 'site_staff' }, { name: '场站员工', key: 'site_staff' },
]; ];
// 3. 扁平化菜单 // 扁平化菜单
const flattenMenu = (menus) => { const flattenMenu = (menus) => {
let arr = []; let arr = [];
const loop = (list, parentPath = '') => { const loop = (list, parentPath = '') => {
@@ -66,12 +66,31 @@ const flattenMenu = (menus) => {
return arr; return arr;
}; };
// 转树形结构(用于Tree组件)
const buildTree = (flatten) => {
const map = {};
const tree = [];
flatten.forEach(item => {
map[item.id] = { ...item, children: [] };
});
flatten.forEach(item => {
if (item.parentId === 0) {
tree.push(map[item.id]);
} else {
if (map[item.parentId]) {
map[item.parentId].children.push(map[item.id]);
}
}
});
return tree;
};
// 存储角色权限 // 存储角色权限
const rolePermissionMap = {}; const rolePermissionMap = {};
export default function Roles() { export default function Roles() {
const [menus, setMenus] = useState(flattenMenu(menuData)); const [menus, setMenus] = useState(flattenMenu(menuData));
const [menuTree, setMenuTree] = useState(menuData); const [menuTree, setMenuTree] = useState(buildTree(flattenMenu(menuData)));
// 新增/编辑菜单 // 新增/编辑菜单
const [menuModal, setMenuModal] = useState(false); const [menuModal, setMenuModal] = useState(false);
@@ -83,26 +102,48 @@ export default function Roles() {
const [selectedRole, setSelectedRole] = useState(''); const [selectedRole, setSelectedRole] = useState('');
const [checkedKeys, setCheckedKeys] = useState([]); const [checkedKeys, setCheckedKeys] = useState([]);
// 菜单类型:一级/二级
const menuType = Form.useWatch('menuType', menuForm);
// 每次菜单变化,重新生成树形
useEffect(() => {
setMenuTree(buildTree(menus));
}, [menus]);
// 打开编辑 // 打开编辑
const handleEdit = (record) => { const handleEdit = (record) => {
setEditMenu(record); setEditMenu(record);
menuForm.setFieldsValue(record); menuForm.setFieldsValue({
...record,
menuType: record.parentId === 0 ? 'top' : 'sub',
});
setMenuModal(true); setMenuModal(true);
}; };
// 保存菜单(新增+编辑) // 保存菜单(新增+编辑)
const handleSaveMenu = () => { const handleSaveMenu = () => {
menuForm.validateFields().then(values => { menuForm.validateFields().then(values => {
const { menuType, parentId, title, path } = values;
if (editMenu) { if (editMenu) {
// 编辑 // 编辑
setMenus(menus.map(m => m.id === editMenu.id ? { ...m, ...values } : m)); setMenus(menus.map(m =>
m.id === editMenu.id
? {
...m,
title,
path,
parentId: menuType === 'top' ? 0 : Number(parentId)
}
: m
));
message.success('编辑成功'); message.success('编辑成功');
} else { } else {
// 新增 // 新增
const newMenu = { const newMenu = {
...values,
id: Date.now(), id: Date.now(),
parentId: 0, title,
path,
parentId: menuType === 'top' ? 0 : Number(parentId),
}; };
setMenus([...menus, newMenu]); setMenus([...menus, newMenu]);
message.success('新增菜单成功'); message.success('新增菜单成功');
@@ -123,7 +164,6 @@ export default function Roles() {
message.warning('请先选择角色'); message.warning('请先选择角色');
return; return;
} }
// 回显已保存权限
const saved = rolePermissionMap[selectedRole] || []; const saved = rolePermissionMap[selectedRole] || [];
setCheckedKeys(saved); setCheckedKeys(saved);
setPermModal(true); setPermModal(true);
@@ -136,6 +176,9 @@ export default function Roles() {
setPermModal(false); setPermModal(false);
}; };
// 一级菜单列表(用于父级选择)
const topMenus = menus.filter(m => m.parentId === 0);
const columns = [ const columns = [
{ title: '菜单名称', dataIndex: 'title', key: 'title', width: 180 }, { title: '菜单名称', dataIndex: 'title', key: 'title', width: 180 },
{ title: '路由地址', dataIndex: 'fullPath', key: 'fullPath' }, { title: '路由地址', dataIndex: 'fullPath', key: 'fullPath' },
@@ -202,7 +245,7 @@ export default function Roles() {
dataSource={menus} dataSource={menus}
rowKey="id" rowKey="id"
pagination={false} pagination={false}
bordered variant
/> />
{/* 菜单 新增/编辑 弹窗 */} {/* 菜单 新增/编辑 弹窗 */}
@@ -214,6 +257,24 @@ export default function Roles() {
width={500} width={500}
> >
<Form form={menuForm} layout="vertical"> <Form form={menuForm} layout="vertical">
<Form.Item name="menuType" label="菜单类型" rules={[{ required: true }]}>
<Select placeholder="请选择菜单类型">
<Option value="top">一级菜单</Option>
<Option value="sub">二级菜单</Option>
</Select>
</Form.Item>
{/* 二级菜单才显示父级选择 */}
{menuType === 'sub' && (
<Form.Item name="parentId" label="上级菜单" rules={[{ required: true }]}>
<Select placeholder="请选择上级菜单">
{topMenus.map(m => (
<Option key={m.id} value={m.id}>{m.title}</Option>
))}
</Select>
</Form.Item>
)}
<Form.Item name="title" label="菜单名称" rules={[{ required: true }]}> <Form.Item name="title" label="菜单名称" rules={[{ required: true }]}>
<Input placeholder="请输入菜单名称" /> <Input placeholder="请输入菜单名称" />
</Form.Item> </Form.Item>

View File

@@ -139,13 +139,7 @@ export default function Organization() {
<Form.Item name="code" label="组织编码" rules={[{ required: true }]}> <Form.Item name="code" label="组织编码" rules={[{ required: true }]}>
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item name="parentId" label="上级组织">
<TreeSelect
treeData={treeData}
placeholder="选择上级"
fieldNames={{ label: 'name', value: 'id' }}
/>
</Form.Item>
<Form.Item name="status" label="状态"> <Form.Item name="status" label="状态">
<Select> <Select>
<Option value="0">正常</Option> <Option value="0">正常</Option>

View File

@@ -78,7 +78,7 @@ export default function VideoControl() {
value={selectedDevice.id} value={selectedDevice.id}
onChange={(id) => setSelectedDevice(onlineDevices.find(d => d.id === id)!)} onChange={(id) => setSelectedDevice(onlineDevices.find(d => d.id === id)!)}
style={{ width: 220, fontWeight: 'bold' }} style={{ width: 220, fontWeight: 'bold' }}
bordered={false} variant={false}
options={onlineDevices.map(d => ({ label: d.name, value: d.id }))} options={onlineDevices.map(d => ({ label: d.name, value: d.id }))}
suffixIcon={<VideoCameraOutlined style={{ color: '#1890ff' }} />} suffixIcon={<VideoCameraOutlined style={{ color: '#1890ff' }} />}
/> />
@@ -147,7 +147,7 @@ export default function VideoControl() {
<Col flex="auto"> <Col flex="auto">
<div className="flex items-center justify-between mb-4"> <div className="flex items-center justify-between mb-4">
<Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase' }}>系统集成作业指令 ({selectedDevice.type})</Text> <Text strong type="secondary" style={{ fontSize: 10, textTransform: 'uppercase' }}>系统集成作业指令 ({selectedDevice.type})</Text>
<Tag color="success" bordered={false} style={{ fontSize: 10, fontWeight: 'bold' }}>SIGNAL: 100% EXCELLENT</Tag> <Tag color="success" variant={false} style={{ fontSize: 10, fontWeight: 'bold' }}>SIGNAL: 100% EXCELLENT</Tag>
</div> </div>
<Space className="w-full" size="middle"> <Space className="w-full" size="middle">
<Button icon={<CustomerServiceOutlined />} style={{ borderRadius: 2 }} block>双轴双向对讲</Button> <Button icon={<CustomerServiceOutlined />} style={{ borderRadius: 2 }} block>双轴双向对讲</Button>

View File

@@ -1,18 +1,11 @@
import React, { lazy, Suspense } from 'react'; import React, { lazy, Suspense } from 'react';
import { createBrowserRouter, RouterProvider } from 'react-router-dom'; import { createBrowserRouter } from 'react-router-dom';
import type { RouteObject } from 'react-router-dom'; import type { RouteObject } from 'react-router-dom';
// ============================================================
// 路由懒加载 & 分层架构
// 所有业务 Page 均通过 React.lazy 实现按需加载,减小首屏 JS 体积
// ============================================================
// 布局组件
const Layout = lazy(() => import('../components/Layout')); const Layout = lazy(() => import('../components/Layout'));
const ProtectedRoute = lazy(() => import('../components/ProtectedRoute')); const ProtectedRoute = lazy(() => import('../components/ProtectedRoute'));
const Login = lazy(() => import('../pages/Login')); const Login = lazy(() => import('../pages/Login'));
// 业务页面(按需加载)
const Home = lazy(() => import('../pages/Home')); const Home = lazy(() => import('../pages/Home'));
const Devices = lazy(() => import('../pages/Devices')); const Devices = lazy(() => import('../pages/Devices'));
const Video = lazy(() => import('../pages/Video')); const Video = lazy(() => import('../pages/Video'));
@@ -25,7 +18,6 @@ const Organization = lazy(() => import('../pages/Organization'));
const StationManage = lazy(() => import('../pages/StationManage')); const StationManage = lazy(() => import('../pages/StationManage'));
const SerialNumGenerate = lazy(() => import('../pages/SerialNumGenerate')); const SerialNumGenerate = lazy(() => import('../pages/SerialNumGenerate'));
// 公共加载骨架(路由切换时闪烁优化)
function PageFallback() { function PageFallback() {
return ( return (
<div className="flex items-center justify-center h-full min-h-[200px]"> <div className="flex items-center justify-center h-full min-h-[200px]">
@@ -34,18 +26,15 @@ function PageFallback() {
); );
} }
// ============================================================
// 路由元信息表(权限 · 标题 · 图标)
// ============================================================
export const routeMeta: Record<string, { export const routeMeta: Record<string, {
title: string; title: string;
roles: string[]; roles: string[];
requiresAuth: boolean; requiresAuth: boolean;
}> = { }> = {
'/': { title: '概览控制台', roles: ['admin', 'operator', 'viewer'], requiresAuth: true }, '/': { title: '总览首页', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
'/devices': { title: '设备管理', roles: ['admin', 'operator'], requiresAuth: true }, '/devices': { title: '设备管理', roles: ['admin', 'operator'], requiresAuth: true },
'/video': { title: '在线视频', roles: ['admin', 'operator', 'viewer'], requiresAuth: true }, '/video': { title: '在线视频', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
'/alerts': { title: '警报中心', roles: ['admin', 'operator'], requiresAuth: true }, '/alerts': { title: '告警中心', roles: ['admin', 'operator'], requiresAuth: true },
'/downloads': { title: '视频下载', roles: ['admin', 'operator'], requiresAuth: true }, '/downloads': { title: '视频下载', roles: ['admin', 'operator'], requiresAuth: true },
'/serialNumGenerate': { title: '序列号生成', roles: ['admin'], requiresAuth: true }, '/serialNumGenerate': { title: '序列号生成', roles: ['admin'], requiresAuth: true },
'/users': { title: '用户管理', roles: ['admin'], requiresAuth: true }, '/users': { title: '用户管理', roles: ['admin'], requiresAuth: true },
@@ -55,9 +44,6 @@ export const routeMeta: Record<string, {
'/station': { title: '场站管理', roles: ['admin'], requiresAuth: true }, '/station': { title: '场站管理', roles: ['admin'], requiresAuth: true },
}; };
// ============================================================
// 路由表(完整配置,支持权限过滤)
// ============================================================
const routes: RouteObject[] = [ const routes: RouteObject[] = [
{ {
path: '/login', path: '/login',

View File

@@ -1,5 +1,5 @@
// ============================================================ // ============================================================
// 机器人智慧服务系统 - 全局类型定义 // 光伏电站智能监控与运维系统 - 全局类型定义
// ============================================================ // ============================================================
// ------------------- 通用 ------------------- // ------------------- 通用 -------------------