refactor(设备字段): 移除冗余字段并更新必填字段验证逻辑
移除设备模型中的owner、department和assetId字段,这些字段不再使用 更新设备导入接口的必填字段验证逻辑,使用硬编码的必填字段列表以保持前后端一致
This commit is contained in:
@@ -143,39 +143,12 @@ const defaultDeviceFields = [
|
|||||||
visible: true,
|
visible: true,
|
||||||
isSystem: false
|
isSystem: false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
fieldName: 'owner',
|
|
||||||
displayName: '责任人',
|
|
||||||
fieldType: 'string',
|
|
||||||
required: false,
|
|
||||||
order: 15,
|
|
||||||
visible: true,
|
|
||||||
isSystem: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'department',
|
|
||||||
displayName: '所属部门',
|
|
||||||
fieldType: 'string',
|
|
||||||
required: false,
|
|
||||||
order: 16,
|
|
||||||
visible: true,
|
|
||||||
isSystem: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
fieldName: 'assetId',
|
|
||||||
displayName: '资产编号',
|
|
||||||
fieldType: 'string',
|
|
||||||
required: false,
|
|
||||||
order: 17,
|
|
||||||
visible: true,
|
|
||||||
isSystem: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
fieldName: 'brand',
|
fieldName: 'brand',
|
||||||
displayName: '品牌',
|
displayName: '品牌',
|
||||||
fieldType: 'string',
|
fieldType: 'string',
|
||||||
required: false,
|
required: false,
|
||||||
order: 18,
|
order: 15,
|
||||||
visible: true,
|
visible: true,
|
||||||
isSystem: false
|
isSystem: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -524,13 +524,16 @@ router.post('/import', async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 动态获取必填字段配置(从数据库读取)
|
// 真正的必填字段列表(与前端表单一致)
|
||||||
const requiredFieldConfigs = deviceFields.filter(field => field.required);
|
// 注意:设备ID由系统自动生成,功率/购买日期/保修到期已改为非必填
|
||||||
const requiredFieldNames = requiredFieldConfigs.map(field => field.displayName);
|
const trulyRequiredFields = [
|
||||||
|
'设备名称', '设备类型', '型号', '序列号',
|
||||||
|
'所在机房名称', '所在机柜名称', '位置(U)', '高度(U)', '状态'
|
||||||
|
];
|
||||||
|
|
||||||
// 验证必填字段
|
// 验证必填字段
|
||||||
const missingFields = [];
|
const missingFields = [];
|
||||||
for (const fieldName of requiredFieldNames) {
|
for (const fieldName of trulyRequiredFields) {
|
||||||
const value = fieldValueMap[fieldName];
|
const value = fieldValueMap[fieldName];
|
||||||
if (!value || (typeof value === 'string' && value.trim() === '')) {
|
if (!value || (typeof value === 'string' && value.trim() === '')) {
|
||||||
missingFields.push(fieldName);
|
missingFields.push(fieldName);
|
||||||
|
|||||||
Reference in New Issue
Block a user