物料-采购件入库页面功能实现

This commit is contained in:
dxc
2026-01-27 15:50:23 +08:00
parent 2f8a5c55b1
commit 3afea217b7
45 changed files with 1522 additions and 2756 deletions

View File

@ -0,0 +1,14 @@
from flask import Blueprint
from .buy import inbound_buy_bp
# 后续如果有 semi.py 或 product.py在这里导入
# from .semi import inbound_semi_bp
# 创建聚合蓝图
inbound_bp = Blueprint('inbound', __name__)
# 挂载子模块。url_prefix 会进行路径拼接
# 路径变为:/buy/...
inbound_bp.register_blueprint(inbound_buy_bp, url_prefix='/buy')
# 后续扩展:
# inbound_bp.register_blueprint(inbound_semi_bp, url_prefix='/semi')

View File

@ -0,0 +1,70 @@
from flask import Blueprint, request, jsonify
from app.services.inbound.buy_service import BuyInboundService
import traceback
# 定义蓝图
inbound_buy_bp = Blueprint('inbound_buy', __name__)
# ------------------------------------------------------------------
# 1. 获取列表 (GET)
# ------------------------------------------------------------------
@inbound_buy_bp.route('/list', methods=['GET'])
def get_list():
try:
page = request.args.get('page', 1, type=int)
limit = request.args.get('pageSize', 15, type=int)
result = BuyInboundService.get_list(page, limit)
return jsonify({
"code": 200,
"msg": "success",
"data": result
})
except Exception as e:
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500
# ------------------------------------------------------------------
# 2. 新增入库 (POST)
# ------------------------------------------------------------------
@inbound_buy_bp.route('/submit', methods=['POST'])
def submit():
try:
data = request.get_json()
if not data:
return jsonify({"code": 400, "msg": "No data provided"}), 400
BuyInboundService.handle_inbound(data)
return jsonify({"code": 200, "msg": "入库成功"})
except Exception as e:
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500
# ------------------------------------------------------------------
# 3. 更新入库 (PUT)
# ------------------------------------------------------------------
@inbound_buy_bp.route('/<int:id>', methods=['PUT'])
def update_buy(id):
try:
data = request.get_json()
BuyInboundService.update_inbound(id, data)
return jsonify({"code": 200, "msg": "更新成功"})
except Exception as e:
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500
# ------------------------------------------------------------------
# 4. 删除入库 (DELETE)
# ------------------------------------------------------------------
@inbound_buy_bp.route('/<int:id>', methods=['DELETE'])
def delete_buy(id):
try:
BuyInboundService.delete_inbound(id)
return jsonify({"code": 200, "msg": "删除成功"})
except Exception as e:
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500