From 558fa53970528abea8330b9897812a550d3576d6 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Wed, 8 Jul 2026 01:27:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=A0=87=E7=AD=BE=E8=AF=AD=E4=B9=89=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20&=20=E5=88=86=E9=85=8D=E5=BF=AB=E9=80=92=E5=8F=B7?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E8=BF=9B=E5=BA=A6=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 状态标签语义化: print_status 已打印, pick_status 已拣货, pack_status 已打包, storage_status 已分配 - 全局移除订单状态(status)列: pendingCloums/reviewColums/expectionColumns 及所有页面模板 - 新增 TaskProgressDialog 组件 + useTaskProgress 组合式函数 - 分配快递号改为异步任务模式: 提交后弹出进度窗口, 完成后自动关闭刷新列表 - allocateExpressCodeTaskProgress API 支持轮询任务进度 --- .../order.pendingOrder/orderpendingOrder.ts | 19 +++ src/components/TaskProgressDialog.vue | 108 ++++++++++++++ src/composables/useTaskProgress.ts | 132 ++++++++++++++++++ .../config/order-common-config.ts | 21 ++- .../order/orderManagement/deliveryOrder.vue | 6 - .../order/orderManagement/exceptionOrder.vue | 40 ++++-- .../order/orderManagement/outboundOrder.vue | 5 - .../order/orderManagement/pendingOrder.vue | 40 ++++-- .../order/orderManagement/reviewOrder.vue | 5 - .../orderManagement/utils/toolbar-actions.ts | 60 ++++++-- .../component/PendingOrderListPanel.vue | 6 - src/views/warehouses/index.vue | 2 +- 12 files changed, 376 insertions(+), 68 deletions(-) create mode 100644 src/components/TaskProgressDialog.vue create mode 100644 src/composables/useTaskProgress.ts diff --git a/src/api/order.pendingOrder/orderpendingOrder.ts b/src/api/order.pendingOrder/orderpendingOrder.ts index 857cb87b..93192251 100644 --- a/src/api/order.pendingOrder/orderpendingOrder.ts +++ b/src/api/order.pendingOrder/orderpendingOrder.ts @@ -365,6 +365,23 @@ export function orderPendingOrderAllocateExpressCode( } as any); } +/** 查询分配快递号任务进度 */ +export function orderPendingOrderAllocateExpressCodeTaskProgress( + data: { task_id: string }, +): Promise { + return request({ + url: "/system", + method: "post", + params: { + method: "order.pendingOrder.allocateExpressCodeTaskProgress", + v, + timestamp: Date.now(), + }, + data, + isSystemApi: true, + } as any); +} + export function orderPendingOrderAllocateStorage( data: PendingOrderAllocateStorageParams, ): Promise { @@ -713,6 +730,7 @@ export type OrderPendingOrderApi = { markPendingOutboundOrder: typeof orderPendingOrderMarkPendingOutboundOrder; cancelOrder: typeof orderPendingOrderCancelOrder; allocateExpressCode: typeof orderPendingOrderAllocateExpressCode; + allocateExpressCodeTaskProgress: typeof orderPendingOrderAllocateExpressCodeTaskProgress; allocateStorage: typeof orderPendingOrderAllocateStorage; allocateStorageProgress: typeof orderPendingOrderAllocateStorageProgress; cancelAllocateStorage: typeof orderPendingOrderCancelAllocateStorage; @@ -745,6 +763,7 @@ export const orderPendingOrder: OrderPendingOrderApi = { markPendingOutboundOrder: orderPendingOrderMarkPendingOutboundOrder, cancelOrder: orderPendingOrderCancelOrder, allocateExpressCode: orderPendingOrderAllocateExpressCode, + allocateExpressCodeTaskProgress: orderPendingOrderAllocateExpressCodeTaskProgress, allocateStorage: orderPendingOrderAllocateStorage, allocateStorageProgress: orderPendingOrderAllocateStorageProgress, cancelAllocateStorage: orderPendingOrderCancelAllocateStorage, diff --git a/src/components/TaskProgressDialog.vue b/src/components/TaskProgressDialog.vue new file mode 100644 index 00000000..7afa0967 --- /dev/null +++ b/src/components/TaskProgressDialog.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/src/composables/useTaskProgress.ts b/src/composables/useTaskProgress.ts new file mode 100644 index 00000000..1756b72a --- /dev/null +++ b/src/composables/useTaskProgress.ts @@ -0,0 +1,132 @@ +import { ref, reactive, onBeforeUnmount } from 'vue' + +export interface TaskProgressState { + taskId: string + status: 'submitted' | 'running' | 'success' | 'failed' | '' + progress: number + message: string + error: string + result: any +} + +export interface UseTaskProgressOptions { + /** 轮询进度接口,接收 taskId,返回进度数据 */ + pollFn: (taskId: string) => Promise<{ status?: string; progress?: number; message?: string; error?: string; result?: any } | null> + /** 成功回调 */ + onSuccess?: (result: any, taskId: string) => void + /** 失败回调 */ + onError?: (error: string, taskId: string) => void + /** 轮询间隔(ms),默认 2000 */ + interval?: number + /** 最大轮询次数,默认 120 */ + maxAttempts?: number +} + +export function useTaskProgress(options: UseTaskProgressOptions) { + const { pollFn, onSuccess, onError, interval = 2000, maxAttempts = 120 } = options + + const visible = ref(false) + const polling = ref(false) + + const state = reactive({ + taskId: '', + status: '', + progress: 0, + message: '', + error: '', + result: null + }) + + let timer: ReturnType | null = null + + function reset() { + state.taskId = '' + state.status = '' + state.progress = 0 + state.message = '' + state.error = '' + state.result = null + } + + function stop() { + if (timer) { + clearTimeout(timer) + timer = null + } + polling.value = false + } + + function close() { + stop() + visible.value = false + reset() + } + + async function startPolling(taskId: string) { + reset() + state.taskId = taskId + state.status = 'submitted' + state.progress = 5 + visible.value = true + polling.value = true + + for (let i = 0; i < maxAttempts; i++) { + await new Promise(resolve => { + timer = setTimeout(resolve, interval) + }) + if (!polling.value) return + + try { + const res = await pollFn(taskId) + if (!res) continue + + const status = res.status || '' + state.status = (status as any) || 'running' + state.progress = res.progress ?? state.progress + state.message = res.message || '' + state.error = res.error || '' + state.result = res.result || null + + if (status === 'success' || status === 'completed') { + state.progress = 100 + polling.value = false + onSuccess?.(state.result, taskId) + // 完成后延迟自动关闭 + timer = setTimeout(() => { + visible.value = false + reset() + }, 1500) + return + } + if (status === 'failed' || status === 'error') { + polling.value = false + onError?.(state.error || '任务失败', taskId) + return + } + // 仍在运行中 + if (i === 0) { + state.status = 'running' + } + } catch { + // 轮询异常,继续重试 + } + } + // 超时 + polling.value = false + state.error = '任务超时,请稍后刷新查看结果' + onError?.(state.error, taskId) + } + + onBeforeUnmount(() => { + stop() + }) + + return { + visible, + polling, + state, + startPolling, + stop, + close + } +} diff --git a/src/views/order/orderManagement/config/order-common-config.ts b/src/views/order/orderManagement/config/order-common-config.ts index f8695e9a..ec779fb8 100644 --- a/src/views/order/orderManagement/config/order-common-config.ts +++ b/src/views/order/orderManagement/config/order-common-config.ts @@ -29,23 +29,23 @@ export const COMMON_TRANSLATIONS: Record> = { storage_status: { 'none': '未分配', 'padding': '分配中', - 'fin': '已完成', + 'fin': '已分配', 'error': '错误' }, print_status: { 'none': '未打印', 'padding': '打印中', - 'fin': '已完成' + 'fin': '已打印' }, pick_status: { 'none': '未拣货', 'padding': '拣货中', - 'fin': '已完成' + 'fin': '已拣货' }, pack_status: { 'none': '未打包', 'padding': '打包中', - 'fin': '已完成' + 'fin': '已打包' }, intercept_status: { 'none': '无', @@ -1032,7 +1032,7 @@ export const syncStatusFilterOptionsExtended = [ export const storageStatusFilterOptions = [ { label: '未分配', value: 'none' }, // { label: '分配中', value: 'padding' }, - { label: '已完成', value: 'fin' }, + { label: '已分配', value: 'fin' }, { label: '错误', value: 'error' }, ] @@ -1051,20 +1051,20 @@ export const postStatusFilterOptionsExtended = [ export const pickStatusFilterOptions = [ { label: '未拣货', value: 'none' }, // { label: '拣货中', value: 'padding' }, - { label: '已完成', value: 'fin' }, + { label: '已拣货', value: 'fin' }, { label: '错误', value: 'error' }, ] export const packStatusFilterOptions = [ { label: '未打包', value: 'none' }, // { label: '打包中', value: 'padding' }, - { label: '已完成', value: 'fin' }, + { label: '已打包', value: 'fin' }, { label: '错误', value: 'error' }, ] export const printStatusFilterOptions = [ { label: '未打印', value: 'none' }, - { label: '已完成', value: 'fin' }, + { label: '已打印', value: 'fin' }, { label: '错误', value: 'error' }, ] @@ -1206,7 +1206,7 @@ export const storageAssignScanField = scanWorkflowField({ type: 'select', options: [ { label: '未分配', value: '__storage_assign_unassigned__', operator: 'in', conditionValue: ['unassigned', 'assigning', 'error'] }, - { label: '已完成', value: '__storage_assign_completed__', operator: 'eq', conditionValue: 'completed' } + { label: '已分配', value: '__storage_assign_completed__', operator: 'eq', conditionValue: 'completed' } ] }) @@ -1497,7 +1497,6 @@ export const reviewColums = applyOrderListCopyActions([ orderStoreRemarkColumn, { prop: 'sys_platform_name', label: '平台编码', width: '100' }, { prop: 'name', label: '收件人', width: '110' }, - { prop: 'status', label: '订单状态', width: '100' }, { prop: 'sync_status', label: '同步状态', width: '100' }, { prop: 'recheck_status', label: '复核状态', width: '100' }, { prop: 'is_urgency', label: '是否紧急', width: '80' }, @@ -1662,7 +1661,6 @@ export const pendingCloums = [ { prop: 'mobile', label: '电话', width: '120' }, { prop: 'buyer_message', label: '买家留言', minWidth: '180' }, { prop: 'is_urgency', label: '是否紧急', width: '100' }, - { prop: 'status', label: '订单状态', width: '100' }, { prop: 'sync_status', label: '同步状态', width: '100' }, { prop: 'storage_status', label: '储位状态', width: '100' }, { prop: 'post_status', label: '快递状态', width: '100' }, @@ -1982,7 +1980,6 @@ export const expectionColumns = [ { prop: 'shop_nick', label: '店铺名称', width: '140' }, orderStoreRemarkColumn, { prop: 'is_urgency', label: '是否紧急', width: '100' }, - { prop: 'status', label: '订单状态', width: '100' }, { prop: 'sync_status', label: '同步状态', width: '100' }, { prop: 'storage_status', label: '储位状态', width: '100' }, { prop: 'post_status', label: '快递状态', width: '100' }, diff --git a/src/views/order/orderManagement/deliveryOrder.vue b/src/views/order/orderManagement/deliveryOrder.vue index c5392097..b588b458 100644 --- a/src/views/order/orderManagement/deliveryOrder.vue +++ b/src/views/order/orderManagement/deliveryOrder.vue @@ -61,12 +61,6 @@ @refresh="loadData" @selection-change="onSelectionChange" > - -