longz
2026-06-25 66e3e77580f3bf51830e39c9322a69002bf18671
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
import { getPageResult, getResult, postResult } from './core/request'
import type {
  MiniApprovalAllItem,
  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
}
 
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 fetchSharedTicketVisitorCode(ticketUuid: string) {
  return getResult<MiniMyVisitorCodeOrderItem>('/api/mini/appointments/shared/ticket-code', {
    params: { ticketUuid },
  })
}
 
export async function fetchMyApprovalTodos(params?: {
  page?: number
  size?: number
  visitorNameKeyword?: 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
  visitorNameKeyword?: 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 fetchMyApprovalAll(params?: {
  page?: number
  size?: number
  visitorNameKeyword?: string
  visitDate?: string
}) {
  const response = await getPageResult<MiniApprovalAllItem[]>(
    '/api/mini/approvals/all',
    { 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<MiniApprovalAllItem>
}
 
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>
}