This commit is contained in:
2026-09-10 11:17:45 +08:00
parent 6a038c89ca
commit 9b5b324fe8
5 changed files with 79 additions and 8 deletions
+15 -1
View File
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { downloadInboundCartonLabels, downloadPlatformInboundHoldEvidence, getPlatformInbound, getPlatformInboundHold, holdPlatformInbound, listPlatformInbounds, releasePlatformInbound, uploadPlatformInboundHoldEvidence } from './api'
import { downloadInboundCartonLabels, downloadInboundCartonLabelsBatch, downloadPlatformInboundHoldEvidence, getPlatformInbound, getPlatformInboundHold, holdPlatformInbound, listPlatformInbounds, releasePlatformInbound, uploadPlatformInboundHoldEvidence } from './api'
vi.mock('@/shared/api/http', () => ({
ApiResponseError: class ApiResponseError extends Error {
@@ -117,6 +117,20 @@ describe('platform inbound query API', () => {
})
})
it('downloads one PDF for a cross-customer batch of inbound orders', async () => {
const pdf = new Blob(['pdf'], { type: 'application/pdf' })
vi.mocked(http.post).mockResolvedValueOnce(pdf)
const items = [
{ tenantId: '10001', inboundId: '19001' },
{ tenantId: '10002', inboundId: '19002' },
]
await expect(downloadInboundCartonLabelsBatch(items)).resolves.toBe(pdf)
expect(http.post).toHaveBeenCalledWith('/platform/inbounds/carton-label-pdf', items, {
responseType: 'blob', timeout: 120_000,
})
})
it('loads and normalizes the tenant-scoped hold state and immutable history', async () => {
vi.mocked(http.get).mockResolvedValue({ data: {
inboundId: 19001, tenantId: 10002, holdFlag: true, currentHoldReason: ' 待核对货款 ', version: '4',
+19
View File
@@ -238,6 +238,25 @@ export async function downloadInboundCartonLabels(tenantId: string, inboundId: s
return response
}
export interface InboundCartonLabelBatchItem {
tenantId: string
inboundId: string
}
export async function downloadInboundCartonLabelsBatch(items: InboundCartonLabelBatchItem[]) {
const response = await http.post<Blob, Blob>(
`${basePath}/carton-label-pdf`,
items,
{ responseType: 'blob', timeout: 120_000 },
)
if (response.type.includes('json')) {
const error = JSON.parse(await response.text()) as Partial<ApiEnvelope<unknown>>
throw new ApiResponseError(error.message || '批量箱唛生成失败', error.code || 'UNKNOWN', undefined,
error.data, error.requestId, error.traceId)
}
return response
}
export async function downloadDropshipPalletLabel(tenantId: string, inboundId: string, palletId: string) {
return http.get<Blob, Blob>(
`/platform/v1/first-leg/pda-dropship/inbound-orders/${encodeURIComponent(inboundId)}/pallets/${encodeURIComponent(palletId)}/print`,
+1 -1
View File
@@ -1,5 +1,5 @@
export { getInboundMeasurement, saveInboundMeasurementDraft, updateMeasurementCalculationStrategy } from './measurement/api'
export { createInboundHoldIdempotencyKey, downloadPlatformInboundHoldEvidence, getPlatformInboundHold, holdPlatformInbound, releasePlatformInbound, uploadPlatformInboundHoldEvidence } from './core/api'
export { createInboundHoldIdempotencyKey, downloadInboundCartonLabelsBatch, downloadPlatformInboundHoldEvidence, getPlatformInboundHold, holdPlatformInbound, releasePlatformInbound, uploadPlatformInboundHoldEvidence } from './core/api'
export { default as InboundMeasurementPanel } from './measurement/InboundMeasurementPanel.vue'
export { default as InboundMeasurementDialog } from './measurement/InboundMeasurementDialog.vue'
export { default as MeasurementEvidenceThumbnail } from './measurement/components/MeasurementEvidenceThumbnail.vue'