中英文切换 初始化
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>
|
||||
|
||||
@@ -27,6 +27,7 @@ import { addWorkOrder } from '@/api/workOrder.js';
|
||||
import { alarmLevelConfig, alarmTypeMap, handleStatusMap } from '../../constants.js';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store/index.js';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { RangePicker } = DatePicker;
|
||||
const { Text } = Typography;
|
||||
@@ -37,8 +38,10 @@ const { Option } = Select;
|
||||
|
||||
// 快速根据 value 获取 label
|
||||
const getLevelLabel = (val) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const item = errorLevelOptions.find(opt => opt.value === val);
|
||||
return item?.label || '未知';
|
||||
return item?.label || t('constants.locationUnknown');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -90,6 +93,7 @@ const AlarmLevelTag = ({ level, size = 'small' }) => {
|
||||
};
|
||||
|
||||
export default function AlarmCenterPage() {
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [detailLoading, setDetailLoading] = useState(false);
|
||||
@@ -196,7 +200,7 @@ export default function AlarmCenterPage() {
|
||||
// 表单赋值
|
||||
form.setFieldsValue({
|
||||
handleStatus: res.data.handleStatus,
|
||||
handleRemark: '已处理'
|
||||
handleRemark: t('constants.handled')
|
||||
});
|
||||
setDrawerVisible(true);
|
||||
}
|
||||
@@ -214,7 +218,7 @@ export default function AlarmCenterPage() {
|
||||
alarmId: currentAlarm.id,
|
||||
handleStatus: values.handleStatus,
|
||||
handleResult: values.handleResult,
|
||||
handleRemark: values.handleRemark || '已处理',
|
||||
handleRemark: values.handleRemark || t('constants.handled'),
|
||||
rootCause: values.rootCause || '无'
|
||||
});
|
||||
messageApi.success('处理成功');
|
||||
@@ -254,12 +258,12 @@ export default function AlarmCenterPage() {
|
||||
const handleUpdateAlarm = async (values) => {
|
||||
try {
|
||||
await updateAlarm(values);
|
||||
messageApi.success('修改成功');
|
||||
messageApi.success(t('profile.modifySuccess'));
|
||||
setEditModalVisible(false);
|
||||
fetchList(); // 刷新列表
|
||||
fetchStat(); // 刷新统计
|
||||
} catch (err) {
|
||||
messageApi.error('修改失败');
|
||||
messageApi.error(t('profile.modifyFailed'));
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
@@ -300,31 +304,31 @@ export default function AlarmCenterPage() {
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '设备名称',
|
||||
title: t('devices.deviceName'),
|
||||
dataIndex: 'deviceName',
|
||||
width: 280
|
||||
},
|
||||
{
|
||||
title: '告警类型',
|
||||
title: t('alerts.alertType'),
|
||||
dataIndex: 'alarmType',
|
||||
width: 120,
|
||||
render: (t) => alarmTypeMap[t] || '-'
|
||||
},
|
||||
{
|
||||
title: '告警级别',
|
||||
title: t('alerts.alertLevel'),
|
||||
dataIndex: 'alarmLevel',
|
||||
width: 100,
|
||||
render: (l) => <AlarmLevelTag level={l} size="small" />
|
||||
|
||||
},
|
||||
{
|
||||
title: '告警时间',
|
||||
title: t('alerts.alertTime'),
|
||||
dataIndex: 'alarmTime',
|
||||
width: 180,
|
||||
render: (t) => t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
|
||||
},
|
||||
{
|
||||
title: '处理状态',
|
||||
title: t('alerts.handleStatus'),
|
||||
dataIndex: 'handleStatus',
|
||||
width: 110,
|
||||
render: (s) => {
|
||||
@@ -339,7 +343,7 @@ export default function AlarmCenterPage() {
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: t('roles.actions'),
|
||||
width: 100,
|
||||
fixed: 'right',
|
||||
render: (_, record) => (
|
||||
@@ -390,17 +394,17 @@ export default function AlarmCenterPage() {
|
||||
|
||||
const pieData = [
|
||||
{
|
||||
name: '错误',
|
||||
name: t('constants.error'),
|
||||
value: statData.levelStats?.["ERROR"] || 0,
|
||||
color: '#FF4D4F',
|
||||
},
|
||||
{
|
||||
name: '警告',
|
||||
name: t('constants.warning'),
|
||||
value: statData.levelStats?.['WARNING'] || 0,
|
||||
color: '#FA8C16',
|
||||
},
|
||||
{
|
||||
name: '信息',
|
||||
name: t('constants.infoLevel'),
|
||||
value: statData.levelStats?.['INFO'] || 0,
|
||||
color: '#FADB14',
|
||||
},
|
||||
@@ -657,7 +661,7 @@ export default function AlarmCenterPage() {
|
||||
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
|
||||
<Row gutter={[8, 8]} align="middle">
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>告警级别</div>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>{t('alerts.alertLevel')}</div>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
value={queryParams.alarmLevel}
|
||||
@@ -666,15 +670,15 @@ export default function AlarmCenterPage() {
|
||||
/>
|
||||
</Col>
|
||||
<Col>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>处理状态</div>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>{t('alerts.handleStatus')}</div>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
value={queryParams.handleStatus}
|
||||
allowClear
|
||||
onChange={v => setQueryParams({ ...queryParams, handleStatus: v })}
|
||||
options={[
|
||||
{ value: 1, label: '待处理' },
|
||||
{ value: 2, label: '已关闭' },
|
||||
{ value: 1, label: t('constants.pending') },
|
||||
{ value: 2, label: t('constants.closed') },
|
||||
]}
|
||||
/>
|
||||
</Col>
|
||||
@@ -722,7 +726,7 @@ export default function AlarmCenterPage() {
|
||||
fetchList();
|
||||
fetchStat();
|
||||
fetchChartAllAlarm(); // 新增:刷新图表全量告警
|
||||
}}>重置</Button>
|
||||
}}>{t('common.reset')}</Button>
|
||||
<Button type="primary" style={{ borderRadius: 8, background: '#165DFF' }} onClick={() => {
|
||||
fetchList(); // 刷新列表
|
||||
fetchStat(); // 刷新统计
|
||||
@@ -770,7 +774,7 @@ export default function AlarmCenterPage() {
|
||||
{/* 三个图表 */}
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警趋势" style={{ borderRadius: 8 }}>
|
||||
<Card bordered={false} title={t('alerts.alertTrend')} style={{ borderRadius: 8 }}>
|
||||
<UniversalLineChart
|
||||
data={getAlarmTrendData()}
|
||||
xKey="date"
|
||||
@@ -781,19 +785,19 @@ export default function AlarmCenterPage() {
|
||||
series={[
|
||||
{
|
||||
key: 'ERROR',
|
||||
name: '错误',
|
||||
name: t('constants.error'),
|
||||
color: '#FF4D4F',
|
||||
strokeWidth: 2,
|
||||
},
|
||||
{
|
||||
key: 'WARNING',
|
||||
name: '警告',
|
||||
name: t('constants.warning'),
|
||||
color: '#FA8C16',
|
||||
strokeWidth: 2,
|
||||
},
|
||||
{
|
||||
key: 'INFO',
|
||||
name: '信息',
|
||||
name: t('constants.infoLevel'),
|
||||
color: '#FADB14',
|
||||
strokeWidth: 2,
|
||||
},
|
||||
@@ -818,12 +822,12 @@ export default function AlarmCenterPage() {
|
||||
<UniversalBarChart
|
||||
data={[
|
||||
{
|
||||
name: '待处理',
|
||||
name: t('constants.pending'),
|
||||
pending: statData.pending || 0,
|
||||
},
|
||||
|
||||
{
|
||||
name: '已关闭',
|
||||
name: t('constants.closed'),
|
||||
pending: statData.closed || 0,
|
||||
},
|
||||
]}
|
||||
@@ -875,9 +879,9 @@ export default function AlarmCenterPage() {
|
||||
{/* 告警基础信息 */}
|
||||
<Descriptions column={1} bordered size="small" style={{ marginBottom: 16 }}>
|
||||
<Descriptions.Item label="来源设备">{currentAlarm.deviceName || '-'}</Descriptions.Item>
|
||||
<Descriptions.Item label="告警类型">{alarmTypeMap[currentAlarm.alarmType] || '-'}</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="处理状态">
|
||||
<Descriptions.Item label={t('alerts.handleStatus')}>
|
||||
{(() => {
|
||||
let color = 'default';
|
||||
const status = currentAlarm.handleStatus;
|
||||
@@ -920,14 +924,14 @@ export default function AlarmCenterPage() {
|
||||
|
||||
{/* 处理操作 */}
|
||||
<Card size="small" title="处理操作" style={{ marginBottom: 16 }}>
|
||||
<Form.Item label="处理状态" name="handleStatus" rules={[{ required: true, message: '请选择处理状态' }]}>
|
||||
<Form.Item label={t('alerts.handleStatus')} name="handleStatus" rules={[{ required: true, message: '请选择处理状态' }]}>
|
||||
<Select>
|
||||
<Option value={1}>待处理</Option>
|
||||
<Option value={1}>{t('constants.pending')}</Option>
|
||||
|
||||
<Option value={2}>已关闭</Option>
|
||||
<Option value={2}>{t('constants.closed')}</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item label="处理结果" name="handleResult" rules={[{ required: true, message: '请选择确认处理结果' }]}>
|
||||
<Form.Item label={t('alerts.handleResult')} name="handleResult" rules={[{ required: true, message: '请选择确认处理结果' }]}>
|
||||
<Select
|
||||
placeholder="请选择确认处理结果"
|
||||
options={alarmHandleResultOptions}
|
||||
@@ -936,7 +940,7 @@ export default function AlarmCenterPage() {
|
||||
<Form.Item label="根因分析" name="rootCause">
|
||||
<Input.TextArea rows={2} placeholder="请输入处理备注" />
|
||||
</Form.Item>
|
||||
<Form.Item label="处理备注" name="handleRemark">
|
||||
<Form.Item label={t('alerts.handleRemark')} name="handleRemark">
|
||||
<Input.TextArea rows={2} placeholder="请输入处理备注" />
|
||||
</Form.Item>
|
||||
|
||||
@@ -980,7 +984,7 @@ export default function AlarmCenterPage() {
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="告警级别"
|
||||
label={t('alerts.alertLevel')}
|
||||
name="alarmLevel"
|
||||
rules={[{ required: true, message: '请选择告警级别' }]}
|
||||
>
|
||||
@@ -990,16 +994,16 @@ export default function AlarmCenterPage() {
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="告警类型"
|
||||
label={t('alerts.alertType')}
|
||||
name="alarmType"
|
||||
rules={[{ required: true, message: '请选择告警类型' }]}
|
||||
>
|
||||
<Select>
|
||||
<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>
|
||||
<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>
|
||||
|
||||
@@ -1012,7 +1016,7 @@ export default function AlarmCenterPage() {
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item style={{ textAlign: 'right', marginBottom: 0 }}>
|
||||
<Button onClick={() => setEditModalVisible(false)}>取消</Button>
|
||||
<Button onClick={() => setEditModalVisible(false)}>{t('common.cancel')}</Button>
|
||||
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>
|
||||
确认修改
|
||||
</Button>
|
||||
@@ -1038,11 +1042,11 @@ export default function AlarmCenterPage() {
|
||||
onFinish={submitCreateOrder}
|
||||
>
|
||||
<Form.Item
|
||||
label="工单标题"
|
||||
label={t('workOrder.orderTitle')}
|
||||
name="orderTitle"
|
||||
rules={[{ required: true, message: '请输入工单标题' }]}
|
||||
rules={[{ required: true, message: t('workOrder.pleaseInputTitle') }]}
|
||||
>
|
||||
<Input placeholder="请输入工单标题" />
|
||||
<Input placeholder={t('workOrder.pleaseInputTitle')} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -1059,7 +1063,7 @@ export default function AlarmCenterPage() {
|
||||
|
||||
|
||||
<Form.Item style={{ textAlign: 'right', marginBottom: 0 }}>
|
||||
<Button onClick={() => setCreateOrderModalVisible(false)}>取消</Button>
|
||||
<Button onClick={() => setCreateOrderModalVisible(false)}>{t('common.cancel')}</Button>
|
||||
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>
|
||||
确认生成工单
|
||||
</Button>
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
Modal, Descriptions, Input, Select
|
||||
} from 'antd';
|
||||
import { EyeOutlined } from '@ant-design/icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const AntdCard = Card as any;
|
||||
const { Search } = Input;
|
||||
@@ -17,6 +18,7 @@ const mockAlarms = [
|
||||
];
|
||||
|
||||
const AlarmRealtime = () => {
|
||||
const { t } = useTranslation();
|
||||
// 弹窗控制
|
||||
const [detailVisible, setDetailVisible] = useState(false);
|
||||
const [currentAlarm, setCurrentAlarm] = useState<any>(null);
|
||||
@@ -43,32 +45,32 @@ const AlarmRealtime = () => {
|
||||
|
||||
// 表格列
|
||||
const columns = [
|
||||
{ title: '时间', dataIndex: 'time', width: 180 },
|
||||
{ title: t('common.time'), dataIndex: 'time', width: 180 },
|
||||
{ title: '设备', dataIndex: 'deviceName' },
|
||||
{
|
||||
title: '级别',
|
||||
render: (l: any) => {
|
||||
const color = l.level === 'warn' ? 'orange' : l.level === 'error' ? 'red' : 'blue';
|
||||
const text = l.level === 'warn' ? '警告' : l.level === 'error' ? '严重' : '提示';
|
||||
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: '状态',
|
||||
title: t('roles.status'),
|
||||
render: (r: any) => {
|
||||
const statusMap = {
|
||||
unprocessed: { status: 'error', text: '未处理' },
|
||||
unprocessed: { status: 'error', text: t('home.unhandled') },
|
||||
processing: { status: 'warning', text: '处理中' },
|
||||
processed: { status: 'success', text: '已处理' },
|
||||
closed: { status: 'default', text: '已关闭' },
|
||||
processed: { status: 'success', text: t('constants.handled') },
|
||||
closed: { status: 'default', text: t('constants.closed') },
|
||||
};
|
||||
const s = statusMap[r.status] || statusMap.unprocessed;
|
||||
return <Badge status={s.status as any} text={s.text} />;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: t('roles.actions'),
|
||||
render: (_: any, record: any) => (
|
||||
<Button type="link" icon={<EyeOutlined />} onClick={() => showDetail(record)}>
|
||||
详情
|
||||
@@ -80,7 +82,7 @@ const AlarmRealtime = () => {
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
<AntdCard
|
||||
title="实时告警"
|
||||
title={t('alerts.realtimeAlert')}
|
||||
extra={
|
||||
<Search
|
||||
placeholder="搜索设备名称/告警内容"
|
||||
@@ -108,23 +110,23 @@ const AlarmRealtime = () => {
|
||||
>
|
||||
{currentAlarm && (
|
||||
<Descriptions column={1} bordered>
|
||||
<Descriptions.Item label="告警时间">{currentAlarm.time}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备名称">{currentAlarm.deviceName}</Descriptions.Item>
|
||||
<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="告警级别">
|
||||
<Descriptions.Item label={t('alerts.alertLevel')}>
|
||||
<Tag color={currentAlarm.level === 'warn' ? 'orange' : currentAlarm.level === 'error' ? 'red' : 'blue'}>
|
||||
{currentAlarm.level === 'warn' ? '警告' : currentAlarm.level === 'error' ? '严重' : '提示'}
|
||||
{currentAlarm.level === 'warn' ? t('constants.warning') : currentAlarm.level === 'error' ? t('constants.critical') : t('constants.info')}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="处理状态">
|
||||
<Descriptions.Item label={t('alerts.handleStatus')}>
|
||||
<Badge
|
||||
status={
|
||||
currentAlarm.status === 'unprocessed' ? 'error' :
|
||||
currentAlarm.status === 'processing' ? 'warning' : 'success'
|
||||
}
|
||||
text={
|
||||
currentAlarm.status === 'unprocessed' ? '未处理' :
|
||||
currentAlarm.status === 'processing' ? '处理中' : '已处理'
|
||||
currentAlarm.status === 'unprocessed' ? t('home.unhandled') :
|
||||
currentAlarm.status === 'processing' ? '处理中' : t('constants.handled')
|
||||
}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
|
||||
// 从你的设备接入页面 导入 物模型数据
|
||||
//import { modelList, modelDetailList } from './DeviceAccessPage';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const AntdCard = Card as any;
|
||||
const { Search } = Input;
|
||||
@@ -18,6 +19,7 @@ const mockRules = [
|
||||
];
|
||||
|
||||
const AlarmRules = () => {
|
||||
const { t } = useTranslation();
|
||||
const [list, setList] = useState(mockRules);
|
||||
const [filteredList, setFilteredList] = useState(mockRules);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
@@ -27,7 +29,7 @@ const AlarmRules = () => {
|
||||
// 下拉选项
|
||||
const [deviceTypeOpts, setDeviceTypeOpts] = useState([
|
||||
{ value: 'sensor', label: '传感器' },
|
||||
{ value: 'camera', label: '摄像头' },
|
||||
{ value: 'camera', label: t('devices.camera') },
|
||||
{ value: 'battery', label: '电池设备' },
|
||||
]);
|
||||
const [propList, setPropList] = useState<any[]>([]);
|
||||
@@ -66,12 +68,12 @@ const AlarmRules = () => {
|
||||
const updated = list.map(item => item.id === editingId ? { ...item, ...data } : item);
|
||||
setList(updated);
|
||||
setFilteredList(updated);
|
||||
message.success('修改成功');
|
||||
message.success(t('profile.modifySuccess'));
|
||||
} else {
|
||||
const newRule = { ...data, id: Date.now() };
|
||||
setList([...list, newRule]);
|
||||
setFilteredList([...list, newRule]);
|
||||
message.success('新增成功');
|
||||
message.success(t('common.addSuccess'));
|
||||
}
|
||||
setModalVisible(false);
|
||||
});
|
||||
@@ -82,7 +84,7 @@ const AlarmRules = () => {
|
||||
const newList = list.filter(x => x.id !== id);
|
||||
setList(newList);
|
||||
setFilteredList(newList);
|
||||
message.success('删除成功');
|
||||
message.success(t('common.deleteSuccess'));
|
||||
};
|
||||
|
||||
// 加载物模型属性
|
||||
@@ -103,26 +105,26 @@ const AlarmRules = () => {
|
||||
|
||||
const columns = [
|
||||
{ title: '规则名称', dataIndex: 'name' },
|
||||
{ title: '设备类型', dataIndex: 'deviceType' },
|
||||
{ title: t('devices.deviceType'), dataIndex: 'deviceType' },
|
||||
{
|
||||
title: '告警级别',
|
||||
title: t('alerts.alertLevel'),
|
||||
render: (r: any) => {
|
||||
const color = r.level === 'error' ? 'red' : r.level === 'warn' ? 'orange' : 'blue';
|
||||
const text = { error:'严重', warn:'警告', info:'提示' }[r.level];
|
||||
const text = { error:t('constants.critical'), warn:t('constants.warning'), info:t('constants.info') }[r.level];
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
}
|
||||
},
|
||||
{ title: '触发条件', dataIndex: 'condition' },
|
||||
{
|
||||
title: '状态',
|
||||
render: (r: any) => <Badge status={r.status ? 'success' : 'error'} text={r.status ? '启用' : '禁用'} />
|
||||
title: t('roles.status'),
|
||||
render: (r: any) => <Badge status={r.status ? 'success' : 'error'} text={r.status ? t('common.enable') : '禁用'} />
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: t('roles.actions'),
|
||||
render: (r: any) => (
|
||||
<Space>
|
||||
<Button type="link" icon={<EditOutlined />} onClick={() => openEdit(r)}>编辑</Button>
|
||||
<Popconfirm onConfirm={() => handleDelete(r.id)}><Button type="link" danger>删除</Button></Popconfirm>
|
||||
<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>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
@@ -134,7 +136,7 @@ const AlarmRules = () => {
|
||||
title="告警规则配置"
|
||||
extra={
|
||||
<Space>
|
||||
<Search placeholder="搜索" style={{ width: 260 }} onSearch={handleSearch} />
|
||||
<Search placeholder={t('common.search')} style={{ width: 260 }} onSearch={handleSearch} />
|
||||
<Button icon={<PlusOutlined />} type="primary" onClick={openAdd}>新增规则</Button>
|
||||
</Space>
|
||||
}
|
||||
@@ -154,7 +156,7 @@ const AlarmRules = () => {
|
||||
<Input placeholder="例如:温度超上限" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="设备类型" name="deviceType" rules={[{ required: true }]}>
|
||||
<Form.Item label={t('devices.deviceType')} name="deviceType" rules={[{ required: true }]}>
|
||||
<Select>
|
||||
{deviceTypeOpts.map(o => <Select.Option key={o.value} value={o.value}>{o.label}</Select.Option>)}
|
||||
</Select>
|
||||
@@ -193,15 +195,15 @@ const AlarmRules = () => {
|
||||
<Input placeholder="填写数值" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="告警级别" name="level" rules={[{ required: true }]}>
|
||||
<Form.Item label={t('alerts.alertLevel')} name="level" rules={[{ required: true }]}>
|
||||
<Select>
|
||||
<Select.Option value="error">严重</Select.Option>
|
||||
<Select.Option value="warn">警告</Select.Option>
|
||||
<Select.Option value="info">提示</Select.Option>
|
||||
<Select.Option value="error">{t('constants.critical')}</Select.Option>
|
||||
<Select.Option value="warn">{t('constants.warning')}</Select.Option>
|
||||
<Select.Option value="info">{t('constants.info')}</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="启用" name="status" valuePropName="checked">
|
||||
<Form.Item label={t('common.enable')} name="status" valuePropName="checked">
|
||||
<Switch />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@@ -10,8 +10,10 @@ import * as echarts from 'echarts';
|
||||
|
||||
// 接口引入
|
||||
import { getAlarmStatistics } from '../../api/alarmApi.js';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const AlarmStatistics = () => {
|
||||
const { t } = useTranslation();
|
||||
const barChartRef = useRef(null);
|
||||
const pieChartRef = useRef(null);
|
||||
|
||||
@@ -77,7 +79,7 @@ const AlarmStatistics = () => {
|
||||
series: [{
|
||||
type: 'pie',
|
||||
radius: ['40%', '70%'],
|
||||
data: pieData.length ? pieData : [{ value: 1, name: '暂无数据' }],
|
||||
data: pieData.length ? pieData : [{ value: 1, name: t('common.noData') }],
|
||||
color: ['#F53F3F', '#FF7D00', '#F7BA1E', '#165DFF'],
|
||||
}]
|
||||
};
|
||||
@@ -97,7 +99,7 @@ const AlarmStatistics = () => {
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24, background: '#f5f7fa', minHeight: '100vh' }}>
|
||||
<Card title="告警概览" bordered={false} style={{ marginBottom: 24, borderRadius: 8 }}>
|
||||
<Card title={t('alerts.alertOverview')} bordered={false} style={{ marginBottom: 24, borderRadius: 8 }}>
|
||||
<Row gutter={16} align="middle">
|
||||
<Col xs={24} sm={12} md={6}>
|
||||
<Space size={16}>
|
||||
@@ -105,7 +107,7 @@ const AlarmStatistics = () => {
|
||||
<BellOutlined style={{ fontSize: 24, color: '#F53F3F' }} />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>告警总数</div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>{t('report.totalAlerts')}</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 700 }}>{statData.total || 0}</div>
|
||||
</div>
|
||||
</Space>
|
||||
@@ -129,7 +131,7 @@ const AlarmStatistics = () => {
|
||||
<ClockCircleOutlined style={{ fontSize: 24, color: '#FF7D00' }} />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>待处理</div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>{t('constants.pending')}</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 700 }}>{statData.pending || 0}</div>
|
||||
</div>
|
||||
</Space>
|
||||
@@ -141,7 +143,7 @@ const AlarmStatistics = () => {
|
||||
<CheckCircleOutlined style={{ fontSize: 24, color: '#00B42A' }} />
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>已关闭</div>
|
||||
<div style={{ fontSize: 14, color: '#4E5969' }}>{t('constants.closed')}</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 700 }}>{statData.closed || 0}</div>
|
||||
</div>
|
||||
</Space>
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
Modal, Form, Input, Select
|
||||
} from 'antd';
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const AntdCard = Card as any;
|
||||
const { Option } = Select;
|
||||
@@ -17,6 +18,7 @@ const mockSub = [
|
||||
];
|
||||
|
||||
const AlarmSubscription = () => {
|
||||
const { t } = useTranslation();
|
||||
const [list, setList] = useState(mockSub);
|
||||
const [filteredList, setFilteredList] = useState(mockSub);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
@@ -77,19 +79,19 @@ const AlarmSubscription = () => {
|
||||
|
||||
const columns = [
|
||||
{ title: '订阅名称', dataIndex: 'name' },
|
||||
{ title: '设备类型', dataIndex: 'deviceType' },
|
||||
{ title: '告警级别', dataIndex: 'level' },
|
||||
{ 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: '操作',
|
||||
title: t('roles.actions'),
|
||||
render: (r) => (
|
||||
<Space>
|
||||
<Button type="link" icon={<EditOutlined />} onClick={() => openEdit(r)}>编辑</Button>
|
||||
<Popconfirm title="确定删除?" onConfirm={() => handleDelete(r.id)}>
|
||||
<Button type="link" danger icon={<DeleteOutlined />}>删除</Button>
|
||||
<Button type="link" icon={<EditOutlined />} onClick={() => openEdit(r)}>{t('roles.edit')}</Button>
|
||||
<Popconfirm title={t('common.confirmDelete')} onConfirm={() => handleDelete(r.id)}>
|
||||
<Button type="link" danger icon={<DeleteOutlined />}>{t('roles.delete')}</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
@@ -99,7 +101,7 @@ const AlarmSubscription = () => {
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
<AntdCard
|
||||
title="告警订阅"
|
||||
title={t('alerts.alarmSubscription')}
|
||||
extra={
|
||||
<Space>
|
||||
<Search
|
||||
@@ -134,21 +136,21 @@ const AlarmSubscription = () => {
|
||||
<Input placeholder="请输入订阅名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="设备类型" name="deviceType" rules={[{ required: true }]}>
|
||||
<Form.Item label={t('devices.deviceType')} name="deviceType" rules={[{ required: true }]}>
|
||||
<Select>
|
||||
<Option value="all">全部设备</Option>
|
||||
<Option value="sensor">传感器</Option>
|
||||
<Option value="camera">摄像头</Option>
|
||||
<Option value="camera">{t('devices.camera')}</Option>
|
||||
<Option value="battery">电池设备</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="告警级别" name="level" rules={[{ required: true }]}>
|
||||
<Form.Item label={t('alerts.alertLevel')} name="level" rules={[{ required: true }]}>
|
||||
<Select>
|
||||
<Option value="all">全部级别</Option>
|
||||
<Option value="error">严重</Option>
|
||||
<Option value="warn">警告</Option>
|
||||
<Option value="info">提示</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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user