import type { PageParam, PageResult } from '#/packages/effects/request/src';
|
|
import { requestClient } from '#/api/request';
|
|
export namespace HrmAttendanceRecordApi {
|
/** 考勤记录 */
|
export interface AttendanceRecord {
|
id?: number;
|
userId?: number;
|
userName?: string;
|
deptId?: number;
|
deptName?: string;
|
phone?: string;
|
date?: string;
|
clockInTime?: string;
|
clockOutTime?: string;
|
clockInType?: number;
|
clockInTypeName?: string;
|
clockOutType?: number;
|
clockOutTypeName?: string;
|
workHours?: number;
|
overtimeHours?: number;
|
location?: string;
|
/** 上班打卡经度(WGS84) */
|
clockInLongitude?: number;
|
/** 上班打卡纬度(WGS84) */
|
clockInLatitude?: number;
|
/** 上班定位精度,米 */
|
clockInAccuracy?: number;
|
/** 上班距打卡地点距离,米 */
|
clockInDistance?: number;
|
/** 上班打卡地点地址快照 */
|
clockInAddress?: string;
|
/** 下班打卡经度(WGS84) */
|
clockOutLongitude?: number;
|
/** 下班打卡纬度(WGS84) */
|
clockOutLatitude?: number;
|
/** 下班定位精度,米 */
|
clockOutAccuracy?: number;
|
/** 下班距打卡地点距离,米 */
|
clockOutDistance?: number;
|
/** 下班打卡地点地址快照 */
|
clockOutAddress?: string;
|
dataSource?: number;
|
dataSourceName?: string;
|
/** 当天是否请假(存在审批通过且与工作时段重叠的请假单) */
|
leaveFlag?: boolean;
|
/** 当天请假工时(小时),未请假为 0 */
|
leaveHours?: number;
|
/** 当天请假类型,逗号分隔的 HrmLeaveTypeEnum.type,如 "1,2" */
|
leaveTypes?: string;
|
remark?: string;
|
createTime?: string;
|
}
|
|
/** 我的考勤状态(/hrm/attendance/record/my-status) */
|
export interface AttendanceMyStatus {
|
/** 员工姓名 */
|
employeeName?: string;
|
userName?: string;
|
deptName?: string;
|
/** 考勤日期 */
|
date?: string;
|
/** 服务器时间 */
|
serverTime?: string;
|
/** 是否工作日 */
|
workDay?: boolean;
|
/** 休息日原因,如:国庆节、周六 */
|
restDayReason?: string;
|
/** 打卡地点名称 */
|
locationName?: string;
|
locationAddress?: string;
|
/** 是否启用定位范围校验 */
|
locationRequired?: boolean;
|
/** 允许打卡半径,单位米 */
|
radiusMeters?: number;
|
/** 当日考勤记录,未打卡时为 null */
|
record?: AttendanceRecord;
|
/** 今日记录ID */
|
recordId?: number;
|
clockInTime?: string;
|
clockOutTime?: string;
|
clockInType?: number;
|
clockOutType?: number;
|
clockInDone?: boolean;
|
clockOutDone?: boolean;
|
workHours?: number;
|
overtimeHours?: number;
|
location?: string;
|
/** 当天是否请假 */
|
onLeave?: boolean;
|
/** 当天请假工时(小时),未请假为 0 */
|
leaveHours?: number;
|
/** 当天请假类型名称,多段用顿号分隔,如 "事假、病假" */
|
leaveTypeNames?: string;
|
/** 当前可打卡状态 */
|
clockable?: {
|
clockIn?: boolean;
|
clockOut?: boolean;
|
/** 下一步动作:in-上班打卡,out-下班打卡,none-无需打卡 */
|
nextAction?: 'in' | 'none' | 'out' | string;
|
/** 提示文案 */
|
message?: string;
|
};
|
}
|
|
/** 考勤统计 */
|
export interface AttendanceStatistics {
|
userId?: number;
|
userName?: string;
|
deptName?: string;
|
totalDays?: number;
|
normalDays?: number;
|
lateDays?: number;
|
earlyDays?: number;
|
absentDays?: number;
|
overtimeHours?: number;
|
totalWorkHours?: number;
|
}
|
}
|
|
/** 定位打卡坐标,后端仅接受 WGS84 */
|
export interface AttendanceClockLocation {
|
longitude: number;
|
latitude: number;
|
accuracy: number;
|
coordinateSystem: 'WGS84';
|
}
|
|
/** 定位打卡结果;未启用定位范围校验时,距离与半径为空 */
|
export interface AttendanceClockResponse {
|
record?: HrmAttendanceRecordApi.AttendanceRecord;
|
locationName?: string;
|
distanceMeters?: number;
|
radiusMeters?: number;
|
withinRange?: boolean;
|
}
|
|
/** 查询考勤记录分页列表 */
|
export function getAttendanceRecordPage(params: PageParam) {
|
return requestClient.get<PageResult<HrmAttendanceRecordApi.AttendanceRecord>>(
|
'/hrm/attendance/record/page',
|
{ params },
|
);
|
}
|
|
/**
|
* 查询当前登录人的考勤状态
|
*
|
* @param date 考勤日期,格式 yyyy-MM-dd,不传取服务器当天
|
*/
|
export function getAttendanceMyStatus(date?: string) {
|
return requestClient.get<HrmAttendanceRecordApi.AttendanceMyStatus>(
|
'/hrm/attendance/record/my-status',
|
date ? { params: { date } } : undefined,
|
);
|
}
|
|
/** 查询考勤统计(按月) */
|
export function getAttendanceStatistics(params: {
|
userId?: number;
|
deptId?: number;
|
month: string;
|
}) {
|
return requestClient.get<HrmAttendanceRecordApi.AttendanceStatistics[]>(
|
'/hrm/attendance/record/statistics',
|
{ params },
|
);
|
}
|
|
/** 导入考勤记录 */
|
export function importAttendanceRecord(file: File, updateSupport: boolean) {
|
return requestClient.upload('/hrm/attendance/record/import', {
|
file,
|
updateSupport,
|
});
|
}
|
|
/** 下载考勤导入模板 */
|
export function importAttendanceTemplate() {
|
return requestClient.download('/hrm/attendance/record/get-import-template');
|
}
|
|
/** 导出考勤记录 */
|
export function exportAttendanceRecord(params: any) {
|
return requestClient.download('/hrm/attendance/record/export-excel', { params });
|
}
|
|
/**
|
* 上班打卡
|
*
|
* 同时提交定位(JSON body)与旧版地点文本(query 参数):
|
* - 新后端按定位校验打卡范围,未启用定位时忽略定位;
|
* - 旧后端只读取 location 参数,保证升级前后都能正常打卡。
|
*/
|
export function clockIn(
|
data?: AttendanceClockLocation | null,
|
location?: string,
|
) {
|
return requestClient.post<AttendanceClockResponse>(
|
'/hrm/attendance/record/clock-in',
|
data ?? null,
|
location ? { params: { location } } : undefined,
|
);
|
}
|
|
/** 下班打卡,参数说明同 clockIn */
|
export function clockOut(
|
data?: AttendanceClockLocation | null,
|
location?: string,
|
) {
|
return requestClient.post<AttendanceClockResponse>(
|
'/hrm/attendance/record/clock-out',
|
data ?? null,
|
location ? { params: { location } } : undefined,
|
);
|
}
|