import { FlowBeforeList } from '@/api/workFlow/FlowBefore' import { FlowDelegateList } from '@/api/workFlow/FlowDelegate' function extractTotal(res) { const data = (res && res.data) || {} const p = data.pagination || {} if (p.total !== undefined && p.total !== null) return Number(p.total) || 0 if (p.Total !== undefined && p.Total !== null) return Number(p.Total) || 0 if (Array.isArray(data.list)) return data.list.length return 0 } /** * 工作台待办真实数量: * - 待我审核:FlowBefore category=1 * - 已办事宜:FlowBefore category=2 * - 流程委托:FlowDelegate 列表 * (Dashboard/FlowTodoCount 后端目前是空实现,不能用) */ export async function fetchFlowWorkbenchCounts() { const query = { currentPage: 1, pageSize: 1, sort: 'desc', sidx: '' } const [todoRes, doneRes, entrustRes] = await Promise.all([ FlowBeforeList(1, query).catch(() => null), FlowBeforeList(2, query).catch(() => null), FlowDelegateList(query).catch(() => null) ]) return { toBeReviewed: extractTotal(todoRes), flowDone: extractTotal(doneRes), entrust: extractTotal(entrustRes) } } /** 待办事项列表(最近 N 条) */ export async function fetchFlowTodoList(pageSize = 8) { const res = await FlowBeforeList(1, { currentPage: 1, pageSize, sort: 'desc', sidx: '' }) return ((res.data && res.data.list) || []) }