refactor: 统一代码风格并迁移至 ESLint 新配置

style(backend): 格式化模型文件代码
style(frontend): 调整组件代码格式
chore: 删除旧 ESLint 配置并添加新配置
refactor(backend): 重构模型定义语法
style: 统一箭头函数和对象属性简写
This commit is contained in:
zhang1106
2026-03-27 19:12:16 +08:00
parent 6a8d4144ff
commit 63f0cb570e
166 changed files with 15483 additions and 11170 deletions
+158 -154
View File
@@ -6,168 +6,172 @@ const InventoryTask = require('./InventoryTask');
const Room = require('./Room');
const Rack = require('./Rack');
const PendingDevice = sequelize.define('PendingDevice', {
pendingId: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false,
unique: true
},
serialNumber: {
type: DataTypes.STRING,
allowNull: false,
comment: '设备序列号'
},
deviceName: {
type: DataTypes.STRING,
allowNull: true,
comment: '设备名称'
},
deviceType: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: 'other',
comment: '设备类型: server, switch, router, storage, other'
},
roomId: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: Room,
key: 'roomId'
const PendingDevice = sequelize.define(
'PendingDevice',
{
pendingId: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false,
unique: true,
},
comment: '所属机房ID'
},
rackId: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: Rack,
key: 'rackId'
serialNumber: {
type: DataTypes.STRING,
allowNull: false,
comment: '设备序列号',
},
comment: '所属机柜ID'
},
position: {
type: DataTypes.INTEGER,
allowNull: true,
comment: 'U位'
},
height: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: 1,
comment: '高度(U)'
},
powerConsumption: {
type: DataTypes.FLOAT,
allowNull: true,
defaultValue: 0,
comment: '功率(W)'
},
model: {
type: DataTypes.STRING,
allowNull: true,
comment: '设备型号'
},
brand: {
type: DataTypes.STRING,
allowNull: true,
comment: '品牌'
},
ipAddress: {
type: DataTypes.STRING,
allowNull: true,
comment: 'IP地址'
},
purchaseDate: {
type: DataTypes.DATE,
allowNull: true,
comment: '购买日期'
},
warrantyExpiry: {
type: DataTypes.DATE,
allowNull: true,
comment: '保修到期'
},
description: {
type: DataTypes.TEXT,
allowNull: true,
comment: '描述'
},
customFields: {
type: DataTypes.JSON,
defaultValue: {},
allowNull: true
},
status: {
type: DataTypes.STRING,
defaultValue: 'pending',
comment: 'pending: 待同步, synced: 已同步, deleted: 已删除'
},
planId: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: InventoryPlan,
key: 'planId'
deviceName: {
type: DataTypes.STRING,
allowNull: true,
comment: '设备名称',
},
comment: '关联的盘点计划ID'
},
taskId: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: InventoryTask,
key: 'taskId'
deviceType: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: 'other',
comment: '设备类型: server, switch, router, storage, other',
},
comment: '关联的盘点任务ID'
},
createdBy: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: User,
key: 'userId'
roomId: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: Room,
key: 'roomId',
},
comment: '所属机房ID',
},
comment: '创建人'
},
syncedAt: {
type: DataTypes.DATE,
allowNull: true,
comment: '同步时间'
},
syncedBy: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: User,
key: 'userId'
rackId: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: Rack,
key: 'rackId',
},
comment: '所属机柜ID',
},
position: {
type: DataTypes.INTEGER,
allowNull: true,
comment: 'U位',
},
height: {
type: DataTypes.INTEGER,
allowNull: true,
defaultValue: 1,
comment: '高度(U)',
},
powerConsumption: {
type: DataTypes.FLOAT,
allowNull: true,
defaultValue: 0,
comment: '功率(W)',
},
model: {
type: DataTypes.STRING,
allowNull: true,
comment: '设备型号',
},
brand: {
type: DataTypes.STRING,
allowNull: true,
comment: '品牌',
},
ipAddress: {
type: DataTypes.STRING,
allowNull: true,
comment: 'IP地址',
},
purchaseDate: {
type: DataTypes.DATE,
allowNull: true,
comment: '购买日期',
},
warrantyExpiry: {
type: DataTypes.DATE,
allowNull: true,
comment: '保修到期',
},
description: {
type: DataTypes.TEXT,
allowNull: true,
comment: '描述',
},
customFields: {
type: DataTypes.JSON,
defaultValue: {},
allowNull: true,
},
status: {
type: DataTypes.STRING,
defaultValue: 'pending',
comment: 'pending: 待同步, synced: 已同步, deleted: 已删除',
},
planId: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: InventoryPlan,
key: 'planId',
},
comment: '关联的盘点计划ID',
},
taskId: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: InventoryTask,
key: 'taskId',
},
comment: '关联的盘点任务ID',
},
createdBy: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: User,
key: 'userId',
},
comment: '创建人',
},
syncedAt: {
type: DataTypes.DATE,
allowNull: true,
comment: '同步时间',
},
syncedBy: {
type: DataTypes.STRING,
allowNull: true,
references: {
model: User,
key: 'userId',
},
comment: '同步人',
},
syncedDeviceId: {
type: DataTypes.STRING,
allowNull: true,
comment: '同步后生成的设备ID',
},
remark: {
type: DataTypes.TEXT,
allowNull: true,
comment: '备注',
},
comment: '同步人'
},
syncedDeviceId: {
type: DataTypes.STRING,
allowNull: true,
comment: '同步后生成的设备ID'
},
remark: {
type: DataTypes.TEXT,
allowNull: true,
comment: '备注'
{
tableName: 'pending_devices',
timestamps: true,
indexes: [
{ fields: ['serialNumber'] },
{ fields: ['status'] },
{ fields: ['planId'] },
{ fields: ['taskId'] },
{ fields: ['createdBy'] },
{ fields: ['roomId'] },
{ fields: ['rackId'] },
],
}
}, {
tableName: 'pending_devices',
timestamps: true,
indexes: [
{ fields: ['serialNumber'] },
{ fields: ['status'] },
{ fields: ['planId'] },
{ fields: ['taskId'] },
{ fields: ['createdBy'] },
{ fields: ['roomId'] },
{ fields: ['rackId'] }
]
});
);
PendingDevice.belongsTo(User, { foreignKey: 'createdBy', as: 'Creator' });
PendingDevice.belongsTo(User, { foreignKey: 'syncedBy', as: 'Syncer' });