feat: 培训记录/绩效考核/违纪记录独立列表页+菜单入口
- 后端: 新增3个组织级列表接口 (training/performance/disciplinary /list) - 前端: 新增3个列表页面,支持搜索、分页、新增/编辑/删除弹窗 - 侧边栏: 团队分组新增培训记录、绩效考核、违纪记录入口 - 路由+面包屑注册 - 社公商保改名为社保公积金
This commit is contained in:
@@ -746,6 +746,95 @@ router.get('/:id/evidence-chain/export', authMiddleware, async (req: AuthRequest
|
||||
}
|
||||
})
|
||||
|
||||
// ========== 组织级列表查询 ==========
|
||||
|
||||
// 培训记录列表(全员)
|
||||
router.get('/training/list', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
const orgId = req.user!.orgId
|
||||
const page = parseInt(req.query.page as string) || 1
|
||||
const pageSize = parseInt(req.query.pageSize as string) || 20
|
||||
const keyword = (req.query.keyword as string) || ''
|
||||
const where: any = { orgId }
|
||||
if (keyword) {
|
||||
const employees = await prisma.employee.findMany({
|
||||
where: { orgId, name: { contains: keyword } },
|
||||
select: { id: true },
|
||||
})
|
||||
where.employeeId = { in: employees.map(e => e.id) }
|
||||
}
|
||||
const [records, total] = await Promise.all([
|
||||
prisma.trainingRecord.findMany({
|
||||
where,
|
||||
include: { employee: { select: { id: true, name: true, department: true } } },
|
||||
orderBy: { trainingDate: 'desc' },
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
}),
|
||||
prisma.trainingRecord.count({ where }),
|
||||
])
|
||||
res.json({ success: true, data: { records, total, page, pageSize } })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 绩效记录列表(全员)
|
||||
router.get('/performance/list', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
const orgId = req.user!.orgId
|
||||
const page = parseInt(req.query.page as string) || 1
|
||||
const pageSize = parseInt(req.query.pageSize as string) || 20
|
||||
const keyword = (req.query.keyword as string) || ''
|
||||
const where: any = { orgId }
|
||||
if (keyword) {
|
||||
const employees = await prisma.employee.findMany({
|
||||
where: { orgId, name: { contains: keyword } },
|
||||
select: { id: true },
|
||||
})
|
||||
where.employeeId = { in: employees.map(e => e.id) }
|
||||
}
|
||||
const [records, total] = await Promise.all([
|
||||
prisma.performanceRecord.findMany({
|
||||
where,
|
||||
include: { employee: { select: { id: true, name: true, department: true } } },
|
||||
orderBy: { period: 'desc' },
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
}),
|
||||
prisma.performanceRecord.count({ where }),
|
||||
])
|
||||
res.json({ success: true, data: { records, total, page, pageSize } })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// 违纪记录列表(全员)
|
||||
router.get('/disciplinary/list', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
const orgId = req.user!.orgId
|
||||
const page = parseInt(req.query.page as string) || 1
|
||||
const pageSize = parseInt(req.query.pageSize as string) || 20
|
||||
const keyword = (req.query.keyword as string) || ''
|
||||
const where: any = { orgId }
|
||||
if (keyword) {
|
||||
const employees = await prisma.employee.findMany({
|
||||
where: { orgId, name: { contains: keyword } },
|
||||
select: { id: true },
|
||||
})
|
||||
where.employeeId = { in: employees.map(e => e.id) }
|
||||
}
|
||||
const [records, total] = await Promise.all([
|
||||
prisma.disciplinaryRecord.findMany({
|
||||
where,
|
||||
include: { employee: { select: { id: true, name: true, department: true } } },
|
||||
orderBy: { violationDate: 'desc' },
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
}),
|
||||
prisma.disciplinaryRecord.count({ where }),
|
||||
])
|
||||
res.json({ success: true, data: { records, total, page, pageSize } })
|
||||
} catch (err) { next(err) }
|
||||
})
|
||||
|
||||
// ========== 违纪记录 CRUD ==========
|
||||
|
||||
router.get('/:employeeId/disciplinary', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
|
||||
Reference in New Issue
Block a user