From cf75b80e132cb3102a2d73bdea8e5a479057215d Mon Sep 17 00:00:00 2001 From: dxc Date: Mon, 2 Mar 2026 13:39:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=8A=E6=88=90=E5=93=81=E6=88=90=E5=93=81?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E4=BA=8EBOM=E8=A1=A8=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inventory-backend/app/api/v1/inbound/product.py | 17 +++++++++++++++++ inventory-backend/app/api/v1/inbound/semi.py | 17 +++++++++++++++++ inventory-web/src/api/inbound/product.ts | 13 +++++++++++-- inventory-web/src/api/inbound/semi.ts | 11 ++++++++++- 4 files changed, 55 insertions(+), 3 deletions(-) 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