feat(设备字段): 添加系统字段保护机制

为设备字段添加isSystem属性标记系统字段,防止误删核心字段
后端添加字段删除前的系统字段检查
前端在管理界面标记并禁用系统字段的删除操作
更新导入模板生成逻辑以适配动态字段配置
优化设备导入功能,支持字段名称变更
This commit is contained in:
zhang1106
2026-02-04 17:10:58 +08:00
parent b4d8749fff
commit 8ac528356e
9 changed files with 501 additions and 190 deletions
+32
View File
@@ -0,0 +1,32 @@
const { sequelize } = require('../db');
async function updateSystemFields() {
try {
console.log('开始更新系统字段标记...');
// 系统字段列表
const systemFields = [
'deviceId', 'name', 'type', 'model', 'serialNumber',
'rackId', 'position', 'height', 'powerConsumption',
'status', 'purchaseDate', 'warrantyExpiry',
'ipAddress', 'description'
];
// 更新系统字段标记
for (const fieldName of systemFields) {
const [result] = await sequelize.query(
`UPDATE deviceFields SET isSystem = 1 WHERE fieldName = '${fieldName}'`,
{ type: sequelize.QueryTypes.RAW }
);
console.log(`标记系统字段: ${fieldName}`);
}
console.log('系统字段标记更新完成');
process.exit(0);
} catch (error) {
console.error('更新失败:', error);
process.exit(1);
}
}
updateSystemFields();