后端增强: - DashboardStats 新增 tasks_rejected, tasks_rework, unread_notifications - 新增 GET /dashboard/recent-activity 最近动态端点 - 关联 Task + Product 表返回完整动态信息 前端改版 (AdminDashboard.tsx): - 4 张概览卡片: 产品流转 | 任务状态 | 品质通知 | 完成率 - 每张卡片含进度条(百分比标注) + 中文说明 - SVG 环形图展示任务完成率 - 最近流转动态时间线 (8条) - 快捷入口: 创建产品/任务管理/打印配置/扫码干活 - 底部说明卡片解释"产品 vs 任务"的区别 - 响应式网格填满全屏, 无空白区域
25 lines
788 B
Python
25 lines
788 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_recent_activity, RecentActivity,
|
|
)
|
|
|
|
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("/recent-activity", response_model=list[RecentActivity])
|
|
async def recent_activity(
|
|
limit: int = Query(10, ge=1, le=50),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
"""最近任务动态 — 看板活动时间线"""
|
|
return await get_recent_activity(db, limit)
|