diff --git a/frontend/src/api/org-center/index.ts b/frontend/src/api/org-center/index.ts index f7cc55f..64c2ac5 100644 --- a/frontend/src/api/org-center/index.ts +++ b/frontend/src/api/org-center/index.ts @@ -58,6 +58,8 @@ export interface OrgListQuery { module_key?: string dept_id?: string keyword?: string + /** 在职口径(000167):true 时仅保留成员管理在职人员(状态 1-5),过滤离职/退休 */ + on_duty?: boolean page?: number page_size?: number } diff --git a/frontend/src/views/org-center/OrgCenter.vue b/frontend/src/views/org-center/OrgCenter.vue index c1707cf..85ad7e0 100644 --- a/frontend/src/views/org-center/OrgCenter.vue +++ b/frontend/src/views/org-center/OrgCenter.vue @@ -589,6 +589,7 @@ watch(pickerUserIds, (ids) => { }) // 员工列表:module_key='training' 联查职称角色展示;keyword 按姓名/工号/部门过滤。 +// on_duty 只保留成员管理在职人员(1-5),离职/退休不再出现在员工档案。 // 分页循环拉全量(page_size=500 单页会把最早建档的员工截断,分页器误显「共500条」)。 const loadEmployees = async () => { loading.value = true @@ -596,6 +597,7 @@ const loadEmployees = async () => { employees.value = await listAllOrgEmployees({ module_key: ORG_MODULE_TRAINING, keyword: keyword.value.trim() || undefined, + on_duty: true, }) } finally { loading.value = false diff --git a/internal/application/repository/orgcenter.go b/internal/application/repository/orgcenter.go index 23f7d7a..0e656f8 100644 --- a/internal/application/repository/orgcenter.go +++ b/internal/application/repository/orgcenter.go @@ -81,6 +81,12 @@ func (r *orgCenterRepository) employeeFilter(ctx context.Context, tenantID uint6 if q.EmploymentStatus > 0 { tx = tx.Where("u.employment_status = ?", q.EmploymentStatus) } + // 在职口径过滤:员工档案列表只保留成员管理在职人员(状态 1-5), + // 离职(6)/退休(7)不再展示;users 联查不上的档案行同样视作不在职隐藏。 + if q.OnDutyOnly { + tx = tx.Where("u.employment_status BETWEEN ? AND ?", + types.EmploymentStatusProbation, types.EmploymentStatusIntern) + } if q.Keyword != "" { // 按姓名/工号/部门名/岗位模糊查找;姓名取真实姓名(display_name) // 回退平台账号(username),与列表展示口径一致。 diff --git a/internal/handler/orgcenter/orgcenter.go b/internal/handler/orgcenter/orgcenter.go index a31d7c7..6a9654d 100644 --- a/internal/handler/orgcenter/orgcenter.go +++ b/internal/handler/orgcenter/orgcenter.go @@ -40,6 +40,10 @@ func orgListQueryFromRequest(c *gin.Context) *types.OrgListQuery { if v, err := strconv.Atoi(c.Query("employment_status")); err == nil && types.IsValidEmploymentStatus(v) { q.EmploymentStatus = v } + // 在职口径(on_duty=true):员工档案列表仅保留在职人员(1-5),过滤离职/退休。 + if v, err := strconv.ParseBool(c.Query("on_duty")); err == nil { + q.OnDutyOnly = v + } if v, err := strconv.Atoi(c.Query("page")); err == nil { q.Page = v } diff --git a/internal/types/orgcenter.go b/internal/types/orgcenter.go index 6ea1049..dac41df 100644 --- a/internal/types/orgcenter.go +++ b/internal/types/orgcenter.go @@ -93,10 +93,13 @@ func (OrgModuleMember) TableName() string { return "org_module_members" } // OrgListQuery 组织中心通用列表查询(分页 + 关键词 + 部门过滤)。 // EmploymentStatus 在职状态过滤(000167):0 = 不过滤;选人场景传 // EmploymentStatusFormal(3) 仅拉取正式员工。 +// OnDutyOnly 在职口径过滤:员工档案列表只保留成员管理在职人员(状态 1-5), +// 离职(6)/退休(7)不再展示。 type OrgListQuery struct { DeptID string Keyword string EmploymentStatus int + OnDutyOnly bool Page int PageSize int }