feat: add pallet label printing
This commit is contained in:
@@ -256,6 +256,34 @@ function normalizeHistory(raw: LoadingHistory): LoadingHistory {
|
||||
}
|
||||
}
|
||||
|
||||
export interface PalletLabel {
|
||||
labelId: string
|
||||
itemId: string
|
||||
accountId: string
|
||||
inboundId: string
|
||||
inboundCode: string
|
||||
containerNo: string
|
||||
destinationWarehouseCode: string
|
||||
destinationWarehouseName: string | null
|
||||
palletIndex: number
|
||||
palletCode: string
|
||||
}
|
||||
|
||||
export interface PalletLabelGroup {
|
||||
destinationWarehouseCode: string
|
||||
destinationWarehouseName: string | null
|
||||
totalCount: number
|
||||
labels: PalletLabel[]
|
||||
}
|
||||
|
||||
export interface PalletLabelManifest {
|
||||
planId: string
|
||||
planNo: string
|
||||
containerNo: string
|
||||
totalCount: number
|
||||
groups: PalletLabelGroup[]
|
||||
}
|
||||
|
||||
function normalizePage<T extends LoadingListSummary>(raw: RawPage<T>, normalize: (row: T) => T): LoadingListPage<T> {
|
||||
return {
|
||||
records: (raw.records || []).map(normalize),
|
||||
@@ -353,3 +381,26 @@ export async function getConfirmedLoadingList(planId: string, warehouseId: strin
|
||||
histories: (result.histories || []).map(normalizeHistory),
|
||||
}
|
||||
}
|
||||
|
||||
export async function preparePalletLabels(planId: string, warehouseId: string) {
|
||||
const response = await http.post<ApiEnvelope<PalletLabelManifest>, ApiEnvelope<PalletLabelManifest>>(
|
||||
`${basePath}/loading-plans/${encodeURIComponent(planId)}/pallet-labels/prepare`, null, { params: { warehouseId } },
|
||||
)
|
||||
const result = unwrapApiResponse(response)
|
||||
return {
|
||||
...result,
|
||||
planId: requiredId(result.planId),
|
||||
groups: (result.groups || []).map((group) => ({
|
||||
...group,
|
||||
labels: (group.labels || []).map((label) => ({ ...label, labelId: requiredId(label.labelId), itemId: requiredId(label.itemId), accountId: requiredId(label.accountId), inboundId: requiredId(label.inboundId) })),
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
export function printPalletLabels(planId: string, warehouseId: string, destinationWarehouseCode?: string, count?: number) {
|
||||
return http.post<Blob, Blob>(
|
||||
`${basePath}/loading-plans/${encodeURIComponent(planId)}/pallet-labels/print`,
|
||||
{ destinationWarehouseCode: destinationWarehouseCode || null, count: count || null },
|
||||
{ params: { warehouseId }, responseType: 'blob', timeout: 60_000 },
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user