feat(floorplan): 新增机房平面图功能模块

refactor(models): 为Room和Rack模型添加布局相关字段
feat(routes): 实现机房平面图相关API接口
feat(components): 添加平面图编辑器、画布渲染及交互组件
feat(hooks): 实现平面图数据管理和状态管理
feat(pages): 新增机房平面图页面入口
style(components): 优化平面图组件样式和交互体验
This commit is contained in:
zhang1106
2026-04-30 16:26:39 +08:00
parent 4ab5265882
commit 979c28fdcd
34 changed files with 3108 additions and 62 deletions
+36
View File
@@ -691,4 +691,40 @@ router.post('/import', async (req, res) => {
}
});
// 更新机柜位置
router.put('/:rackId/position', async (req, res) => {
try {
const { rowPos, colPos, facing } = req.body;
const rack = await Rack.findByPk(req.params.rackId);
if (!rack) {
return res.status(404).json({ error: '机柜不存在' });
}
if (rowPos !== undefined && colPos !== undefined) {
const conflict = await Rack.findOne({
where: {
roomId: rack.roomId,
rackId: { [require('sequelize').Op.ne]: req.params.rackId },
rowPos,
colPos,
},
});
if (conflict) {
return res.status(409).json({ error: `位置(${rowPos},${colPos})已被机柜${conflict.name}占用` });
}
}
const updateData = {};
if (rowPos !== undefined) updateData.rowPos = rowPos;
if (colPos !== undefined) updateData.colPos = colPos;
if (facing !== undefined) updateData.facing = facing;
await Rack.update(updateData, { where: { rackId: req.params.rackId } });
const updatedRack = await Rack.findByPk(req.params.rackId);
res.json(updatedRack);
} catch (error) {
res.status(400).json({ error: error.message });
}
});
module.exports = router;