feat: BOM 库存接口支持按版本查询,修复同一编号多版本下拉回显错乱

This commit is contained in:
yueli
2026-09-02 18:39:17 +08:00
parent 85130db6ea
commit bf7b2cc6d3
3 changed files with 9 additions and 7 deletions

View File

@ -198,9 +198,10 @@ def save_bom():
@jwt_required()
@permission_required('bom_manage')
def get_bom_with_stock_by_no(bom_no):
"""根据 BOM 编号获取配方详情及库存信息"""
"""根据 BOM 编号 (和可选 version) 获取配方详情及库存信息"""
try:
data = BomService.get_bom_with_stock_by_bom_no(bom_no)
version = request.args.get('version')
data = BomService.get_bom_with_stock_by_bom_no(bom_no, version=version)
if not data:
return jsonify({'code': 404, 'msg': 'BOM 不存在'}), 404
# 字段级脱敏

View File

@ -422,11 +422,11 @@ class BomService:
return bom_no
@staticmethod
def get_bom_with_stock_by_bom_no(bom_no):
def get_bom_with_stock_by_bom_no(bom_no, version=None):
"""
根据 bom_no 获取配方详情,并计算(已修复 N+1 性能问题)
根据 bom_no (和可选 version) 获取配方详情,并计算(已修复 N+1 性能问题)
"""
detail = BomService.get_bom_detail(bom_no)
detail = BomService.get_bom_detail(bom_no, version=version)
if not detail or not detail.get('children'):
return detail