diff --git a/inventory-backend/app/api/v1/inbound/product.py b/inventory-backend/app/api/v1/inbound/product.py index bfbcbfc..c276606 100644 --- a/inventory-backend/app/api/v1/inbound/product.py +++ b/inventory-backend/app/api/v1/inbound/product.py @@ -165,6 +165,23 @@ def get_manager_history(): try: data = ProductInboundService.get_history_managers(keyword) return jsonify({"code": 200, "msg": "success", "data": data}) + except Exception as e: + traceback.print_exc() + return jsonify({"code": 500, "msg": str(e)}), 500 + +# ------------------------------------------------------------------ +# 9. BOM 原材料成本自动核算 (新增) +# ------------------------------------------------------------------ +@inbound_product_bp.route('/calculate-bom-cost', methods=['GET']) +@permission_required('inbound_product') +def calculate_bom_cost(): + try: + bom_code = request.args.get('bom_code') + bom_version = request.args.get('bom_version') + if not bom_code or not bom_version: + return jsonify({"code": 400, "msg": "bom_code和bom_version不能为空"}), 400 + cost = ProductInboundService.calculate_bom_cost(bom_code, bom_version) + return jsonify({"code": 200, "msg": "success", "data": cost}) except Exception as e: traceback.print_exc() return jsonify({"code": 500, "msg": str(e)}), 500 \ No newline at end of file diff --git a/inventory-backend/app/api/v1/inbound/semi.py b/inventory-backend/app/api/v1/inbound/semi.py index c121ba4..1939d56 100644 --- a/inventory-backend/app/api/v1/inbound/semi.py +++ b/inventory-backend/app/api/v1/inbound/semi.py @@ -162,6 +162,23 @@ def get_manager_history(): try: data = SemiInboundService.get_history_managers(keyword) return jsonify({"code": 200, "msg": "success", "data": data}) + except Exception as e: + traceback.print_exc() + return jsonify({"code": 500, "msg": str(e)}), 500 + +# ------------------------------------------------------------------ +# 9. BOM 原材料成本自动核算 (新增) +# ------------------------------------------------------------------ +@inbound_semi_bp.route('/calculate-bom-cost', methods=['GET']) +@permission_required('inbound_semi') +def calculate_bom_cost(): + try: + bom_code = request.args.get('bom_code') + bom_version = request.args.get('bom_version') + if not bom_code or not bom_version: + return jsonify({"code": 400, "msg": "bom_code和bom_version不能为空"}), 400 + cost = SemiInboundService.calculate_bom_cost(bom_code, bom_version) + return jsonify({"code": 200, "msg": "success", "data": cost}) except Exception as e: traceback.print_exc() return jsonify({"code": 500, "msg": str(e)}), 500 \ No newline at end of file diff --git a/inventory-web/src/api/inbound/product.ts b/inventory-web/src/api/inbound/product.ts index 4bddee6..c65f671 100644 --- a/inventory-web/src/api/inbound/product.ts +++ b/inventory-web/src/api/inbound/product.ts @@ -42,7 +42,7 @@ export function searchMaterialBase(keyword: string, page: number = 1) { }) } -// 搜索BOM (新增) +// 搜索BOM export function searchBom(keyword: string) { return request({ url: '/inbound/product/search-bom', @@ -68,11 +68,20 @@ export function getFilterOptions() { }) } -// [新增] 负责人历史记录 +// [新增] 负责人历史记录全局查询 export function getManagerHistory(params: any) { return request({ url: '/inbound/product/suggestions/managers', method: 'get', params }) +} + +// [新增] BOM 成本自动计算 +export function calculateBomCost(params: {bom_code: string, bom_version: string}) { + return request({ + url: '/inbound/product/calculate-bom-cost', + method: 'get', + params + }) } \ No newline at end of file diff --git a/inventory-web/src/api/inbound/semi.ts b/inventory-web/src/api/inbound/semi.ts index 58da771..b3964d3 100644 --- a/inventory-web/src/api/inbound/semi.ts +++ b/inventory-web/src/api/inbound/semi.ts @@ -70,11 +70,20 @@ export function getFilterOptions() { }) } -// [新增] 生产负责人历史记录 +// [新增] 生产负责人历史记录全局查询 export function getManagerHistory(params: any) { return request({ url: '/inbound/semi/suggestions/managers', method: 'get', params }) +} + +// [新增] BOM 成本自动计算 +export function calculateBomCost(params: {bom_code: string, bom_version: string}) { + return request({ + url: '/inbound/semi/calculate-bom-cost', + method: 'get', + params + }) } \ No newline at end of file