告警和 工单细节优化
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
BranchesOutlined,
|
||||
RobotOutlined
|
||||
} from '@ant-design/icons';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Line, Bar, Pie } from '@ant-design/charts';
|
||||
import CesiumMap from '../components/Map';
|
||||
import { getWeatherData, getWeatherType } from '../lib/utils';
|
||||
@@ -24,6 +25,8 @@ import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../com
|
||||
// 👇 在这里引入你的工单接口(改成你真实的接口地址)
|
||||
import { addWorkOrder } from '../api/workOrder';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { getAlarmList } from '../api/alarmApi';
|
||||
import { RootState } from '../store';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
@@ -34,6 +37,9 @@ export default function StationDashboard() {
|
||||
// 👇 获取当前选中的电站(从redux拿,修复缺失)
|
||||
const { currentStation } = useSelector((state) => state.station);
|
||||
const { userInfo } = useSelector((state) => state.user);
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
const [alarmList, setAlarmList] = useState([]);
|
||||
|
||||
|
||||
// 天气数据
|
||||
const [weatherdata, setWeatherData] = useState({
|
||||
@@ -75,11 +81,9 @@ export default function StationDashboard() {
|
||||
alarmCount: 8,
|
||||
costSaved: 36540
|
||||
};
|
||||
// 组件内部
|
||||
const navigate = useNavigate();
|
||||
|
||||
const realtimeAlerts = [
|
||||
{ level: "INFO", type: "设备离线", time: "04-28 18:44" },
|
||||
{ level: "严重", type: "逆变器温度过高", time: "04-28 18:44" }
|
||||
];
|
||||
|
||||
const deviceStatus = [
|
||||
{ name: "汇流箱", count: "2/2", status: "异常 1" },
|
||||
@@ -203,6 +207,27 @@ export default function StationDashboard() {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
const fetchList = async () => {
|
||||
try {
|
||||
const data = {
|
||||
pageNum: 1,
|
||||
pageSize: 999999,
|
||||
siteId: stationId
|
||||
}
|
||||
const res = await getAlarmList(data);
|
||||
if (res.code === 200) {
|
||||
setAlarmList(res?.rows || []);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
messageApi.error('加载失败');
|
||||
} finally {
|
||||
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
fetchList()
|
||||
}, [stationId])
|
||||
|
||||
|
||||
|
||||
@@ -218,7 +243,7 @@ export default function StationDashboard() {
|
||||
{ title: '当前功率', value: '812.6', unit: 'kW', sub: '装机容量 1,000 kWp', color: '#165DFF', bg: '#E8F3FF', icon: <DashboardOutlined /> },
|
||||
{ title: 'Performance Ratio', value: '82.6%', unit: '', sub: '昨日 81.3% ↑1.3%', color: '#00B42A', bg: '#E8FFEA', icon: <BarChartOutlined /> },
|
||||
{ title: '系统可用率', value: '99.35%', unit: '', sub: '昨日 99.12% ↑0.23%', color: '#165DFF', bg: '#E8F3FF', icon: <RiseOutlined /> },
|
||||
{ title: '告警数量', value: '8', unit: '', sub: '未处理 5 / 已处理 3', color: '#F53F3F', bg: '#FFF1F0', icon: <BellOutlined /> },
|
||||
{ title: '告警数量', value: alarmList.length, unit: '', sub: `未处理 ${alarmList.filter(item => item.handleStatus == 1).length} / 已关闭 ${alarmList.filter(item => item.handleStatus == 2).length}`, color: '#F53F3F', bg: '#FFF1F0', icon: <BellOutlined /> },
|
||||
{ title: '节省运维成本', value: '¥ 36,540', unit: '', sub: '本月累计节省', color: '#FF7D00', bg: '#FFF7E8', icon: <MoneyCollectOutlined /> },
|
||||
].map((item, idx) => (
|
||||
<Col key={idx} style={{
|
||||
@@ -414,25 +439,25 @@ export default function StationDashboard() {
|
||||
{/* 右侧 */}
|
||||
<Col xs={24} xl={6}>
|
||||
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
||||
<Card title={<span style={{ fontWeight: 800 }}>实时告警</span>} extra={<Button type="link" size="small">更多 ></Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
|
||||
<Card title={<span style={{ fontWeight: 800 }}>实时告警</span>} extra={<Button type="link" size="small" onClick={() => navigate('/alerts')}>更多 ></Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 12, padding: '0 4px 8px', borderBottom: '1px solid #f0f0f0', fontSize: 13, color: '#666' }}>
|
||||
<span style={{ flex: 3 }}>告警内容</span>
|
||||
<span style={{ flex: 1, textAlign: 'center' }}>级别</span>
|
||||
<span style={{ flex: 1.5, textAlign: 'right' }}>发生时间</span>
|
||||
</div>
|
||||
{realtimeAlerts.map((alert, idx) => {
|
||||
let dotColor = alert.level === '严重' ? '#ff4d4f' : alert.level === '重要' ? '#fa8c16' : '#1677ff';
|
||||
let tagColor = alert.level === '严重' ? 'error' : alert.level === '重要' ? 'warning' : 'processing';
|
||||
{alarmList.slice(0, 2).map((alert, idx) => {
|
||||
let dotColor = alert.alarmLevel === 'ERROR' ? '#ff4d4f' : alert.alarmLevel === 'WARNING' ? '#fa8c16' : '#1677ff';
|
||||
let tagColor = alert.alarmLevel === 'ERROR' ? 'error' : alert.alarmLevel === 'WARNING' ? 'warning' : 'processing';
|
||||
return (
|
||||
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12, padding: '0 4px', borderBottom: idx < realtimeAlerts.length - 1 ? '1px solid #f5f5f5' : 'none', paddingBottom: 8 }}>
|
||||
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12, padding: '0 4px', borderBottom: idx < 1 ? '1px solid #f5f5f5' : 'none', paddingBottom: 8 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', flex: 3, minWidth: 0 }}>
|
||||
<div style={{ width: 12, height: 12, borderRadius: '50%', backgroundColor: dotColor, marginRight: 8, flexShrink: 0 }} />
|
||||
<span style={{ fontSize: 13, fontWeight: 500 }}>{alert.type}</span>
|
||||
<span style={{ fontSize: 13, fontWeight: 500 }}>{alert.alarmTitle}</span>
|
||||
</div>
|
||||
<div style={{ flex: 1, textAlign: 'center' }}>
|
||||
<Tag color={tagColor} style={{ fontSize: 12 }}>{alert.level}</Tag>
|
||||
<Tag color={tagColor} style={{ fontSize: 12 }}>{alert.alarmLevel}</Tag>
|
||||
</div>
|
||||
<div style={{ flex: 1.5, textAlign: 'right', fontSize: 13 }}>{alert.time}</div>
|
||||
<div style={{ flex: 1.5, textAlign: 'right', fontSize: 13 }}>{alert.createTime}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user