refactor: 统一代码风格并迁移至 ESLint 新配置
style(backend): 格式化模型文件代码 style(frontend): 调整组件代码格式 chore: 删除旧 ESLint 配置并添加新配置 refactor(backend): 重构模型定义语法 style: 统一箭头函数和对象属性简写
This commit is contained in:
+109
-105
@@ -1,112 +1,116 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../db');
|
||||
|
||||
const ConsumableLog = sequelize.define('ConsumableLog', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
const ConsumableLog = sequelize.define(
|
||||
'ConsumableLog',
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
consumableId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '耗材ID',
|
||||
},
|
||||
consumableName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '耗材名称',
|
||||
},
|
||||
operationType: {
|
||||
type: DataTypes.ENUM('in', 'out', 'create', 'update', 'delete', 'adjust', 'import'),
|
||||
allowNull: false,
|
||||
comment: '操作类型',
|
||||
},
|
||||
quantity: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0,
|
||||
comment: '变动数量(入库为正,出库为负)',
|
||||
},
|
||||
previousStock: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
comment: '操作前库存',
|
||||
},
|
||||
currentStock: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
comment: '操作后库存',
|
||||
},
|
||||
operator: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '操作人',
|
||||
},
|
||||
reason: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '操作原因',
|
||||
},
|
||||
notes: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: '备注',
|
||||
},
|
||||
relatedId: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '关联ID(如订单号、盘点ID等)',
|
||||
},
|
||||
isEditable: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: true,
|
||||
comment: '是否可编辑(创建、导入的记录可编辑,系统生成的出入库记录不可编辑)',
|
||||
},
|
||||
originalLogId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
comment: '原始日志ID(用于追踪修改历史链)',
|
||||
},
|
||||
modifiedBy: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
comment: '修改人',
|
||||
},
|
||||
modifiedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
comment: '修改时间',
|
||||
},
|
||||
modificationReason: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
comment: '修改原因',
|
||||
},
|
||||
isConsumableDeleted: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
comment: '关联耗材是否已被删除',
|
||||
},
|
||||
consumableSnapshot: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
comment: '耗材快照信息(分类、单位、供应商等),用于耗材删除后追溯',
|
||||
},
|
||||
snList: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
defaultValue: [],
|
||||
comment: '本次操作的SN序列号列表',
|
||||
},
|
||||
},
|
||||
consumableId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '耗材ID'
|
||||
},
|
||||
consumableName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '耗材名称'
|
||||
},
|
||||
operationType: {
|
||||
type: DataTypes.ENUM('in', 'out', 'create', 'update', 'delete', 'adjust', 'import'),
|
||||
allowNull: false,
|
||||
comment: '操作类型'
|
||||
},
|
||||
quantity: {
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 0,
|
||||
comment: '变动数量(入库为正,出库为负)'
|
||||
},
|
||||
previousStock: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
comment: '操作前库存'
|
||||
},
|
||||
currentStock: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
comment: '操作后库存'
|
||||
},
|
||||
operator: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '操作人'
|
||||
},
|
||||
reason: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '操作原因'
|
||||
},
|
||||
notes: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: '备注'
|
||||
},
|
||||
relatedId: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '关联ID(如订单号、盘点ID等)'
|
||||
},
|
||||
isEditable: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: true,
|
||||
comment: '是否可编辑(创建、导入的记录可编辑,系统生成的出入库记录不可编辑)'
|
||||
},
|
||||
originalLogId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
comment: '原始日志ID(用于追踪修改历史链)'
|
||||
},
|
||||
modifiedBy: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
comment: '修改人'
|
||||
},
|
||||
modifiedAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: true,
|
||||
comment: '修改时间'
|
||||
},
|
||||
modificationReason: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
comment: '修改原因'
|
||||
},
|
||||
isConsumableDeleted: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: false,
|
||||
comment: '关联耗材是否已被删除'
|
||||
},
|
||||
consumableSnapshot: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
comment: '耗材快照信息(分类、单位、供应商等),用于耗材删除后追溯'
|
||||
},
|
||||
snList: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
defaultValue: [],
|
||||
comment: '本次操作的SN序列号列表'
|
||||
{
|
||||
tableName: 'consumable_logs',
|
||||
timestamps: true,
|
||||
comment: '耗材操作日志表',
|
||||
indexes: [
|
||||
{ fields: ['consumableId'] },
|
||||
{ fields: ['operationType'] },
|
||||
{ fields: ['createdAt'] },
|
||||
{ fields: ['consumableId', 'createdAt'] },
|
||||
{ fields: ['originalLogId'] },
|
||||
{ fields: ['isEditable'] },
|
||||
{ fields: ['isConsumableDeleted'] },
|
||||
],
|
||||
}
|
||||
}, {
|
||||
tableName: 'consumable_logs',
|
||||
timestamps: true,
|
||||
comment: '耗材操作日志表',
|
||||
indexes: [
|
||||
{ fields: ['consumableId'] },
|
||||
{ fields: ['operationType'] },
|
||||
{ fields: ['createdAt'] },
|
||||
{ fields: ['consumableId', 'createdAt'] },
|
||||
{ fields: ['originalLogId'] },
|
||||
{ fields: ['isEditable'] },
|
||||
{ fields: ['isConsumableDeleted'] }
|
||||
]
|
||||
});
|
||||
);
|
||||
|
||||
module.exports = ConsumableLog;
|
||||
|
||||
Reference in New Issue
Block a user