WMS_MAIN/app/model/entry_order_receiving.js
liufumingren 5ef99e3bed 1
2026-07-01 14:00:59 +08:00

77 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.

'use strict';
module.exports = app => {
const { BIGINT, DATE } = app.Sequelize;
const EntryOrderReceiving = app.model.define('wms_entry_order_receiving', {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
comment: '主键ID',
},
entry_order_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '入库单ID,关联 wms_entry_order.id',
},
receiving_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '收货单ID,关联 wms_receiving.id',
},
created_at: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
updated_at: {
type: DATE,
allowNull: false,
comment: '更新时间',
},
}, {
tableName: 'wms_entry_order_receiving',
comment: '入库单-收货单主表级绑定关系表',
timestamps: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
paranoid: true,
deletedAt: 'deleted_at',
indexes: [
{
name: 'idx_entry_order_id',
fields: [ 'entry_order_id' ],
},
{
name: 'idx_receiving_id',
fields: [ 'receiving_id' ],
},
{
name: 'uk_entry_order_receiving',
unique: true,
fields: [ 'entry_order_id', 'receiving_id' ],
},
],
});
// 关联关系
EntryOrderReceiving.associate = function() {
const { EntryOrderReceiving, EntryOrder, Receiving } = app.model;
// 关联入库单
EntryOrderReceiving.belongsTo(EntryOrder, {
foreignKey: 'entry_order_id',
as: 'entryOrder',
});
// 关联收货单
EntryOrderReceiving.belongsTo(Receiving, {
foreignKey: 'receiving_id',
as: 'receiving',
});
};
return EntryOrderReceiving;
};