From 7a78975ce7028fbbebbcdc05c6ff6d4da30977bd Mon Sep 17 00:00:00 2001 From: dxc Date: Tue, 27 Jan 2026 16:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2=E6=96=87=E5=AD=97=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E4=BB=A5=E5=8F=8A=E8=B0=83=E6=95=B4=E6=96=87=E5=AD=97?= =?UTF-8?q?=E6=A0=8F=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/inbound/buy_service.py | 32 ++-- inventory-web/.env.development | 2 +- inventory-web/src/views/dashboard/index.vue | 7 - inventory-web/src/views/material/list.vue | 9 +- inventory-web/src/views/stock/inbound/buy.vue | 148 +++++++++--------- inventory-web/src/views/stock/query.vue | 11 -- inventory-web/src/views/stock/semi.vue | 11 -- 7 files changed, 104 insertions(+), 116 deletions(-) delete mode 100644 inventory-web/src/views/stock/query.vue delete mode 100644 inventory-web/src/views/stock/semi.vue diff --git a/inventory-backend/app/services/inbound/buy_service.py b/inventory-backend/app/services/inbound/buy_service.py index 312195c..52545b2 100644 --- a/inventory-backend/app/services/inbound/buy_service.py +++ b/inventory-backend/app/services/inbound/buy_service.py @@ -44,6 +44,11 @@ class BuyInboundService: except ValueError: in_date_val = datetime.utcnow().date() + # --- 修改部分:增加字段兼容性,确保前端传参能被正确读取 --- + in_qty = float(data.get('in_quantity') or data.get('qty_inbound') or 0) + u_price = float(data.get('unit_price') or data.get('price_unit') or 0) + # --------------------------------------------------- + # 3. 创建 StockBuy new_stock = StockBuy( base_id=material.id, @@ -53,12 +58,12 @@ class BuyInboundService: batch_number=data.get('batch_number'), status='在库', inspection_status=data.get('inspection_status'), - in_quantity=data.get('in_quantity', 0), - stock_quantity=data.get('in_quantity', 0), - available_quantity=data.get('in_quantity', 0), - warehouse_location=data.get('warehouse_location'), - unit_price=data.get('unit_price', 0), - total_price=data.get('total_price', 0), + in_quantity=in_qty, + stock_quantity=in_qty, + available_quantity=in_qty, + warehouse_location=data.get('warehouse_location') or data.get('warehouse_loc'), + unit_price=u_price, + total_price=in_qty * u_price, currency=data.get('currency', 'CNY'), exchange_rate=data.get('exchange_rate', 1.0), supplier_name=data.get('supplier_name'), @@ -85,10 +90,11 @@ class BuyInboundService: if not stock: raise ValueError("记录不存在") - # 1. 更新普通字段 + # 1. 更新普通字段 (增加对 warehouse_loc 的兼容) if 'serial_number' in data: stock.serial_number = data['serial_number'] if 'batch_number' in data: stock.batch_number = data['batch_number'] if 'warehouse_location' in data: stock.warehouse_location = data['warehouse_location'] + if 'warehouse_loc' in data: stock.warehouse_location = data['warehouse_loc'] if 'supplier_name' in data: stock.supplier_name = data['supplier_name'] if 'status' in data: stock.status = data['status'] if 'inspection_status' in data: stock.inspection_status = data['inspection_status'] @@ -101,13 +107,14 @@ class BuyInboundService: if 'category' in data: stock.material.category = data['category'] if 'unit' in data: stock.material.unit = data['unit'] - # 3. 核心逻辑:数量与价格联动 + # 3. 核心逻辑:数量与价格联动 (增加对前端返回字段名 qty_inbound 和 price_unit 的识别) qty_changed = False price_changed = False # (A) 数量变更 -> 更新库存和可用量 - if 'in_quantity' in data: - new_qty = float(data['in_quantity']) + new_qty_input = data.get('in_quantity') or data.get('qty_inbound') + if new_qty_input is not None: + new_qty = float(new_qty_input) old_qty = float(stock.in_quantity) diff = new_qty - old_qty @@ -118,8 +125,9 @@ class BuyInboundService: qty_changed = True # (B) 单价变更 - if 'unit_price' in data: - new_price = float(data['unit_price']) + new_price_input = data.get('unit_price') or data.get('price_unit') + if new_price_input is not None: + new_price = float(new_price_input) if new_price != float(stock.unit_price): stock.unit_price = new_price price_changed = True diff --git a/inventory-web/.env.development b/inventory-web/.env.development index 84a38dc..0b9e90e 100644 --- a/inventory-web/.env.development +++ b/inventory-web/.env.development @@ -1,3 +1,3 @@ # .env.development # 注意:这里必须写你电脑的局域网 IP -VITE_API_BASE_URL=http://172.25.16.1:8000/api/v1 \ No newline at end of file +VITE_API_BASE_URL=http://172.16.0.95:8000/api/v1 \ No newline at end of file diff --git a/inventory-web/src/views/dashboard/index.vue b/inventory-web/src/views/dashboard/index.vue index 8dd903b..5a73df0 100644 --- a/inventory-web/src/views/dashboard/index.vue +++ b/inventory-web/src/views/dashboard/index.vue @@ -28,13 +28,6 @@ 借库申请 - -
- - - 数据大屏 (开发中) - -
diff --git a/inventory-web/src/views/material/list.vue b/inventory-web/src/views/material/list.vue index 9f05488..82973be 100644 --- a/inventory-web/src/views/material/list.vue +++ b/inventory-web/src/views/material/list.vue @@ -3,7 +3,6 @@ + \ No newline at end of file diff --git a/inventory-web/src/views/stock/inbound/buy.vue b/inventory-web/src/views/stock/inbound/buy.vue index fbfe004..82aca0e 100644 --- a/inventory-web/src/views/stock/inbound/buy.vue +++ b/inventory-web/src/views/stock/inbound/buy.vue @@ -2,19 +2,19 @@
- 全量采购入库登记 - 刷新数据 + 采购入库登记 + 刷新数据
基础层字段 - {{ c.label }} + {{ c.label }} 库存/财务层字段 - {{ c.label }} + {{ c.label }}
@@ -25,15 +25,16 @@ border stripe style="width: 100%" - size="small" + size="default" highlight-current-row + class="custom-big-table" >