Files
yunrui_asset/backend/models/InventoryTask.js
T
zhang1106 63f0cb570e refactor: 统一代码风格并迁移至 ESLint 新配置
style(backend): 格式化模型文件代码
style(frontend): 调整组件代码格式
chore: 删除旧 ESLint 配置并添加新配置
refactor(backend): 重构模型定义语法
style: 统一箭头函数和对象属性简写
2026-03-27 19:12:16 +08:00

82 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { DataTypes } = require('sequelize');
const { sequelize } = require('../db');
const InventoryTask = sequelize.define(
'InventoryTask',
{
taskId: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false,
unique: true,
},
planId: {
type: DataTypes.STRING,
allowNull: false,
},
targetType: {
type: DataTypes.STRING,
allowNull: false,
comment: 'room:机房, rack:机柜, device:设备',
},
targetId: {
type: DataTypes.STRING,
allowNull: false,
comment: '目标ID(机房ID/机柜ID/设备ID',
},
targetName: {
type: DataTypes.STRING,
allowNull: true,
comment: '目标名称',
},
status: {
type: DataTypes.STRING,
defaultValue: 'pending',
comment: 'pending:待执行, in_progress:进行中, completed:已完成, skipped:已跳过',
},
totalDevices: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: '设备总数',
},
checkedDevices: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: '已盘点设备数',
},
normalDevices: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: '正常设备数',
},
abnormalDevices: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: '异常设备数',
},
assignedTo: {
type: DataTypes.STRING,
allowNull: true,
},
assignedAt: {
type: DataTypes.DATE,
allowNull: true,
},
completedAt: {
type: DataTypes.DATE,
allowNull: true,
},
remark: {
type: DataTypes.TEXT,
allowNull: true,
},
},
{
tableName: 'inventory_tasks',
timestamps: true,
indexes: [{ fields: ['planId'] }, { fields: ['status'] }, { fields: ['assignedTo'] }],
}
);
module.exports = InventoryTask;