47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import type { Employee } from '~/types/api'
|
|
import { request } from '~/utils/request'
|
|
|
|
export type EmployeeListQuery = {
|
|
page?: number
|
|
pageSize?: number
|
|
role?: string
|
|
status?: string
|
|
keyword?: string
|
|
}
|
|
|
|
export const employeeApi = {
|
|
list: (query: EmployeeListQuery) =>
|
|
request<{ employees: Employee[]; total: number; page: number; pageSize: number }>(
|
|
'/health/employee',
|
|
{ query }
|
|
),
|
|
|
|
create: (body: Record<string, unknown>) =>
|
|
request<{ employee: Employee }>('/health/employee', {
|
|
method: 'POST',
|
|
body,
|
|
}),
|
|
|
|
update: (id: string, body: Record<string, unknown>) =>
|
|
request<{ employee: Employee }>(`/health/employee/${id}`, {
|
|
method: 'PUT',
|
|
body,
|
|
}),
|
|
|
|
updateStatus: (id: string, status: string) =>
|
|
request<{ employee: Employee }>(`/health/employee/${id}/status`, {
|
|
method: 'PATCH',
|
|
body: { status },
|
|
}),
|
|
|
|
/** 实习转正 / 调级 / 钻石设星 */
|
|
updateLevel: (
|
|
id: string,
|
|
body: { stage?: 'intern' | 'certified'; grade?: string; star?: number }
|
|
) =>
|
|
request<{ employee: Employee }>(`/health/employee/${id}/level`, {
|
|
method: 'PATCH',
|
|
body,
|
|
}),
|
|
}
|