feat: 添加工单统计自动刷新功能并优化设备选择逻辑

refactor(工单管理): 重构设备选择表单并优化UI体验

fix(工单统计): 修复每日完成工单统计不准确的问题

perf(后端): 添加批量导出接口优化大数据量查询性能

chore: 添加react-transition-group依赖支持动画效果

feat(设备管理): 添加设备全量查询接口支持导出功能

style(工单管理): 优化表单布局和样式提升用户体验

refactor(工单字段): 优化字段管理组件处理空值情况

fix(机柜管理): 修复机柜列表查询接口参数问题

docs: 移除不再使用的工单字段管理页面
This commit is contained in:
zhang1106
2026-03-24 17:10:38 +08:00
parent 1b898814ed
commit 4e8d9be864
13 changed files with 1559 additions and 367 deletions
+61
View File
@@ -584,6 +584,67 @@ router.get('/', validateQuery(queryDeviceSchema), async (req, res) => {
}
});
const MAX_EXPORT_SIZE = 50000;
router.get('/all', async (req, res) => {
try {
const { keyword, status, type, rackId, roomId } = req.query;
const where = {};
if (keyword) {
const escapedKeyword = keyword.replace(/'/g, "''");
where[Op.or] = [
{ deviceId: { [Op.like]: `%${escapedKeyword}%` } },
{ name: { [Op.like]: `%${escapedKeyword}%` } },
{ type: { [Op.like]: `%${escapedKeyword}%` } },
{ model: { [Op.like]: `%${escapedKeyword}%` } },
{ serialNumber: { [Op.like]: `%${escapedKeyword}%` } },
{ ipAddress: { [Op.like]: `%${escapedKeyword}%` } }
];
}
if (status && status !== 'all') {
where.status = status;
}
if (type && type !== 'all') {
where.type = type;
}
if (rackId) {
where.rackId = rackId;
}
if (roomId && roomId !== 'all') {
where['$Rack.roomId$'] = roomId;
}
const devices = await Device.findAll({
where,
include: [
{
model: Rack,
include: [{ model: Room }],
separate: false
}
],
limit: MAX_EXPORT_SIZE,
order: [['createdAt', 'DESC']],
distinct: true,
subQuery: false
});
res.json({
devices,
total: devices.length
});
} catch (error) {
console.error('获取设备列表失败:', error);
res.status(500).json({ error: error.message });
}
});
// 生成设备ID的辅助函数
async function generateDeviceId() {
// 获取当前最大的设备ID序号