liu
17 小时以前 611dd8268e40caa4d97e8954b85b5adaaef99afa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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;
    remark?: string;
    createTime?: 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 },
  );
}
 
/** 查询考勤统计(按月) */
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,
  );
}