添加条形码内容

This commit is contained in:
dxc
2026-02-02 15:06:20 +08:00
parent a1133aac94
commit cf6a4a8957
11 changed files with 449 additions and 34 deletions

View File

@ -1,11 +1,13 @@
# app/api/v1/inbound/buy.py
from flask import Blueprint, request, jsonify
from app.services.inbound.buy_service import BuyInboundService
import traceback
inbound_buy_bp = Blueprint('inbound_buy', __name__)
# ------------------------------------------------------------------
# 0. 基础物料搜索 (新增)
# 0. 基础物料搜索
# ------------------------------------------------------------------
@inbound_buy_bp.route('/search-base', methods=['GET'])
def search_base():
@ -25,6 +27,7 @@ def search_base():
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500
# ------------------------------------------------------------------
# 1. 获取列表
# ------------------------------------------------------------------
@ -38,8 +41,9 @@ def get_list():
except Exception as e:
return jsonify({"code": 500, "msg": str(e)}), 500
# ------------------------------------------------------------------
# 2. 新增入库
# 2. 新增入库 (修改:返回创建的对象数据)
# ------------------------------------------------------------------
@inbound_buy_bp.route('/submit', methods=['POST'])
def submit():
@ -47,12 +51,21 @@ def submit():
data = request.get_json()
if not data:
return jsonify({"code": 400, "msg": "No data"}), 400
BuyInboundService.handle_inbound(data)
return jsonify({"code": 200, "msg": "入库成功"})
# 调用 Service 处理入库,获取新创建的对象
new_stock = BuyInboundService.handle_inbound(data)
# 返回成功信息以及新创建的数据包含生成的ID和SKU供前端打印使用
return jsonify({
"code": 200,
"msg": "入库成功",
"data": new_stock.to_dict()
})
except Exception as e:
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500
# ------------------------------------------------------------------
# 3. 更新入库
# ------------------------------------------------------------------
@ -65,6 +78,7 @@ def update_buy(id):
except Exception as e:
return jsonify({"code": 500, "msg": str(e)}), 500
# ------------------------------------------------------------------
# 4. 删除
# ------------------------------------------------------------------