告警和 工单细节优化
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>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Layout, Card, Row, Col, Button, Table, Tag, Select, Input, Typography, Space,
|
||||
Statistic, Modal, message, Empty, Drawer, Descriptions, Timeline, Divider, Form, Tabs, Progress, Badge, DatePicker, Pagination, Popconfirm
|
||||
Statistic, Modal, message, Empty, Drawer, Descriptions, Timeline, Divider, Form, Tabs, Progress, Badge, DatePicker, Pagination, Popconfirm, Image
|
||||
} from 'antd';
|
||||
import {
|
||||
CheckOutlined, ClockCircleOutlined, ControlOutlined,
|
||||
@@ -243,9 +243,9 @@ const WorkOrderPage = () => {
|
||||
if (item.orderStatus === 2 || item.orderStatus === 5) running++;
|
||||
|
||||
// 已完成工单计算处理时长
|
||||
if (item.orderStatus === 4 && item.actualStartTime && item.actualEndTime) {
|
||||
if (item.orderStatus === 3 && item.createTime && item.actualEndTime) {
|
||||
finishCount++;
|
||||
const costMin = dayjs(item.actualEndTime).diff(dayjs(item.actualStartTime), 'minute');
|
||||
const costMin = dayjs(item.actualEndTime).diff(dayjs(item.createTime), 'minute');
|
||||
totalCostHour += costMin / 60;
|
||||
allFinishOrder.push(item);
|
||||
}
|
||||
@@ -437,7 +437,9 @@ const WorkOrderPage = () => {
|
||||
const queryParams = {
|
||||
...params,
|
||||
pageNum: pagination.current,
|
||||
pageSize: pagination.pageSize
|
||||
pageSize: pagination.pageSize,
|
||||
siteId: stationId,
|
||||
|
||||
};
|
||||
|
||||
const res = await getWorkOrderApi(queryParams);
|
||||
@@ -494,7 +496,9 @@ const WorkOrderPage = () => {
|
||||
|
||||
const values = queryForm.getFieldsValue();
|
||||
console.log('查询表单值:', values);
|
||||
const params: any = {};
|
||||
const params = {
|
||||
siteId: stationId,
|
||||
};
|
||||
|
||||
if (values.orderType) {
|
||||
params.orderType = values.orderType;
|
||||
@@ -1136,24 +1140,84 @@ const WorkOrderPage = () => {
|
||||
</div>
|
||||
|
||||
<Row gutter={[16, 16]} style={{ background: '#f8fafc', padding: 16, borderRadius: 12, marginBottom: 20 }}>
|
||||
<Col span={12}><span style={{ fontSize: 12 }}>来源:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{sourceTypeMap[currentDetail?.sourceType] || '--'}</span></Col>
|
||||
<Col span={12}><span style={{ fontSize: 12 }}>工单类型:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{getWorkOrderTypeText(currentDetail?.orderType)}</span></Col>
|
||||
<Col span={24}><span style={{ fontSize: 12 }}>执行开始时间:</span>
|
||||
<Col span={12}>
|
||||
<span style={{ fontSize: 12 }}>来源:</span>
|
||||
<span style={{ fontSize: 12, fontWeight: 500 }}>{sourceTypeMap[currentDetail?.sourceType] || '--'}</span>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<span style={{ fontSize: 12 }}>工单类型:</span>
|
||||
<span style={{ fontSize: 12, fontWeight: 500 }}>{getWorkOrderTypeText(currentDetail?.orderType)}</span>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<span style={{ fontSize: 12 }}>执行开始时间:</span>
|
||||
<span style={{ fontSize: 12, fontWeight: 500 }}>
|
||||
{currentDetail?.actualStartTime}
|
||||
{currentDetail?.actualStartTime || '--'}
|
||||
</span>
|
||||
</Col>
|
||||
<Col span={24}><span style={{ fontSize: 12 }}>关联设备:</span><span style={{ fontSize: 12, color: '#165DFF', fontWeight: 600 }}>{currentDetail?.deviceName || '无'}</span></Col>
|
||||
<Col span={12}><span style={{ fontSize: 12 }}>关联区域:</span><span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.siteName || '无'}</span></Col>
|
||||
<Col span={24}>
|
||||
<span style={{ fontSize: 12 }}>关联设备:</span>
|
||||
<span style={{ fontSize: 12, color: '#165DFF', fontWeight: 600 }}>{currentDetail?.deviceName || '无'}</span>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<span style={{ fontSize: 12 }}>关联区域:</span>
|
||||
<span style={{ fontSize: 12, fontWeight: 500 }}>{currentDetail?.siteName || '无'}</span>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<span style={{ fontSize: 12 }}>当前状态:</span>
|
||||
<Tag color="blue" style={{ borderRadius: 4, fontWeight: 600, border: 'none', background: '#E8F3FF', color: '#165DFF' }}>{orderStatusConfig[currentDetail?.orderStatus]?.label || '--'}</Tag>
|
||||
<Tag color="blue" style={{ borderRadius: 4, fontWeight: 600, border: 'none', background: '#E8F3FF', color: '#165DFF' }}>
|
||||
{orderStatusConfig[currentDetail?.orderStatus]?.label || '--'}
|
||||
</Tag>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<span style={{ fontSize: 12 }}>任务描述:</span>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginTop: 4, lineHeight: 1.6 }}>{currentDetail?.taskDescription || '暂无描述'}</div>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginTop: 4, lineHeight: 1.6 }}>
|
||||
{currentDetail?.taskDescription || '暂无描述'}
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
{/* ============ 新增:图片&视频附件预览区域 ============ */}
|
||||
{(
|
||||
(currentDetail?.imgUrl && currentDetail.imgUrl.length > 0) ||
|
||||
(currentDetail?.videoUrl && currentDetail.videoUrl.length > 0)
|
||||
) && (
|
||||
<Col span={24}>
|
||||
<div style={{ fontSize: 12, marginBottom: 8 }}>附件素材:</div>
|
||||
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
|
||||
{/* 图片预览组,支持点击放大 */}
|
||||
{currentDetail?.imgUrl?.length > 0 && (
|
||||
<Image.PreviewGroup>
|
||||
{currentDetail.imgUrl.map((rawUrl, idx) => {
|
||||
|
||||
return (
|
||||
<Image
|
||||
key={`img-${idx}`}
|
||||
src={rawUrl}
|
||||
width={110}
|
||||
height={80}
|
||||
style={{ objectFit: 'cover', borderRadius: 6, border: '1px solid #e5e6eb' }}
|
||||
preview
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</Image.PreviewGroup>
|
||||
)}
|
||||
|
||||
{/* 视频预览 */}
|
||||
{currentDetail?.videoUrl?.length > 0 && currentDetail.videoUrl.map((rawUrl, idx) => {
|
||||
return (
|
||||
<video
|
||||
key={`video-${idx}`}
|
||||
src={rawUrl}
|
||||
style={{ width: 110, height: 80, objectFit: 'cover', borderRadius: 6, border: '1px solid #e5e6eb' }}
|
||||
controls
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Col>
|
||||
)}
|
||||
</Row>
|
||||
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
@@ -1618,11 +1682,10 @@ const WorkOrderPage = () => {
|
||||
dataIndex: 'handleStatus',
|
||||
width: 100,
|
||||
render: (s) => {
|
||||
const map = { 1: '待处理', 2: '处理中', 3: '已关闭', 4: '已忽略' };
|
||||
const map = { 1: '待处理', 2: '已关闭', };
|
||||
let tagColor = 'default';
|
||||
if (s === 1) tagColor = 'orange';
|
||||
if (s === 2) tagColor = 'blue';
|
||||
if (s === 3) tagColor = 'green';
|
||||
if (s === 2) tagColor = 'green';
|
||||
return <Tag color={tagColor}>{map[s] || '-'}</Tag>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user