优化
This commit is contained in:
+30
-8
@@ -1,15 +1,22 @@
|
||||
import { apiRequest } from '@/api/http.js'
|
||||
import { apiDownload, apiRequest } from '@/api/http.js'
|
||||
|
||||
const ROOT = '/first-leg/pda-dropship'
|
||||
|
||||
function stableId(value) {
|
||||
return String(value ?? '').trim()
|
||||
}
|
||||
|
||||
function operationId(action, taskId) {
|
||||
const random = Math.random().toString(36).slice(2, 10)
|
||||
return `pda-dropship-${action}-${taskId}-${Date.now()}-${random}`.slice(0, 128)
|
||||
}
|
||||
|
||||
export function listDropshipPalletizationTasks(keyword = '') {
|
||||
export function listDropshipPalletizationTasks(keyword = '', warehouseId) {
|
||||
if (!warehouseId) throw new Error('请先选择作业仓库')
|
||||
const query = String(keyword || '').trim()
|
||||
return apiRequest({ url: `${ROOT}/tasks/pending${query ? `?keyword=${encodeURIComponent(query)}` : ''}`, method: 'GET' })
|
||||
const params = [`warehouseId=${encodeURIComponent(warehouseId)}`]
|
||||
if (query) params.push(`keyword=${encodeURIComponent(query)}`)
|
||||
return apiRequest({ url: `${ROOT}/tasks/pending?${params.join('&')}`, method: 'GET' })
|
||||
}
|
||||
|
||||
export function getDropshipPalletizationTask(taskId, warehouseId) {
|
||||
@@ -17,7 +24,7 @@ export function getDropshipPalletizationTask(taskId, warehouseId) {
|
||||
}
|
||||
|
||||
export function claimDropshipPalletizationTask(taskId, warehouseId) {
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/claim`, method: 'POST', data: { warehouseId } })
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/claim`, method: 'POST', data: { warehouseId: stableId(warehouseId) } })
|
||||
}
|
||||
|
||||
export function resolveDropshipCarton(taskId, warehouseId, boxCode) {
|
||||
@@ -25,17 +32,32 @@ export function resolveDropshipCarton(taskId, warehouseId, boxCode) {
|
||||
}
|
||||
|
||||
export function countDropshipCarton(taskId, payload) {
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/cartons/count`, method: 'POST', data: { ...payload, operationId: payload.operationId || operationId('count', taskId) } })
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/cartons/count`, method: 'POST', data: { ...payload, warehouseId: stableId(payload.warehouseId), operationId: payload.operationId || operationId('count', taskId) } })
|
||||
}
|
||||
|
||||
export function bindDropshipPendingCartons(taskId, warehouseId, palletNo) {
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/pallets/bind-pending`, method: 'POST', data: { warehouseId, palletNo: String(palletNo || '').trim().toUpperCase(), operationId: operationId('bind', taskId) } })
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/pallets/bind-pending`, method: 'POST', data: { warehouseId: stableId(warehouseId), palletNo: String(palletNo || '').trim().toUpperCase(), operationId: operationId('bind', taskId) } })
|
||||
}
|
||||
|
||||
export function createAndBindDropshipPallet(taskId, warehouseId) {
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/pallets/create-and-bind`, method: 'POST', data: { warehouseId, operationId: operationId('create-bind', taskId) } })
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/pallets/create-and-bind`, method: 'POST', data: { warehouseId: stableId(warehouseId), operationId: operationId('create-bind', taskId) } })
|
||||
}
|
||||
|
||||
export function sealDropshipPallet(taskId, warehouseId, pallet) {
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/pallets/${encodeURIComponent(pallet.palletId)}/seal`, method: 'POST', data: { warehouseId, expectedVersion: pallet.version, operationId: operationId('seal', taskId) } })
|
||||
return apiRequest({ url: `${ROOT}/tasks/${encodeURIComponent(taskId)}/pallets/${encodeURIComponent(pallet.palletId)}/seal`, method: 'POST', data: { warehouseId: stableId(warehouseId), expectedVersion: pallet.version, operationId: operationId('seal', taskId) } })
|
||||
}
|
||||
|
||||
export function downloadDropshipPalletLabel(taskId, warehouseId, palletId) {
|
||||
const url = `${ROOT}/tasks/${encodeURIComponent(taskId)}/pallets/${encodeURIComponent(palletId)}/print?warehouseId=${encodeURIComponent(stableId(warehouseId))}`
|
||||
return apiDownload({ url }).then((response) => {
|
||||
const contentType = response.header?.['Content-Type'] || response.header?.['content-type'] || ''
|
||||
if (response.statusCode < 200 || response.statusCode >= 300 || !response.tempFilePath || (contentType && !/^application\/pdf/i.test(contentType))) {
|
||||
const error = new Error('托盘码打印文件生成失败')
|
||||
error.statusCode = response.statusCode
|
||||
error.requestId = response.header?.['X-Request-Id'] || response.header?.['x-request-id']
|
||||
error.traceId = response.header?.['X-Trace-Id'] || response.header?.['x-trace-id']
|
||||
throw error
|
||||
}
|
||||
return response.tempFilePath
|
||||
})
|
||||
}
|
||||
|
||||
+12
-1
@@ -28,6 +28,15 @@ function debugLog(event, payload = {}) {
|
||||
|
||||
const request = apiRequest
|
||||
|
||||
export function listPdaWarehouses() {
|
||||
return request({ url: '/first-leg/pda-loading/warehouses', method: 'GET' }).then((records) =>
|
||||
(Array.isArray(records) ? records : []).map((warehouse) => ({
|
||||
id: String(warehouse.id),
|
||||
warehouseCode: String(warehouse.warehouseCode || ''),
|
||||
warehouseName: String(warehouse.warehouseName || '')
|
||||
})))
|
||||
}
|
||||
|
||||
function stableIdempotencyKey(operationId, suffix = '') {
|
||||
const raw = `pda-${operationId}${suffix ? `-${suffix}` : ''}`
|
||||
let hash = 2166136261
|
||||
@@ -120,8 +129,10 @@ export async function submitContainerPickingBatch(task, actions, { warehouseId,
|
||||
})
|
||||
}
|
||||
|
||||
export function listLoadingOrders({ page = 1, size = 50, keyword = '' } = {}) {
|
||||
export function listLoadingOrders({ page = 1, size = 50, keyword = '', warehouseId } = {}) {
|
||||
if (!warehouseId) throw new Error('请先选择作业仓库')
|
||||
const query = []
|
||||
query.push(`warehouseId=${encodeURIComponent(warehouseId)}`)
|
||||
if (keyword) query.push(`keyword=${encodeURIComponent(keyword)}`)
|
||||
const suffix = query.length ? `?${query.join('&')}` : ''
|
||||
return request({ url: `/first-leg/pda-loading/tasks/pending${suffix}`, method: 'GET' }).then((data) => ({
|
||||
|
||||
Reference in New Issue
Block a user