核心理念转变:
旧: 最近操作历史(谁做了什么)
新: 当前在制品状态(谁的活卡了多久)
后端:
- DashboardStats 新增 unread_messages(协同留言总数)
- 新增 GET /dashboard/wip-tasks(在制品端点)
- 按滞留时间升序排列,PENDING/WIP 任务倒计时
- 自动计算 duration_hours(已滞留小时数)
前端:
- 品质卡片: 新增留言未读数(紫色)
- 在制品看板: 替换原最近动态
每行显示: 状态徽标 | 任务名+负责人+身份证 | 滞留时长
- 滞留颜色: 48h+红 | 24h+橙 | 8h+黄 | <8h灰
- 系统通知可点击跳转
25 lines
782 B
Python
25 lines
782 B
Python
"""Dashboard API"""
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from app.core.database import get_db
|
|
from app.services.dashboard_service import (
|
|
get_dashboard_stats, DashboardStats,
|
|
get_wip_tasks, WipTask,
|
|
)
|
|
|
|
router = APIRouter(prefix="/dashboard", tags=["管理看板"])
|
|
|
|
|
|
@router.get("/stats", response_model=DashboardStats)
|
|
async def dashboard_stats(db: AsyncSession = Depends(get_db)):
|
|
return await get_dashboard_stats(db)
|
|
|
|
|
|
@router.get("/wip-tasks", response_model=list[WipTask])
|
|
async def wip_tasks(
|
|
limit: int = Query(20, ge=1, le=100),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
"""在制品看板 — 当前所有 PENDING/WIP 任务,按滞留时间排序"""
|
|
return await get_wip_tasks(db, limit)
|