中英文切换 初始化
This commit is contained in:
@@ -12,23 +12,25 @@ import {
|
||||
getAlarmDetail
|
||||
} from '../../api/alarmApi.js';
|
||||
import { alarmTypeMap } from '@/constants.js';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { t } from 'i18next';
|
||||
|
||||
const { Option } = Select;
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
|
||||
const alarmLevelConfig = {
|
||||
1: { description: '严重', color: '#FF4D4F' },
|
||||
2: { description: '重要', color: '#FA8C16' },
|
||||
3: { description: '一般', color: '#FADB14' },
|
||||
4: { description: '提示', color: '#1890FF' }
|
||||
1: { description: t('constants.critical'), color: '#FF4D4F' },
|
||||
2: { description: t('constants.important'), color: '#FA8C16' },
|
||||
3: { description: t('constants.general'), color: '#FADB14' },
|
||||
4: { description: t('constants.info'), color: '#1890FF' }
|
||||
};
|
||||
|
||||
const handleStatusMap = {
|
||||
1: '待处理',
|
||||
1: t('constants.pending'),
|
||||
2: '处理中',
|
||||
3: '已关闭',
|
||||
4: '已忽略'
|
||||
3: t('constants.closed'),
|
||||
4: t('constants.ignored')
|
||||
};
|
||||
|
||||
// 自动生成颜色/文字映射
|
||||
@@ -43,6 +45,7 @@ const levelText = Object.keys(alarmLevelConfig).reduce((map, key) => {
|
||||
}, {});
|
||||
|
||||
const AlarmHistory = () => {
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
|
||||
// 抽屉
|
||||
@@ -128,21 +131,21 @@ const AlarmHistory = () => {
|
||||
const columns = [
|
||||
{ title: '告警编号', dataIndex: 'alarmNo', width: 180 },
|
||||
{
|
||||
title: '告警时间',
|
||||
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: '设备名称', dataIndex: 'deviceName', ellipsis: true },
|
||||
{ title: t('devices.deviceName'), dataIndex: 'deviceName', ellipsis: true },
|
||||
{
|
||||
title: '告警类型',
|
||||
title: t('alerts.alertType'),
|
||||
dataIndex: 'alarmType',
|
||||
width: 130,
|
||||
render: (t) => alarmTypeMap[t] || '-'
|
||||
},
|
||||
{
|
||||
title: '告警级别',
|
||||
title: t('alerts.alertLevel'),
|
||||
width: 100,
|
||||
render: (r) => (
|
||||
<Tag color={levelColor[r.alarmLevel]} style={{ border: 'none', color: '#fff' }}>
|
||||
@@ -153,7 +156,7 @@ const AlarmHistory = () => {
|
||||
{ title: '告警标题', dataIndex: 'alarmTitle', ellipsis: true, width: 180 },
|
||||
{ title: '告警内容', dataIndex: 'alarmContent', ellipsis: true },
|
||||
{
|
||||
title: '处理状态',
|
||||
title: t('alerts.handleStatus'),
|
||||
width: 110,
|
||||
render: (r) => {
|
||||
const s = r.handleStatus;
|
||||
@@ -166,7 +169,7 @@ const AlarmHistory = () => {
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: t('roles.actions'),
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
render: (_, r) => (
|
||||
@@ -191,29 +194,29 @@ const AlarmHistory = () => {
|
||||
<Input placeholder="请输入设备ID" style={{ width: 160 }} allowClear />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="alarmLevel" label="告警级别">
|
||||
<Select placeholder="全部" style={{ width: 130 }} allowClear>
|
||||
<Option value={1}>严重</Option>
|
||||
<Option value={2}>重要</Option>
|
||||
<Option value={3}>一般</Option>
|
||||
<Option value={4}>提示</Option>
|
||||
<Form.Item name="alarmLevel" label={t('alerts.alertLevel')}>
|
||||
<Select placeholder={t('common.all')} style={{ width: 130 }} allowClear>
|
||||
<Option value={1}>{t('constants.critical')}</Option>
|
||||
<Option value={2}>{t('constants.important')}</Option>
|
||||
<Option value={3}>{t('constants.general')}</Option>
|
||||
<Option value={4}>{t('constants.info')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="alarmType" label="告警类型">
|
||||
<Select placeholder="全部" style={{ width: 150 }} allowClear>
|
||||
<Option value="UAV_FAULT">无人机故障</Option>
|
||||
<Option value="MOWER_FAULT">割草机故障</Option>
|
||||
<Option value="OTHER_DEVICE_FAULT">其他设备故障</Option>
|
||||
<Option value="SERVER_FAILURE">服务器故障</Option>
|
||||
<Option value="SYSTEM_ERROR">系统错误</Option>
|
||||
<Form.Item name="alarmType" label={t('alerts.alertType')}>
|
||||
<Select placeholder={t('common.all')} style={{ width: 150 }} allowClear>
|
||||
<Option value="UAV_FAULT">{t('constants.uavFault')}</Option>
|
||||
<Option value="MOWER_FAULT">{t('constants.mowerFault')}</Option>
|
||||
<Option value="OTHER_DEVICE_FAULT">{t('constants.otherDeviceFault')}</Option>
|
||||
<Option value="SERVER_FAILURE">{t('constants.serverFailure')}</Option>
|
||||
<Option value="SYSTEM_ERROR">{t('constants.systemError')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item name="handleStatus" label="处理状态">
|
||||
<Select placeholder="全部" style={{ width: 130 }} allowClear>
|
||||
<Option value={1}>待处理</Option>
|
||||
<Option value={2}>已关闭</Option>
|
||||
<Form.Item name="handleStatus" label={t('alerts.handleStatus')}>
|
||||
<Select placeholder={t('common.all')} style={{ width: 130 }} allowClear>
|
||||
<Option value={1}>{t('constants.pending')}</Option>
|
||||
<Option value={2}>{t('constants.closed')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
@@ -228,8 +231,8 @@ const AlarmHistory = () => {
|
||||
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
<Button htmlType="reset">重置</Button>
|
||||
<Button type="primary" htmlType="submit">{t('common.search2')}</Button>
|
||||
<Button htmlType="reset">{t('common.reset')}</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
@@ -269,17 +272,17 @@ const AlarmHistory = () => {
|
||||
<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="设备名称">{currentAlarm?.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警时间">
|
||||
<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') : '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="告警类型">{alarmTypeMap[currentAlarm?.alarmType] || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警级别">
|
||||
<Descriptions.Item label={t('alerts.alertType')}>{alarmTypeMap[currentAlarm?.alarmType] || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.alertLevel')}>
|
||||
<Tag color={levelColor[currentAlarm?.alarmLevel]} style={{ border: 'none', color: '#fff' }}>
|
||||
{levelText[currentAlarm?.alarmLevel]}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理状态">
|
||||
<Descriptions.Item label={t('alerts.handleStatus')}>
|
||||
{(() => {
|
||||
const s = currentAlarm?.handleStatus;
|
||||
let color = 'default';
|
||||
@@ -290,11 +293,11 @@ const AlarmHistory = () => {
|
||||
return <Tag color={color}>{handleStatusMap[s] || '-'}</Tag>;
|
||||
})()}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理人">{currentAlarm?.handleUserName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="处理时间">
|
||||
<Descriptions.Item label={t('alerts.handler')}>{currentAlarm?.handleUserName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.handleTime')}>
|
||||
{currentAlarm?.handleTime ? dayjs(currentAlarm.handleTime).format('YYYY-MM-DD HH:mm:ss') : '-'}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理备注">{currentAlarm?.handleRemark || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label={t('alerts.handleRemark')}>{currentAlarm?.handleRemark || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="根因分析">{currentAlarm?.rootCause || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="推荐处理措施">
|
||||
{currentAlarm?.handleSuggestion || '-'}
|
||||
@@ -308,19 +311,19 @@ const AlarmHistory = () => {
|
||||
<Space>
|
||||
<span>短信:</span>
|
||||
<Tag color={currentAlarm.notifySms === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifySms === 1 ? '已开启' : '已关闭'}
|
||||
{currentAlarm.notifySms === 1 ? '已开启' : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Space>
|
||||
<span>钉钉:</span>
|
||||
<Tag color={currentAlarm.notifyTelegram === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifyTelegram === 1 ? '已开启' : '已关闭'}
|
||||
{currentAlarm.notifyTelegram === 1 ? '已开启' : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
<Space>
|
||||
<span>邮件:</span>
|
||||
<Tag color={currentAlarm.notifyEmail === 1 ? 'green' : 'default'}>
|
||||
{currentAlarm.notifyEmail === 1 ? '已开启' : '已关闭'}
|
||||
{currentAlarm.notifyEmail === 1 ? '已开启' : t('constants.closed')}
|
||||
</Tag>
|
||||
</Space>
|
||||
</Space>
|
||||
|
||||
Reference in New Issue
Block a user