367 lines
12 KiB
TypeScript
367 lines
12 KiB
TypeScript
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
||
|
||
/** 工具栏按钮:可限定仅在对应波次页签显示(1 团购 / 2 散单) */
|
||
export type WaveToolbarButtonConfig = ToolbarButtonConfig & {
|
||
onlyForWaveType?: 1 | 2
|
||
}
|
||
|
||
/** ScanBox 默认 props(与 orderManagement 子页一致的可配置项) */
|
||
export const waveScanBoxConfig = {
|
||
width: '320px',
|
||
treeProps: { children: 'children', label: 'label' } as const,
|
||
autoSubmit: false
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/** 主表 UpperTable 展示与行为默认值 */
|
||
export const waveUpperTableDefaults = {
|
||
title: '波次列表',
|
||
enableColumnConfig: true,
|
||
showIndex: true,
|
||
showSelection: true,
|
||
emptyText: '暂无波次数据'
|
||
}
|
||
|
||
/** 左侧筛选可用字段 */
|
||
export const waveAvailableFields = [
|
||
// { label: '波次ID', value: 'wave_id', type: 'number' },
|
||
{ label: '波次号', value: 'wave_no', type: 'text' },
|
||
{
|
||
label: '波次类型',
|
||
value: 'wave_type',
|
||
type: 'select',
|
||
options: [
|
||
{ label: '团购', value: 1 },
|
||
{ label: '散单', value: 2 }
|
||
]
|
||
},
|
||
{
|
||
label: '波次状态',
|
||
value: 'wave_status',
|
||
type: 'select',
|
||
options: [
|
||
{ label: '自动加团中', value: 0 },
|
||
{ label: '已就绪', value: 1 }
|
||
]
|
||
},
|
||
{ label: '创建人', value: 'creator', type: 'text' },
|
||
{ label: '快递', value: 'logistics_name', type: 'text' },
|
||
// { label: '商品类型', value: 'item_part_type', type: 'text' },
|
||
// { label: '商品部位', value: 'item_part', type: 'text' },
|
||
// { label: '商品快照键', value: 'item_snapshot_key', type: 'text' },
|
||
// { label: '商品结构', value: 'item_detail_machine', type: 'text' },
|
||
{
|
||
label: '区分快递',
|
||
value: 'distinguish_express',
|
||
type: 'select',
|
||
options: [
|
||
{ label: '是', value: 1 },
|
||
{ label: '否', value: 0 }
|
||
]
|
||
},
|
||
{label:'库位分配', value: 'storage_assignment_status', type: 'select', options: [
|
||
{ label: '未分配', value: '未分配' },
|
||
{ label: '部分分配', value: '部分分配' },
|
||
{ label: '已分配', value: '已分配' },
|
||
]},
|
||
{label:'快递分配', value: 'express_assignment_status', type: 'select', options: [
|
||
{ label: '未分配', value: 'none' },
|
||
{ label: '分配中', value: 'padding' },
|
||
{ label: '已完成', value: 'fin' }
|
||
]},
|
||
{label:'打印状态', value: 'print_assignment_status', type: 'select', options: [
|
||
{ label: '未打印', value: 'none' },
|
||
{ label: '打印中', value: 'padding' },
|
||
{ label: '已完成', value: 'fin' }
|
||
]},
|
||
{ label: '最小订单数', value: 'total_orders_min', type: 'number' },
|
||
{ label: '最大订单数', value: 'total_orders_max', type: 'number' },
|
||
{ label: '最小已处理订单', value: 'processed_orders_min', type: 'number' },
|
||
{ label: '最大已处理订单', value: 'processed_orders_max', type: 'number' }
|
||
]
|
||
|
||
/** 抓取散单候选:左侧筛选可用字段 */
|
||
export const fallbackOrderAvailableFields = [
|
||
// { label: '订单ID', value: 'id', type: 'number' },
|
||
{ label: '订单号', value: 'delivery_no', type: 'text' },
|
||
{ label: '物流单号', value: 'tracking_no', type: 'text' },
|
||
{ label: '商品种数最小值', value: 'items_count_min', type: 'number' },
|
||
{ label: '商品种数最大值', value: 'items_count_max', type: 'number' },
|
||
{ label: '商品总数最小值', value: 'items_total_min', type: 'number' },
|
||
{ label: '商品总数最大值', value: 'items_total_max', type: 'number' },
|
||
{ label: '物流公司', value: 'sys_logistics_name', type: 'select', options: [] },
|
||
{ label: '店铺名称', value: 'store_name', type: 'text' },
|
||
{ label: '平台', value: 'sys_platform_name', type: 'select', options: [] }
|
||
// { label: '货主', value: 'owner_name', type: 'select', options: [] },
|
||
// { label: '省份', value: 'province', type: 'text' },
|
||
// { label: '来源平台', value: 'sys_platform_name', type: 'select', options: [] }
|
||
]
|
||
|
||
/** 主表列配置 */
|
||
export const waveBatchColumns = [
|
||
// { prop: 'wave_id', label: '波次ID', minWidth: 160, fixed: 'left' },
|
||
{ prop: 'wave_no', label: '波次编号', minWidth: 180, fixed: 'left' },
|
||
{ prop: 'wave_type', label: '波次类型', minWidth: 96 },
|
||
{ prop: 'wave_status', label: '状态', minWidth: 110 },
|
||
{ prop: 'total_orders', label: '总订单数', minWidth: 110, align: 'right' },
|
||
{ prop: 'order_count', label: '订单数量', minWidth: 100, align: 'right' },
|
||
{ prop: 'processed_orders', label: '已处理订单', minWidth: 108, align: 'right' },
|
||
// { prop: 'item_detail_machine', label: '商品结构', minWidth: 320 },
|
||
// { prop: 'item_part_type', label: '商品类型', minWidth: 120 },
|
||
// { prop: 'item_part', label: '商品部位', minWidth: 220 },
|
||
{ prop: 'distinguish_express', label: '区分快递', minWidth: 100 },
|
||
{ prop: 'storage_assignment_status', label: '库位分配', minWidth: 120 },
|
||
{ prop: 'express_assignment_status', label: '快递分配', minWidth: 120 },
|
||
{ prop: 'print_assignment_status', label: '打印状态', minWidth: 110 },
|
||
{ prop: 'logistics_name', label: '快递', minWidth: 120 },
|
||
{ prop: 'item_snapshot_key', label: '商品快照键', minWidth: 320 },
|
||
{ prop: 'creator', label: '创建人', minWidth: 100 },
|
||
{ prop: 'warehouse_id', label: '仓库ID', minWidth: 110 },
|
||
{ prop: 'create_time', label: '创建时间', minWidth: 168 },
|
||
{ prop: 'update_time', label: '更新时间', minWidth: 168 },
|
||
{ prop: 'operation', label: '操作', minWidth: 110, fixed: 'right' }
|
||
]
|
||
|
||
/** 列表查询 where 白名单(与 sanitizeWaveWhere 一致) */
|
||
export const waveWhereAllowedFieldList = [
|
||
'wave_id',
|
||
'wave_no',
|
||
'wave_type',
|
||
'wave_status',
|
||
'creator',
|
||
'logistics_name',
|
||
'item_part_type',
|
||
'item_part',
|
||
'item_snapshot_key',
|
||
'item_detail_machine',
|
||
'distinguish_express',
|
||
'storage_assignment_status',
|
||
'express_assignment_status',
|
||
'print_assignment_status',
|
||
'total_orders_min',
|
||
'total_orders_max',
|
||
'processed_orders_min',
|
||
'processed_orders_max',
|
||
'source'
|
||
] as const
|
||
|
||
export const waveWhereAllowedFields = new Set<string>(waveWhereAllowedFieldList)
|
||
|
||
/**
|
||
* 主工具栏按钮(action 与波次列表页内 toolbarActionMap 键一致)
|
||
*/
|
||
export const waveToolbarButtons: WaveToolbarButtonConfig[] = [
|
||
{ key: 'refresh', label: '刷新', type: 'primary', size: 'small', loadingKey: 'loading', action: 'loadData' },
|
||
{ key: 'columnConfig', label: '字段设置', size: 'small', action: 'openColumnConfigPanel' },
|
||
{
|
||
key: 'toggleDetail',
|
||
label: '显示详情',
|
||
dynamicLabelKey: 'detailToggleLabel',
|
||
size: 'small',
|
||
action: 'toggleDetailVisible'
|
||
},
|
||
{
|
||
key: 'batchPrint',
|
||
label: '批量打印(0)',
|
||
dynamicLabelKey: 'batchPrintTotal',
|
||
type: 'info',
|
||
size: 'small',
|
||
disabledKey: 'batchPrintDisabled',
|
||
loadingKey: 'batchPrintLoading',
|
||
action: 'handleBatchPrint',
|
||
onlyForWaveType: 1
|
||
},
|
||
{
|
||
key: 'batchAutoGrouping',
|
||
label: '批量改为自动加团',
|
||
type: 'warning',
|
||
size: 'small',
|
||
disabledKey: 'noSelection',
|
||
loadingKey: 'batchAutoGroupingLoading',
|
||
action: 'handleBatchAutoGrouping'
|
||
},
|
||
{
|
||
key: 'batchFinishAutoGrouping',
|
||
label: '批量结束自动加团',
|
||
type: 'success',
|
||
size: 'small',
|
||
disabledKey: 'noSelection',
|
||
loadingKey: 'batchFinishAutoGroupingLoading',
|
||
action: 'handleBatchFinishAutoGrouping'
|
||
},
|
||
{
|
||
key: 'batchCancel',
|
||
label: '批量取消波次',
|
||
type: 'danger',
|
||
size: 'small',
|
||
disabledKey: 'noSelection',
|
||
loadingKey: 'batchCancelLoading',
|
||
action: 'handleBatchCancel'
|
||
},
|
||
{
|
||
key: 'batchAllocateExpress',
|
||
label: '快速分配快递号',
|
||
type: 'success',
|
||
size: 'small',
|
||
disabledKey: 'noSelection',
|
||
loadingKey: 'batchAllocateExpressLoading',
|
||
action: 'handleBatchAllocateExpress'
|
||
},
|
||
{
|
||
key: 'batchAllocateStorage',
|
||
label: '批量分配储位',
|
||
type: 'primary',
|
||
plain: true,
|
||
size: 'small',
|
||
disabledKey: 'noSelection',
|
||
loadingKey: 'batchAllocateStorageLoading',
|
||
action: 'handleBatchAllocateStorage'
|
||
},
|
||
{
|
||
key: 'batchRemoveExceptionOrders',
|
||
label: '批量移除异常订单',
|
||
type: 'danger',
|
||
plain: true,
|
||
size: 'small',
|
||
disabledKey: 'noSelection',
|
||
loadingKey: 'batchRemoveExceptionOrdersLoading',
|
||
action: 'handleBatchRemoveExceptionOrders'
|
||
},
|
||
{
|
||
key: 'fetchGroupOrder',
|
||
label: '抓取团购单',
|
||
type: 'warning',
|
||
size: 'small',
|
||
action: 'openGroupOrderDialog',
|
||
onlyForWaveType: 1
|
||
},
|
||
{
|
||
key: 'fetchSingleOrder',
|
||
label: '抓取散单候选',
|
||
type: 'warning',
|
||
size: 'small',
|
||
action: 'openSingleOrderDialog',
|
||
onlyForWaveType: 2
|
||
}
|
||
]
|
||
|
||
export function getWaveToolbarButtons(waveType: 1 | 2): WaveToolbarButtonConfig[] {
|
||
return waveToolbarButtons.filter(
|
||
(b) => b.onlyForWaveType === undefined || b.onlyForWaveType === waveType
|
||
)
|
||
}
|
||
|
||
/** 异步任务状态文案 */
|
||
export const waveFetchTaskStatusTextMap: Record<string, string> = {
|
||
submitted: '已受理',
|
||
running: '进行中',
|
||
success: '成功',
|
||
failed: '失败',
|
||
not_found: '未找到'
|
||
}
|
||
|
||
/** 波次状态文案 */
|
||
export const waveStatusTextMap: Record<string, string> = {
|
||
'-1': '已取消',
|
||
'0': '自动加团中',
|
||
'1': '已就绪',
|
||
'2': '已打印',
|
||
'3': '拣货中',
|
||
'4': '拣货完成',
|
||
'5': '复核完成',
|
||
'6': '打包完成',
|
||
cancelled: '已取消',
|
||
pending: '自动加团中',
|
||
assigned: '已就绪'
|
||
}
|
||
|
||
/** 波次类型文案 */
|
||
export const waveTypeTextMap: Record<string, string> = {
|
||
'1': '团购',
|
||
'2': '散单'
|
||
}
|
||
|
||
/** 库位分配状态文案 */
|
||
export const waveStorageAssignmentStatusTextMap: Record<string, string> = {
|
||
none: '未分配',
|
||
no_error: '未分配',
|
||
pending: '处理中',
|
||
padding: '处理中',
|
||
processing: '处理中',
|
||
running: '处理中',
|
||
success: '已分配',
|
||
succeeded: '已分配',
|
||
fin: '已分配',
|
||
finished: '已分配',
|
||
done: '已分配',
|
||
completed: '已分配',
|
||
partial: '部分分配',
|
||
partial_failed: '部分分配',
|
||
error: '分配异常',
|
||
failed: '分配异常',
|
||
exception: '分配异常',
|
||
timeout: '处理超时',
|
||
not_found: '未找到'
|
||
}
|
||
|
||
/** 库位分配异常文案 */
|
||
export const waveStorageAssignmentErrorTextMap: Record<string, string> = {
|
||
none: '无',
|
||
no_error: '无',
|
||
no_exception: '无',
|
||
success: '无',
|
||
succeeded: '无',
|
||
fin: '无',
|
||
finished: '无',
|
||
done: '无',
|
||
completed: '无',
|
||
pending: '处理中',
|
||
padding: '处理中',
|
||
processing: '处理中',
|
||
running: '处理中',
|
||
error: '分配异常',
|
||
failed: '分配失败',
|
||
exception: '分配异常',
|
||
timeout: '处理超时',
|
||
not_found: '未找到',
|
||
partial: '部分异常',
|
||
partial_failed: '部分异常'
|
||
}
|
||
|
||
/** 库位分配异常短语翻译规则 */
|
||
export const waveStorageAssignmentErrorPhraseMap: Array<[RegExp, string]> = [
|
||
[/storage assignment/gi, '库位分配'],
|
||
[/assignment/gi, '分配'],
|
||
[/storage/gi, '库位'],
|
||
[/error/gi, '异常'],
|
||
[/failed/gi, '失败'],
|
||
[/exception/gi, '异常'],
|
||
[/timeout/gi, '超时'],
|
||
[/pending|padding|processing|running/gi, '处理中'],
|
||
[/partial/gi, '部分'],
|
||
[/not found/gi, '未找到'],
|
||
[/none|success|succeeded|finished|completed|done|fin/gi, '无']
|
||
]
|
||
|
||
/** 波次策略表单校验规则 */
|
||
export const waveStrategyFormRules = {
|
||
strategy_name: [{ required: true, message: '请输入策略名称', trigger: 'blur' }],
|
||
strategy_type: [{ required: true, message: '请输入策略类型', trigger: 'change' }],
|
||
batch_mode: [{ required: true, message: '请输入批次模式', trigger: 'change' }]
|
||
}
|
||
|
||
/** 波次策略状态选项 */
|
||
export const waveStrategyStatusOptions = [
|
||
{ label: '禁用', value: 0 },
|
||
{ label: '启用', value: 1 }
|
||
]
|
||
|
||
/** 通用布尔选项 */
|
||
export const waveBooleanOptions = [
|
||
{ label: '是', value: true },
|
||
{ label: '否', value: false }
|
||
]
|