From 7aa995a9d6019ea7ae00c540e3df4b000212a51a Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Tue, 28 Jul 2026 09:36:15 +0800 Subject: [PATCH] feat(pl): show archive brand breakdown on inbound/outbound orders Co-authored-by: Cursor --- backend/app/schemas/pl/io_order.py | 1 + backend/app/services/pl_io_order_service.py | 28 +++++++++++++++++++ web-admin/src/api/pl/index.ts | 1 + .../src/views/pl/_shared/IoOrderListPage.vue | 5 ++++ 4 files changed, 35 insertions(+) diff --git a/backend/app/schemas/pl/io_order.py b/backend/app/schemas/pl/io_order.py index 28867b772..70e59172f 100644 --- a/backend/app/schemas/pl/io_order.py +++ b/backend/app/schemas/pl/io_order.py @@ -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") diff --git a/backend/app/services/pl_io_order_service.py b/backend/app/services/pl_io_order_service.py index 647eb1b7c..f1b67901c 100644 --- a/backend/app/services/pl_io_order_service.py +++ b/backend/app/services/pl_io_order_service.py @@ -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 diff --git a/web-admin/src/api/pl/index.ts b/web-admin/src/api/pl/index.ts index b886ae423..903d16d49 100644 --- a/web-admin/src/api/pl/index.ts +++ b/web-admin/src/api/pl/index.ts @@ -775,6 +775,7 @@ export interface PlIoOrderItem { productId?: string productNo?: string productName?: string + brandSummary?: string specification?: string unit?: string unitLabel?: string diff --git a/web-admin/src/views/pl/_shared/IoOrderListPage.vue b/web-admin/src/views/pl/_shared/IoOrderListPage.vue index 37739596f..8b93e02e1 100644 --- a/web-admin/src/views/pl/_shared/IoOrderListPage.vue +++ b/web-admin/src/views/pl/_shared/IoOrderListPage.vue @@ -218,6 +218,11 @@ /> + + +