diff --git a/backend/app/schemas/product.py b/backend/app/schemas/product.py index 2173588..99d5cd2 100644 --- a/backend/app/schemas/product.py +++ b/backend/app/schemas/product.py @@ -58,6 +58,7 @@ class ProductResponse(BaseModel): # 🔧 最新动态 — 该产品活跃任务的最新记录 latest_record_time: datetime | None = None latest_record_content: str | None = None + latest_record_has_images: bool = False model_config = {"from_attributes": True} diff --git a/backend/app/services/product_service.py b/backend/app/services/product_service.py index 4b04600..47d31cb 100644 --- a/backend/app/services/product_service.py +++ b/backend/app/services/product_service.py @@ -472,7 +472,7 @@ async def get_all_products( ) ).subquery() ranked = ( - select(TR.task_id, TR.remark, TR.created_at, Task.product_id, + select(TR.task_id, TR.remark, TR.images, TR.created_at, Task.product_id, sa_func.row_number().over( partition_by=Task.product_id, order_by=TR.created_at.desc() @@ -481,11 +481,12 @@ async def get_all_products( .where(Task.id.in_(select(wip_pending_ids.c.id))) ).subquery() rec_result = await db.execute( - select(ranked.c.product_id, ranked.c.created_at, ranked.c.remark) + select(ranked.c.product_id, ranked.c.created_at, ranked.c.remark, ranked.c.images) .where(ranked.c.rn == 1) ) for row in rec_result: - latest_record_map[row[0]] = (row[1], row[2]) + has_img = bool(row[3] and row[3] != "[]" and row[3] != "null") + latest_record_map[row[0]] = (row[1], row[2], has_img) return [ ProductResponse( @@ -513,8 +514,9 @@ async def get_all_products( overall_status=overall_names.get(p.id) or p.overall_status, status=p.status, created_at=p.created_at, - latest_record_time=latest_record_map.get(p.id, (None, None))[0], - latest_record_content=latest_record_map.get(p.id, (None, None))[1], + latest_record_time=latest_record_map.get(p.id, (None, None, False))[0], + latest_record_content=latest_record_map.get(p.id, (None, None, False))[1], + latest_record_has_images=latest_record_map.get(p.id, (None, None, False))[2], ) for p in products ] diff --git a/frontend/src/pages/admin/AdminTasksPage.tsx b/frontend/src/pages/admin/AdminTasksPage.tsx index 68d6fa2..5743365 100644 --- a/frontend/src/pages/admin/AdminTasksPage.tsx +++ b/frontend/src/pages/admin/AdminTasksPage.tsx @@ -403,10 +403,13 @@ export default function AdminTasksPage() { {/* 最新动态 */}
{p.latest_record_time ? ( - +
{new Date(p.latest_record_time).toLocaleString("zh-CN", { month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit" })}
-
{p.latest_record_content || "—"}
+
+ {p.latest_record_has_images && 📷} + {p.latest_record_content || (p.latest_record_has_images ? "图片记录" : "—")} +
) : } diff --git a/frontend/src/types/admin.ts b/frontend/src/types/admin.ts index 6c378a3..fea9af6 100644 --- a/frontend/src/types/admin.ts +++ b/frontend/src/types/admin.ts @@ -20,6 +20,7 @@ export interface ProductResponse { created_at: string; latest_record_time: string | null; latest_record_content: string | null; + latest_record_has_images: boolean; } /** MOM 物料选项 */