采购件管理修改页面文字大小以及调整文字栏间距

This commit is contained in:
dxc
2026-01-27 16:43:44 +08:00
parent 3afea217b7
commit 7a78975ce7
7 changed files with 104 additions and 116 deletions

View File

@ -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