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
+78 -74
View File
@@ -1,81 +1,85 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../db');
const Consumable = sequelize.define('Consumable', {
consumableId: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false
const Consumable = sequelize.define(
'Consumable',
{
consumableId: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
category: {
type: DataTypes.STRING,
allowNull: false,
},
unit: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: '个',
},
currentStock: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
},
minStock: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 10,
},
maxStock: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '最大库存,0表示无限制',
},
unitPrice: {
type: DataTypes.DECIMAL(10, 2),
allowNull: false,
defaultValue: 0,
},
supplier: {
type: DataTypes.STRING,
},
location: {
type: DataTypes.STRING,
comment: '存放位置',
},
description: {
type: DataTypes.TEXT,
},
snList: {
type: DataTypes.JSON,
allowNull: true,
defaultValue: [],
comment: 'SN序列号列表,JSON数组格式',
},
status: {
type: DataTypes.STRING,
defaultValue: 'active',
},
version: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '乐观锁版本号',
},
},
name: {
type: DataTypes.STRING,
allowNull: false
},
category: {
type: DataTypes.STRING,
allowNull: false
},
unit: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: '个'
},
currentStock: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0
},
minStock: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 10
},
maxStock: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '最大库存,0表示无限制'
},
unitPrice: {
type: DataTypes.DECIMAL(10, 2),
allowNull: false,
defaultValue: 0
},
supplier: {
type: DataTypes.STRING
},
location: {
type: DataTypes.STRING,
comment: '存放位置'
},
description: {
type: DataTypes.TEXT
},
snList: {
type: DataTypes.JSON,
allowNull: true,
defaultValue: [],
comment: 'SN序列号列表,JSON数组格式'
},
status: {
type: DataTypes.STRING,
defaultValue: 'active'
},
version: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '乐观锁版本号'
{
tableName: 'consumables',
timestamps: true,
indexes: [
{ fields: ['category'] },
{ fields: ['status'] },
{ fields: ['category', 'status'] },
{ fields: ['updatedAt'] },
],
}
}, {
tableName: 'consumables',
timestamps: true,
indexes: [
{ fields: ['category'] },
{ fields: ['status'] },
{ fields: ['category', 'status'] },
{ fields: ['updatedAt'] }
]
});
);
module.exports = Consumable;