WMS_MAIN/app/model/package_material.js
liufumingren abf2c4d94a 1
2026-05-29 16:47:38 +08:00

115 lines
2.5 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.

'use strict';
/**
* 包材信息模型。
* @param {import('egg').Application} app Egg 应用实例。
* @return {import('sequelize').ModelCtor<import('sequelize').Model>} Sequelize 模型。
*/
module.exports = app => {
const { BIGINT, STRING, DECIMAL, TINYINT, INTEGER, DATE } = app.Sequelize;
const PackageMaterial = app.model.define('package_material', {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键ID',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID',
},
material_code: {
type: STRING(64),
allowNull: false,
comment: '包材编码',
},
material_name: {
type: STRING(128),
allowNull: false,
comment: '包材名称',
},
material_type: {
type: STRING(32),
allowNull: true,
comment: '包材类型',
},
spec: {
type: STRING(128),
allowNull: true,
comment: '规格描述',
},
length: {
type: DECIMAL(10, 2),
allowNull: true,
comment: '长度(cm)',
},
width: {
type: DECIMAL(10, 2),
allowNull: true,
comment: '宽度(cm)',
},
height: {
type: DECIMAL(10, 2),
allowNull: true,
comment: '高度(cm)',
},
weight: {
type: DECIMAL(10, 3),
allowNull: true,
comment: '重量(kg)',
},
cost_price: {
type: DECIMAL(10, 2),
allowNull: true,
comment: '成本单价',
},
status: {
type: TINYINT(1),
allowNull: false,
defaultValue: 1,
comment: '状态:0=禁用,1=启用',
},
version: {
type: INTEGER.UNSIGNED,
allowNull: false,
defaultValue: 1,
comment: '版本号',
},
created_at: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
updated_at: {
type: DATE,
allowNull: false,
comment: '更新时间',
},
}, {
tableName: 'wms_package_material',
freezeTableName: true,
underscored: true,
timestamps: true,
paranoid: false,
createdAt: 'created_at',
updatedAt: 'updated_at',
comment: '包材信息表',
indexes: [
{
name: 'idx_wms_package_material_warehouse_id',
fields: [ 'warehouse_id' ],
},
{
name: 'uk_wms_package_material_warehouse_material_code',
unique: true,
fields: [ 'warehouse_id', 'material_code' ],
},
],
});
return PackageMaterial;
};