优化
This commit is contained in:
@@ -20,12 +20,6 @@ export async function reviewCargoDiscard(discardNo: string, decision: 'APPROVE'
|
||||
const response = await http.post<ApiEnvelope<CargoDiscardDetail>, ApiEnvelope<CargoDiscardDetail>>(`/platform/v1/last-leg/cargo-discards/${encodeURIComponent(discardNo)}/review`, { decision, remark }, { params: customerId ? { customerId } : undefined })
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
export async function completeCargoDiscard(discardNo: string, customerId?: string) {
|
||||
const response = await http.post<ApiEnvelope<CargoDiscardDetail>, ApiEnvelope<CargoDiscardDetail>>(`/platform/v1/last-leg/cargo-discards/${encodeURIComponent(discardNo)}/complete`, undefined, { params: customerId ? { customerId } : undefined })
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
|
||||
export function downloadCargoDiscardPhoto(discardNo: string, fileId: string, customerId: string) {
|
||||
return http.get<Blob, Blob>(`/platform/v1/last-leg/cargo-discards/${encodeURIComponent(discardNo)}/photos/files/${encodeURIComponent(fileId)}/download`, { params: { customerId }, responseType: 'blob' })
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { http } from '@/shared/api/http'
|
||||
import { allocateWarehouseTransfer, getWarehouseTransfer, listWarehouseTransfers, reviewWarehouseTransfer, outboundWarehouseTransfer, receiveWarehouseTransfer, listTransferReceivingWarehouses } from './warehouseTransfers'
|
||||
import { allocateWarehouseTransfer, getWarehouseTransferCartonLabel, getWarehouseTransfer, listWarehouseTransfers, reviewWarehouseTransfer, outboundWarehouseTransfer, receiveWarehouseTransfer, listTransferReceivingWarehouses } from './warehouseTransfers'
|
||||
|
||||
vi.mock('@/shared/api/http', async (importOriginal) => ({ ...(await importOriginal<typeof import('@/shared/api/http')>()), http: { get: vi.fn(), post: vi.fn() } }))
|
||||
|
||||
describe('warehouseTransfers API', () => {
|
||||
beforeEach(() => vi.clearAllMocks())
|
||||
it('loads server-rendered carton labels using the source transfer and customer scope', async () => {
|
||||
const label = { transferNo: 'WT/1', cartons: [{ cartonMark: 'BOX-1' }], printableHtml: '<html>BOX-1</html>' }
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', data: label })
|
||||
expect(await getWarehouseTransferCartonLabel('customer-1', 'WT/1')).toEqual(label)
|
||||
expect(http.get).toHaveBeenCalledExactlyOnceWith('/platform/v1/last-leg/warehouse-transfers/WT%2F1/carton-label', { params: { customerId: 'customer-1' } })
|
||||
})
|
||||
it('uses the resource-role receiving options contract, never warehouse master list', async () => {
|
||||
vi.mocked(http.get).mockResolvedValue({ code: '200', data: { records: [{ id: 'NY', customerId: 0, warehouseCode: 'NY', warehouseName: '纽约', warehouseType: 'OVERSEAS', status: 'ACTIVE' }], total: 1, page: 1, size: 200, pages: 1 } })
|
||||
expect((await listTransferReceivingWarehouses()).records[0]?.customerId).toBe('0')
|
||||
|
||||
@@ -35,11 +35,21 @@ export interface WarehouseTransferItemDto {
|
||||
id: string
|
||||
skuCode: string
|
||||
productNameZh: string
|
||||
quantity?: number | string | null
|
||||
packageCount: number
|
||||
shippingMark?: string | null
|
||||
}
|
||||
|
||||
export interface WarehouseTransferCartonDto {
|
||||
transferItemId?: string | null
|
||||
transferPalletId?: string | null
|
||||
length?: number | string | null
|
||||
width?: number | string | null
|
||||
height?: number | string | null
|
||||
weight?: number | string | null
|
||||
quantity?: number | string | null
|
||||
countedAt?: string | null
|
||||
discrepancyReason?: string | null
|
||||
cartonMark?: string | null
|
||||
customerCartonMark?: string | null
|
||||
cartonIndex: number
|
||||
@@ -47,6 +57,19 @@ export interface WarehouseTransferCartonDto {
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface WarehouseTransferCartonLabelDto {
|
||||
transferNo: string
|
||||
cartons: WarehouseTransferCartonDto[]
|
||||
printableHtml: string
|
||||
}
|
||||
|
||||
export async function getWarehouseTransferCartonLabel(customerId: string, transferNo: string) {
|
||||
const response = await http.get<ApiEnvelope<WarehouseTransferCartonLabelDto>, ApiEnvelope<WarehouseTransferCartonLabelDto>>(
|
||||
`/platform/v1/last-leg/warehouse-transfers/${encodeURIComponent(transferNo)}/carton-label`, { params: { customerId } },
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export interface WarehouseTransferRelabelBindingDto {
|
||||
operationType: string
|
||||
customerCartonMark: string
|
||||
@@ -61,6 +84,7 @@ export interface WarehouseTransferRelabelBindingDto {
|
||||
export interface WarehouseTransferPalletDto {
|
||||
id: string
|
||||
sequenceNo: number
|
||||
warehouseLocationCode?: string | null
|
||||
palletNo?: string | null
|
||||
cartonCount: number
|
||||
grossWeightKg: number
|
||||
|
||||
Reference in New Issue
Block a user