中英文切换
This commit is contained in:
@@ -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