feat: BOM 库存接口支持按版本查询,修复同一编号多版本下拉回显错乱
This commit is contained in:
@ -198,9 +198,10 @@ def save_bom():
|
|||||||
@jwt_required()
|
@jwt_required()
|
||||||
@permission_required('bom_manage')
|
@permission_required('bom_manage')
|
||||||
def get_bom_with_stock_by_no(bom_no):
|
def get_bom_with_stock_by_no(bom_no):
|
||||||
"""根据 BOM 编号获取配方详情及库存信息"""
|
"""根据 BOM 编号 (和可选 version) 获取配方详情及库存信息"""
|
||||||
try:
|
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:
|
if not data:
|
||||||
return jsonify({'code': 404, 'msg': 'BOM 不存在'}), 404
|
return jsonify({'code': 404, 'msg': 'BOM 不存在'}), 404
|
||||||
# 字段级脱敏
|
# 字段级脱敏
|
||||||
|
|||||||
@ -422,11 +422,11 @@ class BomService:
|
|||||||
return bom_no
|
return bom_no
|
||||||
|
|
||||||
@staticmethod
|
@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'):
|
if not detail or not detail.get('children'):
|
||||||
return detail
|
return detail
|
||||||
|
|
||||||
|
|||||||
@ -19,12 +19,13 @@ export function getBomSummary(params?: { keyword?: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取BOM详情(含库存信息)
|
// 获取BOM详情(含库存信息)
|
||||||
export function getBomWithStock(bomNo: string) {
|
export function getBomWithStock(bomNo: string, version?: string) {
|
||||||
const trimmed = bomNo.replace(/^\/+|\/+$/g, '');
|
const trimmed = bomNo.replace(/^\/+|\/+$/g, '');
|
||||||
const encoded = encodeURIComponent(trimmed);
|
const encoded = encodeURIComponent(trimmed);
|
||||||
return request({
|
return request({
|
||||||
url: `/v1/bom/stock/${encoded}`,
|
url: `/v1/bom/stock/${encoded}`,
|
||||||
method: 'get'
|
method: 'get',
|
||||||
|
params: version ? { version } : {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user