feat(机柜管理): 实现机柜ID自动生成功能

- 修改机柜创建逻辑,当rackId为空时自动生成RACKxxx格式的ID
- 更新验证规则,rackId改为可选字段并允许空值
- 调整前端表单提示,明确机柜ID可留空自动生成
- 优化导入功能,支持自动生成机柜ID并改进验证逻辑
- 提供机柜导入模板下载功能,模板中明确ID可留空
This commit is contained in:
zhang1106
2026-02-06 13:33:45 +08:00
parent 80e427d52d
commit 258b7af7c8
3 changed files with 166 additions and 95 deletions
+2 -4
View File
@@ -6,14 +6,12 @@ const RACK_STATUS = ['active', 'inactive', 'maintenance'];
// 创建机柜验证Schema
const createRackSchema = Joi.object({
rackId: 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()