fix: 彻底解耦出库/借库权限联动 + 路由去硬编码roles + 补API权限保护
根因: 借库选单页面14处硬编码outbound_selection:operation, 导致两模块权限联动 修复: - borrow/apply: 14处outbound_selection:operation→op_borrow_apply:operation - stock.py: 拆分_do_get_stock_list裸逻辑, 出库/借库各绑独立权限码 - transactions: 新增/borrow/stock-list端点(@permission(op_borrow_apply)) - transaction.ts: 新增getBorrowStockList前端API函数 - outbound.py: 出库审批4端点改用独立outbound_approval权限码 - transactions.py: 借库审批3端点补@permission(op_borrow_approval) - purchase.py: 采购管理7端点补@permission(inbound_buy) - audit.py: 审计日志补@permission(system_audit) - router: 清除全部6处硬编码roles, 交由动态权限树控制
This commit is contained in:
@ -209,15 +209,9 @@ def get_all_stock():
|
||||
# ==============================================================================
|
||||
# 分页库存查询接口(服务端分页,出库/盘点/借用模块共用)
|
||||
# ==============================================================================
|
||||
@bp.route('/list', methods=['GET'])
|
||||
@jwt_required()
|
||||
def get_stock_list():
|
||||
def _do_get_stock_list():
|
||||
"""
|
||||
分页获取库存列表(stock_quantity > 0)
|
||||
参数:
|
||||
page - 页码(默认 1)
|
||||
pageSize - 每页条数(默认 20)
|
||||
keyword - 搜索关键字(模糊匹配名称/规格/SKU)
|
||||
分页获取库存列表(stock_quantity > 0) — 裸逻辑,供各模块复用
|
||||
"""
|
||||
try:
|
||||
page = request.args.get('page', 1, type=int)
|
||||
@ -352,6 +346,14 @@ def get_stock_list():
|
||||
return jsonify({'msg': f'获取库存列表失败: {str(e)}'}), 500
|
||||
|
||||
|
||||
@bp.route('/list', methods=['GET'])
|
||||
@jwt_required()
|
||||
@permission_required('outbound_selection')
|
||||
def get_stock_list():
|
||||
"""出库选单专用库存列表"""
|
||||
return _do_get_stock_list()
|
||||
|
||||
|
||||
# --- 草稿箱接口 ---
|
||||
|
||||
@bp.route('/draft/list', methods=['GET'])
|
||||
|
||||
@ -234,7 +234,7 @@ def get_current_user_info():
|
||||
# --------------------------------------------------------
|
||||
@outbound_bp.route('/request', methods=['POST'])
|
||||
@jwt_required()
|
||||
@permission_required('outbound_list')
|
||||
@permission_required('outbound_approval')
|
||||
def create_outbound_request():
|
||||
"""
|
||||
创建出库审批单(申请阶段,用户只需提交宏观物料信息,无需关联具体库存记录)
|
||||
@ -323,7 +323,7 @@ def create_outbound_request():
|
||||
# --------------------------------------------------------
|
||||
@outbound_bp.route('/request/<int:request_id>/approve', methods=['PATCH'])
|
||||
@jwt_required()
|
||||
@permission_required('outbound_list')
|
||||
@permission_required('outbound_approval')
|
||||
def approve_outbound_request(request_id):
|
||||
"""
|
||||
审批出库申请
|
||||
@ -377,7 +377,7 @@ def approve_outbound_request(request_id):
|
||||
# --------------------------------------------------------
|
||||
@outbound_bp.route('/request', methods=['GET'])
|
||||
@jwt_required()
|
||||
@permission_required('outbound_list')
|
||||
@permission_required('outbound_approval')
|
||||
def get_outbound_request_list():
|
||||
"""
|
||||
获取出库审批单列表
|
||||
@ -424,7 +424,7 @@ def get_outbound_request_list():
|
||||
# --------------------------------------------------------
|
||||
@outbound_bp.route('/request/<int:request_id>', methods=['GET'])
|
||||
@jwt_required()
|
||||
@permission_required('outbound_list')
|
||||
@permission_required('outbound_approval')
|
||||
def get_outbound_request_detail(request_id):
|
||||
"""获取出库审批单详情"""
|
||||
try:
|
||||
|
||||
@ -155,6 +155,7 @@ def get_records():
|
||||
# --- 提交借库申请 ---
|
||||
@trans_bp.route('/borrow/request', methods=['POST'])
|
||||
@jwt_required()
|
||||
@permission_required('op_borrow_approval')
|
||||
def submit_borrow_request():
|
||||
"""
|
||||
提交借库申请(仅存储意向,不扣库存)
|
||||
@ -216,6 +217,7 @@ def submit_borrow_request():
|
||||
# --- 审批借库申请 ---
|
||||
@trans_bp.route('/borrow/request/<int:request_id>/approve', methods=['PATCH'])
|
||||
@jwt_required()
|
||||
@permission_required('op_borrow_approval')
|
||||
def approve_borrow_request(request_id):
|
||||
"""
|
||||
审批借库申请
|
||||
@ -257,6 +259,7 @@ def approve_borrow_request(request_id):
|
||||
# --- 获取借库审批单列表 ---
|
||||
@trans_bp.route('/borrow/request', methods=['GET'])
|
||||
@jwt_required()
|
||||
@permission_required('op_borrow_approval')
|
||||
def get_borrow_request_list():
|
||||
"""
|
||||
获取借库审批单列表
|
||||
@ -282,6 +285,16 @@ def get_borrow_request_list():
|
||||
return jsonify({'code': 500, 'msg': str(e)}), 500
|
||||
|
||||
|
||||
# --- 借库选单:库存查询(独立权限)---
|
||||
@trans_bp.route('/borrow/stock-list', methods=['GET'])
|
||||
@jwt_required()
|
||||
@permission_required('op_borrow_apply')
|
||||
def get_borrow_stock_list():
|
||||
"""借库选单专用库存列表,与出库选单共享底层逻辑"""
|
||||
from app.api.v1.inbound.stock import _do_get_stock_list
|
||||
return _do_get_stock_list()
|
||||
|
||||
|
||||
# --- 执行借库扣减(审批通过后调用)---
|
||||
@trans_bp.route('/borrow/dispatch', methods=['POST'])
|
||||
@jwt_required()
|
||||
|
||||
Reference in New Issue
Block a user