WEB/src/views/order/orderManagement/config/order-common-config.ts
2026-08-05 18:12:37 +08:00

2206 lines
95 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** 订单管理页面配置 */
export const ORDER_PAGE_CONFIG = {
/**
* 单页模式:开启后不显示标签切换区域,
* 直接展示默认页签(待处理订单)的内容
*/
singlePage: false
}
// 通用翻译映射
export const COMMON_TRANSLATIONS: Record<string, Record<string, string>> = {
is_urgency: {
'Y': '是',
'N': '否'
},
status: {
'pedding': '待审核',
'created': '已创建',
'cancel': '已取消',
'error': '错误',
'after-sales-error': '售后异常',
'finished': '已完成',
'cancelled': '已作废',
'archived': '已归档'
},
sync_status: {
'padding': '待同步',
'pedding': '待同步',
'pending': '待同步',
'fin': '已同步',
'error': '错误',
'none': '未同步'
},
order_status: {
'WAIT_AUDIT': '待审核',
'AUDITED': '已审核'
},
storage_status: {
'none': '未分配',
'padding': '分配中',
'fin': '已分配',
'error': '错误'
},
print_status: {
'none': '未打印',
'padding': '打印中',
'fin': '已打印'
},
pick_status: {
'none': '未拣货',
'padding': '拣货中',
'fin': '已拣货'
},
pack_status: {
'none': '未打包',
'padding': '打包中',
'fin': '已打包'
},
intercept_status: {
'none': '无',
'pending': '待拦截',
'success': '已拦截'
},
invoice_flag: {
'Y': '是',
'N': '否'
},
post_status: {
'padding': '分配中',
'fin': '已分配',
'timeout': '超时',
'error': '错误',
'none': '未分配'
},
outbound_status: {
'none': '未归档',
'padding': '归档中',
'pending': '归档中',
'pedding': '归档中',
'processing': '归档中',
'fin': '已归档',
'done': '已归档',
'finished': '已归档',
'archived': '已归档',
'error': '归档异常',
'failed': '归档失败'
},
order_type: {
'JYCK': '交易出库',
'JACK': '交易出库',
'TRANSFER': '调拨出库',
'RETURN': '退货出库',
'OTHER': '其他出库',
},
source_platform_code: {
'OFFLINE': '线下',
'PDD': '拼多多',
'JD': '京东',
'TAOBAO': '淘宝',
'TB': '淘宝'
},
/** 与 list 接口 raw 行字段一致(同 source_platform_code 展示映射) */
sys_platform_code: {
'OFFLINE': '线下',
'PDD': '拼多多',
'JD': '京东',
'TAOBAO': '淘宝',
'TB': '淘宝'
},
inspection_status: {
'none': '未审核',
'pending': '待审核',
'padding': '审核中',
'fin': '审核通过',
'reject': '审核驳回',
'error': '审核异常'
},
recheck_status: {
'none': '未复核',
'fin': '已复核',
'error': '错误'
},
lock_status: {
none: '未锁定',
warehouse: '仓库锁定'
},
claim_status: {
none: '未认领',
fin: '已认领'
},
sended_status: {
none: '未发货',
padding: '发货中',
fin: '已发货'
},
print_lock_status: {
none: '未锁定',
warehouse: '仓库锁定'
},
weight_type: {
'0': '常规',
'1': '轻货',
'2': '重货',
'3': '冷链'
},
create_channel: {
'QM': '奇门',
'API': 'API',
'IMPORT': '导入',
'MANUAL': '手动',
'PLATFORM': '平台'
}
}
// 通用标签类型映射
export const COMMON_TAG_TYPES: Record<string, Record<string, string>> = {
is_urgency: {
'Y': 'danger',
'N': 'info'
},
status: {
'pedding': 'warning',
'pending': 'warning',
'created': 'success',
'cancel': 'danger',
'cancelled': 'danger',
'error': 'danger',
'after-sales-error': 'danger',
'finished': 'success',
'archived': 'info'
},
sync_status: {
'padding': 'warning',
'pedding': 'warning',
'pending': 'warning',
'fin': 'success',
'error': 'danger',
'none': 'info'
},
order_status: {
'WAIT_AUDIT': 'warning',
'AUDITED': 'success'
},
storage_status: {
'none': 'info',
'padding': 'warning',
'pending': 'warning',
'fin': 'success',
'error': 'danger'
},
print_status: {
'none': 'info',
'padding': 'warning',
'pending': 'warning',
'fin': 'success'
},
pick_status: {
'none': 'info',
'padding': 'warning',
'pending': 'warning',
'fin': 'success'
},
pack_status: {
'none': 'info',
'padding': 'warning',
'pending': 'warning',
'fin': 'success'
},
post_status: {
'padding': 'warning',
'pending': 'warning',
'fin': 'success',
'timeout': 'danger',
'error': 'danger',
'none': 'info'
},
outbound_status: {
'none': 'info',
'padding': 'warning',
'pending': 'warning',
'pedding': 'warning',
'processing': 'warning',
'fin': 'success',
'done': 'success',
'finished': 'success',
'archived': 'success',
'error': 'danger',
'failed': 'danger'
},
inspection_status: {
'none': 'info',
'pending': 'warning',
'padding': 'warning',
'fin': 'success',
'reject': 'danger',
'error': 'danger'
},
recheck_status: {
'none': 'info',
'fin': 'success',
'error': 'danger'
},
lock_status: {
none: 'info',
warehouse: 'warning'
},
claim_status: {
none: 'info',
fin: 'success'
},
sended_status: {
none: 'info',
padding: 'warning',
fin: 'success'
},
print_lock_status: {
none: 'info',
warehouse: 'warning'
},
weight_type: {
'0': 'info',
'1': '',
'2': 'warning',
'3': 'danger'
}
}
export interface ToolbarButtonConfig {
key: string
label: string
dynamicLabelKey?: string
size?: '' | 'default' | 'small' | 'large'
type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger'
plain?: boolean
loadingKey?: string
disabledKey?: string
action: string
/** 下拉按钮:主按钮点击 action,菜单项使用 dropdownOptions[].action */
buttonType?: 'default' | 'dropdown'
dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }>
}
export interface ToolbarApiActionConfig {
action: string
apiMethod: string
payloadKey?: string
confirmText?: string
confirmType?: 'warning' | 'error' | 'info' | 'success'
successText: string
failText: string
}
export type PendingBatchAsyncTaskType = 'intercept' | 'unintercept' | 'lock' | 'unlock'
export interface PendingBatchAsyncTaskConfig {
taskType: PendingBatchAsyncTaskType
action: string
submitApiMethod: string
progressApiMethod: string
title: string
description: string
submitButtonText: string
resultCountLabel: string
resultIdsLabel: string
progressCountKey: string
progressIdsKey: string
failText: string
}
export const ORDER_TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
refresh: { key: 'refresh', label: '刷新', type: 'primary', size: 'small', action: 'loadData' },
export: {
key: 'export',
label: '导出',
size: 'small',
loadingKey: 'exportLoading',
action: 'handleExportWaybill',
buttonType: 'dropdown',
dropdownOptions: [
{ label: '不含明细', action: 'handleExportWaybill' },
{ label: '含明细', action: 'handleExportItem', divided: true }
]
},
exportSelection: {
key: 'exportSelection',
label: '导出选中',
size: 'small',
loadingKey: 'exportSelectionLoading',
disabledKey: 'hasNoSelection',
action: 'handleExportSelection'
},
deliveryExport: {
key: 'deliveryExport',
label: '导出',
size: 'small',
loadingKey: 'exportLoading',
action: 'handleExportWaybill',
buttonType: 'dropdown',
dropdownOptions: [
{ label: '导出选中', action: 'handleExportSelection' },
{ label: '导出全部', action: 'handleExportWaybill' }
]
},
columnConfig: { key: 'columnConfig', label: '字段设置', size: 'small', action: 'openColumnConfigPanel' },
toggleDetail: { key: 'toggleDetail', label: '显示详情', dynamicLabelKey: 'detailToggleLabel', size: 'small', action: 'toggleDetailVisible' },
reverseReview: { key: 'reverseReview', label: '反审回待审核', size: 'small', loadingKey: 'actionLoading', disabledKey: 'hasNoSelection', action: 'handleReverseReview' },
createOrder: { key: 'createOrder', label: '建单', size: 'small', type: 'primary', plain: true, action: 'openCreateOrderDialog' },
// markPendingOutbound: { key: 'markPendingOutbound', label: '标记待出库', size: 'small', type: 'warning', loadingKey: 'actionLoading', disabledKey: 'hasNoSelection', action: 'handleMarkPendingOutbound' },
allocateStorage: { key: 'allocateStorage', label: '分配储位', size: 'small', type: 'primary', plain: true, loadingKey: 'storageAllocateLoading', disabledKey: 'hasNoSelection', action: 'openStorageAllocateDialog' },
cancelAllocateStorage: { key: 'cancelAllocateStorage', label: '取消分配储位', size: 'small', type: 'danger', plain: true, loadingKey: 'storageAllocateLoading', disabledKey: 'hasNoSelection', action: 'openStorageCancelDialog' },
waveSingleFetchByIds: {
key: 'waveSingleFetchByIds',
label: '抓取散单',
size: 'small',
type: 'primary',
plain: true,
loadingKey: 'waveSingleFetchLoading',
disabledKey: 'hasNoSelection',
action: 'handleWaveSingleFetchByIds'
},
allocateExpress: { key: 'allocateExpress', label: '分配快递号', size: 'small', type: 'success', loadingKey: 'allocateLoading', disabledKey: 'hasNoSelection', action: 'openAllocateExpressDialog' },
batchQuickRecheck: {
key: 'batchQuickRecheck',
label: '批量发货',
size: 'small',
type: 'success',
plain: true,
disabledKey: 'hasNoSelection',
action: 'openBatchQuickRecheckDialog'
},
manualWaybill: { key: 'manualWaybill', label: '录入运单号', size: 'small', type: 'primary', plain: true, loadingKey: 'manualWaybillLoading', disabledKey: 'notSingleSelection', action: 'openManualWaybillDialog' },
updateExpress: { key: 'updateExpress', label: '修改快递', size: 'small', type: 'warning', plain: true, loadingKey: 'updateOrderMetaLoading', disabledKey: 'hasNoSelection', action: 'openUpdateOrderExpressDialog' },
updatePlatform: { key: 'updatePlatform', label: '修改平台', size: 'small', type: 'info', plain: true, loadingKey: 'updateOrderMetaLoading', disabledKey: 'hasNoSelection', action: 'openUpdateOrderPlatformDialog' },
updateAddress: { key: 'updateAddress', label: '修改地址', size: 'small', type: 'warning', plain: true, loadingKey: 'updateAddressLoading', disabledKey: 'hasNoSelection', action: 'openUpdateAddressDialog' },
updateRemark: { key: 'updateRemark', label: '修改留言', size: 'small', type: 'warning', plain: true, loadingKey: 'updateRemarkLoading', disabledKey: 'hasNoSelection', action: 'openUpdateRemarkDialog' },
cloneOrder: { key: 'cloneOrder', label: '克隆订单', size: 'small', type: 'warning', plain: true, loadingKey: 'cloneOrderLoading', disabledKey: 'notSingleSelection', action: 'openCloneOrderDialog' },
syncOrderIds: { key: 'syncOrderIds', label: '同步订单', size: 'small', type: 'primary', plain: true, loadingKey: 'syncOrderIdsLoading', disabledKey: 'hasNoSelection', action: 'openSyncOrderIdsDialog' },
cancelOrder: { key: 'cancelOrder', label: '取消订单', size: 'small', type: 'danger', loadingKey: 'actionLoading', disabledKey: 'hasNoSelection', action: 'handleCancelOrder' },
batchIntercept: { key: 'batchIntercept', label: '批量拦截', size: 'small', type: 'danger', plain: true, loadingKey: 'batchAsyncTaskLoading', disabledKey: 'hasNoSelection', action: 'handleBatchIntercept' },
batchUnintercept: { key: 'batchUnintercept', label: '解除拦截', size: 'small', type: 'warning', plain: true, loadingKey: 'batchAsyncTaskLoading', disabledKey: 'hasNoSelection', action: 'handleBatchUnintercept' },
batchLock: { key: 'batchLock', label: '批量锁定', size: 'small', type: 'warning', plain: true, loadingKey: 'batchAsyncTaskLoading', disabledKey: 'hasNoSelection', action: 'handleBatchLock' },
batchUnlock: { key: 'batchUnlock', label: '批量解锁', size: 'small', type: 'primary', plain: true, loadingKey: 'batchAsyncTaskLoading', disabledKey: 'hasNoSelection', action: 'handleBatchUnlock' },
batchPrint: { key: 'batchPrint', label: '批量打印', size: 'small', type: 'primary', loadingKey: 'batchPrintLoading', disabledKey: 'hasNoSelection', action: 'handleBatchPrint' },
batchReview: { key: 'batchReview', label: '批量审核通过', size: 'small', type: 'success', loadingKey: 'reviewSubmitting', disabledKey: 'hasNoSelection', action: 'handleBatchReview' },
manualOutboundMigrate: {
key: 'manualOutboundMigrate',
label: '手动出库迁移',
size: 'small',
type: 'warning',
loadingKey: 'manualLoading',
disabledKey: 'hasNoOutboundTarget',
action: 'handleToolbarManualOutbound'
},
resolveException: {
key: 'resolveException',
label: '处理异常订单',
size: 'small',
type: 'warning',
loadingKey: 'resolveExceptionLoading',
disabledKey: 'hasNoSelection',
action: 'openResolveExceptionDialog'
},
allocateSubOrderNumber: {
key: 'allocateSubOrderNumber',
label: '分配子单号',
size: 'small',
type: 'primary',
plain: true,
loadingKey: 'allocateSubOrderNumberLoading',
disabledKey: 'notSingleSelection',
action: 'openAllocateSubOrderNumberDialog'
},
subWaybillPrint: {
key: 'subWaybillPrint',
label: '子单号打印',
size: 'small',
type: 'success',
plain: true,
loadingKey: 'subWaybillPrintLoading',
disabledKey: 'hasNoSelection',
action: 'handleSubWaybillPrint'
}
}
export function pickToolbarButtons(keys: string[]) {
return keys
.map((key) => ORDER_TOOLBAR_BUTTONS[key])
.filter((button): button is ToolbarButtonConfig => Boolean(button))
}
/** 取消订单(待处理 / 待审核等页面共用,接口 order.pendingOrder.cancelOrder) */
export const ORDER_CANCEL_TOOLBAR_API_ACTION: ToolbarApiActionConfig = {
action: 'handleCancelOrder',
apiMethod: 'cancelOrder',
payloadKey: 'ids',
confirmText: '确定取消选中的 {count} 条订单吗?',
confirmType: 'error',
successText: '取消订单成功',
failText: '取消订单失败'
}
/** 同步批量操作:提交后立即返回结果 */
export const PENDING_SYNC_TOOLBAR_API_ACTIONS: ToolbarApiActionConfig[] = [
{
action: 'handleReverseReview',
apiMethod: 'reverseReviewOrder',
payloadKey: 'ids',
confirmText: '确定将选中的 {count} 条订单反审回待审核吗?',
confirmType: 'warning',
successText: '反审成功',
failText: '反审失败'
},
{
action: 'handleMarkPendingOutbound',
apiMethod: 'markPendingOutboundOrder',
payloadKey: 'ids',
confirmText: '确定将选中的 {count} 条订单标记为待出库吗?',
confirmType: 'warning',
successText: '标记待出库成功',
failText: '标记待出库失败'
},
ORDER_CANCEL_TOOLBAR_API_ACTION
]
/** 异步批量任务:提交后返回 task_id,需轮询 TaskProgress */
export const PENDING_BATCH_ASYNC_TASK_ACTIONS: PendingBatchAsyncTaskConfig[] = [
{
taskType: 'intercept',
action: 'handleBatchIntercept',
submitApiMethod: 'batchIntercept',
progressApiMethod: 'batchInterceptTaskProgress',
title: '批量拦截',
description: '提交后将异步更新订单 intercept_status 为 requested,可在下方查看任务进度。',
submitButtonText: '提交拦截',
resultCountLabel: '已拦截',
resultIdsLabel: '已拦截订单ID',
progressCountKey: 'intercepted_order_count',
progressIdsKey: 'intercepted_order_ids',
failText: '批量拦截失败'
},
{
taskType: 'unintercept',
action: 'handleBatchUnintercept',
submitApiMethod: 'batchUnintercept',
progressApiMethod: 'batchUninterceptTaskProgress',
title: '批量解除拦截',
description: '提交后将异步更新订单 intercept_status 为 none,可在下方查看任务进度。',
submitButtonText: '提交解除拦截',
resultCountLabel: '已解除拦截',
resultIdsLabel: '已解除拦截订单ID',
progressCountKey: 'unintercepted_order_count',
progressIdsKey: 'unintercepted_order_ids',
failText: '批量解除拦截失败'
},
{
taskType: 'lock',
action: 'handleBatchLock',
submitApiMethod: 'batchLock',
progressApiMethod: 'batchLockTaskProgress',
title: '批量锁定',
description: '提交后将异步更新订单 lock_status 为 warehouse,可在下方查看任务进度。',
submitButtonText: '提交锁定',
resultCountLabel: '已锁定',
resultIdsLabel: '已锁定订单ID',
progressCountKey: 'locked_order_count',
progressIdsKey: 'locked_order_ids',
failText: '批量锁定失败'
},
{
taskType: 'unlock',
action: 'handleBatchUnlock',
submitApiMethod: 'batchUnlock',
progressApiMethod: 'batchUnlockTaskProgress',
title: '批量解锁',
description: '提交后将异步更新订单 lock_status 为 none,可在下方查看任务进度。',
submitButtonText: '提交解锁',
resultCountLabel: '已解锁',
resultIdsLabel: '已解锁订单ID',
progressCountKey: 'unlocked_order_count',
progressIdsKey: 'unlocked_order_ids',
failText: '批量解锁失败'
}
]
/** @deprecated 请使用 PENDING_SYNC_TOOLBAR_API_ACTIONS */
export const PENDING_TOOLBAR_API_ACTIONS = PENDING_SYNC_TOOLBAR_API_ACTIONS
export const REVIEW_TOOLBAR_API_ACTIONS: ToolbarApiActionConfig[] = [
{
action: 'handleBatchReview',
apiMethod: 'reviewOrder',
payloadKey: 'ids',
confirmText: '确定审核通过选中的 {count} 条订单吗?',
confirmType: 'warning',
successText: '审核成功',
failText: '订单审核失败,请稍后重试'
}
]
/** 待审核页复用待处理订单接口的同步操作 */
export const REVIEW_ORDER_SHARED_API_ACTIONS: ToolbarApiActionConfig[] = [
ORDER_CANCEL_TOOLBAR_API_ACTION
]
function normalizeUrgencyValue(value: any): string | undefined {
if (value === true || value === 1 || value === '1') return 'Y'
if (value === false || value === 0 || value === '0') return 'N'
const s = String(value).trim().toUpperCase()
if (s === 'Y' || s === 'YES' || s === 'TRUE') return 'Y'
if (s === 'N' || s === 'NO' || s === 'FALSE') return 'N'
return undefined
}
function normalizeSyncStatusKey(value: any): string {
return String(value ?? '').trim()
}
function normalizeOrderTypeKey(value: any): string {
return String(value ?? '').trim().toUpperCase()
}
function lookupTranslationTable(table: Record<string, string> | undefined, field: string, value: any): string | undefined {
if (!table) return undefined
if (table[value] !== undefined) return table[value]
if (field === 'sync_status') {
const k = normalizeSyncStatusKey(value)
if (k && table[k] !== undefined) return table[k]
const lower = k.toLowerCase()
const hit = Object.keys(table).find((key) => key.toLowerCase() === lower)
if (hit) return table[hit]
}
if (field === 'order_type') {
const k = normalizeOrderTypeKey(value)
if (k && table[k] !== undefined) return table[k]
}
return undefined
}
export function getTagType(field: string, value: any) {
if (field === 'is_urgency') {
const y = normalizeUrgencyValue(value)
const urgencyTags = COMMON_TAG_TYPES['is_urgency']
if (y && urgencyTags && urgencyTags[y] !== undefined) {
return urgencyTags[y]
}
}
const map = COMMON_TAG_TYPES[field]
if (map) {
if (map[value] !== undefined) return map[value]
if (field === 'sync_status') {
const k = normalizeSyncStatusKey(value)
if (k && map[k] !== undefined) return map[k]
const lower = k.toLowerCase()
const hit = Object.keys(map).find((key) => key.toLowerCase() === lower)
if (hit) return map[hit]
}
if (field === 'order_type') {
const k = normalizeOrderTypeKey(value)
if (k && map[k] !== undefined) return map[k]
}
}
return 'info'
}
export function translateOrderField(field: string, value: any) {
if (value === null || value === undefined || value === '') {
return '-'
}
if (field === 'is_urgency') {
const y = normalizeUrgencyValue(value)
const urgencyText = COMMON_TRANSLATIONS['is_urgency']
if (y && urgencyText && urgencyText[y] !== undefined) {
return urgencyText[y]
}
}
const table = COMMON_TRANSLATIONS[field]
const translated = lookupTranslationTable(table, field, value)
if (translated !== undefined) return translated
return value
}
const INTERCEPT_STATUS_MAP: Record<string, string> = {
none: '无',
pending: '待拦截',
success: '已拦截',
requesting: '请求拦截中',
requested: '已请求拦截',
intercepting: '拦截中',
intercepted_in_transit: '在途拦截成功',
intercepted_at_warehouse: '仓库拦截成功',
returning: '退回中',
returned: '已退回',
delivered_by_mistake: '已误派送',
timeout: '超时',
cancelled: '已取消',
failed: '失败',
exception: '异常'
}
export function translateInterceptStatus(value: any): string {
const normalized = String(value ?? 'none').trim().toLowerCase()
if (!normalized || normalized === 'none') {
return INTERCEPT_STATUS_MAP.none ?? '无'
}
return INTERCEPT_STATUS_MAP[normalized] ?? INTERCEPT_STATUS_MAP[String(value).trim()] ?? String(value)
}
export function getInterceptStatusTagType(value: unknown): string {
const normalized = String(value ?? 'none').trim().toLowerCase()
if (!normalized || normalized === 'none') return 'info'
if (['failed', 'exception', 'timeout', 'delivered_by_mistake'].includes(normalized)) return 'danger'
if (['success', 'intercepted_in_transit', 'intercepted_at_warehouse', 'returned'].includes(normalized)) {
return 'success'
}
if (['pending', 'requesting', 'requested', 'intercepting', 'returning'].includes(normalized)) {
return 'warning'
}
return 'danger'
}
function pad2(value: number) {
return String(value).padStart(2, '0')
}
export function formatOrderTime(value: unknown) {
if (value === undefined || value === null || value === '') return '-'
if (value instanceof Date) {
if (Number.isNaN(value.getTime())) return '-'
return `${value.getFullYear()}-${pad2(value.getMonth() + 1)}-${pad2(value.getDate())} ${pad2(value.getHours())}:${pad2(value.getMinutes())}:${pad2(value.getSeconds())}`
}
if (typeof value === 'number' || /^\d+$/.test(String(value))) {
const raw = Number(value)
if (!Number.isFinite(raw)) return String(value)
const milliseconds = raw < 1000000000000 ? raw * 1000 : raw
const date = new Date(milliseconds)
if (Number.isNaN(date.getTime())) return String(value)
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())}`
}
const text = String(value).trim()
if (!text) return '-'
const date = new Date(text)
if (Number.isNaN(date.getTime())) return text
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())}`
}
function orderTimeFormatter(_row: any, _column: any, cellValue: unknown) {
return formatOrderTime(cellValue)
}
function waybillCodesFormatter(_row: any, _column: any, cellValue: unknown) {
if (cellValue === undefined || cellValue === null || cellValue === '') return '-'
const normalizeList = (list: any[]) =>
list
.map((item) => String(item ?? '').trim())
.filter((item) => item.length > 0)
.join(', ')
if (Array.isArray(cellValue)) {
const text = normalizeList(cellValue)
return text || '-'
}
const text = String(cellValue).trim()
if (!text) return '-'
// 兼容后端返回 JSON 字符串:["776..."] / ["A","B"]
if (text.startsWith('[') && text.endsWith(']')) {
try {
const parsed = JSON.parse(text)
if (Array.isArray(parsed)) {
const normalized = normalizeList(parsed)
return normalized || '-'
}
} catch {
// 非法 JSON 时回退原文
}
}
return text
}
function orderTypeFormatter(_row: any, _column: any, cellValue: unknown) {
return translateOrderField('order_type', cellValue)
}
function weightTypeFormatter(_row: any, _column: any, cellValue: unknown) {
return translateOrderField('weight_type', cellValue)
}
/** 订单详情 descriptions 中需格式化为本地时间的字段(与列表 formatter 一致) */
export const ORDER_DETAIL_TIME_FIELDS = new Set([
'place_order_time',
'pay_time',
'delivery_time',
'create_at',
'created_at',
'updated_at',
'delete_at',
'operate_time',
'recheck_time'
])
export type OrderDetailFieldConfig = {
prop: string
label: string
span?: number
tag?: boolean
amount?: boolean
time?: boolean
waybill?: boolean
multiline?: boolean
}
export type OrderDetailSectionConfig = {
title: string
column?: number
fields: OrderDetailFieldConfig[]
}
/** 订单明细显示全部:对齐 order.pendingOrder.detail data.detail 字段 */
export const orderDetailFullSections: OrderDetailSectionConfig[] = [
{
title: '基础信息',
column: 4,
fields: [
{ prop: 'id', label: '订单ID' },
{ prop: 'delivery_order_code', label: '外部订单号' },
{ prop: 'pre_delivery_order_code', label: '前置单号' },
{ prop: 'pre_delivery_order_id', label: '前置单ID' },
{ prop: 'order_type', label: '订单类型' },
{ prop: 'warehouse_code', label: '仓库编码' },
{ prop: 'create_channel', label: '来源' },
{ prop: 'order_flag', label: '订单标记', span: 4, multiline: true },
{ prop: 'sys_platform_name', label: '平台编码' },
{ prop: 'source_platform_name', label: '来源平台名' },
{ prop: 'source_platform_code', label: '来源平台编码', tag: true },
{ prop: 'source_order_codes', label: '平台交易单号' },
{ prop: 'shop_nick', label: '店铺名称' },
{ prop: 'buyer_nick', label: '买家昵称' },
{ prop: 'seller_nick', label: '卖家昵称' },
{ prop: 'store_id', label: '货主ID' },
{ prop: 'warehouse_id', label: '仓库ID' },
{ prop: 'from_key', label: '来源键' },
{ prop: 'service_code', label: '服务编码' },
{ prop: 'oaid', label: 'OAID' },
{ prop: 'is_urgency', label: '是否紧急', tag: true },
{ prop: 'invoice_flag', label: '发票标记', tag: true },
{ prop: 'pay_no', label: '支付单号' },
{ prop: 'remark', label: '备注', span: 4, multiline: true },
{ prop: 'buyer_message', label: '买家留言', span: 2, multiline: true },
{ prop: 'seller_message', label: '卖家留言', span: 2, multiline: true },
{ prop: 'extend_props', label: '扩展属性', span: 4, multiline: true }
]
},
{
title: '流程与状态',
column: 4,
fields: [
{ prop: 'status', label: '订单状态', tag: true },
{ prop: 'step', label: '流程步骤' },
{ prop: 'sync_status', label: '同步状态', tag: true },
{ prop: 'inspection_status', label: '审核状态', tag: true },
{ prop: 'recheck_status', label: '复核状态', tag: true },
{ prop: 'outbound_status', label: '数据归档', tag: true },
{ prop: 'storage_status', label: '储位状态', tag: true },
{ prop: 'post_status', label: '快递状态', tag: true },
{ prop: 'pick_status', label: '拣货状态', tag: true },
{ prop: 'pack_status', label: '打包状态', tag: true },
{ prop: 'print_status', label: '打印状态', tag: true },
{ prop: 'sended_status', label: '发货状态', tag: true },
{ prop: 'claim_status', label: '认领状态', tag: true },
{ prop: 'lock_status', label: '锁定状态', tag: true },
{ prop: 'intercept_status', label: '拦截状态', tag: true },
{ prop: 'print_lock_status', label: '打印锁定', tag: true },
{ prop: 'wave_no', label: '波次号' },
{ prop: 'wave_id', label: '波次ID' },
{ prop: 'wave_strategy_version', label: '波次策略版本' },
{ prop: 'wave_scan_result', label: '波次扫描结果' },
{ prop: 'basket_number', label: '篮号' }
]
},
{
title: '收货与物流',
column: 3,
fields: [
{ prop: 'name', label: '收件人' },
{ prop: 'mobile', label: '电话' },
{ prop: 'tel', label: '固定电话' },
{ prop: 'email', label: '邮箱' },
{ prop: 'country_code', label: '国家编码' },
{ prop: 'province', label: '省份' },
{ prop: 'city', label: '城市' },
{ prop: 'area', label: '区/县' },
{ prop: 'town', label: '镇/街道' },
{ prop: 'zip_code', label: '邮编' },
{ prop: 'detail_address', label: '详细地址', span: 3, multiline: true },
{ prop: 'id_type', label: '证件类型' },
{ prop: 'id_number', label: '证件号码' },
{ prop: 'logistics_name', label: '快递' },
{ prop: 'logistics_code', label: '快递编码' },
{ prop: 'sys_logistics_name', label: '系统快递名称' },
{ prop: 'sys_logistics_code', label: '系统快递编码' },
{ prop: 'express_code', label: '快递单号' },
{ prop: 'logistics_area_code', label: '物流区域编码' },
{ prop: 'waybill_codes', label: '运单号', span: 3, waybill: true, multiline: true },
{ prop: 'delivery_type', label: '发货服务类型' },
{ prop: 'weight_type', label: '重量类型' }
]
},
{
title: '金额汇总',
column: 4,
fields: [
{ prop: 'total_amount', label: '订单总金额', amount: true },
{ prop: 'item_amount', label: '商品金额', amount: true },
{ prop: 'discount_amount', label: '折扣金额', amount: true },
{ prop: 'freight', label: '运费', amount: true },
{ prop: 'ar_amount', label: '应收金额', amount: true },
{ prop: 'got_amount', label: '实收金额', amount: true },
{ prop: 'service_fee', label: '服务费', amount: true },
{ prop: 'items', label: '商品明细摘要', span: 4 },
{ prop: 'items_count', label: '商品种类' },
{ prop: 'items_total', label: '商品总数' },
{ prop: 'items_weight', label: '商品重量(g)' },
{ prop: 'items_hash', label: '商品哈希', span: 2 },
{ prop: 'items_crc', label: '商品CRC' }
]
},
{
title: '时间信息',
column: 4,
fields: [
{ prop: 'place_order_time', label: '下单时间', time: true },
{ prop: 'pay_time', label: '支付时间', time: true },
{ prop: 'delivery_time', label: '配送时间', time: true },
{ prop: 'create_at', label: '创建时间', time: true },
{ prop: 'updated_at', label: '更新时间', time: true },
{ prop: 'delete_at', label: '删除时间', time: true },
{ prop: 'recheck_time', label: '复核时间', time: true },
{ prop: 'operator_name', label: '操作人' },
{ prop: 'operate_time', label: '操作时间', time: true }
]
}
]
/** 订单明细精简显示:常用字段(默认) */
export const orderDetailCompactSections: OrderDetailSectionConfig[] = [
{
title: '基础信息',
column: 3,
fields: [
{ prop: 'delivery_order_code', label: '外部订单号' },
{ prop: 'order_type', label: '订单类型' },
{ prop: 'sys_platform_name', label: '平台' },
{ prop: 'create_channel', label: '来源' },
{ prop: 'shop_nick', label: '店铺名称' },
{ prop: 'buyer_nick', label: '买家昵称' },
{ prop: 'status', label: '订单状态', tag: true },
{ prop: 'source_order_codes', label: '平台交易单号' },
{ prop: 'is_urgency', label: '是否紧急', tag: true },
{ prop: 'seller_nick', label: '卖家昵称' },
{ prop: 'order_flag', label: '订单标记', span: 3, multiline: true }
]
},
{
title: '流程与状态',
column: 3,
fields: [
{ prop: 'sync_status', label: '同步状态', tag: true },
{ prop: 'inspection_status', label: '审核状态', tag: true },
{ prop: 'recheck_status', label: '复核状态', tag: true },
{ prop: 'storage_status', label: '储位状态', tag: true },
{ prop: 'post_status', label: '快递状态', tag: true },
{ prop: 'outbound_status', label: '数据归档', tag: true },
{ prop: 'wave_no', label: '波次号' },
{ prop: 'pick_status', label: '拣货状态', tag: true },
{ prop: 'pack_status', label: '打包状态', tag: true },
{ prop: 'print_status', label: '打印状态', tag: true },
{ prop: 'intercept_status', label: '拦截状态', tag: true },
{ prop: 'lock_status', label: '锁定状态', tag: true }
]
},
{
title: '收货与物流',
column: 3,
fields: [
{ prop: 'name', label: '收件人' },
{ prop: 'mobile', label: '电话' },
{ prop: 'province', label: '省份' },
{ prop: 'city', label: '城市' },
{ prop: 'area', label: '区/县' },
{ prop: 'logistics_name', label: '快递' },
{ prop: 'detail_address', label: '详细地址', span: 3, multiline: true },
{ prop: 'waybill_codes', label: '运单号', span: 3, waybill: true, multiline: true }
]
},
{
title: '金额汇总',
column: 3,
fields: [
{ prop: 'total_amount', label: '订单总金额', amount: true },
{ prop: 'item_amount', label: '商品金额', amount: true },
{ prop: 'freight', label: '运费', amount: true },
{ prop: 'items_count', label: '商品种类' },
{ prop: 'items_total', label: '商品总数' },
{ prop: 'items_weight', label: '商品重量(g)' }
]
},
{
title: '时间信息',
column: 3,
fields: [
{ prop: 'place_order_time', label: '下单时间', time: true },
{ prop: 'pay_time', label: '支付时间', time: true },
{ prop: 'delivery_time', label: '配送时间', time: true },
{ prop: 'create_at', label: '创建时间', time: true },
{ prop: 'updated_at', label: '更新时间', time: true },
{ prop: 'recheck_time', label: '复核时间', time: true }
]
}
]
export type OrderItemColumnConfig = {
prop: string
label: string
width?: number | string
minWidth?: number | string
align?: 'left' | 'center' | 'right'
showOverflowTooltip?: boolean
amount?: boolean
time?: boolean
image?: boolean
}
/** 商品明细精简显示:常用字段(默认) */
export const orderItemCompactColumns: OrderItemColumnConfig[] = [
{ prop: 'images', label: '图片', width: 80, align: 'center', image: true },
{ prop: 'item_code', label: '商品编码', minWidth: 140, showOverflowTooltip: true },
{ prop: 'item_name', label: '商品名称', minWidth: 180, showOverflowTooltip: true },
{ prop: 'order_line_no', label: '行号', width: 80, align: 'center' },
{ prop: 'plan_qty', label: '计划数量', width: 100, align: 'center' },
{ prop: 'sku_property', label: '规格', width: 120, showOverflowTooltip: true },
{ prop: 'stock_unit', label: '单位', width: 80, align: 'center' },
{ prop: 'stock_id', label: 'SKU', width: 100, align: 'center' },
{ prop: 'store_id', label: '货主ID', width: 100, align: 'center' },
]
/** 商品明细显示全部:对齐 data.json items 返回字段 */
export const orderItemFullColumns: OrderItemColumnConfig[] = [
{ prop: 'images', label: '图片', width: 80, align: 'center', image: true },
{ prop: 'id', label: '明细ID', width: 90, align: 'center' },
{ prop: 'order_id', label: '订单ID', width: 90, align: 'center' },
{ prop: 'order_line_no', label: '行号', width: 80, align: 'center' },
{ prop: 'item_code', label: '商品编码', minWidth: 140, showOverflowTooltip: true },
{ prop: 'item_name', label: '商品名称', minWidth: 180, showOverflowTooltip: true },
{ prop: 'stock_id', label: 'SKU', width: 100, align: 'center' },
{ prop: 'plan_qty', label: '计划数量', width: 100, align: 'center' },
{ prop: 'quantity', label: '库存数量', width: 100, align: 'right' },
{ prop: 'locked_quantity', label: '锁定数量', width: 100, align: 'right' },
{ prop: 'sku_property', label: '规格', minWidth: 140, showOverflowTooltip: true },
{ prop: 'stock_unit', label: '单位', width: 80, align: 'center' },
{ prop: 'is_batch_mgmt', label: '批次管理', width: 100, align: 'center' },
{ prop: 'is_shelf_life_mgmt', label: '效期管理', width: 100, align: 'center' },
{ prop: 'packing_requirements', label: '包装要求', minWidth: 120, showOverflowTooltip: true },
{ prop: 'store_id', label: '货主ID', width: 100, align: 'center' },
]
/**
* 仅列表基础能力:刷新 / 导出 / 字段设置 / 详情开关。
*/
export const simpleListToolbarButtonKeys = [
'refresh',
'export',
'exportSelection',
'columnConfig',
'toggleDetail'
]
export const simpleListToolbarButtons = pickToolbarButtons(simpleListToolbarButtonKeys)
/** ScanBox 筛选字段分组:基础信息 + 工作流程(工作流程字段以 label 为分组名) */
export const SCAN_BASIC_INFO_GROUP = '基础信息'
/** 为 ScanBox 基础信息字段附加分组标签 */
export function scanBasicField(field: Record<string, any>) {
return { ...field, group: SCAN_BASIC_INFO_GROUP }
}
/** 为 ScanBox 工作流程字段附加分组标签(按字段 label 独立分组) */
export function scanWorkflowField(field: Record<string, any>) {
return { ...field, group: field.label }
}
/** 通用下拉选项 */
export const isUrgencyFilterOptions = [
{ label: '是', value: 'Y' },
{ label: '否', value: 'N' },
]
export const buyerMessageHasFilterOptions = [
{ label: '有留言', value: 'has' },
{ label: '无留言', value: 'none' },
]
export const syncStatusFilterOptionsBasic = [
{ label: '待同步', value: 'padding' },
{ label: '已同步', value: 'fin' },
{ label: '错误', value: 'error' },
]
export const syncStatusFilterOptionsExtended = [
{ label: '待同步', value: 'padding' },
// { label: '同步中', value: 'pending' },
{ label: '已同步', value: 'fin' },
{ label: '未同步', value: 'none' },
]
export const storageStatusFilterOptions = [
{ label: '未分配', value: 'none' },
// { label: '分配中', value: 'padding' },
{ label: '已分配', value: 'fin' },
{ label: '错误', value: 'error' },
]
export const postStatusFilterOptions = [
{ label: '未分配', value: 'none' },
// { label: '分配中', value: 'padding' },
{ label: '已分配', value: 'fin' },
{ label: '错误', value: 'error' },
]
export const postStatusFilterOptionsExtended = [
...postStatusFilterOptions,
{ label: '超时', value: 'timeout' },
]
export const pickStatusFilterOptions = [
{ label: '未拣货', value: 'none' },
// { label: '拣货中', value: 'padding' },
{ label: '已拣货', value: 'fin' },
{ label: '错误', value: 'error' },
]
export const packStatusFilterOptions = [
{ label: '未打包', value: 'none' },
// { label: '打包中', value: 'padding' },
{ label: '已打包', value: 'fin' },
{ label: '错误', value: 'error' },
]
export const printStatusFilterOptions = [
{ label: '未打印', value: 'none' },
{ label: '已打印', value: 'fin' },
{ label: '错误', value: 'error' },
]
export const outboundStatusFilterOptions = [
{ label: '未归档', value: 'none' },
{ label: '归档中', value: 'padding' },
{ label: '已归档', value: 'fin' },
]
export const interceptStatusFilterOptions = [
{ label: '无', value: 'none' },
{ label: '待拦截', value: 'pending' },
{ label: '已拦截', value: 'success' },
]
export const pendingOrderStatusFilterOptions = [
{ label: '待审核', value: 'pedding' },
{ label: '已创建', value: 'created' },
{ label: '已取消', value: 'cancel' },
{ label: '售后异常', value: 'after-sales-error' },
{ label: '已完成', value: 'finished' },
{ label: '已作废', value: 'cancelled' },
{ label: '已归档', value: 'archived' },
]
/** 待审核与待处理等页面不共用订单状态筛选项 */
export const reviewOrderStatusFilterOptions = [
{ label: '待审核', value: 'pedding' },
{ label: '已创建', value: 'created' },
]
export const exceptionOrderStatusFilterOptions = [
{ label: '待审核', value: 'pedding' },
{ label: '已创建', value: 'created' },
{ label: '已作废', value: 'cancelled' },
{ label: '已归档', value: 'archived' },
]
export const archiveOrderStatusFilterOptions = [
{ label: '待审核', value: 'pedding' },
{ label: '已创建', value: 'created' },
{ label: '已完成', value: 'finished' },
{ label: '已作废', value: 'cancelled' },
{ label: '已归档', value: 'archived' },
]
export const recheckStatusFilterOptions = [
{ label: '未复核', value: 'none' },
{ label: '已复核', value: 'fin' },
{ label: '错误', value: 'error' },
]
export const inspectionStatusFilterOptions = [
{ label: '未审核', value: 'none' },
{ label: '待审核', value: 'pending' },
{ label: '审核中', value: 'padding' },
{ label: '审核通过', value: 'fin' },
{ label: '审核驳回', value: 'reject' },
{ label: '审核异常', value: 'error' },
]
export const claimStatusFilterOptions = [
{ label: '未认领', value: 'none' },
{ label: '已认领', value: 'fin' },
]
export const lockStatusFilterOptions = [
{ label: '未锁定', value: 'none' },
{ label: '仓库锁定', value: 'warehouse' },
]
/** 单号类字段:支持 IN(逗号分隔)批量查询 */
export const ORDER_BULK_SEARCH_OPERATORS = ['eq', 'ne', 'like', 'notlike', 'contains', 'in', 'notin', 'startswith', 'endswith']
/** 可复用 ScanBox 字段片段(基础信息) */
export const storeScanField = scanBasicField({ label: '货主', value: 'store_id', type: 'select', multiple: true, options: [] })
export const orderIdScanField = scanBasicField({ label: '订单ID', value: 'id', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
export const orderFlagScanField = scanBasicField({ label: '订单标记', value: 'order_flag', type: 'text', operators: ['like', 'notlike'], defaultOperator: 'like' })
export const waveNoScanField = scanBasicField({ label: '波次号', value: 'wave_no', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
export const deliveryOrderCodeScanField = scanBasicField({ label: '发货单号', value: 'delivery_order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
/** ScanBox:外部订单号(待处理订单专用,模糊匹配发货单号,替代表格右上角快捷搜索) */
export const pendingOrderQuickSearchScanField = scanBasicField({ label: '外部订单号', value: 'delivery_order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'like' })
/** ScanBox:搜索订单号(模糊匹配发货单号,替代表格右上角快捷搜索) */
export const orderQuickSearchScanField = scanBasicField({ label: '搜索订单号', value: 'delivery_order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'like' })
export const sourceOrderCodesScanField = scanBasicField({ label: '平台交易单号', value: 'source_order_codes', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
export const pendingOrderCodeScanField = scanBasicField({ label: '发货单号', value: 'order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
export const exceptionOrderCodeScanField = scanBasicField({ label: '发货单号', value: 'order_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
export const shopNickScanField = scanBasicField({ label: '店铺名称', value: 'shop_nick', type: 'text' })
export const sysPlatformNameScanField = scanBasicField({ label: '平台', value: 'sys_platform_name', type: 'select', options: [] })
export const sysPlatformCodeScanField = scanBasicField({ label: '平台编码', value: 'sys_platform_name', type: 'select', options: [] })
export const buyerNickScanField = scanBasicField({ label: '买家昵称', value: 'buyer_nick', type: 'text' })
export const receiverNameScanField = scanBasicField({ label: '收件人', value: 'name', type: 'text' })
export const receiverMobileScanField = scanBasicField({ label: '电话', value: 'mobile', type: 'text' })
export const receiverProvinceScanField = scanBasicField({ label: '省份', value: 'province', type: 'text' })
export const receiverCityScanField = scanBasicField({ label: '城市', value: 'city', type: 'text' })
export const receiverAreaScanField = scanBasicField({ label: '区县', value: 'area', type: 'text' })
export const logisticsNameScanField = scanBasicField({ label: '物流公司', value: 'logistics_name', type: 'select', options: [] })
export const waybillCodesScanField = scanBasicField({ label: '快递单号', value: 'waybill_codes', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
export const expressCodeScanField = scanBasicField({ label: '快递单号', value: 'express_code', type: 'text', operators: ORDER_BULK_SEARCH_OPERATORS, defaultOperator: 'eq' })
export const createAtRangeScanField = scanBasicField({ label: '创建时间', value: 'create_at', type: 'datetimerange' })
export const payTimeRangeScanField = scanBasicField({ label: '支付时间', value: 'pay_time', type: 'datetimerange' })
export const deliveryTimeRangeScanField = scanBasicField({ label: '配送时间', value: 'delivery_time', type: 'datetimerange' })
export const placeOrderTimeRangeScanField = scanBasicField({ label: '下单时间', value: 'place_order_time', type: 'datetimerange' })
export const isUrgencyScanField = scanBasicField({ label: '是否紧急', value: 'is_urgency', type: 'select', options: isUrgencyFilterOptions })
export const buyerMessageHasScanField = scanBasicField({ label: '有无留言', value: 'buyer_message_has', type: 'select', options: buyerMessageHasFilterOptions })
export const buyerMessageScanField = scanBasicField({ label: '留言', value: 'buyer_message', type: 'text', defaultOperator: 'like' })
/** 可复用 ScanBox 字段片段(工作流程) */
export const orderStatusScanField = (options: Array<{ label: string; value: string }>) =>
scanWorkflowField({ label: '订单状态', value: 'status', type: 'select', options })
export const syncStatusScanField = scanWorkflowField({ label: '同步状态', value: 'sync_status', type: 'select', options: syncStatusFilterOptionsBasic })
export const inspectionStatusScanField = scanWorkflowField({ label: '审核状态', value: 'inspection_status', type: 'select', options: inspectionStatusFilterOptions })
export const recheckStatusScanField = scanWorkflowField({ label: '复核状态', value: 'recheck_status', type: 'select', options: recheckStatusFilterOptions })
export const storageStatusScanField = scanWorkflowField({ label: '储位状态', value: 'storage_status', type: 'select', options: storageStatusFilterOptions })
export const postStatusScanField = scanWorkflowField({ label: '快递状态', value: 'post_status', type: 'select', options: postStatusFilterOptions })
export const pickStatusScanField = scanWorkflowField({ label: '拣货状态', value: 'pick_status', type: 'select', options: pickStatusFilterOptions })
export const packStatusScanField = scanWorkflowField({ label: '打包状态', value: 'pack_status', type: 'select', options: packStatusFilterOptions })
export const printStatusScanField = scanWorkflowField({ label: '打印状态', value: 'print_status', type: 'select', options: printStatusFilterOptions })
export const outboundStatusScanField = scanWorkflowField({ label: '数据归档', value: 'outbound_status', type: 'select', options: outboundStatusFilterOptions })
export const claimStatusScanField = scanWorkflowField({ label: '认领状态', value: 'claim_status', type: 'select', options: claimStatusFilterOptions })
export const lockStatusScanField = scanWorkflowField({ label: '锁定状态', value: 'lock_status', type: 'select', options: lockStatusFilterOptions })
export const interceptStatusScanField = scanWorkflowField({ label: '拦截状态', value: 'intercept_status', type: 'select', options: interceptStatusFilterOptions })
/** ScanBox:波次分配 → where.wave_id 为 { operator: 'eq'|'ne', value: 0 } */
export const waveAssignmentScanField = scanBasicField({
label: '波次分配',
value: 'wave_id',
type: 'select',
conditionType: 'number',
options: [
{ label: '未分配波次', value: '__wave_assign_eq_0__', operator: 'eq', conditionValue: 0 },
{ label: '已分配波次', value: '__wave_assign_ne_0__', operator: 'ne', conditionValue: 0 }
]
})
/** ScanBox:储位分配(合并 unassigned/assigning/error 为「未分配」) */
export const storageAssignScanField = scanWorkflowField({
label: '储位分配',
value: 'storage_status',
type: 'select',
options: [
{ label: '未分配', value: '__storage_assign_unassigned__', operator: 'in', conditionValue: ['unassigned', 'assigning', 'error'] },
{ label: '已分配', value: '__storage_assign_completed__', operator: 'eq', conditionValue: 'completed' }
]
})
/** ScanBox:快递公司(快递编码),选项由 index.getExpressList + fillExpressCompanyScanFieldOptions 注入 */
export const expressCompanyScanField = scanBasicField({
label: '快递公司',
value: 'logistics_code',
type: 'select',
options: [] as Array<{ label: string; value: string }>
})
export function mapExpressListToCompanySelectOptions(rawList: any[]): Array<{ label: string; value: string }> {
const result: Array<{ label: string; value: string }> = []
const seen = new Set<string>()
for (const item of rawList || []) {
const codeRaw = ['code', 'logistics_code', 'express_code']
.map((k) => item?.[k])
.find((v) => v !== undefined && v !== null && v !== '')
const code = String(codeRaw ?? '').trim()
if (!code || seen.has(code)) continue
const nameRaw = ['name', 'logistics_name', 'express_name']
.map((k) => item?.[k])
.find((v) => v !== undefined && v !== null && v !== '')
const name = String(nameRaw ?? '').trim()
result.push({ value: code, label: name ? `${code} - ${name}` : code })
seen.add(code)
}
return result
}
export function fillExpressCompanyScanFieldOptions(availableFields: any[], expressRaw: any[]) {
const field = availableFields.find((f: any) => f.value === 'logistics_code')
if (field) field.options = mapExpressListToCompanySelectOptions(expressRaw)
}
/** ScanBox:货主,选项由 index.loadStores + fillStoreScanFieldOptions 注入 */
export function resolveStoreOptionLabel(item: any, fallbackValue?: string | number): string {
const fallback = String(fallbackValue ?? '').trim()
const candidates = [
item?.label,
item?.store_remask,
item?.store_name,
item?.name,
item?.storeName
]
for (const candidate of candidates) {
const text = String(candidate ?? '').trim()
if (text) return text
}
return fallback
}
export function mapStoreListToSelectOptions(rawStores: any[]): Array<{ label: string; value: number | string }> {
const result: Array<{ label: string; value: number | string }> = []
const seen = new Set<string>()
for (const item of rawStores || []) {
const rawValue = item?.value ?? item?.store_id ?? item?.id ?? item?.storeId
if (rawValue === undefined || rawValue === null || rawValue === '') continue
const value = Number.isNaN(Number(rawValue)) ? String(rawValue) : Number(rawValue)
const key = String(value)
if (seen.has(key)) continue
const label = resolveStoreOptionLabel(item, key)
result.push({ label, value })
seen.add(key)
}
return result
}
export function extractStoreListFromResponse(storesRes: any): any[] {
return storesRes?.stores || storesRes?.data?.stores || storesRes?.data || []
}
export function fillStoreScanFieldOptions(availableFields: any[], rawStores: any[]) {
const field = availableFields.find((f: any) => f.value === 'store_id')
if (field) field.options = mapStoreListToSelectOptions(rawStores)
}
// === ScanBox 筛选分组常量 ===
const SCAN_QUICK_FILTER_GROUP = '快速筛选'
const SCAN_ORDER_INFO_GROUP = '订单信息'
const SCAN_PROCESS_STATUS_GROUP = '流程状态'
const SCAN_RECEIVING_INFO_GROUP = '收货信息'
const SCAN_TIME_GROUP = '时间'
// deliveryOrder相关配置
export const deliveryAvailableFields = [
// 快速筛选
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
// 订单信息
{ ...orderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...waybillCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sysPlatformNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
// 流程状态
{ ...orderStatusScanField(pendingOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
{ ...outboundStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...inspectionStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...storageStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...postStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...claimStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...lockStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...interceptStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
// 收货信息
{ ...receiverNameScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...receiverMobileScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
// 时间
{ ...createAtRangeScanField, group: SCAN_TIME_GROUP },
{ ...payTimeRangeScanField, group: SCAN_TIME_GROUP },
{ ...deliveryTimeRangeScanField, group: SCAN_TIME_GROUP },
]
/** upper-table 列点击复制:`copy` 仅复制;`copyQr` 复制并弹出快递单号二维码 */
export type UpperTableCopyAction = 'copy' | 'copyQr'
const ORDER_LIST_COPY_ACTIONS: Record<string, UpperTableCopyAction> = {
delivery_order_code: 'copy',
order_code: 'copy',
wave_no: 'copy',
source_order_codes: 'copy',
express_numbers: 'copyQr',
waybill_codes: 'copyQr',
express_code: 'copyQr',
}
export function applyOrderListCopyActions<T extends { prop: string; formatter?: unknown }>(columns: T[]): T[] {
return columns.map((col) => {
const copyAction = ORDER_LIST_COPY_ACTIONS[col.prop]
if (!copyAction) return col
if (copyAction === 'copyQr') {
const { formatter: _formatter, ...rest } = col
return { ...rest, copyAction } as unknown as T
}
return { ...col, copyAction } as T
})
}
/** 订单列表:货主(接口字段 store_remark) */
export const orderStoreRemarkColumn = {
prop: 'store_remark',
label: '货主',
width: '120',
showOverflowTooltip: true
}
export const deliveryColumns = applyOrderListCopyActions([
{ prop: 'id', label: '订单ID', width: '80' },
{ prop: 'delivery_order_code', label: '发货单号', width: '170', fixed: 'left' },
{ prop: 'pre_delivery_order_code', label: '前置单号', width: '150' },
{ prop: 'shop_nick', label: '店铺名称', width: '140' },
orderStoreRemarkColumn,
{ prop: 'wave_no', label: '波次号', width: '150' },
{ prop: 'wave_id', label: '波次ID', width: '90' },
{ prop: 'order_flag', label: '订单标记', minWidth: '220' },
{ prop: 'sys_platform_name', label: '平台', width: '110' },
{ prop: 'create_channel', label: '来源', width: '120' },
{ prop: 'sys_platform_name', label: '平台编码', width: '100' },
{ prop: 'order_type', label: '订单类型', width: '90', formatter: orderTypeFormatter },
{ prop: 'buyer_nick', label: '买家昵称', width: '120' },
{ prop: 'seller_nick', label: '卖家昵称', width: '120' },
{ prop: 'name', label: '收件人', width: '100' },
{ prop: 'mobile', label: '电话', width: '120' },
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
{ prop: 'province', label: '省份', width: '90' },
{ prop: 'city', label: '城市', width: '90' },
{ prop: 'area', label: '区/县', width: '90' },
{ prop: 'status', label: '订单状态', width: '100', formatter: (row: any) => translateOrderField('status', row.status) },
{ prop: 'outbound_status', label: '数据归档', width: '100' },
{ prop: 'sync_status', label: '同步状态', width: '100' },
{ prop: 'inspection_status', label: '审核状态', width: '100' },
{ prop: 'recheck_status', label: '复核状态', width: '100' },
{ prop: 'storage_status', label: '储位状态', width: '90' },
{ prop: 'post_status', label: '快递状态', width: '90' },
{ prop: 'print_status', label: '打印状态', width: '100' },
{ prop: 'pick_status', label: '拣货状态', width: '90' },
{ prop: 'pack_status', label: '打包状态', width: '90' },
{ prop: 'claim_status', label: '认领状态', width: '100' },
{ prop: 'lock_status', label: '锁定状态', width: '100' },
{ prop: 'intercept_status', label: '拦截状态', width: '100', tag: true },
{ prop: 'logistics_name', label: '快递', width: '120' },
{ prop: 'sys_logistics_name', label: '系统快递', width: '120' },
// { prop: 'express_numbers', label: '运单号', width: '160', formatter: waybillCodesFormatter },
{ prop: 'waybill_codes', label: '运单号', width: '150', formatter: waybillCodesFormatter },
{ prop: 'source_order_codes', label: '平台交易单号', width: '140' },
{ prop: 'is_urgency', label: '是否紧急', width: '80' },
{ prop: 'invoice_flag', label: '发票', width: '80' },
{ prop: 'weight_type', label: '重量类型', width: '90', formatter: weightTypeFormatter },
{ prop: 'delivery_type', label: '配送类型', width: '100' },
{ prop: 'basket_number', label: '篮号', width: '90' },
{ prop: 'items_count', label: '商品种类', width: '90' },
{ prop: 'items_total', label: '商品总数', width: '90' },
{ prop: 'items_weight', label: '商品重量(g)', width: '90' },
{ prop: 'total_amount', label: '订单金额', width: '100' },
{ prop: 'item_amount', label: '商品金额', width: '100' },
{ prop: 'freight', label: '运费', width: '90' },
{ prop: 'remark', label: '留言', width: '140' },
{ prop: 'operator_name', label: '操作人', width: '100' },
{ prop: 'pay_time', label: '支付时间', width: '160', formatter: orderTimeFormatter },
{ prop: 'delivery_time', label: '配送时间', width: '160', formatter: orderTimeFormatter },
{ prop: 'operate_time', label: '操作时间', width: '160', formatter: orderTimeFormatter },
{ prop: 'place_order_time', label: '时效', width: '160', formatter: orderTimeFormatter },
{ prop: 'create_at', label: '创建时间', width: '160', formatter: orderTimeFormatter },
])
/** 配送订单详情分区(与 orderDetailFullSections 一致) */
export const deliveryOrderDetailSections = orderDetailFullSections
export const deliverydetail = [
{ label: '订单总金额', prop: 'total_amount' },
{ label: '商品总金额', prop: 'item_amount' },
{ label: '订单折扣金额', prop: 'discount_amount' },
{ label: '商品名称(预留位置)', prop: 'item_name' },
{ label: '商品SKU', prop: 'items' },
{ label: '商品种类数', prop: 'items_count' },
{ label: '商品总数', prop: 'items_total' },
{ label: '商品重量(g)', prop: 'items_weight' },
{ label: '货主', prop: 'store_id' },
{ label: '国家编码', prop: 'country_code' },
{ label: '详细地址', prop: 'detail_address' },
]
export const deliverybuttonList: any[] = [
{
label: 'EXCEL操作',
type: 'dropdown',
command: 'handleDeliveryOperation',
options: [
{ label: '导出配送单(不含明细)', value: 'export-delivery-nodetail' },
{ label: '快递号导入(含明细)', value: 'import-delivery-detail' },
]
},
{
label: '打印操作',
type: 'dropdown',
command: 'handleDeliveryPrintOperation',
options: [
{ label: '打印发货单', value: 'print-delivery' },
{ label: '打印拣货单', value: 'print-picking' },
{ label: '打印面单(菜鸟)', value: 'print-waybill-cainiao', divided: true },
{ label: '打印面单(拼多多)', value: 'print-waybill-pdd' },
]
},
]
/** deliveryOrder */
export const deliveryOrderToolbarButtonKeys = [
...simpleListToolbarButtonKeys,
'batchPrint',
'allocateSubOrderNumber',
]
export const deliveryOrderToolbarButtons = pickToolbarButtons(deliveryOrderToolbarButtonKeys)
// revieworder相关配置
export const reviewAvailableFields = [
// 快速筛选
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
// 订单信息
{ ...orderQuickSearchScanField, label: '发货单号', group: SCAN_ORDER_INFO_GROUP },
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sysPlatformCodeScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
// 流程状态
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...orderStatusScanField(reviewOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
// 收货信息
{ ...receiverNameScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...receiverMobileScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
// 时间
{ ...createAtRangeScanField, group: SCAN_TIME_GROUP },
]
export const reviewColums = applyOrderListCopyActions([
{ prop: 'id', label: '订单ID', width: '80' },
{ prop: 'delivery_order_code', label: '发货单号', width: '170' },
{ prop: 'wave_no', label: '波次号', width: '170' },
{ prop: 'order_flag', label: '订单标记', minWidth: '260' },
{ prop: 'shop_nick', label: '店铺名称', width: '140' },
orderStoreRemarkColumn,
{ prop: 'sys_platform_name', label: '平台编码', width: '100' },
{ prop: 'source_order_codes', label: '平台交易单号', width: '140' },
{ prop: 'status', label: '订单状态', width: '100', formatter: (row: any) => translateOrderField('status', row.status) },
{ prop: 'name', label: '收件人', width: '110' },
{ prop: 'sync_status', label: '同步状态', width: '100' },
{ prop: 'recheck_status', label: '复核状态', width: '100' },
{ prop: 'is_urgency', label: '是否紧急', width: '80' },
{ prop: 'logistics_name', label: '快递', width: '120' },
{ prop: 'items_total', label: '商品总数', width: '100' },
{ prop: 'items_count', label: '商品种类', width: '100' },
{ prop: 'items_weight', label: '商品重量(g)', width: '110' },
{ prop: 'total_amount', label: '订单金额', width: '110' },
{ prop: 'pay_time', label: '支付时间', width: '165', formatter: orderTimeFormatter },
{ prop: 'operator_name', label: '审核人', width: '100' },
{ prop: 'operate_time', label: '审核时间', width: '165', formatter: orderTimeFormatter },
{ prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter },
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
])
export const reviewOrderDetail = [
// 基础信息
{ prop: 'delivery_order_code', label: '发货单号' },
{ prop: 'pre_delivery_order_code', label: '前置单号' },
{ prop: 'order_type', label: '订单类型' },
{ prop: 'order_flag', label: '订单标记' },
{ prop: 'create_channel', label: '来源' },
{ prop: 'sys_platform_name', label: '平台编码' },
{ prop: 'shop_nick', label: '店铺名称' },
{ prop: 'buyer_nick', label: '买家昵称' },
{ prop: 'seller_nick', label: '卖家昵称' },
{ prop: 'status', label: '订单状态', formatter: (row: any) => translateOrderField('status', row.status) },
{ prop: 'is_urgency', label: '是否紧急' },
{ prop: 'invoice_flag', label: '发票标记' },
{ prop: 'sync_status', label: '同步状态' },
{ prop: 'inspection_status', label: '审核状态' },
{ prop: 'source_order_codes', label: '平台交易单号' },
{ prop: 'pay_no', label: '支付单号' },
// 金额与商品
{ prop: 'total_amount', label: '订单总金额' },
{ prop: 'item_amount', label: '商品金额' },
{ prop: 'discount_amount', label: '折扣金额' },
{ prop: 'freight', label: '运费' },
{ prop: 'ar_amount', label: '应收金额' },
{ prop: 'got_amount', label: '实收金额' },
{ prop: 'items', label: '商品清单', span: 3 },
{ prop: 'items_count', label: '商品种类' },
{ prop: 'items_total', label: '商品总数' },
{ prop: 'items_weight', label: '商品重量(g)' },
// 收货与物流
{ prop: 'name', label: '收件人' },
{ prop: 'mobile', label: '电话' },
{ prop: 'tel', label: '固定电话' },
{ prop: 'province', label: '省份' },
{ prop: 'city', label: '城市' },
{ prop: 'area', label: '区县' },
{ prop: 'town', label: '镇街' },
{ prop: 'detail_address', label: '详细地址', span: 2 },
{ prop: 'zip_code', label: '邮编' },
{ prop: 'logistics_name', label: '快递' },
{ prop: 'waybill_codes', label: '运单号' },
{ prop: 'delivery_type', label: '发货类型' },
{ prop: 'weight_type', label: '重量类型' },
// 时间信息
{ prop: 'place_order_time', label: '下单时间' },
{ prop: 'pay_time', label: '支付时间' },
{ prop: 'delivery_time', label: '配送时间' },
{ prop: 'create_at', label: '创建时间' },
{ prop: 'operator_name', label: '审核人' },
{ prop: 'operate_time', label: '审核时间' },
]
export const reviewOrderbuttonList: any[] = [
{
label: '审核操作',
type: 'dropdown',
command: 'handleReviewOperation',
options: [
{ label: '审核通过', value: 'approve' },
{ label: '审核驳回', value: 'reject' },
]
}
]
export const reviewToolbarButtonKeys = [
...simpleListToolbarButtonKeys,
'createOrder',
'batchReview',
'updateRemark',
'cancelOrder'
]
/** 页面级按钮列表:reviewOrder 直接消费,避免页面内重复拼装 */
export const reviewToolbarButtons = pickToolbarButtons(reviewToolbarButtonKeys)
/** entrustWarehouse(委托外仓) */
export const entrustWarehouseToolbarButtonKeys = simpleListToolbarButtonKeys
export const entrustWarehouseToolbarButtons = simpleListToolbarButtons
/** deliveryException(配送异常) */
export const deliveryExceptionToolbarButtonKeys = simpleListToolbarButtonKeys
export const deliveryExceptionToolbarButtons = simpleListToolbarButtons
/** 待出库:在简单列表基础上增加手动出库迁移 */
export const outboundToolbarButtonKeys = [
...simpleListToolbarButtonKeys,
'manualOutboundMigrate',
]
export const outboundToolbarButtons = pickToolbarButtons(outboundToolbarButtonKeys)
// pendingOrder相关配置
export const pendingAvailableFields = [
// 快速筛选
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
// 订单信息
{ ...pendingOrderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...waybillCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sysPlatformNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
// 流程状态
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...storageStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...postStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...orderStatusScanField(pendingOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
// 收货信息
{ ...receiverNameScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...receiverMobileScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...receiverProvinceScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...receiverCityScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...receiverAreaScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
// 时间
{ ...placeOrderTimeRangeScanField, group: SCAN_TIME_GROUP },
{ ...createAtRangeScanField, group: SCAN_TIME_GROUP },
]
export const pendingCloums = [
{ prop: 'id', label: '订单ID', width: '80' },
{ prop: 'delivery_order_code', label: '外部订单号', width: '170' ,fixed: 'left'},
{ prop: 'wave_no', label: '波次号', width: '170' },
{ prop: 'order_flag', label: '订单标记', minWidth: '260' },
{ prop: 'shop_nick', label: '店铺名称', width: '140' },
orderStoreRemarkColumn,
{ prop: 'sys_platform_name', label: '平台编码', width: '100' },
{ prop: 'name', label: '收件人', width: '110' },
{ prop: 'mobile', label: '电话', width: '120' },
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
{ prop: 'is_urgency', label: '是否紧急', width: '100' },
{ prop: 'sync_status', label: '同步状态', width: '100' },
{ prop: 'storage_status', label: '储位状态', width: '100' },
{ prop: 'post_status', label: '快递状态', width: '100' },
{ prop: 'pick_status', label: '拣货状态', width: '100' },
{ prop: 'pack_status', label: '打包状态', width: '100' },
{ prop: 'intercept_status', label: '拦截状态', width: '100', tag: true },
{ prop: 'express_numbers', label: '快递单号', width: '160', formatter: waybillCodesFormatter },
{ prop: 'items_count', label: '商品种类', width: '100' },
{ prop: 'items_total', label: '商品总数', width: '100' },
{ prop: 'items_weight', label: '商品重量(g)', width: '110' },
{ prop: 'province', label: '省份', width: '100' },
{ prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter },
{ prop: 'pay_time', label: '支付时间', width: '160', formatter: orderTimeFormatter },
{ prop: 'place_order_time', label: '时效', width: '165', formatter: orderTimeFormatter },
{ prop: 'create_channel', label: '来源', width: '120' },
{ prop: 'source_order_codes', label: '平台交易单号', width: '140' },
{ prop: 'logistics_name', label: '快递', width: '120' },
{ prop: 'remark', label: '留言', width: '160' },
]
/** 列表字段显示名(以待处理订单 pendingCloums 为准,含动态插入列) */
export const ORDER_LIST_FIELD_LABELS: Record<string, string> = {
...Object.fromEntries(pendingCloums.map((col) => [col.prop, col.label])),
recheck_status: '复核状态',
print_status: '打印状态',
outbound_status: '数据归档',
inspection_status: '审核状态',
order_code: '发货单号',
total_amount: '订单金额',
source_order_codes: '平台交易单号',
order_type: '订单类型',
buyer_nick: '买家昵称',
buyer_message: '买家留言',
seller_message: '卖家留言',
pre_delivery_order_code: '前置单号',
delivery_time: '配送时间',
items_weight: '商品重量(g)',
waybill_codes: '运单号',
weight_type: '重量类型',
}
export function applyOrderListColumnLabels<T extends { prop: string; label: string }>(columns: T[]): T[] {
return columns.map((col) => {
const standard = ORDER_LIST_FIELD_LABELS[col.prop]
return standard ? { ...col, label: standard } : col
})
}
/** 待处理订单列表标准列:在基础列上补全复核、打印列 */
export function buildPendingStyleColumns(baseColumns: ReadonlyArray<{ prop: string; label: string; [key: string]: any }> = pendingCloums) {
const source = applyOrderListColumnLabels(Array.isArray(baseColumns) ? [...baseColumns] : [])
const recheckColumn = { prop: 'recheck_status', label: ORDER_LIST_FIELD_LABELS.recheck_status, width: '100' }
if (!source.some((col) => String(col?.prop || '') === 'recheck_status')) {
const insertAfterIndex = source.findIndex((col) => String(col?.prop || '') === 'sync_status')
if (insertAfterIndex >= 0) {
source.splice(insertAfterIndex + 1, 0, recheckColumn)
} else {
source.push(recheckColumn)
}
}
if (!source.some((col) => String(col?.prop || '') === 'print_status')) {
const printColumn = { prop: 'print_status', label: ORDER_LIST_FIELD_LABELS.print_status, width: '100' }
const insertAfterIndex = source.findIndex((col) => String(col?.prop || '') === 'post_status')
if (insertAfterIndex >= 0) {
source.splice(insertAfterIndex + 1, 0, printColumn)
} else {
source.push(printColumn)
}
}
return applyOrderListCopyActions(source)
}
export const pendingOrderDetail = [
// 基础信息
{ prop: 'delivery_order_code', label: '外部订单号' },
{ prop: 'pre_delivery_order_code', label: '前置单号' },
{ prop: 'order_type', label: '订单类型' },
{ prop: 'order_flag', label: '订单标记' },
{ prop: 'create_channel', label: '来源' },
{ prop: 'sys_platform_name', label: '平台编码' },
{ prop: 'shop_nick', label: '店铺名称' },
{ prop: 'buyer_nick', label: '买家昵称' },
{ prop: 'seller_nick', label: '卖家昵称' },
{ prop: 'status', label: '订单状态', formatter: (row: any) => translateOrderField('status', row.status) },
{ prop: 'sync_status', label: '同步状态' },
{ prop: 'is_urgency', label: '是否紧急' },
{ prop: 'invoice_flag', label: '发票标记' },
{ prop: 'source_order_codes', label: '平台交易单号' },
{ prop: 'pay_no', label: '支付单号' },
// 金额与商品
{ prop: 'total_amount', label: '订单总金额' },
{ prop: 'item_amount', label: '商品金额' },
{ prop: 'discount_amount', label: '折扣金额' },
{ prop: 'freight', label: '运费' },
{ prop: 'ar_amount', label: '应收金额' },
{ prop: 'got_amount', label: '实收金额' },
{ prop: 'items', label: '商品清单', span: 3 },
{ prop: 'items_count', label: '商品种类' },
{ prop: 'items_total', label: '商品总数' },
{ prop: 'items_weight', label: '商品重量(g)' },
// 收货与物流
{ prop: 'name', label: '收件人' },
{ prop: 'mobile', label: '电话' },
{ prop: 'tel', label: '固定电话' },
{ prop: 'province', label: '省份' },
{ prop: 'city', label: '城市' },
{ prop: 'area', label: '区县' },
{ prop: 'town', label: '镇街' },
{ prop: 'detail_address', label: '详细地址', span: 2 },
{ prop: 'zip_code', label: '邮编' },
{ prop: 'logistics_name', label: '快递' },
{ prop: 'waybill_codes', label: '运单号' },
{ prop: 'delivery_type', label: '发货服务类型' },
{ prop: 'weight_type', label: '重量类型' },
// 时间信息
{ prop: 'place_order_time', label: '下单时间' },
{ prop: 'pay_time', label: '支付时间' },
{ prop: 'delivery_time', label: '配送时间' },
{ prop: 'create_at', label: '创建时间' },
{ prop: 'operator_name', label: '操作人' },
{ prop: 'operate_time', label: '操作时间' },
]
export const pendingOrderbuttonList: any[] = [
{
label: 'EXCEL操作',
type: 'dropdown',
command: 'handleExcelOperation',
options: [
{ label: '订单导入', value: 'import-order' },
{ label: '快递号导入', value: 'import-delivery' },
{ label: '地址导入', value: 'import-address' },
{ label: '导出订单(不含明细)', value: 'export-summary', divided: true },
{ label: '导出订单(含明细)', value: 'export-detail' },
]
},
{
label: '打印操作',
type: 'dropdown',
command: 'handlePrintOperation',
options: [
{ label: '打印发货单', value: 'print-delivery' },
{ label: '打印拣货单', value: 'print-picking' },
{ label: '打印面单(菜鸟)', value: 'print-waybill-cainiao', divided: true },
{ label: '打印面单(拼多多)', value: 'print-waybill-pdd' },
]
},
{
label: '分配快递号',
type: 'dropdown',
command: 'handleAssignDelivery',
options: [
{ label: '分配快递号', value: 'assign-delivery' },
]
},
{
label: '拆分',
type: 'dropdown',
command: 'handleSplitOrder',
options: [
{ label: '拆分', value: 'split' },
]
}
]
export const pendingToolbarButtonKeys = [
...simpleListToolbarButtonKeys,
'reverseReview',
'createOrder',
'markPendingOutbound',
'waveSingleFetchByIds',
'allocateStorage',
'cancelAllocateStorage',
'allocateExpress',
'manualWaybill',
'updateExpress',
'updatePlatform',
'updateAddress',
'updateRemark',
'batchQuickRecheck',
'cloneOrder',
'syncOrderIds',
'cancelOrder',
'batchIntercept',
'batchUnintercept',
'batchLock',
'batchUnlock',
'batchPrint',
'resolveException',
'allocateSubOrderNumber',
'subWaybillPrint'
]
/** 页面级按钮列表:pendingOrder 直接消费,避免页面内重复拼装 */
export const pendingToolbarButtons = pickToolbarButtons(pendingToolbarButtonKeys)
/**
* deliveryException
*/
export const exceptionToolbarButtonKeys = [...pendingToolbarButtonKeys]
export const exceptionToolbarButtons = pickToolbarButtons(exceptionToolbarButtonKeys)
// outboundOrder(保留储位分配筛选,与待处理订单的储位状态区分)
export const outboundAvailableFields = pendingAvailableFields.map((field: any) =>
field.value === 'storage_status' ? storageAssignScanField : field
)
export const outboundColumns = pendingCloums
// orderWorkbench相关配置
export const workbenchStatusOptions = [
{ label: '待处理', value: 'pedding' },
{ label: '已完成', value: 'fin' },
{ label: '异常', value: 'error' }
]
export const workbenchAvailableFields = [
// 快速筛选
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
// 订单信息
{ ...deliveryOrderCodeScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...buyerNickScanField, group: SCAN_ORDER_INFO_GROUP },
// 流程状态
{ ...orderStatusScanField(workbenchStatusOptions), group: SCAN_PROCESS_STATUS_GROUP },
// 收货信息
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
]
export const workbenchColumns = applyOrderListCopyActions([
{ prop: 'id', label: '订单ID', width: '80' },
{ prop: 'delivery_order_code', label: '发货单号', minWidth: 160 },
{ prop: 'wave_no', label: '波次号', minWidth: 160 },
{ prop: 'order_flag', label: '订单标记', minWidth: 260 },
{ prop: 'sys_platform_name', label: '平台', minWidth: 120 },
{ prop: 'create_channel', label: '来源', minWidth: 120 },
{ prop: 'shop_nick', label: '店铺名称', minWidth: 140 },
orderStoreRemarkColumn,
{ prop: 'buyer_nick', label: '买家昵称', minWidth: 140 },
{ prop: 'name', label: '收件人', minWidth: 100 },
{ prop: 'mobile', label: '电话', minWidth: 120 },
{ prop: 'buyer_message', label: '买家留言', minWidth: 180 },
{ prop: 'seller_message', label: '卖家留言', minWidth: 180 },
{ prop: 'is_urgency', label: '是否紧急', minWidth: 100 },
{ prop: 'status', label: '订单状态', minWidth: 120, formatter: (row: any) => translateOrderField('status', row.status) },
{ prop: 'sync_status', label: '同步状态', minWidth: 110 },
{ prop: 'inspection_status', label: '审核状态', minWidth: 110 },
{ prop: 'outbound_status', label: '数据归档', minWidth: 120 },
{ prop: 'logistics_name', label: '快递', minWidth: 120 },
{ prop: 'waybill_codes', label: '运单号', minWidth: 140, formatter: waybillCodesFormatter },
{ prop: 'items_total', label: '商品总数', minWidth: 100 },
{ prop: 'items_weight', label: '商品重量(g)', minWidth: 110 },
{ prop: 'total_amount', label: '订单金额', minWidth: 110 },
{ prop: 'create_at', label: '创建时间', minWidth: 170, formatter: orderTimeFormatter },
{ prop: 'updated_at', label: '更新时间', minWidth: 170, formatter: orderTimeFormatter }
])
export const workbenchBadgeItems = [
{ key: 'reviewOrder', label: '待审核' },
{ key: 'pendingOrder', label: '待处理' },
{ key: 'outboundOrder', label: '待出库' },
{ key: 'expectionOrder', label: '异常' },
{ key: 'entrustOrder', label: '委托外仓' },
{ key: 'deliveryOrder', label: '配送' },
{ key: 'deliveryExpectionOrder', label: '配送异常' },
{ key: 'archiveOrder', label: '归档' }
]
// expectionOrder相关配置
export const expectionOrderAvailableFields = [
// 快速筛选
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
// 订单信息
{ ...orderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCodeScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
// 流程状态
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...storageStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...postStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...interceptStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...orderStatusScanField(exceptionOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
// 收货信息
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
// 时间
{ ...createAtRangeScanField, group: SCAN_TIME_GROUP },
]
export const expectionColumns = [
{ prop: 'id', label: '订单ID', width: '80' },
{ prop: 'delivery_order_code', label: '发货单号', width: '170' },
{ prop: 'wave_no', label: '波次号', width: '170' },
{ prop: 'sys_platform_name', label: '平台编码', width: '120' },
{ prop: 'create_channel', label: '来源', width: '120' },
{ prop: 'shop_nick', label: '店铺名称', width: '140' },
orderStoreRemarkColumn,
{ prop: 'is_urgency', label: '是否紧急', width: '100' },
{ prop: 'sync_status', label: '同步状态', width: '100' },
{ prop: 'storage_status', label: '储位状态', width: '100' },
{ prop: 'post_status', label: '快递状态', width: '100' },
{ prop: 'pick_status', label: '拣货状态', width: '100' },
{ prop: 'pack_status', label: '打包状态', width: '100' },
{ prop: 'intercept_status', label: '拦截状态', width: '100', tag: true },
{ prop: 'express_numbers', label: '运单号', width: '160', formatter: waybillCodesFormatter },
{ prop: 'name', label: '收件人', width: '110' },
{ prop: 'mobile', label: '电话', width: '120' },
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
{ prop: 'logistics_name', label: '快递', width: '120' },
{ prop: 'pre_delivery_order_code', label: '前置单号', width: '140' },
{ prop: 'order_flag', label: '订单标记', minWidth: '260' },
{ prop: 'items_total', label: '商品总数', width: '100' },
{ prop: 'items_weight', label: '商品重量(g)', width: '110' },
{ prop: 'total_amount', label: '订单金额', width: '110' },
{ prop: 'pay_time', label: '支付时间', width: '165', formatter: orderTimeFormatter },
{ prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter },
]
export const expectionOrderDetail = [
// 基础信息
{ prop: 'delivery_order_code', label: '发货单号' },
{ prop: 'order_code', label: '发货单号' },
{ prop: 'order_type', label: '订单类型' },
{ prop: 'shop_nick', label: '店铺名称' },
{ prop: 'sys_platform_name', label: '平台' },
{ prop: 'create_channel', label: '来源' },
{ prop: 'status', label: '订单状态', formatter: (row: any) => translateOrderField('status', row.status) },
{ prop: 'intercept_status', label: '拦截状态' },
// 异常/状态标记
{ prop: 'order_flag', label: '订单标记', span: 3 },
{ prop: 'lock_status', label: '锁定状态' },
{ prop: 'sync_status', label: '同步状态' },
{ prop: 'post_status', label: '快递状态' },
// 收货信息
{ prop: 'name', label: '收件人' },
{ prop: 'mobile', label: '电话' },
{ prop: 'province', label: '省份' },
{ prop: 'city', label: '城市' },
{ prop: 'area', label: '区县' },
{ prop: 'detail_address', label: '详细地址' },
// 物流信息
{ prop: 'logistics_name', label: '快递' },
{ prop: 'express_code', label: '运单号' },
// 统计信息
{ prop: 'items_count', label: '商品种类' },
{ prop: 'items_total', label: '商品总数' },
{ prop: 'items_weight', label: '商品重量(g)' },
// 时间信息
{ prop: 'create_at', label: '创建时间' },
{ prop: 'updated_at', label: '更新时间' },
{ prop: 'operate_time', label: '操作时间' },
]
export const expectionOrderbuttonList: any[] = [
{
label: 'EXCEL操作',
type: 'dropdown',
command: 'handleExpectionOperation',
options: [
{ label: '异常跟踪单导入', value: 'import-exception-tracking' },
{ label: '导出异常跟踪单', value: 'export-exception-tracking' },
]
}
]
// deliveryException相关配置
export const archiveAvailableFields = [
// 快速筛选
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
// 订单信息
{ ...orderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
// 流程状态
{ ...orderStatusScanField(archiveOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...outboundStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
// 收货信息
{ ...receiverNameScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...receiverMobileScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
]
export const archiveColumns = applyOrderListCopyActions([
{ prop: 'id', label: '订单ID', width: '80' },
{ prop: 'order_code', label: '发货单号', width: '180' },
{ prop: 'delivery_order_code', label: '发货单号', width: '160' },
{ prop: 'wave_no', label: '波次号', width: '160' },
{ prop: 'order_flag', label: '订单标记', minWidth: '260' },
{ prop: 'shop_nick', label: '店铺名称', width: '140' },
orderStoreRemarkColumn,
{ prop: 'create_channel', label: '来源', width: '120' },
{ prop: 'name', label: '收件人', width: '120' },
{ prop: 'mobile', label: '电话', width: '120' },
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
{ prop: 'items_weight', label: '商品重量(g)', width: '110' },
{ prop: 'logistics_name', label: '快递', width: '120' },
{ prop: 'status', label: '订单状态', width: '100', formatter: (row: any) => translateOrderField('status', row.status) },
{ prop: 'create_at', label: '创建时间', width: '160' },
{ prop: 'updated_at', label: '归档时间', width: '160' },
])
export const archiveOrderDetail = [
// 基础信息
{ prop: 'delivery_order_code', label: '发货单号' },
{ prop: 'order_code', label: '发货单号' },
{ prop: 'order_type', label: '订单类型' },
{ prop: 'shop_nick', label: '店铺名称' },
{ prop: 'sys_platform_name', label: '平台' },
{ prop: 'create_channel', label: '来源' },
{ prop: 'status', label: '订单状态', formatter: (row: any) => translateOrderField('status', row.status) },
// 收货信息
{ prop: 'name', label: '收件人' },
{ prop: 'mobile', label: '电话' },
{ prop: 'province', label: '省份' },
{ prop: 'city', label: '城市' },
{ prop: 'area', label: '区县' },
{ prop: 'detail_address', label: '详细地址' },
// 物流信息
{ prop: 'logistics_name', label: '快递' },
{ prop: 'express_code', label: '运单号' },
// 金额/统计
{ prop: 'total_amount', label: '总金额' },
{ prop: 'item_amount', label: '商品金额' },
{ prop: 'items_count', label: '商品种类' },
{ prop: 'items_total', label: '商品总数' },
// 时间信息
{ prop: 'place_order_time', label: '下单时间' },
{ prop: 'pay_time', label: '支付时间' },
{ prop: 'create_at', label: '创建时间' },
{ prop: 'updated_at', label: '归档/更新时间' },
]
/** archiveOrder */
export const archiveOrderToolbarButtonKeys = simpleListToolbarButtonKeys
export const archiveOrderToolbarButtons = simpleListToolbarButtons