import { getPageResult, getResult, postResult } from './core/request'
|
import type {
|
MiniApprovalDetailItem,
|
MiniApprovalTodoItem,
|
MiniAppointmentCreateRequest,
|
MiniAppointmentCreateResult,
|
MiniAppointmentPageResult,
|
MiniAppointmentListItem,
|
MiniMyAppointmentDetailItem,
|
MiniSharedAppointmentDetailItem,
|
MiniMyVisitorCodeOrderItem,
|
MiniVisitRecordItem,
|
} from '@/types/appointment'
|
|
export async function createAppointment(payload: MiniAppointmentCreateRequest) {
|
const result = await postResult<MiniAppointmentCreateResult>('/api/mini/appointments', payload)
|
return result.id
|
}
|
|
export async function fetchMyAppointmentOrders(params?: {
|
page?: number
|
size?: number
|
status?: string
|
keyword?: string
|
}) {
|
const response = await getPageResult<MiniAppointmentListItem[]>(
|
'/api/mini/appointments/my-orders',
|
{ params },
|
)
|
return {
|
records: response.result || [],
|
page: response.page ?? params?.page ?? 1,
|
size: response.size ?? params?.size ?? 10,
|
total: response.total ?? 0,
|
pages: response.pages ?? 0,
|
} satisfies MiniAppointmentPageResult<MiniAppointmentListItem>
|
}
|
|
export async function fetchMyAppointmentDetail(orderId: number, orderUuid: string) {
|
return getResult<MiniMyAppointmentDetailItem>(`/api/mini/appointments/${orderId}`, {
|
params: { uuid: orderUuid },
|
})
|
}
|
|
export async function cancelMyAppointment(orderId: number, orderUuid: string) {
|
return postResult<void>(`/api/mini/appointments/${orderId}/cancel`, undefined, {
|
params: { uuid: orderUuid },
|
})
|
}
|
|
export async function deleteMyAppointment(orderId: number, orderUuid: string) {
|
return postResult<void>(`/api/mini/appointments/${orderId}/delete`, undefined, {
|
params: { uuid: orderUuid },
|
})
|
}
|
|
export async function fetchMyVisitorCodes() {
|
return getResult<MiniMyVisitorCodeOrderItem[]>('/api/mini/appointments/my-visitor-codes')
|
}
|
|
export async function fetchSharedAppointmentDetail(orderUuid: string) {
|
return getResult<MiniSharedAppointmentDetailItem>('/api/mini/appointments/shared/detail', {
|
params: { uuid: orderUuid },
|
})
|
}
|
|
export async function fetchSharedVisitorCodes(orderUuid: string) {
|
return getResult<MiniMyVisitorCodeOrderItem>('/api/mini/appointments/shared/visitor-codes', {
|
params: { uuid: orderUuid },
|
})
|
}
|
|
export async function fetchMyApprovalTodos(params?: {
|
page?: number
|
size?: number
|
visitedUserNameKeyword?: string
|
visitDate?: string
|
}) {
|
const response = await getPageResult<MiniApprovalTodoItem[]>(
|
'/api/mini/approvals/todo',
|
{ params },
|
)
|
return {
|
records: response.result || [],
|
page: response.page ?? params?.page ?? 1,
|
size: response.size ?? params?.size ?? 10,
|
total: response.total ?? 0,
|
pages: response.pages ?? 0,
|
} satisfies MiniAppointmentPageResult<MiniApprovalTodoItem>
|
}
|
|
export async function fetchMyApprovalHistory(params?: {
|
page?: number
|
size?: number
|
status?: string
|
visitedUserNameKeyword?: string
|
visitDate?: string
|
}) {
|
const response = await getPageResult<MiniAppointmentListItem[]>(
|
'/api/mini/appointments/mine',
|
{ params },
|
)
|
return {
|
records: response.result || [],
|
page: response.page ?? params?.page ?? 1,
|
size: response.size ?? params?.size ?? 10,
|
total: response.total ?? 0,
|
pages: response.pages ?? 0,
|
} satisfies MiniAppointmentPageResult<MiniAppointmentListItem>
|
}
|
|
export async function fetchApprovalDetail(params: {
|
taskId?: number
|
taskUuid?: string
|
orderId?: number
|
orderUuid?: string
|
}) {
|
return getResult<MiniApprovalDetailItem>('/api/mini/approvals/detail', { params })
|
}
|
|
export async function submitHandlerApproval(payload: {
|
taskId: number
|
taskUuid: string
|
approve: boolean
|
comment: string
|
passAccessAreaIds?: number[]
|
involveOtherLocalUnit: boolean
|
passLocalUnitIds?: number[]
|
}) {
|
return postResult<void>('/api/mini/approvals/handler/action', payload)
|
}
|
|
export async function submitGeneralApproval(payload: {
|
taskId: number
|
taskUuid: string
|
approve: boolean
|
comment: string
|
noticeIds?: number[]
|
}) {
|
return postResult<void>('/api/mini/approvals/action', payload)
|
}
|
|
export async function fetchVisitRecords(params?: {
|
page?: number
|
size?: number
|
futureOnly?: boolean
|
visitorNameKeyword?: string
|
visitDate?: string
|
}) {
|
const response = await getPageResult<MiniVisitRecordItem[]>(
|
'/api/mini/appointments/visit-records',
|
{ params },
|
)
|
return {
|
records: response.result || [],
|
page: response.page ?? params?.page ?? 1,
|
size: response.size ?? params?.size ?? 10,
|
total: response.total ?? 0,
|
pages: response.pages ?? 0,
|
} satisfies MiniAppointmentPageResult<MiniVisitRecordItem>
|
}
|