diff --git a/src/components/DictManager.jsx b/src/components/DictManager.jsx
new file mode 100644
index 0000000..7507588
--- /dev/null
+++ b/src/components/DictManager.jsx
@@ -0,0 +1,104 @@
+import React, { useState } from 'react';
+import {
+ Table, Input, Button, Form, Space, Card, Modal
+} from 'antd';
+import { EditOutlined, DeleteOutlined } from '@ant-design/icons';
+
+
+// 🔥 组件
+const DictManager = ({
+ title,
+ data,
+ onAdd,
+ onUpdate,
+ onDelete,
+ loading,
+}) => {
+ const [visible, setVisible] = useState(false);
+ const [form] = Form.useForm();
+ const [editing, setEditing] = useState(null);
+
+ // 编辑
+ const handleEdit = (record) => {
+ setEditing(record);
+ form.setFieldsValue(record);
+ setVisible(true);
+ };
+
+ // 提交
+ const handleSubmit = () => {
+ form.validateFields().then(values => {
+ if (editing) {
+ onUpdate({ ...editing, ...values });
+ } else {
+ onAdd({ id: Date.now(), ...values });
+ }
+ setVisible(false);
+ form.resetFields();
+ setEditing(null);
+ });
+ };
+
+ // 表格列
+ const columns = [
+ { title: '存储值', dataIndex: 'value', key: 'value' },
+ { title: '显示名', dataIndex: 'label', key: 'label' },
+ {
+ title: '操作',
+ key: 'action',
+ render: (_, record) => (
+
+ } onClick={() => handleEdit(record)}>
+ 编辑
+
+ } onClick={() => onDelete(record.id)}>
+ 删除
+
+
+ ),
+ },
+ ];
+
+ return (
+
+
+
+
+
+ setVisible(false)}
+ onOk={handleSubmit}
+ confirmLoading={loading}
+ >
+
+
+
+
+
+
+
+
+
+ );
+};
+export default DictManager;
diff --git a/src/components/SystemSetting/DeviceManagement.tsx b/src/components/SystemSetting/DeviceManagement.tsx
index 546a50b..e120f55 100644
--- a/src/components/SystemSetting/DeviceManagement.tsx
+++ b/src/components/SystemSetting/DeviceManagement.tsx
@@ -10,6 +10,8 @@ import {
message,
Modal,
Tabs,
+ Card,
+ InputNumber,
} from 'antd';
import {
SearchOutlined,
@@ -18,6 +20,7 @@ import {
EditOutlined,
DeleteOutlined,
} from '@ant-design/icons';
+import SerialNumGenerate from "./SerialNumGenerate"
// 模拟数据
const allDeviceList = [
@@ -43,6 +46,8 @@ const tabs = [
{ key: 'smart', label: '智能装备', filter: (item) => ['CLEANING_DEVICE', 'ROBOT', 'DRONE'].includes(item.type) },
];
+
+
export default function DeviceManagementPage() {
const [activeTab, setActiveTab] = useState('all');
const [form] = Form.useForm();
@@ -50,7 +55,7 @@ export default function DeviceManagementPage() {
const [deviceList, setDeviceList] = useState(allDeviceList);
// 根据 Tab 过滤数据
- const filteredByTab = deviceList.filter(tabs.find(t => t.key === activeTab).filter);
+ const filteredByTab = deviceList.filter(tabs.find(t => t.key === activeTab)?.filter || (() => false));
// 表格列定义
const columns = [
@@ -144,40 +149,49 @@ export default function DeviceManagementPage() {
+
- {/* 筛选栏 */}
-
-
-
-
-
- } onClick={handleSearch}>查询
-
-
- } onClick={handleReset}>重置
-
-
- } onClick={handleAdd}>新增
-
-
-
+ {/* ====================== 判断显示内容 ====================== */}
+ {activeTab === 'serialGenerate' ? (
+
+ ) : (
+ // 显示原来的设备列表
+ <>
+ {/* 筛选栏 */}
+
+
+
+
+
+ } onClick={handleSearch}>查询
+
+
+ } onClick={handleReset}>重置
+
+
+ } onClick={handleAdd}>新增
+
+
+
- {/* 表格 */}
- `共 ${total} 条`,
- }}
- />
+ {/* 表格 */}
+ `共 ${total} 条`,
+ }}
+ />
+ >
+ )}
);
}
diff --git a/src/components/SystemSetting/SerialNumGenerate.jsx b/src/components/SystemSetting/SerialNumGenerate.jsx
new file mode 100644
index 0000000..0c0cdfd
--- /dev/null
+++ b/src/components/SystemSetting/SerialNumGenerate.jsx
@@ -0,0 +1,257 @@
+import React, { useState, useRef, useEffect } from 'react';
+import {
+ Form, Select, Input, Button, Space, message, Card, Typography,
+ Row, Col, Modal, Table, Tag, Divider
+} from 'antd';
+import QRCode from 'qrcode';
+import axios from 'axios';
+import DictManager from "../DictManager"
+
+const { Text } = Typography;
+
+// ====================== 【可管理】字典数据 ======================
+const useDict = () => {
+ // 类型
+ const [types, setTypes] = useState([
+ { id: 1, value: 'mower', label: '割草机' },
+ { id: 2, value: 'vacuum', label: '巡检机' },
+ ]);
+ // 型号
+ const [models, setModels] = useState([
+ { id: 1, value: 'MC700', label: 'MC700' },
+ { id: 2, value: 'MC800', label: 'MC800' },
+ { id: 3, value: 'MC900', label: 'MC900' },
+ ]);
+ // 配置
+ const [configs, setConfigs] = useState([
+ { id: 1, value: 'AIR', label: 'AIR' },
+ { id: 2, value: 'PRO', label: 'PRO' },
+ { id: 3, value: 'MAX', label: 'MAX' },
+ ]);
+ // 国家
+ const [countries, setCountries] = useState([
+ { id: 1, value: '中国', label: '中国' },
+ { id: 2, value: '美国', label: '美国' },
+ { id: 3, value: '日本', label: '日本' },
+ ]);
+ // 省份
+ const [provinces, setProvinces] = useState([
+ { id: 1, value: '江苏', label: '江苏' },
+ { id: 2, value: '浙江', label: '浙江' },
+ { id: 3, value: '广东', label: '广东' },
+ ]);
+
+ return {
+ types, setTypes,
+ models, setModels,
+ configs, setConfigs,
+ countries, setCountries,
+ provinces, setProvinces,
+ };
+};
+
+
+
+// ====================== 主组件 ======================
+const SerialNumGenerate = () => {
+ const [form] = Form.useForm();
+ const [qrUrl, setQrUrl] = useState('');
+ const [qrText, setQrText] = useState('');
+ const [loading, setLoading] = useState(false);
+ const qrRef = useRef(null);
+ const [queryCode, setQueryCode] = useState('');
+ const [queryLoading, setQueryLoading] = useState(false);
+ const [manageVisible, setManageVisible] = useState(false);
+
+ const {
+ types, setTypes,
+ models, setModels,
+ configs, setConfigs,
+ countries, setCountries,
+ provinces, setProvinces,
+ } = useDict();
+
+ // 生成二维码
+ const generateQRCode = async () => {
+ try {
+ const values = await form.validateFields();
+ const timestamp = new Date().getTime();
+ const qrContent = `${values.model}-${values.config}-${values.type}-${values.country}-${values.province}-${values.code}-${timestamp}`;
+ const url = await QRCode.toDataURL(qrContent);
+ setQrUrl(url);
+ setQrText(qrContent);
+ message.success('生成成功!');
+ } catch (e) { message.error('请完善信息'); }
+ };
+
+ // 保存
+ const saveToDatabase = async () => {
+ if (!qrUrl) return message.warning('先生成二维码');
+ setLoading(true);
+ try {
+ const values = await form.validateFields();
+ await axios.post('/api/save-qrcode', { ...values, qrCode: qrUrl, qrText });
+ message.success('保存成功');
+ } catch {
+ message.error('保存失败');
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ // 查询
+ const handleQueryQRCode = async () => {
+ if (!queryCode) return message.warning('请输入编号');
+ setQueryLoading(true);
+ try {
+ const res = await axios.get('/api/query-qrcode', { params: { code: queryCode } });
+ if (res.data?.qrCode) {
+ setQrUrl(res.data.qrCode);
+ setQrText(res.data.qrText || '');
+ message.success('查询成功');
+ } else message.warning('未找到');
+ } catch {
+ message.error('查询失败');
+ } finally {
+ setQueryLoading(false);
+ }
+ };
+
+ return (
+
+
setManageVisible(true)}>数据管理}
+ >
+
+ {/* 左侧表单 */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* 查询 */}
+
+
+ setQueryCode(e.target.value)} placeholder="输入编号" />
+
+
+
+
+
+ {/* 右侧二维码 */}
+
+
+ {qrText && (
+
+ {qrText}
+
+ )}
+
+ {qrUrl ? (
+

+ ) : (
+
请先生成二维码
+ )}
+
+
+
+
+
+
+
+
+
+
+ {/* ====================== 数据管理弹窗 ====================== */}
+
setManageVisible(false)}>关闭}
+ destroyOnClose
+ onCancel={() => setManageVisible(false)}
+
+ >
+ setTypes([...types, { id: Date.now(), ...item }])}
+ onUpdate={(item) => setTypes(types.map(t => t.id === item.id ? item : t))}
+ onDelete={(id) => setTypes(types.filter(t => t.id !== id))}
+ />
+ setModels([...models, { id: Date.now(), ...item }])}
+ onUpdate={(item) => setModels(models.map(m => m.id === item.id ? item : m))}
+ onDelete={(id) => setModels(models.filter(m => m.id !== id))}
+ />
+ setConfigs([...configs, { id: Date.now(), ...item }])}
+ onUpdate={(item) => setConfigs(configs.map(c => c.id === item.id ? item : c))}
+ onDelete={(id) => setConfigs(configs.filter(c => c.id !== id))}
+ />
+ setCountries([...countries, { id: Date.now(), ...item }])}
+ onUpdate={(item) => setCountries(countries.map(c => c.id === item.id ? item : c))}
+ onDelete={(id) => setCountries(countries.filter(c => c.id !== id))}
+ />
+ setProvinces([...provinces, { id: Date.now(), ...item }])}
+ onUpdate={(item) => setProvinces(provinces.map(p => p.id === item.id ? item : p))}
+ onDelete={(id) => setProvinces(provinces.filter(p => p.id !== id))}
+ />
+
+
+ );
+};
+
+export default SerialNumGenerate;
diff --git a/src/components/alerts/AlarmHistory.tsx b/src/components/alerts/AlarmHistory.tsx
index d0618b0..c21a7b8 100644
--- a/src/components/alerts/AlarmHistory.tsx
+++ b/src/components/alerts/AlarmHistory.tsx
@@ -1,9 +1,9 @@
import React, { useState, useEffect } from 'react';
import {
Card, Table, Tag, Space, Button,
- Drawer, Descriptions, Form, Select, Pagination, message
+ Drawer, Descriptions, Form, Select, Pagination, message, DatePicker, Input
} from 'antd';
-import { EyeOutlined, NotificationOutlined } from '@ant-design/icons';
+import { EyeOutlined } from '@ant-design/icons';
import dayjs from 'dayjs';
// 接口
@@ -13,6 +13,7 @@ import {
} from '../../api/alarmApi.js';
const { Option } = Select;
+const { RangePicker } = DatePicker;
// ====================== 枚举配置 ======================
const alarmTypeMap = {
@@ -66,8 +67,11 @@ const AlarmHistory = () => {
// 查询条件
const [queryParams, setQueryParams] = useState({
+ deviceId: '',
alarmLevel: '',
handleStatus: '',
+ startTime: '',
+ endTime: '',
});
// 获取列表
@@ -106,7 +110,20 @@ const AlarmHistory = () => {
// 搜索
const handleSearch = (values) => {
- setQueryParams(values);
+ let startTime = '';
+ let endTime = '';
+ if (values.timeRange && values.timeRange.length === 2) {
+ startTime = values.timeRange[0].format('YYYY-MM-DD HH:mm:ss');
+ endTime = values.timeRange[1].format('YYYY-MM-DD HH:mm:ss');
+ }
+
+ setQueryParams({
+ deviceId: values.deviceId || '',
+ alarmLevel: values.alarmLevel || '',
+ handleStatus: values.handleStatus || '',
+ startTime,
+ endTime,
+ });
setPageNum(1);
};
@@ -123,6 +140,7 @@ const AlarmHistory = () => {
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: '告警级别',
@@ -169,6 +187,11 @@ const AlarmHistory = () => {
onFinish={handleSearch}
style={{ marginBottom: 16, flexWrap: 'wrap', gap: 16 }}
>
+ {/* 设备ID */}
+
+
+
+
+ {/* 时间范围 */}
+
+
+
+
@@ -217,7 +249,7 @@ const AlarmHistory = () => {
- {/* 右侧详情抽屉 —— 新版设计稿样式 */}
+ {/* 右侧详情抽屉 */}
{
-
- 短信
+ 短信:
{currentAlarm.notifySms === 1 ? '已开启' : '已关闭'}
-
- 钉钉
+ 钉钉:
{currentAlarm.notifyTelegram === 1 ? '已开启' : '已关闭'}
-
邮件:
{currentAlarm.notifyEmail === 1 ? '已开启' : '已关闭'}
diff --git a/src/components/alerts/AlarmOverview.tsx b/src/components/alerts/AlarmOverview.tsx
index 52a6292..b573cbd 100644
--- a/src/components/alerts/AlarmOverview.tsx
+++ b/src/components/alerts/AlarmOverview.tsx
@@ -75,7 +75,7 @@ export default function AlarmCenterPage() {
deviceId: '',
alarmLevel: '',
handleStatus: '',
- beginTime: '',
+ startTime: '',
endTime: '',
});
@@ -319,7 +319,7 @@ export default function AlarmCenterPage() {
if (arr) {
setQueryParams({
...queryParams,
- beginTime: arr[0].format('YYYY-MM-DD HH:mm:ss'),
+ startTime: arr[0].format('YYYY-MM-DD HH:mm:ss'),
endTime: arr[1].format('YYYY-MM-DD HH:mm:ss')
});
}
@@ -329,7 +329,7 @@ export default function AlarmCenterPage() {