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:
@@ -15,14 +15,21 @@ function extractVariables(content: string): string[] {
|
||||
router.get('/', authMiddleware, async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const { category, search } = req.query
|
||||
const page = parseInt(req.query.page as string) || 1
|
||||
const pageSize = Math.min(parseInt(req.query.pageSize as string) || 20, 200)
|
||||
const where: any = { orgId: req.user!.orgId, status: 'ACTIVE' }
|
||||
if (category) where.category = category
|
||||
if (search) where.name = { contains: String(search) }
|
||||
const items = await (prisma as any).enterpriseTemplate.findMany({
|
||||
where,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
})
|
||||
res.json({ success: true, data: items })
|
||||
const [items, total] = await Promise.all([
|
||||
(prisma as any).enterpriseTemplate.findMany({
|
||||
where,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
}),
|
||||
(prisma as any).enterpriseTemplate.count({ where }),
|
||||
])
|
||||
res.json({ success: true, data: { items, total, page, pageSize, totalPages: Math.ceil(total / pageSize) } })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ const router = Router()
|
||||
router.get('/', authMiddleware, async (req: AuthRequest, res: Response, next: NextFunction) => {
|
||||
try {
|
||||
const status = req.query.status as string | undefined
|
||||
const policies = await getPolicies(req.user!.orgId, status)
|
||||
res.json({ success: true, data: policies })
|
||||
const page = parseInt(req.query.page as string) || 1
|
||||
const pageSize = Math.min(parseInt(req.query.pageSize as string) || 20, 200)
|
||||
const result = await getPolicies(req.user!.orgId, status, page, pageSize)
|
||||
res.json({ success: true, data: result })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
|
||||
@@ -162,7 +162,9 @@ router.get('/drafts', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
const status = req.query.status as string | undefined
|
||||
const search = req.query.search as string | undefined
|
||||
const department = req.query.department as string | undefined
|
||||
const result = await getDrafts(req.user!.orgId, status, search, department)
|
||||
const page = parseInt(req.query.page as string) || 1
|
||||
const pageSize = Math.min(parseInt(req.query.pageSize as string) || 20, 200)
|
||||
const result = await getDrafts(req.user!.orgId, status, search, department, page, pageSize)
|
||||
res.json({ success: true, data: result })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
|
||||
Reference in New Issue
Block a user