import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config' /** 工具栏按钮:可限定仅在对应波次页签显示(1 团购 / 2 散单) */ export type WaveToolbarButtonConfig = ToolbarButtonConfig & { onlyForWaveType?: 1 | 2 } /** ScanBox 默认 props(全站 scan-box 侧栏宽度统一为 250px) */ export const waveScanBoxConfig = { width: '250px', 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: '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: '未分配' }, { label: '部分分配', value: '部分分配' }, { label: '已分配', value: '已分配' }, ]}, { label:'打印状态', value: 'print_assignment_status', type: 'select', options: [ { label: '未打印', value: '未打印' }, { label: '部分打印', value: '部分打印' }, { label: '已打印', value: '已打印' }, ]}, { 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: '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(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: 'batchPrintPickingList', label: '批量打印拣货单(0)', dynamicLabelKey: 'batchPickingPrintTotal', type: 'info', plain: true, size: 'small', disabledKey: 'noSelection', loadingKey: 'batchPrintLoading', action: 'handleBatchPrintPickingList', 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 = { submitted: '已受理', running: '进行中', success: '成功', failed: '失败', not_found: '未找到' } /** 波次状态文案 */ export const waveStatusTextMap: Record = { '-1': '已取消', '0': '自动加团中', '1': '已就绪', '2': '已打印', '3': '拣货中', '4': '拣货完成', '5': '复核完成', '6': '打包完成', cancelled: '已取消', pending: '自动加团中', assigned: '已就绪' } /** 波次类型文案 */ export const waveTypeTextMap: Record = { '1': '团购', '2': '散单' } /** 库位分配状态文案 */ export const waveStorageAssignmentStatusTextMap: Record = { 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 = { 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 } ] // --------------------------------------------------------------------------- // 拣货中任务页(pickTaskWave):与散单页共用 waveScanBoxConfig;筛选字段见 pickTaskWaveAvailableFields // --------------------------------------------------------------------------- /** 列表与工具栏文案 */ export const pickTaskWaveListDefaults = { toolbarHint: '当前仓库拣货任务(order.wave.wavePickTaskList)', listTitle: '拣货任务列表', emptyText: '暂无拣货任务', loadingEmptyText: '加载中...', loadFailedEmptyText: '加载失败', noWarehouseEmptyText: '未获取到仓库ID' } /** 分页与详情弹窗 */ export const pickTaskWavePaginationDefaults = { pageSizes: [20, 50, 100, 200] as const, layout: 'total, sizes, prev, pager, next, jumper' as const, initialPageSize: 20 } /** 供模板 :page-sizes 绑定(避免 readonly 元组在模板中的类型问题) */ export const pickTaskWavePaginationPageSizes = [20, 50, 100, 200] export const pickTaskWaveDetailDialogDefaults = { title: '拣货任务详情', width: '920px' } export type PickTaskWaveToolbarKey = 'search' | 'detailQuery' | 'batchCancel' | 'refresh' export type PickTaskWaveToolbarButton = { key: PickTaskWaveToolbarKey label: string type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' plain?: boolean size?: 'small' | 'default' | 'large' } /** 工具栏按钮顺序与类型(与散单页工具条同一套间距/滚动行为) */ export const pickTaskWaveToolbarButtons: PickTaskWaveToolbarButton[] = [ { key: 'search', label: '查询', type: 'primary', size: 'small' }, { key: 'detailQuery', label: '按任务ID查详情', size: 'small' }, { key: 'batchCancel', label: '批量取消任务', type: 'danger', size: 'small' }, { key: 'refresh', label: '刷新', size: 'small' } ] /** 左侧筛选字段(与 order.wave.wavePickTaskList 入参对应) */ export const pickTaskWaveAvailableFields = [ { label: '任务编号', value: 'task_no', type: 'text' }, // { label: '关键字', value: 'keyword', type: 'text' }, { label: '任务状态', value: 'status', type: 'multiple', options: [ { label: '待开始', value: 0 }, { label: '拣货中', value: 1 }, { label: '待复核', value: 2 }, { label: '已完成', value: 3 }, { label: '已取消', value: 9 } ] }, { label: '复核状态', value: 'review_status', type: 'select', options: [ { label: '未就绪', value: 0 }, { label: '待复核', value: 1 }, { label: '复核中', value: 2 }, { label: '复核通过', value: 3 }, { label: '复核异常', value: 4 } ] }, { label: '拣货模式', value: 'pick_mode', type: 'select', options: [ { label: '小团购', value: 1 }, { label: '单品单件', value: 2 }, { label: '先拣后分', value: 3 }, { label: '边拣边分', value: 4 }, { label: '大团购', value: 5 } ] }, { label: '来源', value: 'source', type: 'select', options: [ { label: '默认', value: 0 }, { label: 'PDA', value: 1 }, { label: '后台', value: 2 } ] }, { label: '拣货员ID', value: 'pick_user_id', type: 'number' }, { label: '复核人ID', value: 'review_user_id', type: 'number' }, { label: '拣货车ID', value: 'cart_id', type: 'number' }, { label: '开始时间', value: 'start_time_range', type: 'daterange' } ] export function formatPickTaskStatus(value: unknown): string { const num = Number(value) if (num === 0) return '待开始' if (num === 1) return '拣货中' if (num === 2) return '待复核' if (num === 3) return '已完成' if (num === 9) return '已取消' return value === null || value === undefined || value === '' ? '-' : String(value) } export function formatPickTaskReviewStatus(value: unknown): string { const num = Number(value) if (num === 0) return '未就绪' if (num === 1) return '待复核' if (num === 2) return '复核中' if (num === 3) return '复核通过' if (num === 4) return '复核异常' return value === null || value === undefined || value === '' ? '-' : String(value) } export function formatPickTaskPickMode(value: unknown): string { const num = Number(value) if (num === 1) return '小团购' if (num === 2) return '单品单件' if (num === 3) return '先拣后分' if (num === 4) return '边拣边分' if (num === 5) return '大团购' return value === null || value === undefined || value === '' ? '-' : String(value) } export function formatPickTaskSource(value: unknown): string { const num = Number(value) if (num === 0) return '默认' if (num === 1) return 'PDA' if (num === 2) return '后台' return value === null || value === undefined || value === '' ? '-' : String(value) } export function getPickTaskStatusTagType(value: unknown): 'info' | 'warning' | 'success' | 'danger' { const num = Number(value) if (num === 0) return 'info' if (num === 1) return 'warning' if (num === 2) return 'danger' if (num === 3) return 'success' if (num === 9) return 'info' return 'info' } export function getPickTaskReviewStatusTagType(value: unknown): 'info' | 'warning' | 'success' | 'danger' { const num = Number(value) if (num === 0) return 'info' if (num === 1) return 'warning' if (num === 2) return 'warning' if (num === 3) return 'success' if (num === 4) return 'danger' return 'info' } export function getPickTaskSourceTagType(value: unknown): 'info' | 'success' { const num = Number(value) if (num === 1) return 'success' return 'info' }