diff --git a/src/api/inventory/sales_order_routes.py b/src/api/inventory/sales_order_routes.py index a896ada..1a4ff6a 100644 --- a/src/api/inventory/sales_order_routes.py +++ b/src/api/inventory/sales_order_routes.py @@ -204,7 +204,12 @@ async def _issue_materials_for_order_creation( warehouse = await _get_default_warehouse(db_session) plan_items, planned_material_cost = await _build_material_plan(db_session, order) if not plan_items: - raise HTTPException(status_code=400, detail="销售单产品未配置物料BOM,无法自动扣减物料") + order.production_no = order.production_no or generate_order_no("WO") + order.production_status = "bom_missing" + order.planned_material_cost = 0 + order.actual_material_cost = 0 + order.status = "manufacturing" + return 0, 0, 0 shortage_items = [item for item in plan_items if item.shortage_quantity > 0] if shortage_items: shortage_text = ",".join([f"{item.material_name} 缺 {item.shortage_quantity}" for item in shortage_items]) @@ -252,7 +257,7 @@ async def _issue_materials_for_order_creation( order.production_status = "material_issued" order.planned_material_cost = round(float(planned_material_cost), 4) order.actual_material_cost = round(float(actual_material_cost), 4) - order.status = "pending" + order.status = "manufacturing" return movement_count, planned_material_cost, actual_material_cost diff --git a/static/vue-app.js b/static/vue-app.js index 6082978..1d86505 100644 --- a/static/vue-app.js +++ b/static/vue-app.js @@ -2144,17 +2144,17 @@ const InventoryView = { })) }; if (state.editingItem) { - await apiRequest(`/api/sales-orders/${state.editingItem.id}`, { + const result = await apiRequest(`/api/sales-orders/${state.editingItem.id}`, { method: 'PUT', body: JSON.stringify(payload) }); - addNotification('销售订单更新成功', 'success'); + addNotification(result.production_status === 'bom_missing' ? '订单已保存,但成品未配置BOM,未扣减物料' : '销售订单更新成功并已自动扣减物料', result.production_status === 'bom_missing' ? 'warning' : 'success'); } else { - await apiRequest('/api/sales-orders', { + const result = await apiRequest('/api/sales-orders', { method: 'POST', body: JSON.stringify(payload) }); - addNotification('销售订单创建成功并已自动扣减物料', 'success'); + addNotification(result.production_status === 'bom_missing' ? '订单已创建,但成品未配置BOM,未扣减物料' : '销售订单创建成功并已自动扣减物料', result.production_status === 'bom_missing' ? 'warning' : 'success'); } closeModal(); loadProductionOrders();