From 920a52e5ae9586e3d07d4a88334b7edb06e7c5c0 Mon Sep 17 00:00:00 2001 From: zhang1106 <849185023@qq.com> Date: Fri, 6 Feb 2026 15:53:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E8=AE=BE=E5=A4=87=E5=AD=97=E6=AE=B5):?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4=E5=86=97=E4=BD=99=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=B9=B6=E6=9B=B4=E6=96=B0=E5=BF=85=E5=A1=AB=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除设备模型中的owner、department和assetId字段,这些字段不再使用 更新设备导入接口的必填字段验证逻辑,使用硬编码的必填字段列表以保持前后端一致 --- backend/initDeviceFields.js | 29 +---------------------------- backend/routes/devices.js | 11 +++++++---- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/backend/initDeviceFields.js b/backend/initDeviceFields.js index c10b676..b7a602c 100644 --- a/backend/initDeviceFields.js +++ b/backend/initDeviceFields.js @@ -143,39 +143,12 @@ const defaultDeviceFields = [ visible: true, 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', displayName: '品牌', fieldType: 'string', required: false, - order: 18, + order: 15, visible: true, isSystem: false } diff --git a/backend/routes/devices.js b/backend/routes/devices.js index 74a6faf..0476f63 100644 --- a/backend/routes/devices.js +++ b/backend/routes/devices.js @@ -524,13 +524,16 @@ router.post('/import', async (req, res) => { }); try { - // 动态获取必填字段配置(从数据库读取) - const requiredFieldConfigs = deviceFields.filter(field => field.required); - const requiredFieldNames = requiredFieldConfigs.map(field => field.displayName); + // 真正的必填字段列表(与前端表单一致) + // 注意:设备ID由系统自动生成,功率/购买日期/保修到期已改为非必填 + const trulyRequiredFields = [ + '设备名称', '设备类型', '型号', '序列号', + '所在机房名称', '所在机柜名称', '位置(U)', '高度(U)', '状态' + ]; // 验证必填字段 const missingFields = []; - for (const fieldName of requiredFieldNames) { + for (const fieldName of trulyRequiredFields) { const value = fieldValueMap[fieldName]; if (!value || (typeof value === 'string' && value.trim() === '')) { missingFields.push(fieldName);