diff --git a/frontend/src/api/tenant/members.ts b/frontend/src/api/tenant/members.ts index 11938e9..a17742d 100644 --- a/frontend/src/api/tenant/members.ts +++ b/frontend/src/api/tenant/members.ts @@ -6,6 +6,31 @@ export type TenantRole = 'owner' | 'admin' | 'contributor' | 'viewer' export type TenantMemberStatus = 'active' | 'invited' | 'suspended' +/** + * 在职状态(users.employment_status,000167):1-5 在职、6 离职、7 退休。 + * 存量/新开户按工号规则落库(首位字母→离职,否则→正式),成员管理页可改; + * 业务选人接口按 =3 正式过滤。 + */ +export type EmploymentStatus = 1 | 2 | 3 | 4 | 5 | 6 | 7 + +export const EMPLOYMENT_STATUS_OPTIONS: { value: EmploymentStatus; labelKey: string }[] = [ + { value: 1, labelKey: 'tenantMember.employmentStatus.probation' }, + { value: 2, labelKey: 'tenantMember.employmentStatus.probationExtended' }, + { value: 3, labelKey: 'tenantMember.employmentStatus.formal' }, + { value: 4, labelKey: 'tenantMember.employmentStatus.temporary' }, + { value: 5, labelKey: 'tenantMember.employmentStatus.intern' }, + { value: 6, labelKey: 'tenantMember.employmentStatus.resigned' }, + { value: 7, labelKey: 'tenantMember.employmentStatus.retired' }, +] + +/** 在职状态展示主题:在职类正向/中性,离职/退休置灰 */ +export function employmentStatusTagTheme(status: number): 'success' | 'warning' | 'primary' | 'default' { + if (status === 3) return 'success' + if (status === 1 || status === 2 || status === 4 || status === 5) return 'warning' + if (status === 6 || status === 7) return 'default' + return 'primary' +} + // TenantMember is the API projection of a (user, tenant) membership row, // already joined with the user's email/username/avatar by the backend. export interface TenantMember { @@ -16,6 +41,8 @@ export interface TenantMember { display_name?: string /** 所属部门:Casdoor 同步回写 users.dept_name(000156 同步态字段),未同步为空 */ dept_name?: string + /** 在职状态(000167):1试用/2试用延期/3正式/4临时/5实习/6离职/7退休 */ + employment_status: number avatar?: string role: TenantRole status: TenantMemberStatus @@ -39,6 +66,8 @@ export interface ListMembersParams { page_size?: number /** 按邮箱/用户名筛选(服务端模糊匹配) */ q?: string + /** 在职状态过滤(000167):1-7,缺省不过滤 */ + employment_status?: number } function buildMembersQuery(params: ListMembersParams | undefined): string { @@ -48,6 +77,9 @@ function buildMembersQuery(params: ListMembersParams | undefined): string { if (params.page_size != null && params.page_size > 0) u.set('page_size', String(params.page_size)) const q = params.q?.trim() if (q) u.set('q', q) + if (params.employment_status != null && params.employment_status > 0) { + u.set('employment_status', String(params.employment_status)) + } const qs = u.toString() return qs ? `?${qs}` : '' } @@ -198,6 +230,22 @@ export async function updateMemberRole( return (await put(`/api/v1/tenants/${tenantId}/members/${userId}`, { role })) as unknown as SimpleResponse } +/** + * 修改成员在职状态(000167):1试用/2试用延期/3正式/4临时/5实习/6离职/7退休。 + * 状态为 users 表的人员属性,跨空间一致。 + * Backend: PUT /api/v1/tenants/:id/members/:user_id/employment-status (Owner+)。 + */ +export async function updateMemberEmploymentStatus( + tenantId: number, + userId: string, + employmentStatus: EmploymentStatus | number, +): Promise { + return (await put( + `/api/v1/tenants/${tenantId}/members/${userId}/employment-status`, + { employment_status: employmentStatus }, + )) as unknown as SimpleResponse +} + /** * Remove a member from the tenant. * Backend: DELETE /api/v1/tenants/:id/members/:user_id (Owner+). diff --git a/frontend/src/api/training/index.ts b/frontend/src/api/training/index.ts index 1e932b5..4978ed4 100644 --- a/frontend/src/api/training/index.ts +++ b/frontend/src/api/training/index.ts @@ -35,6 +35,8 @@ export interface ListQuery { status?: string check_status?: string keyword?: string + /** 在职状态过滤(000167):1试用/2试用延期/3正式/4临时/5实习/6离职/7退休;仅 /members 员工名册消费 */ + employment_status?: number page?: number page_size?: number } @@ -104,10 +106,22 @@ export const listMembers = async (query?: ListQuery) => { // (含默认课长、搜索目标)截断在第一页之外 —— 年度计划收集默认课长消失、 // 手动推送/课程管理/签到/考试等选人下拉搜不到人的共同根因;选人场景一律 // 用本 helper 拉全量,名册继续增长也不再复发。 -export async function listAllTrainingMembers(pageSize = 500): Promise { +// [000167 权限优化] opts.formalOnly 默认 true:选人场景仅拉取正式员工 +// (users.employment_status=3,离职/退休不再出现在选人下拉)。渲染历史记录 +// 人名映射的调用方(考试代交卷/课程参训人标签)传 { formalOnly: false } +// 拉全量,避免历史记录中已离职成员的名字无法回显。 +export async function listAllTrainingMembers( + pageSize = 500, + opts?: { formalOnly?: boolean }, +): Promise { + const formalOnly = opts?.formalOnly !== false const out: TrainingMember[] = [] for (let page = 1; page <= 100; page++) { - const res = await listMembers({ page, page_size: pageSize }) + const res = await listMembers({ + page, + page_size: pageSize, + employment_status: formalOnly ? 3 : undefined, + }) const pageData = unwrap>(res) const items = pageData?.items || [] out.push(...items) diff --git a/frontend/src/components/UserMenu.vue b/frontend/src/components/UserMenu.vue index 99b11b2..79e3d81 100644 --- a/frontend/src/components/UserMenu.vue +++ b/frontend/src/components/UserMenu.vue @@ -86,37 +86,37 @@ - + -