feat: 打通采购申请与入库的按单入库链路

后端变更:
- PurchaseRequest 新增 base_id 硬关联 MaterialBase,StockBuy 新增 request_id 关联采购单
- handle_inbound 支持 request_id 入参,入库后自动反写采购单状态为已完成
- 新增 get_approved_requests 接口,返回已审批未入库采购单列表(含物料信息+历史数据回退匹配)
- create_purchase_request 新增 name+spec_model 自动匹配 MaterialBase
- 新增 SQL 和 Alembic 数据库迁移脚本

前端变更:
- 入库表单新增"从采购单导入"弹窗,支持搜索/选中已审批采购单并一键填充物料和商务信息
- 单价/总价交叉推算,缺项自动补全
- 选中行蓝色高亮+点击整行选中,行级交互优化
This commit is contained in:
yueli
2026-07-14 15:25:00 +08:00
parent 88b754120b
commit a11b7972c3
9 changed files with 643 additions and 16 deletions

View File

@ -208,7 +208,30 @@ def auto_fill_purchase():
# --------------------------------------------------------
# 7. 物料基础信息搜索(分页
# 7. 已审批且未入库的采购单列表(供库管按单入库使用
# GET /api/v1/purchase/approved-unstocked?page=1&keyword=xxx
# --------------------------------------------------------
@purchase_bp.route('/approved-unstocked', methods=['GET'])
@jwt_required()
def get_approved_unstocked_requests():
"""获取已审批通过且未入库的采购申请列表"""
try:
page = int(request.args.get('page', 1))
per_page = int(request.args.get('limit', 20))
keyword = request.args.get('keyword', '').strip() or None
result = PurchaseService.get_approved_requests(
page=page, per_page=per_page, keyword=keyword
)
return jsonify({'code': 200, 'msg': '获取成功', 'data': result}), 200
except Exception as e:
traceback.print_exc()
return jsonify({'code': 500, 'msg': f'获取失败: {str(e)}'}), 500
# --------------------------------------------------------
# 8. 物料基础信息搜索(分页)
# GET /api/v1/purchase/search-material?keyword=xxx&page=1
# --------------------------------------------------------
@purchase_bp.route('/search-material', methods=['GET'])