feat: 在制品列表信息层级重构 + SLA预警色 + 点击跳转
1. 信息层级重构:
主信息: [状态Tag] 任务名 | 负责人: 张三 ⏰3h
附加信息: 物料名 SN:25022 ...A1B2C3 08-12 10:00
新增后端 material_name 字段, 前端卡片式布局
2. SLA滞留预警色:
<12h → 绿色(正常) | 12-24h → 橙色(警告) | >24h → 红色加粗(危险)
3. 交互: 点击卡片新窗口打开对应产品扫码详情页
This commit is contained in:
@ -30,6 +30,7 @@ class WipTask(BaseModel):
|
||||
assignee: str
|
||||
product_sn: str
|
||||
external_serial: str | None # 业务序列号
|
||||
material_name: str # 物料名称
|
||||
status: str
|
||||
received_at: str
|
||||
duration_hours: float
|
||||
@ -132,10 +133,10 @@ async def get_wip_tasks(db: AsyncSession, limit: int = 20) -> list[WipTask]:
|
||||
from app.core.time_utils import get_beijing_time, BEIJING_TZ
|
||||
|
||||
stmt = (
|
||||
select(Task, Product.serial_number, Product.external_serial)
|
||||
select(Task, Product.serial_number, Product.external_serial, Product.material_name)
|
||||
.join(Product, Task.product_id == Product.id)
|
||||
.where(Task.status.in_([TASK_STATUS_PENDING, TASK_STATUS_WIP]))
|
||||
.limit(limit * 2) # 多取一些,后面 Python 统一排序
|
||||
.limit(limit * 2)
|
||||
)
|
||||
result = await db.execute(stmt)
|
||||
rows = result.all()
|
||||
@ -148,7 +149,7 @@ async def get_wip_tasks(db: AsyncSession, limit: int = 20) -> list[WipTask]:
|
||||
|
||||
now = get_beijing_time()
|
||||
wip_list: list[WipTask] = []
|
||||
for task, product_sn, ext_sn in rows:
|
||||
for task, product_sn, ext_sn, mat_name in rows:
|
||||
start = task.received_at or task.created_at
|
||||
if start:
|
||||
if start.tzinfo is None:
|
||||
@ -167,6 +168,7 @@ async def get_wip_tasks(db: AsyncSession, limit: int = 20) -> list[WipTask]:
|
||||
assignee=name_map.get(task.assignee_id or "", task.assignee_id or "未分配"),
|
||||
product_sn=product_sn or "",
|
||||
external_serial=ext_sn or None,
|
||||
material_name=mat_name or "",
|
||||
status=task.status,
|
||||
received_at=recv_str,
|
||||
duration_hours=hours,
|
||||
|
||||
Reference in New Issue
Block a user