fix(设备导入): 调整必填字段验证逻辑并添加调试日志
移除型号作为必填字段,并在验证过程中添加调试日志输出
This commit is contained in:
@@ -525,9 +525,9 @@ router.post('/import', async (req, res) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 真正的必填字段列表(与前端表单一致)
|
// 真正的必填字段列表(与前端表单一致)
|
||||||
// 注意:设备ID由系统自动生成,功率/购买日期/保修到期已改为非必填
|
// 注意:设备ID由系统自动生成,型号/功率/购买日期/保修到期已改为非必填
|
||||||
const trulyRequiredFields = [
|
const trulyRequiredFields = [
|
||||||
'设备名称', '设备类型', '型号', '序列号',
|
'设备名称', '设备类型', '序列号',
|
||||||
'所在机房名称', '所在机柜名称', '位置(U)', '高度(U)', '状态'
|
'所在机房名称', '所在机柜名称', '位置(U)', '高度(U)', '状态'
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -535,12 +535,14 @@ router.post('/import', async (req, res) => {
|
|||||||
const missingFields = [];
|
const missingFields = [];
|
||||||
for (const fieldName of trulyRequiredFields) {
|
for (const fieldName of trulyRequiredFields) {
|
||||||
const value = fieldValueMap[fieldName];
|
const value = fieldValueMap[fieldName];
|
||||||
|
console.log(`验证字段: ${fieldName}, 值:`, value);
|
||||||
if (!value || (typeof value === 'string' && value.trim() === '')) {
|
if (!value || (typeof value === 'string' && value.trim() === '')) {
|
||||||
missingFields.push(fieldName);
|
missingFields.push(fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
|
console.log('fieldValueMap:', fieldValueMap);
|
||||||
throw new Error(`缺少必填字段:${missingFields.join('、')}`);
|
throw new Error(`缺少必填字段:${missingFields.join('、')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user