feat(设备管理): 实现设备ID自动生成功能

- 修改后端验证逻辑,允许设备ID为空或null
- 添加自动生成设备ID功能,格式为DEV+三位数字
- 前端移除设备ID必填校验并隐藏该字段
- 更新设备导入逻辑,支持自动生成设备ID
This commit is contained in:
zhang1106
2026-02-06 15:04:42 +08:00
parent cbbc969b64
commit d5277ce15c
3 changed files with 75 additions and 21 deletions
+2 -4
View File
@@ -9,14 +9,12 @@ const DEVICE_STATUS = ['running', 'maintenance', 'offline', 'fault'];
// 创建设备验证Schema
const createDeviceSchema = Joi.object({
deviceId: Joi.string()
.required()
.max(50)
.pattern(/^[a-zA-Z0-9_-]+$/)
.allow('', null)
.messages({
'string.empty': '设备ID不能为空',
'string.max': '设备ID不能超过50个字符',
'string.pattern.base': '设备ID只能包含字母、数字、下划线和横线',
'any.required': '设备ID是必填字段'
'string.pattern.base': '设备ID只能包含字母、数字、下划线和横线'
}),
name: Joi.string()