feat(pl): show archive brand breakdown on inbound/outbound orders

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-07-28 09:36:15 +08:00
1 parent e7d7e731ba
commit 7aa995a9d6
4 files changed
+35

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ class IoOrderItemRead(BaseModel):
plan_product_id: str = Field(alias="planProductId")
product_id: Optional[str] = Field(default=None, alias="productId")
product_name: Optional[str] = Field(default=None, alias="productName")
brand_summary: Optional[str] = Field(default=None, alias="brandSummary")
specification: Optional[str] = None
unit: Optional[str] = None
plan_qty: Optional[Decimal] = Field(default=None, alias="planQty")
@@ -21,6 +21,7 @@ from app.models.pl_models import (
PlOutboundOrderItem,
PlPlan,
PlPlanProduct,
PlPlanProductBrandQty,
PlTransport,
PlTransportDbLink,
)
@@ -502,6 +503,33 @@ def enrich_io_order_dict(
if public_unit_as_label:
it["unit"] = it.get("unitLabel") or resolve_unit_label(unit_map, it.get("unit"))
brand_summary_by_pp: dict[str, str] = {}
if product_ids:
brand_rows = (
db.query(PlPlanProductBrandQty)
.filter(
PlPlanProductBrandQty.plan_product_id.in_(product_ids),
PlPlanProductBrandQty.tenant_no == tenant_no,
PlPlanProductBrandQty.del_flag == 0,
)
.order_by(PlPlanProductBrandQty.order_num.asc())
.all()
)
grouped: dict[str, list[str]] = {}
for br in brand_rows:
qty = Decimal(str(br.qty or 0))
if qty <= 0:
continue
name = (br.brand_name or "").strip() or "未命名品牌"
# 去掉多余尾零,如 6.000 -> 6
qty_text = format(qty.normalize(), "f")
grouped.setdefault(br.plan_product_id, []).append(f"{name} {qty_text}")
brand_summary_by_pp = {k: " / ".join(v) for k, v in grouped.items()}
for it in raw_items:
pp_id = it.get("planProductId") or ""
it["brandSummary"] = brand_summary_by_pp.get(pp_id) or None
return data
+1
View File
@@ -775,6 +775,7 @@ export interface PlIoOrderItem {
productId?: string
productNo?: string
productName?: string
brandSummary?: string
specification?: string
unit?: string
unitLabel?: string
@@ -218,6 +218,11 @@
/>
<el-table-column prop="productNo" label="产品编号" min-width="110" show-overflow-tooltip />
<el-table-column prop="productName" label="产品名称" min-width="120" show-overflow-tooltip />
<el-table-column label="品牌" min-width="140" show-overflow-tooltip>
<template #default="{ row }">
{{ row.brandSummary || '—' }}
</template>
</el-table-column>
<el-table-column prop="specification" label="型号/规格" min-width="100" show-overflow-tooltip />
<el-table-column label="单位" min-width="80" align="center">
<template #default="{ row }">{{ row.unitLabel || row.unit || '—' }}</template>