WMS_MAIN/app/model/workbench.js

95 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';
module.exports = app => {
const { STRING, BIGINT, DATE, TINYINT, ENUM, JSON: JSON_TYPE } = app.Sequelize;
const Workbench = app.model.define('workbench', {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
comment: '主键ID',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID',
},
name: {
type: STRING(100),
allowNull: false,
comment: '工作台名称(用户自定义)',
},
barcode: {
type: STRING(100),
allowNull: true,
comment: '工作台条码(用户自定义,仓库内唯一)',
},
status: {
type: TINYINT,
allowNull: false,
defaultValue: 1,
comment: '状态:0-禁用 1-启用',
},
type: {
type: ENUM('personal', 'group'),
allowNull: false,
defaultValue: 'personal',
comment: '工作台类型:personal-个人工作台 group-团体工作台',
},
remark: {
type: STRING(500),
allowNull: true,
comment: '备注',
},
device_ids: {
type: JSON_TYPE,
allowNull: true,
comment: '设备ID列表,如 [1,2,3],触发打包任务时透传到 wms_pack_task.device_ids',
},
login_code: {
type: STRING(64),
allowNull: true,
comment: '工作台登录码(前缀+随机,64位,全局唯一)',
},
token: {
type: STRING(64),
allowNull: true,
comment: '工作台令牌(随机64位,绑定后生成)',
},
created_at: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
updated_at: {
type: DATE,
allowNull: false,
comment: '更新时间',
},
deleted_at: {
type: DATE,
allowNull: true,
comment: '软删除时间',
},
}, {
tableName: 'wms_workbench',
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
paranoid: true,
deletedAt: 'deleted_at',
comment: '工作台表',
indexes: [
{ name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] },
{ name: 'idx_barcode', fields: [ 'barcode' ] },
{ name: 'uk_warehouse_barcode', unique: true, fields: [ 'warehouse_id', 'barcode', 'deleted_at' ] },
{ name: 'uk_login_code', unique: true, fields: [ 'login_code' ] },
{ name: 'idx_token', fields: [ 'token' ] },
{ name: 'idx_deleted_at', fields: [ 'deleted_at' ] },
],
});
return Workbench;
};