From fa65eecf5e3ed680b3cf3921433b5e1aa483fc9c Mon Sep 17 00:00:00 2001 From: zhang96110 Date: Wed, 1 Apr 2026 03:31:42 +0000 Subject: [PATCH] =?UTF-8?q?fix(devices):=20=E4=BF=AE=E5=A4=8D=20batch-stat?= =?UTF-8?q?us=20=E8=B7=AF=E7=94=B1=20affectedCount=20=E6=9C=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=AF=BC=E8=87=B4=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加缺失的 Device.update() 调用,实际执行批量状态更新 - 定义 affectedCount 变量,解决 ReferenceError 崩溃问题 - 修复前 PUT /batch-status 必定抛出 500 错误 --- backend/routes/devices.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/routes/devices.js b/backend/routes/devices.js index fe4ea64..02d6c09 100644 --- a/backend/routes/devices.js +++ b/backend/routes/devices.js @@ -1628,6 +1628,12 @@ router.put('/batch-status', async (req, res) => { .map(d => `${d.name}(编号:${d.deviceId}${d.rackName ? `,机柜:${d.rackName}` : ''})`) .join('、'); + // 执行批量状态更新 + const [affectedCount] = await Device.update( + { status }, + { where: { deviceId: { [Op.in]: deviceIds } } } + ); + const statusChangeDesc = `批量变更${affectedCount}台设备状态:${deviceSummary} → ${statusText[status]}`; await logDeviceOperation('status_change', statusChangeDesc, {