91 lines
2.4 KiB
TypeScript
91 lines
2.4 KiB
TypeScript
import { http } from './http'
|
||
import type { PageResult } from '@/types/crud'
|
||
|
||
/** 人员(staff)实体。字段字典锚点见 shared/data-model spec。 */
|
||
export interface Staff {
|
||
id: string
|
||
tenantCode: string
|
||
userId: string | null
|
||
name: string
|
||
idCardNo: string
|
||
personCode: string | null
|
||
phone: string
|
||
jobType: string
|
||
workType: string
|
||
entryDate: number | null
|
||
leaveDate: number | null
|
||
employStatus: string
|
||
certType: string | null
|
||
certNo: string | null
|
||
certLevel: string | null
|
||
certExpire: number | null
|
||
certStatus: string | null
|
||
certVerifyUrl: string | null
|
||
groupLeaderId: string | null
|
||
createdAt: number
|
||
createdBy: string | null
|
||
updatedAt: number
|
||
deletedAt: number | null
|
||
}
|
||
|
||
export interface StaffListQuery {
|
||
page: number
|
||
pageSize: number
|
||
name?: string
|
||
jobType?: string
|
||
employStatus?: string
|
||
}
|
||
|
||
/** 建档入参(日期字段为 YYYY-MM-DD 字符串)。 */
|
||
export interface StaffCreateData {
|
||
userId?: string
|
||
name: string
|
||
idCardNo: string
|
||
personCode?: string
|
||
phone: string
|
||
jobType: string
|
||
workType: string
|
||
entryDate?: string
|
||
leaveDate?: string
|
||
employStatus: string
|
||
certType?: string
|
||
certNo?: string
|
||
certLevel?: string
|
||
certExpire?: string
|
||
certStatus?: string
|
||
certVerifyUrl?: string
|
||
groupLeaderId?: string
|
||
}
|
||
|
||
/** 改人员入参(全部可选)。 */
|
||
export type StaffUpdateData = Partial<StaffCreateData>
|
||
|
||
/** 人员分页列表。 */
|
||
export function listStaff(query: StaffListQuery, signal?: AbortSignal): Promise<PageResult<Staff>> {
|
||
const params: Record<string, unknown> = { page: query.page, pageSize: query.pageSize }
|
||
if (query.name) params.name = query.name
|
||
if (query.jobType) params.jobType = query.jobType
|
||
if (query.employStatus) params.employStatus = query.employStatus
|
||
return http.get<PageResult<Staff>>('/staff', { params, signal })
|
||
}
|
||
|
||
/** 建档。 */
|
||
export function createStaff(data: StaffCreateData): Promise<Staff> {
|
||
return http.post<Staff>('/staff', data)
|
||
}
|
||
|
||
/** 改人员。 */
|
||
export function updateStaff(id: string, data: StaffUpdateData): Promise<Staff> {
|
||
return http.patch<Staff>(`/staff/${id}`, data)
|
||
}
|
||
|
||
/** 删除(软删)。 */
|
||
export function deleteStaff(id: string): Promise<unknown> {
|
||
return http.delete(`/staff/${id}`)
|
||
}
|
||
|
||
/** 指定归属组长(groupLeaderId 传 null 解除归属)。 */
|
||
export function assignGroupLeader(id: string, groupLeaderId: string | null): Promise<Staff> {
|
||
return http.post<Staff>(`/staff/${id}/group`, { groupLeaderId })
|
||
}
|