工作台「最近动态」原为聚合端点内嵌、固定截断前 20 条,操作日志变长后 既撑大响应又只能看到头部。改为独立分页端点: - GET /api/v1/dashboard/activities,支持 pageNum/pageSize/module 筛选 - 模块筛选项与列表同源返回(全量模块名,不随翻页变化),前端不必再取一次全量 - 聚合端点去掉内嵌 activities,避免同一份数据两处查询 前端改用 usePagedList + 统一 AppPagination(每页 10/20/50),模块筛选由 本地过滤改为服务端筛选。集成测试 13 例(含翻页不重不漏 / 模块筛选 / 越权 403)。 Co-Authored-By: Claude Code <noreply@anthropic.com>
121 lines
2.9 KiB
TypeScript
121 lines
2.9 KiB
TypeScript
import { request } from './request'
|
||
import type { PageData } from './types'
|
||
|
||
/** 近 6 个月趋势点(绩效按台账归属月,回款按到账月) */
|
||
export interface TrendPoint {
|
||
month: string
|
||
performance_total: string | null
|
||
receipt_total: string | null
|
||
}
|
||
|
||
export interface SettlementBrief {
|
||
exists: boolean
|
||
status: number | null
|
||
total_performance: string | null
|
||
total_payable: string | null
|
||
locked_at: string | null
|
||
}
|
||
|
||
export interface OverviewBlock {
|
||
month: string
|
||
performance_total: string | null
|
||
payable_total: string | null
|
||
person_count: number
|
||
team_count: number
|
||
settlement: SettlementBrief
|
||
trend: TrendPoint[]
|
||
note: string
|
||
}
|
||
|
||
export interface ApprovalTodoItem {
|
||
order_id: number
|
||
order_no: string
|
||
order_type: number
|
||
submitter_name: string | null
|
||
create_time: string
|
||
}
|
||
|
||
export interface ReceiptTodoItem {
|
||
receipt_id: number
|
||
receipt_batch_no: string
|
||
business_id: number
|
||
business_no: string | null
|
||
amount: string
|
||
receipt_date: string
|
||
}
|
||
|
||
export interface TodoBlock {
|
||
pending_approval_total: number
|
||
pending_approvals: ApprovalTodoItem[]
|
||
unassigned_receipt_total: number
|
||
unassigned_receipts: ReceiptTodoItem[]
|
||
sync_available: boolean
|
||
sync_failure_total: number
|
||
}
|
||
|
||
export interface WarningItem {
|
||
code: string
|
||
level: 'warning' | 'danger'
|
||
object_type: string
|
||
object_id: number
|
||
title: string
|
||
detail: string
|
||
suggest: string
|
||
link: string | null
|
||
}
|
||
|
||
export interface WarningBlock {
|
||
enabled: boolean
|
||
receipt_overdue_days: number
|
||
approval_timeout_days: number
|
||
/** 当前返回的条目(受展示上限约束) */
|
||
items: WarningItem[]
|
||
/** 全部规则命中总数;徽标计数用它,不能用 items.length */
|
||
total: number
|
||
receipt_overdue_total: number
|
||
approval_timeout_total: number
|
||
sync_available: boolean
|
||
}
|
||
|
||
export interface ActivityItem {
|
||
id: number
|
||
module: string
|
||
action: string
|
||
summary: string
|
||
username: string | null
|
||
success: number
|
||
create_time: string
|
||
}
|
||
|
||
export interface DashboardData {
|
||
month: string
|
||
overview: OverviewBlock
|
||
todos: TodoBlock
|
||
warnings: WarningBlock
|
||
}
|
||
|
||
/**
|
||
* 最近动态分页结果:分页字段与全站规范同形(list/total/pageNum/pageSize),
|
||
* 额外带 `modules` —— 全量模块名(不随当前页变化),供模块下拉使用。
|
||
*/
|
||
export interface ActivityPage extends PageData<ActivityItem> {
|
||
modules: string[]
|
||
}
|
||
|
||
export function getDashboard(params: { month?: string }): Promise<DashboardData> {
|
||
return request({ url: '/v1/dashboard', method: 'get', params })
|
||
}
|
||
|
||
/**
|
||
* 分页查询最近动态(工作台动态列表)。
|
||
*
|
||
* 独立于聚合接口:翻页只重取这张列表,不必重算总览/待办/预警。
|
||
*/
|
||
export function listDashboardActivities(params: {
|
||
pageNum?: number
|
||
pageSize?: number
|
||
module?: string
|
||
}): Promise<ActivityPage> {
|
||
return request({ url: '/v1/dashboard/activities', method: 'get', params })
|
||
}
|