基础信息展示以及搜索逻辑进行修复
This commit is contained in:
@ -44,6 +44,19 @@ def get_list():
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# 2.1 选项接口 (GET /api/v1/inbound/base/options) [新增]
|
||||
# ==============================================================================
|
||||
@inbound_base_bp.route('/options', methods=['GET'])
|
||||
def get_options():
|
||||
try:
|
||||
data = MaterialBaseService.get_distinct_options()
|
||||
return jsonify({"code": 200, "msg": "success", "data": data})
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return jsonify({"code": 500, "msg": str(e)}), 500
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# 3. 新增接口 (POST /api/v1/inbound/base/)
|
||||
# 注意:前端 material_base.ts 可能会请求 / 或 /add,这里统一匹配
|
||||
|
||||
@ -7,21 +7,27 @@ inbound_buy_bp = Blueprint('stock_buy', __name__)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 0. 基础物料搜索
|
||||
# 0. 基础物料搜索 (已修改:支持 page 参数)
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_buy_bp.route('/search-base', methods=['GET'])
|
||||
def search_base():
|
||||
"""
|
||||
供前端下拉框远程搜索使用
|
||||
Query Param: keyword (名称或规格)
|
||||
供前端下拉框远程搜索使用,支持分页
|
||||
Query Param: keyword (名称或规格), page (默认1)
|
||||
"""
|
||||
try:
|
||||
keyword = request.args.get('keyword', '')
|
||||
data = BuyInboundService.search_base_material(keyword)
|
||||
page = request.args.get('page', 1, type=int)
|
||||
# 固定每次加载50条
|
||||
limit = 50
|
||||
|
||||
result = BuyInboundService.search_base_material(keyword, page, limit)
|
||||
return jsonify({
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": data
|
||||
"data": result['items'],
|
||||
"total": result['total'],
|
||||
"has_next": result['has_next']
|
||||
})
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
@ -126,18 +132,20 @@ def get_user_suggestions():
|
||||
data = BuyInboundService.get_history_purchasers(keyword)
|
||||
return jsonify({"code": 200, "msg": "success", "data": data})
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 8. 链接建议
|
||||
# ------------------------------------------------------------------
|
||||
@inbound_buy_bp.route('/suggestions/links', methods=['GET'])
|
||||
def get_link_suggestions():
|
||||
base_id = request.args.get('base_id', type=int)
|
||||
link_type = request.args.get('type', 'original') # original or detail
|
||||
link_type = request.args.get('type', 'original') # original or detail
|
||||
if not base_id:
|
||||
return jsonify({"code": 400, "msg": "base_id required"}), 400
|
||||
data = BuyInboundService.get_history_links(base_id, link_type)
|
||||
return jsonify({"code": 200, "msg": "success", "data": data})
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 9. [新增] 库位建议
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user