feat(bom): 归档业务闭环——状态筛选+归档/取消归档入口

- get_bom_list/get_bom_summary 状态过滤支持 archived,enabled 语义改为“启用且未归档”
- get_bom_list 输出补 is_archived;新增 update_archived 与 POST /bom/archive(整组切换归档、清缓存、审计)
- “未指定版本自动取最新”硬化为仅认启用且未归档(get_bom_detail / get_bom_no_by_parent)
- 前端:状态按钮组加“归档”;列表状态列区分归档;操作列加“归档/取消归档”按钮
This commit is contained in:
yueli
2026-09-08 11:13:38 +08:00
parent 1daa60590c
commit 02f74278df
4 changed files with 106 additions and 10 deletions

View File

@ -136,6 +136,35 @@ def update_bom_status():
return jsonify({'code': 500, 'msg': '内部服务器错误'}), 500
# ==================== BOM 归档/取消归档(仍启用可编辑,但不作为其它 BOM 子件引用候选) ====================
@bom_bp.route('/archive', methods=['POST'])
@jwt_required()
@permission_required('bom_manage:operation')
@audit_log(
module='BOM管理',
action='归档/取消归档',
get_target_name_fn=lambda: (request.get_json() or {}).get('bom_no')
)
def update_bom_archive():
"""切换某 BOM 版本(整组)的归档状态。"""
try:
data = request.get_json() or {}
bom_no = data.get('bom_no')
version = data.get('version')
is_archived = data.get('is_archived')
if not bom_no or not version:
return jsonify({'code': 400, 'msg': 'bom_no 与 version 不能为空'}), 400
if not isinstance(is_archived, bool):
return jsonify({'code': 400, 'msg': 'is_archived 必须为布尔值'}), 400
BomService.update_archived(bom_no, version, is_archived)
return jsonify({'code': 200, 'msg': '更新成功'})
except ValueError as e:
return jsonify({'code': 400, 'msg': str(e)}), 400
except Exception as e:
current_app.logger.error(f'更新BOM归档状态失败: {str(e)}')
return jsonify({'code': 500, 'msg': '内部服务器错误'}), 500
@bom_bp.route('/detail/<path:bom_no>', methods=['GET'])
@jwt_required()
@permission_required('bom_manage')