feat: add pallet label printing

This commit is contained in:
2026-09-09 17:27:00 +08:00
parent 8f6d4fc03e
commit a47a7e9767
6 changed files with 137 additions and 2 deletions
@@ -6,6 +6,8 @@ import {
getPreloadPlan,
listConfirmedLoadingLists,
listPreloadPlans,
preparePalletLabels,
printPalletLabels,
updatePreloadTransport,
updateLoadingItemWarehouseRemark,
} from './platformLoadingLists'
@@ -158,4 +160,18 @@ describe('platform loading lists API', () => {
})
})
it('prepares and prints pallet labels by FBA warehouse', async () => {
const post = vi.spyOn(http, 'post')
.mockResolvedValueOnce({ code: '200', message: 'ok', data: { planId: 10, planNo: 'LP-1', containerNo: 'MSCU6639870', totalCount: 2, groups: [{ destinationWarehouseCode: 'ONT8', destinationWarehouseName: 'ONT8', totalCount: 2, labels: [{ labelId: 1, itemId: 2, accountId: 3, inboundId: 4, inboundCode: 'RK-1', containerNo: 'MSCU6639870', destinationWarehouseCode: 'ONT8', destinationWarehouseName: 'ONT8', palletIndex: 1, palletCode: 'MSCU6639870-ONT8-001' }] }] } })
.mockResolvedValueOnce(new Blob(['pdf'], { type: 'application/pdf' }))
const manifest = await preparePalletLabels('10', '20')
const pdf = await printPalletLabels('10', '20', 'ONT8', 1)
expect(manifest).toMatchObject({ planId: '10', groups: [{ labels: [{ labelId: '1', itemId: '2', accountId: '3', inboundId: '4' }] }] })
expect(pdf.type).toBe('application/pdf')
expect(post).toHaveBeenNthCalledWith(1, '/platform/v1/first-leg/loading-plans/10/pallet-labels/prepare', null, { params: { warehouseId: '20' } })
expect(post).toHaveBeenNthCalledWith(2, '/platform/v1/first-leg/loading-plans/10/pallet-labels/print', { destinationWarehouseCode: 'ONT8', count: 1 }, { params: { warehouseId: '20' }, responseType: 'blob', timeout: 60_000 })
})
})