中英文切换
This commit is contained in:
@@ -28,7 +28,7 @@ const alarmLevelConfig = {
|
||||
|
||||
const handleStatusMap = {
|
||||
1: t('constants.pending'),
|
||||
2: '处理中',
|
||||
2: t('alerts.processing'),
|
||||
3: t('constants.closed'),
|
||||
4: t('constants.ignored')
|
||||
};
|
||||
@@ -79,7 +79,7 @@ const AlarmHistory = () => {
|
||||
setTotal(res.total || 0);
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('加载失败');
|
||||
message.error(t('common.loadFailed'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -94,10 +94,10 @@ const AlarmHistory = () => {
|
||||
setCurrentAlarm(res.data);
|
||||
setDrawerVisible(true);
|
||||
} else {
|
||||
message.error('获取详情失败');
|
||||
message.error(t('common.loadDetailFailed'));
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('请求异常');
|
||||
message.error(t('common.requestError'));
|
||||
} finally {
|
||||
setDetailLoading(false);
|
||||
}
|
||||
@@ -129,14 +129,14 @@ const AlarmHistory = () => {
|
||||
|
||||
// 表格列
|
||||
const columns = [
|
||||
{ title: '告警编号', dataIndex: 'alarmNo', width: 180 },
|
||||
{ title: t('alerts.alarmNo'), dataIndex: 'alarmNo', width: 180 },
|
||||
{
|
||||
title: t('alerts.alertTime'),
|
||||
dataIndex: 'alarmTime',
|
||||
width: 190,
|
||||
render: (t) => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
|
||||
},
|
||||
{ title: '设备ID', dataIndex: 'deviceId', width: 160 },
|
||||
{ title: t('common.deviceId'), dataIndex: 'deviceId', width: 160 },
|
||||
{ title: t('devices.deviceName'), dataIndex: 'deviceName', ellipsis: true },
|
||||
{
|
||||
title: t('alerts.alertType'),
|
||||
@@ -153,8 +153,8 @@ const AlarmHistory = () => {
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{ title: '告警标题', dataIndex: 'alarmTitle', ellipsis: true, width: 180 },
|
||||
{ title: '告警内容', dataIndex: 'alarmContent', ellipsis: true },
|
||||
{ title: t('alerts.alarmTitle'), dataIndex: 'alarmTitle', ellipsis: true, width: 180 },
|
||||
{ title: t('alerts.alarmContent'), dataIndex: 'alarmContent', ellipsis: true },
|
||||
{
|
||||
title: t('alerts.handleStatus'),
|
||||
width: 110,
|
||||
@@ -174,7 +174,7 @@ const AlarmHistory = () => {
|
||||
fixed: 'right',
|
||||
render: (_, r) => (
|
||||
<Button type="link" icon={<EyeOutlined />} onClick={() => showDetail(r.id)}>
|
||||
查看详情
|
||||
{t('common.viewDetail')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
@@ -182,7 +182,7 @@ const AlarmHistory = () => {
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24, background: '#f5f7fa', minHeight: '100vh' }}>
|
||||
<Card title="告警历史" style={{ borderRadius: 8 }}>
|
||||
<Card title={t('alerts.alarmHistory')} style={{ borderRadius: 8 }}>
|
||||
<Form
|
||||
form={form}
|
||||
layout="inline"
|
||||
@@ -190,9 +190,9 @@ const AlarmHistory = () => {
|
||||
style={{ marginBottom: 16, flexWrap: 'wrap', gap: 16 }}
|
||||
>
|
||||
{/* 设备ID */}
|
||||
<Form.Item name="deviceId" label="设备ID">
|
||||
<Input placeholder="请输入设备ID" style={{ width: 160 }} allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="deviceId" label={t('common.deviceId')}>
|
||||
<Input placeholder={t('common.pleaseInputDeviceId')} style={{ width: 160 }} allowClear />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="alarmLevel" label={t('alerts.alertLevel')}>
|
||||
<Select placeholder={t('common.all')} style={{ width: 130 }} allowClear>
|
||||
@@ -221,7 +221,7 @@ const AlarmHistory = () => {
|
||||
</Form.Item>
|
||||
|
||||
{/* 时间范围 */}
|
||||
<Form.Item name="timeRange" label="时间范围">
|
||||
<Form.Item name="timeRange" label={t('common.timeRange')}>
|
||||
<RangePicker
|
||||
showTime
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
@@ -254,24 +254,24 @@ const AlarmHistory = () => {
|
||||
onChange={(p, s) => { setPageNum(p); setPageSize(s); }}
|
||||
showSizeChanger
|
||||
showQuickJumper
|
||||
showTotal={(total) => `共 ${total} 条`}
|
||||
showTotal={(total) => `${t('common.total')} ${total} ${t('common.items')}`}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* 右侧详情抽屉 */}
|
||||
<Drawer
|
||||
title="告警详情"
|
||||
title={t('alerts.alertDetail')}
|
||||
open={drawerVisible}
|
||||
onClose={() => setDrawerVisible(false)}
|
||||
width={650}
|
||||
destroyOnClose
|
||||
>
|
||||
<Descriptions column={1} bordered size="small" loading={detailLoading}>
|
||||
<Descriptions.Item label="告警编号">{currentAlarm?.alarmNo || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警标题">{currentAlarm?.alarmTitle || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警内容">{currentAlarm?.alarmContent || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备ID">{currentAlarm?.deviceId || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alarmNo')}>{currentAlarm?.alarmNo || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alarmTitle')}>{currentAlarm?.alarmTitle || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alarmContent')}>{currentAlarm?.alarmContent || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('common.deviceId')}>{currentAlarm?.deviceId || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('devices.deviceName')}>{currentAlarm?.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alertTime')}>
|
||||
{currentAlarm?.alarmTime ? dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss') : '-'}
|
||||
@@ -298,36 +298,36 @@ const AlarmHistory = () => {
|
||||
{currentAlarm?.handleTime ? dayjs(currentAlarm.handleTime).format('YYYY-MM-DD HH:mm:ss') : '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.handleRemark')}>{currentAlarm?.handleRemark || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="根因分析">{currentAlarm?.rootCause || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="推荐处理措施">
|
||||
<Descriptions.Item label={t('alerts.rootCause')}>{currentAlarm?.rootCause || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.recommendedAction')}>
|
||||
{currentAlarm?.handleSuggestion || '-'}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
{/* 通知订阅模块 */}
|
||||
{currentAlarm && (
|
||||
<Card size="small" title="通知订阅" style={{ marginTop: 16 }}>
|
||||
<Space style={{ width: '100%' }}>
|
||||
<Space>
|
||||
<span>短信:</span>
|
||||
<Tag color={currentAlarm.notifySms === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifySms === 1 ? '已开启' : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Space>
|
||||
<span>钉钉:</span>
|
||||
<Tag color={currentAlarm.notifyTelegram === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifyTelegram === 1 ? '已开启' : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Space>
|
||||
<span>邮件:</span>
|
||||
<Tag color={currentAlarm.notifyEmail === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifyEmail === 1 ? '已开启' : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Card size="small" title={t('alerts.notifySubscription')} style={{ marginTop: 16 }}>
|
||||
<Space style={{ width: '100%' }}>
|
||||
<Space>
|
||||
<span>{t('alerts.sms')}:</span>
|
||||
<Tag color={currentAlarm.notifySms === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifySms === 1 ? t('common.enabled') : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
</Card>
|
||||
<Space>
|
||||
<span>{t('alerts.dingTalk')}:</span>
|
||||
<Tag color={currentAlarm.notifyTelegram === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifyTelegram === 1 ? t('common.enabled') : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Space>
|
||||
<span>{t('alerts.email')}:</span>
|
||||
<Tag color={currentAlarm.notifyEmail === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifyEmail === 1 ? t('common.enabled') : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
</Space>
|
||||
</Card>
|
||||
)}
|
||||
</Drawer>
|
||||
</div>
|
||||
|
||||
@@ -156,7 +156,7 @@ export default function AlarmCenterPage() {
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
messageApi.error('加载失败');
|
||||
messageApi.error(t('common.loadFailed'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ export default function AlarmCenterPage() {
|
||||
setDrawerVisible(true);
|
||||
}
|
||||
} catch (err) {
|
||||
messageApi.error('加载详情失败');
|
||||
messageApi.error(t('common.loadDetailFailed'));
|
||||
} finally {
|
||||
setDetailLoading(false);
|
||||
}
|
||||
@@ -219,14 +219,14 @@ export default function AlarmCenterPage() {
|
||||
handleStatus: values.handleStatus,
|
||||
handleResult: values.handleResult,
|
||||
handleRemark: values.handleRemark || t('constants.handled'),
|
||||
rootCause: values.rootCause || '无'
|
||||
rootCause: values.rootCause || t('constants.none')
|
||||
});
|
||||
messageApi.success('处理成功');
|
||||
messageApi.success(t('alerts.handleSuccess'));
|
||||
setDrawerVisible(false);
|
||||
fetchList();
|
||||
fetchStat();
|
||||
} catch (err) {
|
||||
messageApi.error('处理失败');
|
||||
messageApi.error(t('alerts.handleFail'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -238,7 +238,7 @@ export default function AlarmCenterPage() {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `告警记录_${dayjs().format('YYYYMMDDHHmmss')}.xlsx`;
|
||||
a.download = `${t('alerts.exportFileName')}_${dayjs().format('YYYYMMDDHHmmss')}.xlsx`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
});
|
||||
@@ -283,23 +283,23 @@ export default function AlarmCenterPage() {
|
||||
// ====================== 表格列 ======================
|
||||
const columns = [
|
||||
{
|
||||
title: '告警编号',
|
||||
title: t('alerts.alarmNo'),
|
||||
dataIndex: 'alarmNo',
|
||||
render: (text) => <Text style={{ color: '#165DFF', fontWeight: 500 }}>{text}</Text>
|
||||
},
|
||||
{
|
||||
title: '告警标题',
|
||||
title: t('alerts.alarmTitle'),
|
||||
dataIndex: 'alarmTitle',
|
||||
ellipsis: true,
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '告警内容',
|
||||
title: t('alerts.alarmContent'),
|
||||
dataIndex: 'alarmContent',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '上报值',
|
||||
title: t('alerts.reportValue'),
|
||||
dataIndex: 'time_values',
|
||||
ellipsis: true
|
||||
},
|
||||
@@ -353,7 +353,7 @@ export default function AlarmCenterPage() {
|
||||
icon={<EyeOutlined />}
|
||||
onClick={() => showDetail(record.id)}
|
||||
>
|
||||
查看
|
||||
{t('common.view')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
@@ -361,7 +361,7 @@ export default function AlarmCenterPage() {
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => openEditModal(record)}
|
||||
>
|
||||
修改
|
||||
{t('common.modify')}
|
||||
</Button>
|
||||
</Space>
|
||||
|
||||
@@ -457,12 +457,12 @@ export default function AlarmCenterPage() {
|
||||
// ========== 修改:点击生成工单只打开弹窗,不直接请求接口 ==========
|
||||
const handleaddOrder = () => {
|
||||
if (!currentAlarm) {
|
||||
messageApi.warning('无告警信息,无法生成工单');
|
||||
messageApi.warning(t('alerts.noAlarmToCreateOrder'));
|
||||
return;
|
||||
}
|
||||
// 预填充表单
|
||||
orderForm.setFieldsValue({
|
||||
orderTitle: currentAlarm.alarmTitle || '告警生成工单',
|
||||
orderTitle: currentAlarm.alarmTitle || t('alerts.orderFromAlarm'),
|
||||
planStartTime: null
|
||||
});
|
||||
setCreateOrderModalVisible(true);
|
||||
@@ -505,14 +505,14 @@ export default function AlarmCenterPage() {
|
||||
|
||||
const res = await addWorkOrder(params);
|
||||
if (res.code === 0 || res.code === 200) {
|
||||
messageApi.success('工单生成成功');
|
||||
messageApi.success(t('alerts.orderCreated'));
|
||||
setCreateOrderModalVisible(false);
|
||||
orderForm.resetFields();
|
||||
} else {
|
||||
messageApi.error(res.msg || '工单生成失败');
|
||||
messageApi.error(res.msg || t('alerts.orderCreateFail'));
|
||||
}
|
||||
} catch (error) {
|
||||
messageApi.error('接口调用失败');
|
||||
messageApi.error(t('common.apiCallFail'));
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
@@ -524,15 +524,15 @@ export default function AlarmCenterPage() {
|
||||
<Row gutter={[8, 8]} style={{ marginBottom: 8, flexWrap: 'wrap' }}>
|
||||
{[
|
||||
{
|
||||
title: '今日告警总数',
|
||||
title: t('alerts.todayTotalAlerts'),
|
||||
value: todayData.total || 0,
|
||||
trend: (() => {
|
||||
const now = todayData.total ?? 0;
|
||||
const last = yesterdayData.total ?? 0;
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
if (last === 0) return t('alerts.trendNoChange');
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
return rateNum > 0 ? `较昨日 +${rateStr}% ↑` : rateNum < 0 ? `较昨日 ${rateStr}% ↓` : '较昨日 0%';
|
||||
return rateNum > 0 ? t('alerts.trendUp', { rate: rateStr }) : rateNum < 0 ? t('alerts.trendDown', { rate: rateStr }) : t('alerts.trendZero');
|
||||
})(),
|
||||
trendColor: (() => {
|
||||
const now = todayData.total ?? 0;
|
||||
@@ -541,21 +541,21 @@ export default function AlarmCenterPage() {
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
return rateNum > 0 ? '#FF4D4F' : rateNum < 0 ? '#00B42A' : '#86909C';
|
||||
})(),
|
||||
subText: `昨日 ${yesterdayData.total || 0}`,
|
||||
subText: t('alerts.yesterdayValue', { value: yesterdayData.total || 0 }),
|
||||
icon: <BellOutlined />,
|
||||
color: '#FF4D4F',
|
||||
bg: '#FFF1F0'
|
||||
},
|
||||
{
|
||||
title: '今日严重告警',
|
||||
title: t('alerts.todayCriticalAlerts'),
|
||||
value: todayData.levelStats?.["ERROR"] || 0,
|
||||
trend: (() => {
|
||||
const now = todayData.levelStats?.["ERROR"] ?? 0;
|
||||
const last = yesterdayData.levelStats?.["ERROR"] ?? 0;
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
if (last === 0) return t('alerts.trendNoChange');
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
return rateNum > 0 ? `较昨日 +${rateStr}% ↑` : rateNum < 0 ? `较昨日 ${rateStr}% ↓` : '较昨日 0%';
|
||||
return rateNum > 0 ? t('alerts.trendUp', { rate: rateStr }) : rateNum < 0 ? t('alerts.trendDown', { rate: rateStr }) : t('alerts.trendZero');
|
||||
})(),
|
||||
trendColor: (() => {
|
||||
const now = todayData.levelStats?.["ERROR"] ?? 0;
|
||||
@@ -564,21 +564,21 @@ export default function AlarmCenterPage() {
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
return rateNum > 0 ? '#FF4D4F' : rateNum < 0 ? '#00B42A' : '#86909C';
|
||||
})(),
|
||||
subText: `昨日 ${yesterdayData.levelStats?.["ERROR"] || 0}`,
|
||||
subText: t('alerts.yesterdayValue', { value: yesterdayData.levelStats?.["ERROR"] || 0 }),
|
||||
icon: <ExclamationCircleOutlined />,
|
||||
color: '#FF4D4F',
|
||||
bg: '#FFF1F0'
|
||||
},
|
||||
{
|
||||
title: '今日待处理',
|
||||
title: t('alerts.todayPending'),
|
||||
value: todayData.pending || 0,
|
||||
trend: (() => {
|
||||
const now = todayData.pending ?? 0;
|
||||
const last = yesterdayData.pending ?? 0;
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
if (last === 0) return t('alerts.trendNoChange');
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
return rateNum > 0 ? `较昨日 +${rateStr}% ↑` : rateNum < 0 ? `较昨日 ${rateStr}% ↓` : '较昨日 0%';
|
||||
return rateNum > 0 ? t('alerts.trendUp', { rate: rateStr }) : rateNum < 0 ? t('alerts.trendDown', { rate: rateStr }) : t('alerts.trendZero');
|
||||
})(),
|
||||
trendColor: (() => {
|
||||
const now = todayData.pending ?? 0;
|
||||
@@ -587,21 +587,21 @@ export default function AlarmCenterPage() {
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
return rateNum > 0 ? '#FF4D4F' : rateNum < 0 ? '#00B42A' : '#86909C';
|
||||
})(),
|
||||
subText: `昨日 ${yesterdayData.pending || 0}`,
|
||||
subText: t('alerts.yesterdayValue', { value: yesterdayData.pending || 0 }),
|
||||
icon: <ClockCircleOutlined />,
|
||||
color: '#FA8C16',
|
||||
bg: '#FFF7E8'
|
||||
},
|
||||
{
|
||||
title: '今日已关闭',
|
||||
title: t('alerts.todayClosed'),
|
||||
value: todayData.closed || 0,
|
||||
trend: (() => {
|
||||
const now = todayData.closed ?? 0;
|
||||
const last = yesterdayData.closed ?? 0;
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
if (last === 0) return t('alerts.trendNoChange');
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
return rateNum > 0 ? `较昨日 +${rateStr}% ↑` : rateNum < 0 ? `较昨日 ${rateStr}% ↓` : '较昨日 0%';
|
||||
return rateNum > 0 ? t('alerts.trendUp', { rate: rateStr }) : rateNum < 0 ? t('alerts.trendDown', { rate: rateStr }) : t('alerts.trendZero');
|
||||
})(),
|
||||
trendColor: (() => {
|
||||
const now = todayData.closed ?? 0;
|
||||
@@ -610,7 +610,7 @@ export default function AlarmCenterPage() {
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
return rateNum > 0 ? '#FF4D4F' : rateNum < 0 ? '#00B42A' : '#86909C';
|
||||
})(),
|
||||
subText: `昨日 ${yesterdayData.closed || 0}`,
|
||||
subText: t('alerts.yesterdayValue', { value: yesterdayData.closed || 0 }),
|
||||
icon: <CheckCircleOutlined />,
|
||||
color: '#00B42A',
|
||||
bg: '#E8FFEA'
|
||||
@@ -683,9 +683,9 @@ export default function AlarmCenterPage() {
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>设备ID</div>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>{t('common.deviceId')}</div>
|
||||
<Input
|
||||
placeholder="设备ID"
|
||||
placeholder={t('common.deviceId')}
|
||||
value={queryParams.deviceId}
|
||||
onChange={e => setQueryParams({ ...queryParams, deviceId: e.target.value })}
|
||||
style={{ width: 280 }}
|
||||
@@ -697,7 +697,7 @@ export default function AlarmCenterPage() {
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>时间范围</div>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>{t('common.timeRange')}</div>
|
||||
<RangePicker
|
||||
showTime
|
||||
style={{ width: 320 }}
|
||||
@@ -732,10 +732,10 @@ export default function AlarmCenterPage() {
|
||||
fetchStat(); // 刷新统计
|
||||
fetchChartAllAlarm(); // 新增:刷新图表全量告警
|
||||
}}>
|
||||
<SearchOutlined />查询
|
||||
<SearchOutlined />{t('common.search2')}
|
||||
</Button>
|
||||
<Button style={{ borderRadius: 8 }} onClick={doExport}>
|
||||
<FileTextOutlined />导出
|
||||
<FileTextOutlined />{t('common.export')}
|
||||
</Button>
|
||||
</Space>
|
||||
</Col>
|
||||
@@ -807,7 +807,7 @@ export default function AlarmCenterPage() {
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警分类占比" style={{ borderRadius: 8 }}>
|
||||
<Card bordered={false} title={t('alerts.alertTypeProportion')} style={{ borderRadius: 8 }}>
|
||||
<UniversalPieChart
|
||||
data={pieData}
|
||||
height={220}
|
||||
@@ -818,7 +818,7 @@ export default function AlarmCenterPage() {
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警状态统计" style={{ borderRadius: 8 }}>
|
||||
<Card bordered={false} title={t('alerts.alertStatusStatistics')} style={{ borderRadius: 8 }}>
|
||||
<UniversalBarChart
|
||||
data={[
|
||||
{
|
||||
@@ -839,7 +839,7 @@ export default function AlarmCenterPage() {
|
||||
series={[
|
||||
{
|
||||
key: 'pending',
|
||||
name: '数量',
|
||||
name: t('common.quantity'),
|
||||
color: '#165DFF',
|
||||
},
|
||||
]}
|
||||
@@ -849,9 +849,9 @@ export default function AlarmCenterPage() {
|
||||
</Row>
|
||||
|
||||
{/* 告警详情抽屉 */}
|
||||
<Drawer
|
||||
title="告警详情"
|
||||
open={drawerVisible}
|
||||
<Drawer
|
||||
title={t('alerts.alertDetail')}
|
||||
open={drawerVisible}
|
||||
onClose={() => setDrawerVisible(false)}
|
||||
width={480}
|
||||
destroyOnClose
|
||||
@@ -872,15 +872,15 @@ export default function AlarmCenterPage() {
|
||||
<span style={{ fontSize: 16, fontWeight: 700 }}>{currentAlarm.alarmTitle}</span>
|
||||
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: '#86909C' }}>告警编号:{currentAlarm.alarmNo}</div>
|
||||
<div style={{ fontSize: 12, color: '#86909C' }}>{t('alerts.alarmNo')}:{currentAlarm.alarmNo}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 告警基础信息 */}
|
||||
<Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}>
|
||||
<Descriptions.Item label="来源设备">{currentAlarm.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alertType')}>{alarmTypeMap[currentAlarm.alarmType] || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="发生时间">{dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss')}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.sourceDevice')}>{currentAlarm.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alertType')}>{alarmTypeMap[currentAlarm.alarmType] || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.occurTime')}>{dayjs(currentAlarm.alarmTime).format('YYYY-MM-DD HH:mm:ss')}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.handleStatus')}>
|
||||
{(() => {
|
||||
let color = 'default';
|
||||
@@ -899,23 +899,23 @@ export default function AlarmCenterPage() {
|
||||
</Descriptions>
|
||||
|
||||
{/* 告警描述 */}
|
||||
<Card size="small" title="告警描述" style={{ marginBottom: 16 }}>
|
||||
<Card size="small" title={t('alerts.alertDescription')} style={{ marginBottom: 16 }}>
|
||||
<div style={{ color: '#333' }}>{currentAlarm.alarmContent || '-'}</div>
|
||||
</Card>
|
||||
|
||||
{/* 根因分析 */}
|
||||
|
||||
{/* 推荐处理措施 */}
|
||||
<Card size="small" title="推荐处理措施" style={{ marginBottom: 16 }}>
|
||||
<Card size="small" title={t('alerts.recommendedAction')} style={{ marginBottom: 16 }}>
|
||||
<div style={{ color: '#333' }}>{currentAlarm.handleSuggestion || '-'}</div>
|
||||
<div className="flex justify-between">
|
||||
<div>
|
||||
|
||||
</div>
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 12 }}>
|
||||
<Button type="default" onClick={handleContactUser}>联系负责人</Button>
|
||||
<Button type="default" onClick={handleContactUser}>{t('alerts.contactHandler')}</Button>
|
||||
<Button type="primary" onClick={handleaddOrder}>
|
||||
生成工单
|
||||
{t('workOrder.generateOrder')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -923,33 +923,33 @@ export default function AlarmCenterPage() {
|
||||
</Card>
|
||||
|
||||
{/* 处理操作 */}
|
||||
<Card size="small" title="处理操作" style={{ marginBottom: 16 }}>
|
||||
<Form.Item label={t('alerts.handleStatus')} name="handleStatus" rules={[{ required: true, message: '请选择处理状态' }]}>
|
||||
<Select>
|
||||
<Option value={1}>{t('constants.pending')}</Option>
|
||||
<Card size="small" title={t('alerts.handleOperation')} style={{ marginBottom: 16 }}>
|
||||
<Form.Item label={t('alerts.handleStatus')} name="handleStatus" rules={[{ required: true, message: t('alerts.pleaseSelectHandleStatus') }]}>
|
||||
<Select>
|
||||
<Option value={1}>{t('constants.pending')}</Option>
|
||||
|
||||
<Option value={2}>{t('constants.closed')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.handleResult')} name="handleResult" rules={[{ required: true, message: '请选择确认处理结果' }]}>
|
||||
<Select
|
||||
placeholder="请选择确认处理结果"
|
||||
options={alarmHandleResultOptions}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="根因分析" name="rootCause">
|
||||
<Input.TextArea rows={2} placeholder="请输入处理备注" />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.handleRemark')} name="handleRemark">
|
||||
<Input.TextArea rows={2} placeholder="请输入处理备注" />
|
||||
</Form.Item>
|
||||
<Option value={2}>{t('constants.closed')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.handleResult')} name="handleResult" rules={[{ required: true, message: t('alerts.pleaseSelectHandleResult') }]}>
|
||||
<Select
|
||||
placeholder={t('alerts.pleaseSelectHandleResult')}
|
||||
options={alarmHandleResultOptions}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.rootCause')} name="rootCause">
|
||||
<Input.TextArea rows={2} placeholder={t('alerts.pleaseInputHandleRemark')} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('alerts.handleRemark')} name="handleRemark">
|
||||
<Input.TextArea rows={2} placeholder={t('alerts.pleaseInputHandleRemark')} />
|
||||
</Form.Item>
|
||||
|
||||
|
||||
|
||||
</Card>
|
||||
</Card>
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<Button type="primary" block htmlType="submit">确认处理</Button>
|
||||
{/* 底部按钮 */}
|
||||
<Button type="primary" block htmlType="submit">{t('alerts.confirmHandle')}</Button>
|
||||
|
||||
</>
|
||||
</Form>
|
||||
@@ -958,9 +958,9 @@ export default function AlarmCenterPage() {
|
||||
</Drawer>
|
||||
|
||||
{/* ====================== 修改告警弹窗 ====================== */}
|
||||
<Modal
|
||||
title="修改告警"
|
||||
open={editModalVisible}
|
||||
<Modal
|
||||
title={t('alerts.modifyAlert')}
|
||||
open={editModalVisible}
|
||||
onCancel={() => setEditModalVisible(false)}
|
||||
footer={null}
|
||||
width={520}
|
||||
@@ -976,17 +976,17 @@ export default function AlarmCenterPage() {
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="告警标题"
|
||||
label={t('alerts.alarmTitle')}
|
||||
name="alarmTitle"
|
||||
rules={[{ required: true, message: '请输入告警标题' }]}
|
||||
rules={[{ required: true, message: t('alerts.pleaseInputAlarmTitle') }]}
|
||||
>
|
||||
<Input placeholder="请输入告警标题" />
|
||||
<Input placeholder={t('alerts.pleaseInputAlarmTitle')} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label={t('alerts.alertLevel')}
|
||||
name="alarmLevel"
|
||||
rules={[{ required: true, message: '请选择告警级别' }]}
|
||||
rules={[{ required: true, message: t('alerts.pleaseSelectAlertLevel') }]}
|
||||
>
|
||||
<Select options={errorLevelOptions}>
|
||||
|
||||
@@ -996,7 +996,7 @@ export default function AlarmCenterPage() {
|
||||
<Form.Item
|
||||
label={t('alerts.alertType')}
|
||||
name="alarmType"
|
||||
rules={[{ required: true, message: '请选择告警类型' }]}
|
||||
rules={[{ required: true, message: t('alerts.pleaseSelectAlertType') }]}
|
||||
>
|
||||
<Select>
|
||||
<Option value="UAV_FAULT">{t('constants.uavFault')}</Option>
|
||||
@@ -1008,17 +1008,17 @@ export default function AlarmCenterPage() {
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="告警内容"
|
||||
label={t('alerts.alarmContent')}
|
||||
name="alarmContent"
|
||||
rules={[{ required: true, message: '请输入告警内容' }]}
|
||||
rules={[{ required: true, message: t('alerts.pleaseInputAlarmContent') }]}
|
||||
>
|
||||
<Input.TextArea rows={4} placeholder="请输入告警内容" />
|
||||
<Input.TextArea rows={4} placeholder={t('alerts.pleaseInputAlarmContent')} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item style={{ textAlign: 'right', marginBottom: 0 }}>
|
||||
<Button onClick={() => setEditModalVisible(false)}>{t('common.cancel')}</Button>
|
||||
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>
|
||||
确认修改
|
||||
{t('workOrder.confirmModify')}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
@@ -1026,7 +1026,7 @@ export default function AlarmCenterPage() {
|
||||
|
||||
{/* ========== 新增:生成工单弹窗 ========== */}
|
||||
<Modal
|
||||
title="新建工单"
|
||||
title={t('alerts.newOrder')}
|
||||
open={createOrderModalVisible}
|
||||
onCancel={() => {
|
||||
setCreateOrderModalVisible(false);
|
||||
@@ -1050,14 +1050,14 @@ export default function AlarmCenterPage() {
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="计划开始时间"
|
||||
label={t('alerts.planStartTime')}
|
||||
name="planStartTime"
|
||||
rules={[{ required: true, message: '请选择计划开始时间' }]}
|
||||
rules={[{ required: true, message: t('alerts.pleaseSelectPlanStartTime') }]}
|
||||
>
|
||||
<DatePicker
|
||||
showTime
|
||||
style={{ width: '100%' }}
|
||||
placeholder="请选择计划开始时间"
|
||||
placeholder={t('alerts.pleaseSelectPlanStartTime')}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
@@ -1065,7 +1065,7 @@ export default function AlarmCenterPage() {
|
||||
<Form.Item style={{ textAlign: 'right', marginBottom: 0 }}>
|
||||
<Button onClick={() => setCreateOrderModalVisible(false)}>{t('common.cancel')}</Button>
|
||||
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>
|
||||
确认生成工单
|
||||
{t('alerts.confirmCreateOrder')}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
} from 'antd';
|
||||
import { EyeOutlined } from '@ant-design/icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18n from '../i18n';
|
||||
|
||||
const AntdCard = Card as any;
|
||||
const { Search } = Input;
|
||||
@@ -12,9 +13,9 @@ const { Option } = Select;
|
||||
|
||||
// 模拟数据
|
||||
const mockAlarms = [
|
||||
{ id: 1, deviceName: '1#环境传感器', level: 'warn', content: '温度超过阈值 62℃', time: '2026-05-07 10:24:00', status: 'unprocessed' },
|
||||
{ id: 2, deviceName: '2#阵列区球机', level: 'error', content: '视频信号丢失', time: '2026-05-07 10:20:00', status: 'processing' },
|
||||
{ id: 3, deviceName: '3#电池供电设备', level: 'info', content: '电量低于20%', time: '2026-05-07 09:50:00', status: 'processed' },
|
||||
{ id: 1, deviceName: i18n.t('alerts.mockDeviceSensor'), level: 'warn', content: i18n.t('alerts.mockTempExceed', { value: 62 }), time: '2026-05-07 10:24:00', status: 'unprocessed' },
|
||||
{ id: 2, deviceName: i18n.t('alerts.mockDeviceCamera'), level: 'error', content: i18n.t('alerts.mockVideoSignalLost'), time: '2026-05-07 10:20:00', status: 'processing' },
|
||||
{ id: 3, deviceName: i18n.t('alerts.mockDeviceBattery'), level: 'info', content: i18n.t('alerts.mockBatteryLow', { value: 20 }), time: '2026-05-07 09:50:00', status: 'processed' },
|
||||
];
|
||||
|
||||
const AlarmRealtime = () => {
|
||||
@@ -46,22 +47,22 @@ const AlarmRealtime = () => {
|
||||
// 表格列
|
||||
const columns = [
|
||||
{ title: t('common.time'), dataIndex: 'time', width: 180 },
|
||||
{ title: '设备', dataIndex: 'deviceName' },
|
||||
{ title: t('devices.device'), dataIndex: 'deviceName' },
|
||||
{
|
||||
title: '级别',
|
||||
title: t('alerts.level'),
|
||||
render: (l: any) => {
|
||||
const color = l.level === 'warn' ? 'orange' : l.level === 'error' ? 'red' : 'blue';
|
||||
const text = l.level === 'warn' ? t('constants.warning') : l.level === 'error' ? t('constants.critical') : t('constants.info');
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '内容', dataIndex: 'content' },
|
||||
{ title: t('alerts.content'), dataIndex: 'content' },
|
||||
{
|
||||
title: t('roles.status'),
|
||||
render: (r: any) => {
|
||||
const statusMap = {
|
||||
unprocessed: { status: 'error', text: t('home.unhandled') },
|
||||
processing: { status: 'warning', text: '处理中' },
|
||||
processing: { status: 'warning', text: t('alerts.processing') },
|
||||
processed: { status: 'success', text: t('constants.handled') },
|
||||
closed: { status: 'default', text: t('constants.closed') },
|
||||
};
|
||||
@@ -73,7 +74,7 @@ const AlarmRealtime = () => {
|
||||
title: t('roles.actions'),
|
||||
render: (_: any, record: any) => (
|
||||
<Button type="link" icon={<EyeOutlined />} onClick={() => showDetail(record)}>
|
||||
详情
|
||||
{t('common.detail')}
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
@@ -84,11 +85,11 @@ const AlarmRealtime = () => {
|
||||
<AntdCard
|
||||
title={t('alerts.realtimeAlert')}
|
||||
extra={
|
||||
<Search
|
||||
placeholder="搜索设备名称/告警内容"
|
||||
style={{ width: 260 }}
|
||||
onSearch={handleSearch}
|
||||
/>
|
||||
<Search
|
||||
placeholder={t('alerts.searchDeviceContent')}
|
||||
style={{ width: 260 }}
|
||||
onSearch={handleSearch}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{/* 表格 */}
|
||||
@@ -102,7 +103,7 @@ const AlarmRealtime = () => {
|
||||
|
||||
{/* 告警详情弹窗 */}
|
||||
<Modal
|
||||
title="告警详情"
|
||||
title={t('alerts.alertDetail')}
|
||||
open={detailVisible}
|
||||
onCancel={() => setDetailVisible(false)}
|
||||
footer={null}
|
||||
@@ -112,7 +113,7 @@ const AlarmRealtime = () => {
|
||||
<Descriptions column={1} bordered>
|
||||
<Descriptions.Item label={t('alerts.alertTime')}>{currentAlarm.time}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('devices.deviceName')}>{currentAlarm.deviceName}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警内容">{currentAlarm.content}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alarmContent')}>{currentAlarm.content}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alertLevel')}>
|
||||
<Tag color={currentAlarm.level === 'warn' ? 'orange' : currentAlarm.level === 'error' ? 'red' : 'blue'}>
|
||||
{currentAlarm.level === 'warn' ? t('constants.warning') : currentAlarm.level === 'error' ? t('constants.critical') : t('constants.info')}
|
||||
@@ -126,7 +127,7 @@ const AlarmRealtime = () => {
|
||||
}
|
||||
text={
|
||||
currentAlarm.status === 'unprocessed' ? t('home.unhandled') :
|
||||
currentAlarm.status === 'processing' ? '处理中' : t('constants.handled')
|
||||
currentAlarm.status === 'processing' ? t('alerts.processing') : t('constants.handled')
|
||||
}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
|
||||
@@ -8,14 +8,15 @@ import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
// 从你的设备接入页面 导入 物模型数据
|
||||
//import { modelList, modelDetailList } from './DeviceAccessPage';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18n from '../i18n';
|
||||
|
||||
const AntdCard = Card as any;
|
||||
const { Search } = Input;
|
||||
|
||||
// 模拟数据
|
||||
const mockRules = [
|
||||
{ id: 1, name: '温度超温', deviceType: 'sensor', modelId:11, propCode:'temp', level: 'warn', condition: 'temp > 60', status: true },
|
||||
{ id: 2, name: '电池低电量', deviceType: 'battery', modelId:12, propCode:'battery', level: 'info', condition: 'battery < 20', status: false },
|
||||
{ id: 1, name: i18n.t('alerts.mockRuleTemp'), deviceType: 'sensor', modelId:11, propCode:'temp', level: 'warn', condition: 'temp > 60', status: true },
|
||||
{ id: 2, name: i18n.t('alerts.mockRuleBattery'), deviceType: 'battery', modelId:12, propCode:'battery', level: 'info', condition: 'battery < 20', status: false },
|
||||
];
|
||||
|
||||
const AlarmRules = () => {
|
||||
@@ -28,9 +29,9 @@ const AlarmRules = () => {
|
||||
|
||||
// 下拉选项
|
||||
const [deviceTypeOpts, setDeviceTypeOpts] = useState([
|
||||
{ value: 'sensor', label: '传感器' },
|
||||
{ value: 'sensor', label: t('alerts.deviceSensor') },
|
||||
{ value: 'camera', label: t('devices.camera') },
|
||||
{ value: 'battery', label: '电池设备' },
|
||||
{ value: 'battery', label: t('alerts.deviceBattery') },
|
||||
]);
|
||||
const [propList, setPropList] = useState<any[]>([]);
|
||||
|
||||
@@ -104,7 +105,7 @@ const AlarmRules = () => {
|
||||
//}, [form.getFieldValue('modelId')]);
|
||||
|
||||
const columns = [
|
||||
{ title: '规则名称', dataIndex: 'name' },
|
||||
{ title: t('alerts.ruleName'), dataIndex: 'name' },
|
||||
{ title: t('devices.deviceType'), dataIndex: 'deviceType' },
|
||||
{
|
||||
title: t('alerts.alertLevel'),
|
||||
@@ -114,17 +115,17 @@ const AlarmRules = () => {
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '触发条件', dataIndex: 'condition' },
|
||||
{ title: t('alerts.triggerCondition'), dataIndex: 'condition' },
|
||||
{
|
||||
title: t('roles.status'),
|
||||
render: (r: any) => <Badge status={r.status ? 'success' : 'error'} text={r.status ? t('common.enable') : '禁用'} />
|
||||
render: (r: any) => <Badge status={r.status ? 'success' : 'error'} text={r.status ? t('common.enable') : t('common.disable')} />
|
||||
},
|
||||
{
|
||||
title: t('roles.actions'),
|
||||
render: (r: any) => (
|
||||
<Space>
|
||||
<Button type="link" icon={<EditOutlined />} onClick={() => openEdit(r)}>{t('roles.edit')}</Button>
|
||||
<Popconfirm onConfirm={() => handleDelete(r.id)}><Button type="link" danger>roles.delete</Button></Popconfirm>
|
||||
<Popconfirm onConfirm={() => handleDelete(r.id)}><Button type="link" danger>{t('roles.delete')}</Button></Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
@@ -133,11 +134,11 @@ const AlarmRules = () => {
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
<AntdCard
|
||||
title="告警规则配置"
|
||||
title={t('alerts.ruleConfig')}
|
||||
extra={
|
||||
<Space>
|
||||
<Search placeholder={t('common.search')} style={{ width: 260 }} onSearch={handleSearch} />
|
||||
<Button icon={<PlusOutlined />} type="primary" onClick={openAdd}>新增规则</Button>
|
||||
<Button icon={<PlusOutlined />} type="primary" onClick={openAdd}>{t('alerts.addRule')}</Button>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
@@ -145,15 +146,15 @@ const AlarmRules = () => {
|
||||
</AntdCard>
|
||||
|
||||
<Modal
|
||||
title={editingId ? '编辑规则' : '新增规则'}
|
||||
title={editingId ? t('alerts.editRule') : t('alerts.addRule')}
|
||||
open={modalVisible}
|
||||
onCancel={() => setModalVisible(false)}
|
||||
onOk={handleSave}
|
||||
width={600}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item label="规则名称" name="name" rules={[{ required: true }]}>
|
||||
<Input placeholder="例如:温度超上限" />
|
||||
<Form.Item label={t('alerts.ruleName')} name="name" rules={[{ required: true }]}>
|
||||
<Input placeholder={t('alerts.ruleNamePlaceholder')} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label={t('devices.deviceType')} name="deviceType" rules={[{ required: true }]}>
|
||||
@@ -162,7 +163,7 @@ const AlarmRules = () => {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="关联物模型" name="modelId" rules={[{ required: true }]}>
|
||||
<Form.Item label={t('alerts.relatedModel')} name="modelId" rules={[{ required: true }]}>
|
||||
<Select
|
||||
onChange={(val) => {
|
||||
form.setFieldValue('modelId', val);
|
||||
@@ -175,7 +176,7 @@ const AlarmRules = () => {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="监控属性" name="propCode" rules={[{ required: true }]}>
|
||||
<Form.Item label={t('alerts.monitorProperty')} name="propCode" rules={[{ required: true }]}>
|
||||
<Select>
|
||||
{propList.map(p => (
|
||||
<Select.Option key={p.value} value={p.value}>{p.label}</Select.Option>
|
||||
@@ -183,16 +184,16 @@ const AlarmRules = () => {
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="比较符号" name="symbol" rules={[{ required: true }]}>
|
||||
<Form.Item label={t('alerts.compareSymbol')} name="symbol" rules={[{ required: true }]}>
|
||||
<Select style={{ width: 100 }}>
|
||||
<Select.Option value=">">大于 </Select.Option>
|
||||
<Select.Option value="<">小于 </Select.Option>
|
||||
<Select.Option value="==">等于 ==</Select.Option>
|
||||
<Select.Option value=">">{t('constants.gt')} </Select.Option>
|
||||
<Select.Option value="<">{t('constants.lt')} </Select.Option>
|
||||
<Select.Option value="==">{t('constants.eq')} ==</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="阈值" name="threshold" rules={[{ required: true }]}>
|
||||
<Input placeholder="填写数值" />
|
||||
<Form.Item label={t('alerts.threshold')} name="threshold" rules={[{ required: true }]}>
|
||||
<Input placeholder={t('alerts.thresholdPlaceholder')} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label={t('alerts.alertLevel')} name="level" rules={[{ required: true }]}>
|
||||
|
||||
@@ -41,8 +41,8 @@ const AlarmStatistics = () => {
|
||||
const chart = echarts.init(barChartRef.current);
|
||||
|
||||
const option = {
|
||||
title: { text: '近7天告警趋势', textStyle: { fontSize: 14 } },
|
||||
xAxis: { type: 'category', data: ['1日', '2日', '3日', '4日', '5日', '6日', '7日'] },
|
||||
title: { text: t('alerts.sevenDayTrend'), textStyle: { fontSize: 14 } },
|
||||
xAxis: { type: 'category', data: [t('devices.daySuffix', { day: 1 }), t('devices.daySuffix', { day: 2 }), t('devices.daySuffix', { day: 3 }), t('devices.daySuffix', { day: 4 }), t('devices.daySuffix', { day: 5 }), t('devices.daySuffix', { day: 6 }), t('devices.daySuffix', { day: 7 })] },
|
||||
yAxis: { type: 'value' },
|
||||
series: [{
|
||||
data: [5, 8, 12, 9, 15, 7, statData.total || 2],
|
||||
@@ -66,14 +66,14 @@ const AlarmStatistics = () => {
|
||||
const chart = echarts.init(pieChartRef.current);
|
||||
|
||||
const pieData = [
|
||||
{ value: statData.levelStats?.[1] || 0, name: '严重告警' },
|
||||
{ value: statData.levelStats?.[2] || 0, name: '重要告警' },
|
||||
{ value: statData.levelStats?.[3] || 0, name: '一般告警' },
|
||||
{ value: statData.levelStats?.[4] || 0, name: '提示告警' },
|
||||
{ value: statData.levelStats?.[1] || 0, name: t('alerts.criticalAlert') },
|
||||
{ value: statData.levelStats?.[2] || 0, name: t('alerts.importantAlert') },
|
||||
{ value: statData.levelStats?.[3] || 0, name: t('alerts.generalAlert') },
|
||||
{ value: statData.levelStats?.[4] || 0, name: t('alerts.infoAlert') },
|
||||
].filter(i => i.value > 0);
|
||||
|
||||
const option = {
|
||||
title: { text: '告警级别分布' },
|
||||
title: { text: t('alerts.alertLevelDistribution') },
|
||||
tooltip: { trigger: 'item' },
|
||||
legend: { bottom: 0 },
|
||||
series: [{
|
||||
@@ -119,7 +119,7 @@ const AlarmStatistics = () => {
|
||||
<ExclamationCircleOutlined style={{ fontSize: 24, color: '#F53F3F' }} />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>严重告警</div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>{t('alerts.criticalAlert')}</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 700 }}>{statData.levelStats?.[1] || 0}</div>
|
||||
</div>
|
||||
</Space>
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
} from 'antd';
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18n from '../i18n';
|
||||
|
||||
const AntdCard = Card as any;
|
||||
const { Option } = Select;
|
||||
@@ -12,9 +13,9 @@ const { Search } = Input;
|
||||
|
||||
// 模拟数据
|
||||
const mockSub = [
|
||||
{ id: 1, name: '运维订阅', deviceType: 'all', level: 'all', channels: ['短信'] },
|
||||
{ id: 2, name: '管理员订阅', deviceType: 'sensor', level: 'error', channels: ['短信', '邮件'] },
|
||||
{ id: 3, name: '设备订阅', deviceType: 'camera', level: 'warn', channels: ['APP推送'] },
|
||||
{ id: 1, name: i18n.t('alerts.mockSubOps'), deviceType: 'all', level: 'all', channels: ['短信'] },
|
||||
{ id: 2, name: i18n.t('alerts.mockSubAdmin'), deviceType: 'sensor', level: 'error', channels: ['短信', '邮件'] },
|
||||
{ id: 3, name: i18n.t('alerts.mockSubDevice'), deviceType: 'camera', level: 'warn', channels: ['APP推送'] },
|
||||
];
|
||||
|
||||
const AlarmSubscription = () => {
|
||||
@@ -25,6 +26,13 @@ const AlarmSubscription = () => {
|
||||
const [editingId, setEditingId] = useState<number | null>(null);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
// 通知渠道显示映射(值为稳定编码,显示时翻译)
|
||||
const channelLabelMap = {
|
||||
'短信': t('alerts.sms'),
|
||||
'邮件': t('alerts.email'),
|
||||
'APP推送': t('alerts.appPush'),
|
||||
};
|
||||
|
||||
// 搜索筛选
|
||||
const handleSearch = (value) => {
|
||||
const res = list.filter(item =>
|
||||
@@ -78,12 +86,12 @@ const AlarmSubscription = () => {
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{ title: '订阅名称', dataIndex: 'name' },
|
||||
{ title: t('alerts.subscriptionName'), dataIndex: 'name' },
|
||||
{ title: t('devices.deviceType'), dataIndex: 'deviceType' },
|
||||
{ title: t('alerts.alertLevel'), dataIndex: 'level' },
|
||||
{
|
||||
title: '通知渠道',
|
||||
render: (r) => r.channels.map(i => <Tag key={i}>{i}</Tag>)
|
||||
title: t('alerts.notifyChannel'),
|
||||
render: (r) => r.channels.map(i => <Tag key={i}>{channelLabelMap[i] || i}</Tag>)
|
||||
},
|
||||
{
|
||||
title: t('roles.actions'),
|
||||
@@ -104,14 +112,14 @@ const AlarmSubscription = () => {
|
||||
title={t('alerts.alarmSubscription')}
|
||||
extra={
|
||||
<Space>
|
||||
<Search
|
||||
placeholder="搜索订阅/设备/级别"
|
||||
style={{ width: 260 }}
|
||||
onSearch={handleSearch}
|
||||
/>
|
||||
<Button icon={<PlusOutlined />} type="primary" onClick={openAdd}>
|
||||
新增订阅
|
||||
</Button>
|
||||
<Search
|
||||
placeholder={t('alerts.searchSubscription')}
|
||||
style={{ width: 260 }}
|
||||
onSearch={handleSearch}
|
||||
/>
|
||||
<Button icon={<PlusOutlined />} type="primary" onClick={openAdd}>
|
||||
{t('alerts.addSubscription')}
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
@@ -125,40 +133,40 @@ const AlarmSubscription = () => {
|
||||
|
||||
{/* 新增/编辑 弹窗 */}
|
||||
<Modal
|
||||
title={editingId ? '编辑告警订阅' : '新增告警订阅'}
|
||||
title={editingId ? t('alerts.editAlertSubscription') : t('alerts.addAlertSubscription')}
|
||||
open={modalVisible}
|
||||
onCancel={() => setModalVisible(false)}
|
||||
onOk={handleSave}
|
||||
maskClosable={false}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item label="订阅名称" name="name" rules={[{ required: true }]}>
|
||||
<Input placeholder="请输入订阅名称" />
|
||||
<Form.Item label={t('alerts.subscriptionName')} name="name" rules={[{ required: true }]}>
|
||||
<Input placeholder={t('alerts.pleaseInputSubscriptionName')} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label={t('devices.deviceType')} name="deviceType" rules={[{ required: true }]}>
|
||||
<Select>
|
||||
<Option value="all">全部设备</Option>
|
||||
<Option value="sensor">传感器</Option>
|
||||
<Option value="all">{t('alerts.allDevices')}</Option>
|
||||
<Option value="sensor">{t('alerts.deviceSensor')}</Option>
|
||||
<Option value="camera">{t('devices.camera')}</Option>
|
||||
<Option value="battery">电池设备</Option>
|
||||
<Option value="battery">{t('alerts.deviceBattery')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label={t('alerts.alertLevel')} name="level" rules={[{ required: true }]}>
|
||||
<Select>
|
||||
<Option value="all">全部级别</Option>
|
||||
<Option value="all">{t('alerts.allLevels')}</Option>
|
||||
<Option value="error">{t('constants.critical')}</Option>
|
||||
<Option value="warn">{t('constants.warning')}</Option>
|
||||
<Option value="info">{t('constants.info')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="通知渠道" name="channels" rules={[{ required: true }]}>
|
||||
<Select mode="multiple" placeholder="请选择通知渠道">
|
||||
<Option value="短信">短信</Option>
|
||||
<Option value="邮件">邮件</Option>
|
||||
<Option value="APP推送">APP推送</Option>
|
||||
<Form.Item label={t('alerts.notifyChannel')} name="channels" rules={[{ required: true }]}>
|
||||
<Select mode="multiple" placeholder={t('alerts.pleaseSelectChannel')}>
|
||||
<Option value="短信">{t('alerts.sms')}</Option>
|
||||
<Option value="邮件">{t('alerts.email')}</Option>
|
||||
<Option value="APP推送">{t('alerts.appPush')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
Reference in New Issue
Block a user