Merge branch 'dev' into hugo-shipping-notice
This commit is contained in:
commit
472b530be3
397 files changed
+46450
-34171
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* features/chat/leave/leave.api.ts
|
||||
* 用途:封装聊天请假流程的余额查询与 OA 工作流提交请求。
|
||||
* 依赖:shared/utils/auth、shared/api/client。
|
||||
* 逻辑:聊天请假表单调用本模块;后端暂保留 /api/user/leave-* 路径以兼容既有接口。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type { LeaveRequestFormData } from '../types/leave.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
|
||||
export interface LeaveBalanceResult {
|
||||
has_balance: boolean;
|
||||
leave_type_label: string;
|
||||
year: number;
|
||||
total_hours: number | null;
|
||||
used_hours: number | null;
|
||||
remaining_hours: number | null;
|
||||
}
|
||||
|
||||
/** 查询当前用户指定假别的可用余额。 */
|
||||
export const getLeaveBalance = (leaveType: string) =>
|
||||
requestJson<LeaveBalanceResult>(`/api/user/leave-balance?leave_type=${encodeURIComponent(leaveType)}`, auth());
|
||||
|
||||
export interface LeaveWorkflowSubmitResult {
|
||||
request_id?: string;
|
||||
submitted_at?: string;
|
||||
request_name?: string;
|
||||
}
|
||||
|
||||
/** 将聊天内确认后的请假表单提交至 OA 工作流。 */
|
||||
export const submitLeaveWorkflow = (form: LeaveRequestFormData) =>
|
||||
requestJson<LeaveWorkflowSubmitResult>('/api/user/leave-workflow/submit', {
|
||||
method: 'POST',
|
||||
...jsonAuth(),
|
||||
body: JSON.stringify(form),
|
||||
});
|
||||
Reference in new issue
Block a user