feat: 订单列表状态标签语义修正 & 分配快递号异步进度窗口

- 状态标签语义化: print_status 已打印, pick_status 已拣货, pack_status 已打包, storage_status 已分配
- 全局移除订单状态(status)列: pendingCloums/reviewColums/expectionColumns 及所有页面模板
- 新增 TaskProgressDialog 组件 + useTaskProgress 组合式函数
- 分配快递号改为异步任务模式: 提交后弹出进度窗口, 完成后自动关闭刷新列表
- allocateExpressCodeTaskProgress API 支持轮询任务进度
This commit is contained in:
liufumingren 2026-07-08 01:27:29 +08:00
parent 342125bfd6
commit 558fa53970
12 changed files with 376 additions and 68 deletions

View File

@ -365,6 +365,23 @@ export function orderPendingOrderAllocateExpressCode(
} as any);
}
/** 查询分配快递号任务进度 */
export function orderPendingOrderAllocateExpressCodeTaskProgress(
data: { task_id: string },
): Promise<any> {
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<PendingOrderAllocateStorageResponse & { code?: number; message?: string; flag?: string; data?: unknown }> {
@ -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,

View File

@ -0,0 +1,108 @@
<template>
<el-dialog
:model-value="visible"
:title="title"
width="480px"
append-to-body
align-center
:show-close="!polling"
:close-on-click-modal="false"
:close-on-press-escape="!polling"
@update:model-value="emit('update:visible', $event)"
>
<div class="task-progress-panel">
<div class="task-progress-panel__header">
<span class="task-progress-panel__meta">任务ID:{{ taskId || '—' }}</span>
</div>
<el-progress
:percentage="progressPercent"
:status="progressStatus"
:stroke-width="16"
:striped="polling"
:striped-flow="polling"
/>
<div class="task-progress-panel__info">
<span>状态:{{ statusLabel }}</span>
<span>进度:{{ progressPercent }}%</span>
<span v-if="updateTime">更新时间:{{ updateTime }}</span>
</div>
<div v-if="errorText" class="task-progress-panel__error">
{{ errorText }}
</div>
<div v-if="resultText && !polling" class="task-progress-panel__result">
{{ resultText }}
</div>
</div>
<template #footer>
<el-button
size="small"
:type="polling ? 'default' : 'primary'"
:disabled="polling"
@click="emit('close')"
>{{ polling ? '处理中…' : '关闭' }}</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { computed } from 'vue'
const props = defineProps<{
visible: boolean
title?: string
polling: boolean
taskId: string
progressPercent: number
statusLabel: string
errorText?: string
resultText?: string
updateTime?: string
}>()
const emit = defineEmits<{
(e: 'update:visible', value: boolean): void
(e: 'close'): void
}>()
const progressStatus = computed(() => {
if (props.errorText) return 'exception'
if (props.progressPercent >= 100) return 'success'
return ''
})
</script>
<style scoped lang="scss">
.task-progress-panel {
display: flex;
flex-direction: column;
gap: 14px;
}
.task-progress-panel__header,
.task-progress-panel__info {
display: flex;
flex-wrap: wrap;
gap: 12px;
color: #606266;
font-size: 13px;
}
.task-progress-panel__error {
color: #f56c6c;
font-size: 13px;
line-height: 1.6;
padding: 8px 12px;
background: #fef0f0;
border-radius: 4px;
}
.task-progress-panel__result {
color: #67c23a;
font-size: 13px;
line-height: 1.6;
padding: 8px 12px;
background: #f0f9eb;
border-radius: 4px;
}
</style>

View File

@ -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<TaskProgressState>({
taskId: '',
status: '',
progress: 0,
message: '',
error: '',
result: null
})
let timer: ReturnType<typeof setTimeout> | 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<void>(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
}
}

View File

@ -29,23 +29,23 @@ export const COMMON_TRANSLATIONS: Record<string, Record<string, string>> = {
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' },

View File

@ -61,12 +61,6 @@
@refresh="loadData"
@selection-change="onSelectionChange"
>
<template #column-status="{ row }">
<el-tag :type="getTagType('status', row.status)" size="small">
{{ translateOrderField('status', row.status) }}
</el-tag>
</template>
<template #column-is_urgency="{ row }">
<el-tag :type="getTagType('is_urgency', row.is_urgency)" size="small">
{{ translateOrderField('is_urgency', row.is_urgency) }}

View File

@ -89,18 +89,6 @@
@refresh="loadData"
@selection-change="onSelectionChange"
>
<template #column-order_status="{ row }">
<el-tag :type="getTagType('order_status', row.order_status)" size="small">
{{ translateOrderField('order_status', row.order_status) }}
</el-tag>
</template>
<template #column-status="{ row }">
<el-tag :type="getTagType('status', row.status)" size="small">
{{ translateOrderField('status', row.status) }}
</el-tag>
</template>
<template #column-is_urgency="{ row }">
<el-tag :type="getTagType('is_urgency', row.is_urgency)" size="small">
{{ translateOrderField('is_urgency', row.is_urgency) }}
@ -228,6 +216,16 @@
@closed="resetAllocateDialog"
@submit="submitAllocateExpress"
/>
<task-progress-dialog
:visible="allocateExpressProgressVisible"
title="分配快递号进度"
:polling="allocateExpressProgressPolling"
:task-id="allocateExpressProgressState.taskId"
:progress-percent="allocateExpressProgressState.progress"
:status-label="allocateExpressProgressStatusLabel"
:error-text="allocateExpressProgressState.error"
@close="closeAllocateExpressProgress"
/>
<storage-allocate-form
v-model="storageDialogVisible"
v-model:allow-storage-location="storageForm.allowStorageLocation"
@ -439,6 +437,7 @@ import { getOrderPrintData } from '@/api/order.print/orderprint'
import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint'
import { unwrapWavePlatformPrintPayload } from '@/views/order/waveOrder/config/wave-config'
import { useUserStore } from '@/stores/modules/user'
import TaskProgressDialog from '@/components/TaskProgressDialog.vue'
const scanBox = ref<any>(null)
const upperTable = ref<any>(null)
@ -857,11 +856,27 @@ const buttonLabelMap = computed<Record<string, string>>(() => ({
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
}))
const allocateExpressProgressStatusLabel = computed(() => {
const s = allocateExpressProgressState.status
const map: Record<string, string> = {
submitted: '已提交',
running: '处理中',
success: '已完成',
completed: '已完成',
failed: '失败',
error: '错误'
}
return map[s] || s || '—'
})
const {
actionMap: pendingToolbarActionMap,
dialogState: {
allocateDialogVisible,
allocateLoading,
allocateExpressProgressVisible,
allocateExpressProgressPolling,
allocateExpressProgressState,
storageDialogVisible,
storageDialogMode,
storagePendingOrderIds,
@ -928,6 +943,7 @@ const {
submitUpdateRemark,
submitBatchAsyncTask,
handleBatchQuickRecheckSuccess,
closeAllocateExpressProgress,
resetAllocateDialog,
resetStorageAllocateDialog,
resetUpdateOrderMetaDialog,

View File

@ -60,11 +60,6 @@
@refresh="loadData"
@selection-change="onSelectionChange"
>
<template #column-status="{ row }">
<el-tag :type="getTagType('status', row.status)" size="small">
{{ translateOrderField('status', row.status) }}
</el-tag>
</template>
<template #column-post_status="{ row }">
<el-tag :type="getTagType('post_status', row.post_status)" size="small">

View File

@ -57,18 +57,6 @@
@refresh="loadData"
@selection-change="onSelectionChange"
>
<template #column-order_status="{ row }">
<el-tag :type="getTagType('order_status', row.order_status)" size="small">
{{ translateOrderField('order_status', row.order_status) }}
</el-tag>
</template>
<template #column-status="{ row }">
<el-tag :type="getTagType('status', row.status)" size="small">
{{ translateOrderField('status', row.status) }}
</el-tag>
</template>
<template #column-is_urgency="{ row }">
<el-tag :type="getTagType('is_urgency', row.is_urgency)" size="small">
{{ translateOrderField('is_urgency', row.is_urgency) }}
@ -193,6 +181,16 @@
@closed="resetAllocateDialog"
@submit="submitAllocateExpress"
/>
<task-progress-dialog
:visible="allocateExpressProgressVisible"
title="分配快递号进度"
:polling="allocateExpressProgressPolling"
:task-id="allocateExpressProgressState.taskId"
:progress-percent="allocateExpressProgressState.progress"
:status-label="allocateExpressProgressStatusLabel"
:error-text="allocateExpressProgressState.error"
@close="closeAllocateExpressProgress"
/>
<storage-allocate-form
v-model="storageDialogVisible"
v-model:allow-storage-location="storageForm.allowStorageLocation"
@ -357,6 +355,7 @@ import { useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
import TaskProgressDialog from '@/components/TaskProgressDialog.vue'
import { orderPendingOrder } from '@/api/order.pendingorder/orderpendingOrder'
import { orderExpectionOrder } from '@/api/order.expectionorder/orderexpectionorder'
import * as indexApi from '@/api/index/index'
@ -700,6 +699,19 @@ const buttonDisabledMap = computed<Record<string, boolean>>(() => ({
notSingleSelection: selectionRows.value.length !== 1
}))
const allocateExpressProgressStatusLabel = computed(() => {
const s = allocateExpressProgressState.status
const map: Record<string, string> = {
submitted: '已提交',
running: '处理中',
success: '已完成',
completed: '已完成',
failed: '失败',
error: '错误'
}
return map[s] || s || '—'
})
const buttonLabelMap = computed<Record<string, string>>(() => ({
detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情'
}))
@ -709,6 +721,9 @@ const {
dialogState: {
allocateDialogVisible,
allocateLoading,
allocateExpressProgressVisible,
allocateExpressProgressPolling,
allocateExpressProgressState,
storageDialogVisible,
storageDialogMode,
storagePendingOrderIds,
@ -775,6 +790,7 @@ const {
submitUpdateRemark,
submitBatchAsyncTask,
handleBatchQuickRecheckSuccess,
closeAllocateExpressProgress,
resetAllocateDialog,
resetStorageAllocateDialog,
resetUpdateOrderMetaDialog,

View File

@ -56,11 +56,6 @@
@refresh="loadData"
@selection-change="onSelectionChange"
>
<template #column-status="{ row }">
<el-tag :type="getTagType('status', row.status)" size="small">
{{ translateOrderField('status', row.status) }}
</el-tag>
</template>
<template #column-sync_status="{ row }">
<el-tag :type="getTagType('sync_status', row.sync_status)" size="small">

View File

@ -1,6 +1,7 @@
import { ElMessage, ElMessageBox } from 'element-plus'
import { computed, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { useTaskProgress } from '@/composables/useTaskProgress'
import {
PENDING_BATCH_ASYNC_TASK_ACTIONS,
PENDING_SYNC_TOOLBAR_API_ACTIONS,
@ -512,6 +513,35 @@ export function createPendingToolbarController(params: {
const storageAllocateFailedCount = ref(0)
const storageAllocateMessage = ref('')
// 分配快递号任务进度
const {
visible: allocateExpressProgressVisible,
polling: allocateExpressProgressPolling,
state: allocateExpressProgressState,
startPolling: startAllocateExpressPolling,
close: closeAllocateExpressProgress
} = useTaskProgress({
pollFn: async (taskId: string) => {
const res = await params.pendingApi.allocateExpressCodeTaskProgress({ task_id: taskId })
if (!res) return null
return {
status: res.status,
progress: res.progress,
message: res.message,
error: res.error,
result: res.result
}
},
onSuccess: async (_result) => {
ElMessage.success('快递号分配完成')
params.clearSelection()
await params.loadData()
},
onError: (error) => {
ElMessage.error(error || '分配快递号任务失败')
}
})
const updateOrderMetaDialogVisible = ref(false)
const updateOrderMetaDialogMode = ref<'express' | 'platform'>('express')
const updateOrderMetaOrderIds = ref<number[]>([])
@ -1122,15 +1152,23 @@ export function createPendingToolbarController(params: {
ElMessage.error(res?.message || '分配快递号失败')
return
}
const data = res.data || {}
const summary = data.summary
const successLen = Array.isArray(data.success) ? data.success.length : undefined
const failedLen = Array.isArray(data.failed) ? data.failed.length : undefined
let extra = ''
if (summary && typeof summary === 'object') extra = ` ${JSON.stringify(summary)}`
else if (successLen !== undefined || failedLen !== undefined) extra = ` 成功 ${successLen ?? '—'} 条,失败 ${failedLen ?? '—'} 条`
ElMessage.success((res.message || '分配请求已提交') + extra)
allocateDialogVisible.value = false
const taskId = res.task_id
if (taskId) {
// 异步任务模式:关闭对话框,显示进度窗口
allocateDialogVisible.value = false
startAllocateExpressPolling(taskId)
} else {
// 同步模式(兼容旧版)
const data = res.data || {}
const summary = data.summary
const successLen = Array.isArray(data.success) ? data.success.length : undefined
const failedLen = Array.isArray(data.failed) ? data.failed.length : undefined
let extra = ''
if (summary && typeof summary === 'object') extra = ` ${JSON.stringify(summary)}`
else if (successLen !== undefined || failedLen !== undefined) extra = ` 成功 ${successLen ?? '—'} 条,失败 ${failedLen ?? '—'} 条`
ElMessage.success((res.message || '分配请求已提交') + extra)
allocateDialogVisible.value = false
}
params.clearSelection()
await params.loadData()
} catch {
@ -1357,6 +1395,9 @@ export function createPendingToolbarController(params: {
dialogState: {
allocateDialogVisible,
allocateLoading,
allocateExpressProgressVisible,
allocateExpressProgressPolling,
allocateExpressProgressState,
storageDialogVisible,
storageDialogMode,
storagePendingOrderIds,
@ -1423,6 +1464,7 @@ export function createPendingToolbarController(params: {
submitUpdateRemark,
submitBatchAsyncTask,
handleBatchQuickRecheckSuccess,
closeAllocateExpressProgress,
resetAllocateDialog,
resetStorageAllocateDialog,
resetUpdateOrderMetaDialog,

View File

@ -61,12 +61,6 @@
@refresh="loadData"
@selection-change="onSelectionChange"
>
<template #column-status="{ row }">
<el-tag :type="getTagType('status', row.status)" size="small">
{{ translateOrderField('status', row.status) }}
</el-tag>
</template>
<template #column-is_urgency="{ row }">
<el-tag :type="getTagType('is_urgency', row.is_urgency)" size="small">
{{ translateOrderField('is_urgency', row.is_urgency) }}

View File

@ -285,7 +285,7 @@ import {
storeWarehouseConfirmSign,
storeWarehouseUnbind,
storeWarehouseRename
} from '@/api/storewarehouse.store/storeWarehouse'
} from '@/api/storeWarehouse.store/storeWarehouse'
import ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'