liu
9 天以前 70b7935fc261cd5e8eaaf1cfbc8078b04db576d2
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
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,
  );
}