feat: 花名册增加职务筛选 + 去掉解聘页新建按钮
- 后端:roster list 接口增加 position 筛选参数 - 后端:新增 /roster/positions 接口返回在职员工职务去重列表 - 前端:花名册筛选栏增加"全部职务"下拉框 - 前端:导出也支持 position 参数 - 前端:去掉解聘补偿页面的"新建解聘"按钮,解聘统一从花名册发起 - 前端:空状态提示改为"请在花名册中选择员工发起解聘" Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -46,6 +46,21 @@ router.get('/departments', authMiddleware, async (req: AuthRequest, res, next) =
|
||||
}
|
||||
})
|
||||
|
||||
/** 花名册可选职务列表(从在职员工中提取去重) */
|
||||
router.get('/positions', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
const employees = await prisma.employee.findMany({
|
||||
where: { orgId: req.user!.orgId, status: 'ACTIVE' },
|
||||
select: { position: true },
|
||||
distinct: 'position',
|
||||
})
|
||||
const positions = employees.map((e) => e.position).filter(Boolean).sort()
|
||||
res.json({ success: true, data: positions })
|
||||
} catch (err) {
|
||||
next(err)
|
||||
}
|
||||
})
|
||||
|
||||
// 花名册列表(含汇总信息,支持分页和过滤)
|
||||
router.get('/', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
try {
|
||||
@@ -55,6 +70,7 @@ router.get('/', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
const status = req.query.status as string // ACTIVE | PRE_HIRE | RESIGNED
|
||||
const contractStatus = req.query.contractStatus as string // active | expiring | expired | unsigned | etc.
|
||||
const department = req.query.department as string
|
||||
const position = req.query.position as string
|
||||
const skip = (page - 1) * pageSize
|
||||
|
||||
// 使用本地日期午夜,避免时区问题导致当天入职被误判为预入职
|
||||
@@ -71,6 +87,9 @@ router.get('/', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
if (department) {
|
||||
whereBase.department = department
|
||||
}
|
||||
if (position) {
|
||||
whereBase.position = position
|
||||
}
|
||||
if (search && !isIdCardSearch) {
|
||||
whereBase.OR = [
|
||||
{ name: { contains: search } },
|
||||
|
||||
Reference in New Issue
Block a user