feat: 完成仪表盘和导出功能
- DashboardController: 实现完整的后端API - /api/dashboard - 仪表盘数据 - /api/dashboard/kpis - KPI统计 - /api/dashboard/activities - 活动摘要 - /api/dashboard/todos - 待办事项 - /api/dashboard/export - 导出CSV - /api/dashboard/kpis/export - KPI导出 - /api/dashboard/activities/export - 活动导出 - dashboard.ts: 前端服务 - 完整的API调用封装 - 导出功能支持 - 下载工具函数 - 更新任务状态: - TASK-401-405: 仪表盘模块100% - TASK-501-502: 单元测试 Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -103,9 +103,58 @@ export async function getTodos(): Promise<Todo[]> {
|
||||
return response.data.data
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出仪表盘数据
|
||||
*/
|
||||
export async function exportDashboard(format: string = 'csv'): Promise<Blob> {
|
||||
const response = await dashboardApi.get('/dashboard/export', {
|
||||
params: { format },
|
||||
responseType: 'blob'
|
||||
})
|
||||
return response as unknown as Blob
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出KPI数据
|
||||
*/
|
||||
export async function exportKpis(): Promise<Blob> {
|
||||
const response = await dashboardApi.get('/dashboard/kpis/export', {
|
||||
responseType: 'blob'
|
||||
})
|
||||
return response as unknown as Blob
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出活动数据
|
||||
*/
|
||||
export async function exportActivities(): Promise<Blob> {
|
||||
const response = await dashboardApi.get('/dashboard/activities/export', {
|
||||
responseType: 'blob'
|
||||
})
|
||||
return response as unknown as Blob
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件工具函数
|
||||
*/
|
||||
export function downloadBlob(blob: Blob, filename: string) {
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = filename
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
export default {
|
||||
getDashboard,
|
||||
getKpis,
|
||||
getActivitySummary,
|
||||
getTodos
|
||||
getTodos,
|
||||
exportDashboard,
|
||||
exportKpis,
|
||||
exportActivities,
|
||||
downloadBlob
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user