feat: 全部列表页统一分页 + WorkProcess集成现有服务
- WorkProcess/Termination/Evidence/Contracts/Policies/Templates 添加 Pagination 组件 - 后端 getDrafts/getPolicies/enterprise-template 路由添加分页支持(可选参数,向后兼容) - work-process.service CONFIRM case 修正:移除不存在的 probationEndDate 字段 - 新增 migration_add_three_tables.sql 增量迁移文件
This commit is contained in:
@@ -738,7 +738,7 @@ export async function cancelTermination(orgId: string, recordId: string, userId:
|
||||
}
|
||||
|
||||
/** 获取草稿列表 */
|
||||
export async function getDrafts(orgId: string, status?: string, search?: string, department?: string) {
|
||||
export async function getDrafts(orgId: string, status?: string, search?: string, department?: string, page?: number, pageSize?: number) {
|
||||
const where: any = { orgId }
|
||||
if (status) {
|
||||
where.status = status
|
||||
@@ -758,13 +758,18 @@ export async function getDrafts(orgId: string, status?: string, search?: string,
|
||||
}
|
||||
}
|
||||
|
||||
const records = await prisma.terminationRecord.findMany({
|
||||
where,
|
||||
include: { employee: true },
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
})
|
||||
const hasPagination = page && pageSize
|
||||
const [records, total] = await Promise.all([
|
||||
prisma.terminationRecord.findMany({
|
||||
where,
|
||||
include: { employee: true },
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
...(hasPagination ? { skip: (page! - 1) * pageSize!, take: pageSize! } : {}),
|
||||
}),
|
||||
hasPagination ? prisma.terminationRecord.count({ where }) : Promise.resolve(0),
|
||||
])
|
||||
|
||||
return records.map((r) => ({
|
||||
const items = records.map((r) => ({
|
||||
id: r.id,
|
||||
employeeId: r.employeeId,
|
||||
employeeName: r.employee.name,
|
||||
@@ -780,6 +785,11 @@ export async function getDrafts(orgId: string, status?: string, search?: string,
|
||||
createdAt: r.createdAt.toISOString().slice(0, 10),
|
||||
updatedAt: r.updatedAt.toISOString().slice(0, 10),
|
||||
}))
|
||||
|
||||
if (hasPagination) {
|
||||
return { items, total, page, pageSize, totalPages: Math.ceil(total / pageSize!) }
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
/** 获取单条记录详情(含所有流程字段) */
|
||||
|
||||
Reference in New Issue
Block a user