diff --git a/src/modules/inbounds/core/api.ts b/src/modules/inbounds/core/api.ts index 9ef76349..97d5fea3 100644 --- a/src/modules/inbounds/core/api.ts +++ b/src/modules/inbounds/core/api.ts @@ -1,4 +1,4 @@ -import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http' +import { ApiResponseError, http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http' import type { InboundFileSummary, InboundInternalNote, @@ -126,3 +126,24 @@ export async function getPlatformInbound(tenantId: string, inboundId: string) { ) return normalizeDetail(unwrapApiResponse(response)) } + +export async function downloadInboundCartonLabels(tenantId: string, inboundId: string, cartonIndexes?: number[]) { + const response = await http.post( + `${basePath}/${encodeURIComponent(inboundId)}/carton-label-pdf`, + null, + { + params: { + tenantId, + ...(cartonIndexes?.length ? { cartonIndex: cartonIndexes } : {}), + }, + responseType: 'blob', + timeout: 60_000, + }, + ) + if (response.type.includes('json')) { + const error = JSON.parse(await response.text()) as Partial> + throw new ApiResponseError(error.message || '箱唛生成失败', error.code || 'UNKNOWN', undefined, + error.data, error.requestId, error.traceId) + } + return response +}