diff --git a/src/components/alerts/AlarmHistory.tsx b/src/components/alerts/AlarmHistory.tsx
index 8ab52ab..d0618b0 100644
--- a/src/components/alerts/AlarmHistory.tsx
+++ b/src/components/alerts/AlarmHistory.tsx
@@ -14,11 +14,40 @@ import {
const { Option } = Select;
-// 配置
-const levelColor = { 1: '#F53F3F', 2: '#FF7D00', 3: '#F7BA1E', 4: '#165DFF' };
-const levelText = { 1: '严重', 2: '重要', 3: '一般', 4: '提示' };
-const statusText = { 0: '待处理', 1: '处理中', 2: '已关闭' };
-const statusColor = { 0: '#F7BA1E', 1: '#165DFF', 2: '#00B42A' };
+// ====================== 枚举配置 ======================
+const alarmTypeMap = {
+ 1: '设备故障',
+ 2: '数据异常',
+ 3: '通信中断',
+ 4: '性能告警',
+ 5: '安全告警',
+ 6: '环境告警'
+};
+
+const alarmLevelConfig = {
+ 1: { description: '严重', color: '#FF4D4F' },
+ 2: { description: '重要', color: '#FA8C16' },
+ 3: { description: '一般', color: '#FADB14' },
+ 4: { description: '提示', color: '#1890FF' }
+};
+
+const handleStatusMap = {
+ 1: '待处理',
+ 2: '处理中',
+ 3: '已关闭',
+ 4: '已忽略'
+};
+
+// 自动生成颜色/文字映射
+const levelColor = Object.keys(alarmLevelConfig).reduce((map, key) => {
+ map[key] = alarmLevelConfig[key].color;
+ return map;
+}, {});
+
+const levelText = Object.keys(alarmLevelConfig).reduce((map, key) => {
+ map[key] = alarmLevelConfig[key].description;
+ return map;
+}, {});
const AlarmHistory = () => {
const [form] = Form.useForm();
@@ -109,12 +138,15 @@ const AlarmHistory = () => {
{
title: '处理状态',
width: 110,
- render: (r) => (
-
-
- {statusText[r.handleStatus]}
-
- )
+ render: (r) => {
+ const s = r.handleStatus;
+ let color = 'default';
+ if (s === 1) color = 'orange';
+ if (s === 2) color = 'blue';
+ if (s === 3) color = 'green';
+ if (s === 4) color = 'default';
+ return {handleStatusMap[s] || '-'};
+ }
},
{
title: '操作',
@@ -148,9 +180,10 @@ const AlarmHistory = () => {
@@ -207,9 +240,15 @@ const AlarmHistory = () => {
-
- {statusText[currentAlarm?.handleStatus]}
-
+ {(() => {
+ const s = currentAlarm?.handleStatus;
+ let color = 'default';
+ if (s === 1) color = 'orange';
+ if (s === 2) color = 'blue';
+ if (s === 3) color = 'green';
+ if (s === 4) color = 'default';
+ return {handleStatusMap[s] || '-'};
+ })()}
{currentAlarm?.handleUserName || '-'}
@@ -217,8 +256,6 @@ const AlarmHistory = () => {
{currentAlarm?.handleRemark || '-'}
{currentAlarm?.rootCause || '-'}
-
- {/* 新增:推荐处理措施 */}
{currentAlarm?.handleSuggestion || '-'}
diff --git a/src/components/alerts/AlarmOverview.tsx b/src/components/alerts/AlarmOverview.tsx
index bb74e78..dd47ff6 100644
--- a/src/components/alerts/AlarmOverview.tsx
+++ b/src/components/alerts/AlarmOverview.tsx
@@ -22,12 +22,40 @@ import {
const { RangePicker } = DatePicker;
const { Text } = Typography;
-// 级别 + 状态颜色
-const levelColor = { 1: '#F53F3F', 2: '#FF7D00', 3: '#F7BA1E', 4: '#165DFF' };
-const levelText = { 1: '严重', 2: '重要', 3: '一般', 4: '提示' };
+// ====================== 你提供的枚举 ======================
+const alarmTypeMap = {
+ 1: '设备故障',
+ 2: '数据异常',
+ 3: '通信中断',
+ 4: '性能告警',
+ 5: '安全告警',
+ 6: '环境告警'
+};
-const statusColor = { 0: '#F7BA1E', 1: '#165DFF', 2: '#00B42A' };
-const statusText = { 0: '待处理', 1: '处理中', 2: '已关闭' };
+const alarmLevelConfig = {
+ 1: { description: '严重', color: '#FF4D4F' },
+ 2: { description: '重要', color: '#FA8C16' },
+ 3: { description: '一般', color: '#FADB14' },
+ 4: { description: '提示', color: '#1890FF' }
+};
+
+const handleStatusMap = {
+ 1: '待处理',
+ 2: '处理中',
+ 3: '已关闭',
+ 4: '已忽略'
+};
+
+// 颜色映射(从枚举自动生成)
+const levelColor = Object.keys(alarmLevelConfig).reduce((map, key) => {
+ map[key] = alarmLevelConfig[key].color;
+ return map;
+}, {});
+
+const levelText = Object.keys(alarmLevelConfig).reduce((map, key) => {
+ map[key] = alarmLevelConfig[key].description;
+ return map;
+}, {});
export default function AlarmCenterPage() {
const [loading, setLoading] = useState(false);
@@ -106,7 +134,7 @@ export default function AlarmCenterPage() {
// ====================== 处理告警 ======================
const doHandle = async () => {
try {
- await handleAlarm({ id: currentAlarm.id, handleStatus: 2, handleRemark: '已处理' });
+ await handleAlarm({ id: currentAlarm.id, handleStatus: 3, handleRemark: '已处理' });
message.success('处理成功');
setDrawerVisible(false);
fetchList();
@@ -159,6 +187,12 @@ export default function AlarmCenterPage() {
dataIndex: 'deviceName',
width: 160
},
+ {
+ title: '告警类型',
+ dataIndex: 'alarmType',
+ width: 120,
+ render: (t) => alarmTypeMap[t] || '-'
+ },
{
title: '告警级别',
dataIndex: 'alarmLevel',
@@ -179,12 +213,19 @@ export default function AlarmCenterPage() {
title: '处理状态',
dataIndex: 'handleStatus',
width: 110,
- render: (s) => (
-
-
- {statusText[s]}
-
- )
+ render: (s) => {
+ let color = 'default';
+ const text = handleStatusMap[s] || '-';
+ // 1:待处理 2:处理中 3:已关闭 4:已忽略
+ switch (s) {
+ case 1: color = 'orange'; break; // 待处理
+ case 2: color = 'blue'; break; // 处理中
+ case 3: color = 'green'; break; // 已关闭
+ case 4: color = 'default'; break; // 已忽略
+ default: break;
+ }
+ return {text};
+ }
},
{
title: '操作',
@@ -205,7 +246,7 @@ export default function AlarmCenterPage() {
{ type: '提示', value: statData.levelStats?.[4] || 0 },
].filter(i => i.value > 0),
angleField: 'value', colorField: 'type',
- color: ['#F53F3F', '#FF7D00', '#F7BA1E', '#165DFF'],
+ color: ['#FF4D4F', '#FA8C16', '#FADB14', '#1890FF'],
radius: 0.8, innerRadius: 0.6, label: false
};
@@ -240,9 +281,10 @@ export default function AlarmCenterPage() {
onChange={v => setQueryParams({ ...queryParams, handleStatus: v })}
options={[
{ value: '', label: '全部' },
- { value: 0, label: '待处理' },
- { value: 1, label: '处理中' },
- { value: 2, label: '已关闭' },
+ { value: 1, label: '待处理' },
+ { value: 2, label: '处理中' },
+ { value: 3, label: '已关闭' },
+ { value: 4, label: '已忽略' },
]}
/>
@@ -297,12 +339,12 @@ export default function AlarmCenterPage() {
-
+
告警总数
-
+
{statData.total || 0}
@@ -315,12 +357,12 @@ export default function AlarmCenterPage() {
-
+
严重告警
-
+
{statData.levelStats?.[1] || 0}
@@ -333,12 +375,12 @@ export default function AlarmCenterPage() {
-
+
待处理
-
+
{statData.pending || 0}
@@ -351,12 +393,12 @@ export default function AlarmCenterPage() {
-
+
处理中
-
+
{statData.processing || 0}
@@ -425,7 +467,7 @@ export default function AlarmCenterPage() {
]}
xField="date"
yField={['严重']}
- color={['#F53F3F']}
+ color={['#FF4D4F']}
smooth
height={220}
/>
@@ -453,7 +495,7 @@ export default function AlarmCenterPage() {
- {/* 告警详情抽屉 —— 按设计稿完整实现 */}
+ {/* 告警详情抽屉 */}
-
+
@@ -483,10 +525,22 @@ export default function AlarmCenterPage() {
{/* 告警基础信息 */}
{currentAlarm.deviceName || '-'}
- {currentAlarm.deviceType || '-'}
+ {alarmTypeMap[currentAlarm.alarmType] || '-'}
{dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss')}
- {statusText[currentAlarm.handleStatus]}
+ {(() => {
+ let color = 'default';
+ const status = currentAlarm.handleStatus;
+ // 1:待处理 2:处理中 3:已关闭 4:已忽略
+ switch (status) {
+ case 1: color = 'orange'; break;
+ case 2: color = 'blue'; break;
+ case 3: color = 'green'; break;
+ case 4: color = 'default'; break;
+ default: break;
+ }
+ return {handleStatusMap[status] || '-'};
+ })()}
{currentAlarm.handleUserName || '-'}
@@ -513,7 +567,7 @@ export default function AlarmCenterPage() {
短信
-
+
@@ -521,7 +575,7 @@ export default function AlarmCenterPage() {
{/*
*/}
钉钉
-
+
@@ -529,7 +583,7 @@ export default function AlarmCenterPage() {
{/*
*/}
邮件
-
+
diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx
index 181851b..35539b0 100644
--- a/src/pages/Home.tsx
+++ b/src/pages/Home.tsx
@@ -258,8 +258,7 @@ export default function StationDashboard() {
marginBottom: 16,
width: '100%',
margin: '0 0 16px 0',
- flexWrap: 'nowrap',
- overflow: 'hidden'
+ flexWrap: 'wrap',
}}
>
{/* 今日发电量 */}
@@ -275,8 +274,8 @@ export default function StationDashboard() {
日目标 5,000 kWh
-
+
@@ -303,8 +302,8 @@ export default function StationDashboard() {
装机容量 1,000 kWp
-
+
@@ -323,7 +322,7 @@ export default function StationDashboard() {
-
Performance Ratio(PR)
+
Performance Ratio
82.6%
@@ -332,8 +331,8 @@ export default function StationDashboard() {
-
+
@@ -361,8 +360,8 @@ export default function StationDashboard() {
-
+
@@ -391,8 +390,8 @@ export default function StationDashboard() {
-
+
@@ -418,8 +417,8 @@ export default function StationDashboard() {
本月累计节省
-
+