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:
@@ -73,24 +73,31 @@ export async function createPolicy(orgId: string, userId: string, data: { title:
|
||||
/**
|
||||
* 获取制度列表(含阅读签收统计)
|
||||
*/
|
||||
export async function getPolicies(orgId: string, status?: string) {
|
||||
export async function getPolicies(orgId: string, status?: string, page?: number, pageSize?: number) {
|
||||
const where: any = { orgId }
|
||||
if (status) where.status = status
|
||||
const [policies, totalEmployees] = await Promise.all([
|
||||
const hasPagination = page && pageSize
|
||||
const [policies, totalEmployees, total] = await Promise.all([
|
||||
prisma.policyDocument.findMany({
|
||||
where,
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
include: {
|
||||
_count: { select: { readRecords: true } },
|
||||
},
|
||||
...(hasPagination ? { skip: (page! - 1) * pageSize!, take: pageSize! } : {}),
|
||||
}),
|
||||
prisma.employee.count({ where: { orgId, status: 'ACTIVE' } }),
|
||||
hasPagination ? prisma.policyDocument.count({ where }) : Promise.resolve(0),
|
||||
])
|
||||
return policies.map(p => ({
|
||||
const items = policies.map(p => ({
|
||||
...p,
|
||||
readCount: p._count?.readRecords || 0,
|
||||
totalEmployees,
|
||||
}))
|
||||
if (hasPagination) {
|
||||
return { items, total, page, pageSize, totalPages: Math.ceil(total / pageSize!) }
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user