From aca229ea91643fade588d5771f4fd9bb2591b527 Mon Sep 17 00:00:00 2001 From: zhang1106 <849185023@qq.com> Date: Mon, 9 Feb 2026 14:21:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(devices):=20=E5=AF=BC=E5=85=A5=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=8C=85=E5=90=AB=E6=89=80=E6=9C=89=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BB=A5=E7=A1=AE=E4=BF=9D=E6=95=B0=E6=8D=AE=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除对字段visible状态的过滤,确保导入模板包含所有字段(不论visible状态)。这样可以在导入时保证数据完整性,避免因字段过滤导致的数据丢失。 --- backend/routes/devices.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/routes/devices.js b/backend/routes/devices.js index 7f3a842..2f3bb60 100644 --- a/backend/routes/devices.js +++ b/backend/routes/devices.js @@ -152,9 +152,10 @@ router.get('/import-template', async (req, res) => { // 根据字段配置动态生成CSV标题(排除设备ID,由系统自动生成) // 将rackId字段替换为机房名称+机柜名称,以便唯一定位 + // 注意:导入模板包含所有字段(不论visible状态),确保数据完整性 const headers = []; deviceFields - .filter(field => field.visible && field.fieldName !== 'deviceId') + .filter(field => field.fieldName !== 'deviceId') .forEach(field => { // 如果是机柜字段,拆分为机房名称和机柜名称两列 if (field.fieldName === 'rackId') { @@ -174,9 +175,10 @@ router.get('/import-template', async (req, res) => { }); // 准备示例数据(根据字段配置生成,排除设备ID) + // 注意:包含所有字段(不论visible状态) const exampleData = {}; deviceFields - .filter(field => field.visible && field.fieldName !== 'deviceId') + .filter(field => field.fieldName !== 'deviceId') .forEach(field => { // 如果是机柜字段,拆分为机房名称和机柜名称 if (field.fieldName === 'rackId') {