优化
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { overseasHttp } from '@/shared/api/overseasHttp'
|
||||
import { unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
|
||||
import { listSharedReceivingOverseasWarehouseOptions } from '@/modules/iam'
|
||||
import { normalizeOverseasPage, type OverseasPagePayload } from './lastMileOrders'
|
||||
|
||||
@@ -58,29 +58,29 @@ export async function listReceivingOverseasWarehouses() {
|
||||
}
|
||||
|
||||
export async function listPallets(warehouseId: string | undefined, query: { page: number; size: number; keyword?: string; palletType?: string; status?: string }) {
|
||||
const response = await overseasHttp.get<ApiEnvelope<OverseasPagePayload<PalletDto>>, ApiEnvelope<OverseasPagePayload<PalletDto>>>(
|
||||
warehouseId ? `/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets` : '/platform/v1/warehouse-admin/pallets',
|
||||
const response = await http.get<ApiEnvelope<OverseasPagePayload<PalletDto>>, ApiEnvelope<OverseasPagePayload<PalletDto>>>(
|
||||
warehouseId ? `/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets` : '/platform/v1/overseas-warehouse-resources/pallets',
|
||||
{ params: { ...query } },
|
||||
)
|
||||
return normalizeOverseasPage(unwrapApiResponse(response))
|
||||
}
|
||||
export async function getPalletSummary(warehouseId: string, query: { keyword?: string; palletType?: string }) {
|
||||
const path = warehouseId ? `/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/summary` : '/platform/v1/warehouse-admin/pallets/summary'
|
||||
const response = await overseasHttp.get<ApiEnvelope<PalletSummaryDto>, ApiEnvelope<PalletSummaryDto>>(path, { params: { page: 1, size: 1, ...query } })
|
||||
const path = warehouseId ? `/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/summary` : '/platform/v1/overseas-warehouse-resources/pallets/summary'
|
||||
const response = await http.get<ApiEnvelope<PalletSummaryDto>, ApiEnvelope<PalletSummaryDto>>(path, { params: { page: 1, size: 1, ...query } })
|
||||
const value = unwrapApiResponse(response); return { totalCount: Number(value.totalCount), idleCount: Number(value.idleCount), occupiedCount: Number(value.occupiedCount), scrappedCount: Number(value.scrappedCount) }
|
||||
}
|
||||
|
||||
export async function getPallet(warehouseId: string, palletId: string) {
|
||||
const response = await overseasHttp.get<ApiEnvelope<PalletDto>, ApiEnvelope<PalletDto>>(
|
||||
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
||||
const response = await http.get<ApiEnvelope<PalletDto>, ApiEnvelope<PalletDto>>(
|
||||
`/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
||||
{},
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function getPalletLabelPdf(warehouseId: string, palletId: string) {
|
||||
const blob = await overseasHttp.get<Blob, Blob>(
|
||||
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}/label`,
|
||||
const blob = await http.get<Blob, Blob>(
|
||||
`/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}/label`,
|
||||
{ responseType: 'blob', timeout: 60_000 },
|
||||
)
|
||||
if (blob.type.includes('application/json')) unwrapApiResponse(JSON.parse(await blob.text()) as ApiEnvelope<unknown>)
|
||||
@@ -89,15 +89,15 @@ export async function getPalletLabelPdf(warehouseId: string, palletId: string) {
|
||||
}
|
||||
|
||||
export async function createPallet(warehouseId: string, payload: SavePalletPayload) {
|
||||
const response = await overseasHttp.post<ApiEnvelope<string>, ApiEnvelope<string>>(
|
||||
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets`, payload,
|
||||
const response = await http.post<ApiEnvelope<string>, ApiEnvelope<string>>(
|
||||
`/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets`, payload,
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function updatePallet(warehouseId: string, palletId: string, payload: UpdatePalletPayload) {
|
||||
const response = await overseasHttp.put<ApiEnvelope<null>, ApiEnvelope<null>>(
|
||||
`/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
||||
const response = await http.put<ApiEnvelope<null>, ApiEnvelope<null>>(
|
||||
`/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`,
|
||||
payload,
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
|
||||
Reference in New Issue
Block a user