修正新增入库时3个组件的名称筛选逻辑
This commit is contained in:
@ -7,19 +7,27 @@ inbound_product_bp = Blueprint('inbound_product', __name__)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 0. 基础物料搜索
|
||||
# 0. 基础物料搜索 (关键接口:配合 Service 实现自动回填)
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_product_bp.route('/search-base', methods=['GET'])
|
||||
def search_base():
|
||||
"""
|
||||
对应前端 API: /inbound/product/search-base
|
||||
功能: 模糊搜索基础物料,返回 spec, unit, category, type 等详细信息
|
||||
"""
|
||||
try:
|
||||
data = ProductInboundService.search_base_material(request.args.get('keyword', ''))
|
||||
keyword = request.args.get('keyword', '')
|
||||
# 调用 Service 层已修复的 search_base_material 方法
|
||||
data = ProductInboundService.search_base_material(keyword)
|
||||
return jsonify({"code": 200, "msg": "success", "data": data})
|
||||
except Exception as e:
|
||||
# 捕获异常并打印堆栈,方便调试
|
||||
traceback.print_exc()
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 1. 获取列表 (修改:接收 status 参数)
|
||||
# 1. 获取列表 (支持 status 多选筛选)
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_product_bp.route('/list', methods=['GET'])
|
||||
def get_list():
|
||||
@ -27,13 +35,15 @@ def get_list():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
limit = request.args.get('pageSize', 15, type=int)
|
||||
keyword = request.args.get('keyword', '')
|
||||
# 接收状态参数
|
||||
|
||||
# 接收状态参数 (逗号分隔字符串 -> 列表)
|
||||
statuses_str = request.args.get('statuses', '')
|
||||
statuses = statuses_str.split(',') if statuses_str else []
|
||||
|
||||
result = ProductInboundService.get_list(page, limit, keyword, statuses)
|
||||
return jsonify({"code": 200, "msg": "success", "data": result})
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
@ -46,7 +56,7 @@ def submit():
|
||||
# 调用 Service 处理入库,获取新创建的对象
|
||||
new_stock = ProductInboundService.handle_inbound(request.get_json())
|
||||
|
||||
# 返回成功信息以及新创建的数据(包含生成的ID和SKU),供前端打印使用
|
||||
# 返回成功信息以及新创建的数据(包含生成的ID和SKU),供前端自动打印使用
|
||||
return jsonify({
|
||||
"code": 200,
|
||||
"msg": "入库成功",
|
||||
@ -66,6 +76,7 @@ def update(id):
|
||||
ProductInboundService.update_inbound(id, request.get_json())
|
||||
return jsonify({"code": 200, "msg": "更新成功"})
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
@ -78,11 +89,12 @@ def delete(id):
|
||||
ProductInboundService.delete_inbound(id)
|
||||
return jsonify({"code": 200, "msg": "删除成功"})
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 5. [新增] 获取出库历史
|
||||
# 5. 获取出库历史
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_product_bp.route('/<int:id>/history', methods=['GET'])
|
||||
def get_history(id):
|
||||
@ -90,4 +102,5 @@ def get_history(id):
|
||||
data = ProductInboundService.get_outbound_history(id)
|
||||
return jsonify({"code": 200, "msg": "success", "data": data})
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
Reference in New Issue
Block a user