fix: BOM草稿模块缺陷修复(事务回滚 + 外键约束 + 前端状态清理)
This commit is contained in:
@ -5,8 +5,18 @@ class BomTable(db.Model):
|
||||
__tablename__ = 'bom_table'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
parent_id = db.Column(db.Integer, db.ForeignKey('material_base.id'), nullable=False, index=True) # ★ 父子件关联高频列
|
||||
child_id = db.Column(db.Integer, db.ForeignKey('material_base.id'), nullable=False, index=True) # ★ 子件过滤高频列
|
||||
parent_id = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('material_base.id', ondelete='SET NULL'),
|
||||
nullable=False,
|
||||
index=True
|
||||
)
|
||||
child_id = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('material_base.id', ondelete='SET NULL'),
|
||||
nullable=False,
|
||||
index=True
|
||||
)
|
||||
|
||||
bom_no = db.Column(db.String(100), nullable=False, index=True, comment='BOM编号') # ★ Redis 缓存 Key + 列表查询核心列
|
||||
version = db.Column(db.String(50), nullable=False, default='V1.0', index=True, comment='版本') # ★ 配合 bom_no 做唯一性约束
|
||||
@ -24,5 +34,15 @@ class BomTable(db.Model):
|
||||
)
|
||||
|
||||
# relationships
|
||||
parent = db.relationship('MaterialBase', foreign_keys=[parent_id], backref='bom_parents')
|
||||
child = db.relationship('MaterialBase', foreign_keys=[child_id], backref='bom_children')
|
||||
parent = db.relationship(
|
||||
'MaterialBase',
|
||||
foreign_keys=[parent_id],
|
||||
backref='bom_parents',
|
||||
passive_deletes=True
|
||||
)
|
||||
child = db.relationship(
|
||||
'MaterialBase',
|
||||
foreign_keys=[child_id],
|
||||
backref='bom_children',
|
||||
passive_deletes=True
|
||||
)
|
||||
38
inventory-backend/app/models/bom_draft.py
Normal file
38
inventory-backend/app/models/bom_draft.py
Normal file
@ -0,0 +1,38 @@
|
||||
from app.extensions import db
|
||||
|
||||
|
||||
class BomDraftTable(db.Model):
|
||||
__tablename__ = 'bom_draft_table'
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
bom_no = db.Column(db.String(100), nullable=False, index=True, comment='BOM编号')
|
||||
version = db.Column(db.String(50), nullable=False, default='V1.0', index=True, comment='版本')
|
||||
parent_id = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('material_base.id', ondelete='SET NULL'),
|
||||
nullable=True,
|
||||
comment='父件物料ID'
|
||||
)
|
||||
child_id = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('material_base.id', ondelete='SET NULL'),
|
||||
nullable=True,
|
||||
comment='子件物料ID'
|
||||
)
|
||||
dosage = db.Column(db.Numeric(19, 4), comment='个数')
|
||||
loss_rate = db.Column(db.Numeric(5, 2), default=0, nullable=True, comment='损耗率%')
|
||||
remark = db.Column(db.Text, comment='备注')
|
||||
updated_at = db.Column(db.DateTime, default=db.func.now(), onupdate=db.func.now(), comment='更新时间')
|
||||
|
||||
parent = db.relationship(
|
||||
'MaterialBase',
|
||||
foreign_keys=[parent_id],
|
||||
backref='bom_draft_parents',
|
||||
passive_deletes=True
|
||||
)
|
||||
child = db.relationship(
|
||||
'MaterialBase',
|
||||
foreign_keys=[child_id],
|
||||
backref='bom_draft_children',
|
||||
passive_deletes=True
|
||||
)
|
||||
Reference in New Issue
Block a user