WEB/src/views/express/waybill/config/template-config.ts
2026-08-16 18:11:37 +08:00

1015 lines
30 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.

/**
* 【运单模块(仓库侧)】配置文件 — 基于 waveOrder2 架构设计
*
* ===== 数据来源 =====
* API: src/api/waybill.warehouse/index.ts
* - waybillWarehouseList → waybill.warehouse.list 运单列表
* - waybillWarehouseDetail → waybill.warehouse.detail 运单详情
* - waybillWarehouseExport → waybill.warehouse.export 运单导出
*/
import type { Component } from 'vue'
import DetailPanel from './components/DetailPanel.vue'
import LogPanel from './components/LogPanel.vue'
import {
waybillWarehouseList,
waybillWarehouseExport,
waybillWarehouseExportTaskProgress,
} from '@/api/waybill.warehouse'
// ============================================================
// 〇、全局页面配置
// ============================================================
export const PAGE_CONFIG = {
showTabArea: false,
singlePage: true,
enableDetailPanel: true
}
// ============================================================
// 〇-A、组件注册表
// ============================================================
export const COMPONENT_REGISTRY: Record<string, Component> = {
DetailPanel,
LogPanel
}
// ============================================================
// 〇-B、SCANBOX_GROUPS
// ============================================================
export const SCANBOX_GROUPS = {
basic: '基础信息',
logistics: '物流信息',
status: '状态筛选',
time: '时间范围'
} as const
// ============================================================
// 一、FIELD_DICT — 运单字段预设表
// ============================================================
export interface FieldDefinition {
key: string
label: string
scanBox: {
type: 'text' | 'select' | 'daterange' | 'number'
group?: string
options?: { label: string; value: any }[]
multiple?: boolean
filterable?: boolean
} | null
table: {
minWidth?: number
width?: number
fixed?: 'left' | 'right' | boolean
align?: 'left' | 'center' | 'right'
sortable?: boolean
showOverflowTooltip?: boolean
copyAction?: 'copy' | 'copyQr'
copyValue?: (row: any) => any
} | null
slot: {
type: 'tag' | 'text' | 'default' | 'operation'
tagType?: string | Record<string, string>
tagResolver?: string
translateField?: string
format?: 'datetime'
} | null
detailLabel?: string
filterParamMap?: Record<string, string>
}
// ============================================================
// VALUE_MAPS — 值翻译映射
// ============================================================
export const VALUE_MAPS: Record<string, Record<string, string>> = {
waybillStatus: {
'0': '未分配', '1': '已分配',
'未分配': '未分配', '已分配': '已分配'
},
waybillType: {
'1': '主单号', '2': '子单号',
'main': '主单号', 'child': '子单号'
},
yesNo: {
'Y': '是', 'N': '否',
'是': '是', '否': '否'
},
bool: {
'1': '是', '0': '否',
'是': '是', '否': '否',
'true': '是', 'false': '否'
},
packStatus: {
'未打包': '未打包', '已打包': '已打包', '打包中': '打包中'
}
}
export function getOptions(field: string): { label: string; value: string }[] {
const map = VALUE_MAPS[field]
if (!map) return []
const seen = new Set<string>()
const opts: { label: string; value: string }[] = []
const chineseKeys: [string, string][] = []
const otherKeys: [string, string][] = []
for (const [v, l] of Object.entries(map)) {
if (/^[\u4e00-\u9fa5]/.test(v)) {
chineseKeys.push([v, l])
} else {
otherKeys.push([v, l])
}
}
for (const [v, l] of [...chineseKeys, ...otherKeys]) {
if (!seen.has(l)) {
seen.add(l)
opts.push({ label: l, value: v })
}
}
return opts
}
export function translate(field: string, value: any): string {
const map = VALUE_MAPS[field]
if (!map) return String(value ?? '—')
return map[String(value)] ?? String(value ?? '—')
}
export function formatTime(value: any): string {
if (!value) return '—'
try {
const d = new Date(value)
if (isNaN(d.getTime())) return String(value)
const pad = (n: number) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
} catch {
return String(value)
}
}
// ============================================================
// TAG_RESOLVERS — 标签颜色解析器
// ============================================================
export const TAG_RESOLVERS: Record<string, (val: any) => string> = {
resolveWaybillStatusTag(v) {
if (v === undefined || v === null) return 'info'
const s = String(v)
if (s === '1' || s === '已分配') return 'success'
return 'info'
},
resolveYesNoTag(v) {
if (v === undefined || v === null) return 'info'
if (v === 'Y' || v === '是' || v === true || v === 1 || v === '1') return 'warning'
return 'info'
},
resolveWaybillTypeTag(v) {
if (v === undefined || v === null) return 'info'
if (v === '主单号') return 'primary'
if (v === '子单号') return 'warning'
return 'info'
},
resolvePackStatusTag(v) {
if (v === undefined || v === null) return 'info'
if (v === '已打包') return 'success'
if (v === '打包中') return 'warning'
return 'info'
}
}
// ============================================================
// 二、FIELD_DICT 实例 — 运单字段定义
// ============================================================
export const FIELD_DICT: Record<string, FieldDefinition> = {
// —— 基础信息 ——
waybill_code: {
key: 'waybill_code',
label: '运单号',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 170, fixed: 'left', copyAction: 'copy', showOverflowTooltip: true },
slot: null,
detailLabel: '运单号'
},
main_waybill_code: {
key: 'main_waybill_code',
label: '主单号',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 170, copyAction: 'copy', showOverflowTooltip: true },
slot: null,
detailLabel: '主单号'
},
waybill_type: {
key: 'waybill_type',
label: '运单类型',
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('waybillType') },
table: { minWidth: 90, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveWaybillTypeTag', translateField: 'waybillType' },
detailLabel: '运单类型'
},
order_no: {
key: 'order_no',
label: '订单号',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 160, copyAction: 'copy', showOverflowTooltip: true },
slot: null,
detailLabel: '订单号'
},
order_id: {
key: 'order_id',
label: '订单ID',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 90, align: 'center', copyAction: 'copy' },
slot: null,
detailLabel: '订单ID'
},
source_order_codes: {
key: 'source_order_codes',
label: '平台交易单号',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 160, copyAction: 'copy', showOverflowTooltip: true },
slot: null,
detailLabel: '平台交易单号'
},
keyword: {
key: 'keyword',
label: '关键词',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: null,
slot: null
},
business_key: {
key: 'business_key',
label: '业务键',
scanBox: null,
table: { minWidth: 80, align: 'center' },
slot: null,
detailLabel: '业务键'
},
warehouse_name: {
key: 'warehouse_name',
label: '仓库',
scanBox: null,
table: { minWidth: 120, showOverflowTooltip: true },
slot: null,
detailLabel: '仓库名称'
},
store_name: {
key: 'store_name',
label: '货主',
scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: [], multiple: true, filterable: true },
table: { minWidth: 120, showOverflowTooltip: true },
slot: null,
detailLabel: '货主名称'
},
store_remark_name: {
key: 'store_remark_name',
label: '货主备注',
scanBox: null,
table: { minWidth: 120, showOverflowTooltip: true },
slot: null,
detailLabel: '货主备注名'
},
order_type: {
key: 'order_type',
label: '订单类型',
scanBox: null,
table: null,
slot: null,
detailLabel: '订单类型'
},
wave_no: {
key: 'wave_no',
label: '波次号',
scanBox: null,
table: null,
slot: null,
detailLabel: '波次号'
},
pack_quantity: {
key: 'pack_quantity',
label: '打包数量',
scanBox: null,
table: null,
slot: null,
detailLabel: '打包数量'
},
pack_at: {
key: 'pack_at',
label: '打包时间',
scanBox: null,
table: null,
slot: { type: 'text', format: 'datetime' },
detailLabel: '打包时间'
},
packer_name: {
key: 'packer_name',
label: '打包人',
scanBox: null,
table: null,
slot: null,
detailLabel: '打包人'
},
// —— 物流信息 ——
logistics_code: {
key: 'logistics_code',
label: '物流编码',
scanBox: { type: 'select', group: SCANBOX_GROUPS.logistics, options: [] },
table: { minWidth: 100, align: 'center' },
slot: null,
detailLabel: '物流公司编码'
},
logistics_name: {
key: 'logistics_name',
label: '物流公司',
scanBox: null,
table: { minWidth: 120, showOverflowTooltip: true },
slot: null,
detailLabel: '物流公司'
},
logistics_interface_id: {
key: 'logistics_interface_id',
label: '物流接口ID',
scanBox: { type: 'text', group: SCANBOX_GROUPS.logistics },
table: { minWidth: 110, align: 'center' },
slot: null,
detailLabel: '物流接口ID'
},
logistics_interface_name: {
key: 'logistics_interface_name',
label: '物流接口',
scanBox: null,
table: { minWidth: 120, showOverflowTooltip: true },
slot: null,
detailLabel: '物流接口'
},
platform_code: {
key: 'platform_code',
label: '平台',
scanBox: { type: 'select', group: SCANBOX_GROUPS.logistics, options: [] },
table: { minWidth: 90, align: 'center' },
slot: null,
detailLabel: '平台编码'
},
// —— 包裹信息 ——
package_material_id: {
key: 'package_material_id',
label: '包材ID',
scanBox: { type: 'text', group: SCANBOX_GROUPS.basic },
table: { minWidth: 90, align: 'center' },
slot: null,
detailLabel: '包材ID'
},
package_material_name: {
key: 'package_material_name',
label: '包材名称',
scanBox: null,
table: { minWidth: 110, showOverflowTooltip: true },
slot: null,
detailLabel: '包材名称'
},
pack_status: {
key: 'pack_status',
label: '打包状态',
scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('packStatus') },
table: { minWidth: 90, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolvePackStatusTag', translateField: 'packStatus' },
detailLabel: '打包状态'
},
// —— 状态信息 ——
status: {
key: 'status',
label: '运单状态',
scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('waybillStatus') },
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveWaybillStatusTag', translateField: 'waybillStatus' },
detailLabel: '运单状态',
filterParamMap: { '未分配': '0', '已分配': '1' }
},
status_text: {
key: 'status_text',
label: '状态说明',
scanBox: null,
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveWaybillStatusTag', translateField: 'waybillStatus' },
detailLabel: '状态说明'
},
is_back: {
key: 'is_back',
label: '是否退回',
scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('yesNo') },
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveYesNoTag', translateField: 'yesNo' },
detailLabel: '是否退回'
},
is_intercept: {
key: 'is_intercept',
label: '是否拦截',
scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('yesNo') },
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveYesNoTag', translateField: 'yesNo' },
detailLabel: '是否拦截'
},
is_galaxy_receive: {
key: 'is_galaxy_receive',
label: '揽收',
scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('yesNo') },
table: { minWidth: 100, align: 'center' },
slot: { type: 'tag', tagResolver: 'resolveYesNoTag', translateField: 'yesNo' },
detailLabel: '是否揽收'
},
// —— 重量与打印 ——
weighing_weight: {
key: 'weighing_weight',
label: '称重(g)',
scanBox: null,
table: { minWidth: 90, align: 'center', sortable: true },
slot: null,
detailLabel: '称重重量(g)'
},
weighing_weight_display: {
key: 'weighing_weight_display',
label: '称重',
scanBox: null,
table: { minWidth: 100, align: 'center' },
slot: null,
detailLabel: '称重重量'
},
hasWeighingWeight: {
key: 'hasWeighingWeight',
label: '是否已称重',
scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('bool') },
table: null,
slot: null
},
print_count: {
key: 'print_count',
label: '打印次数',
scanBox: null,
table: { minWidth: 90, align: 'center', sortable: true },
slot: null,
detailLabel: '打印次数'
},
last_print_at: {
key: 'last_print_at',
label: '最后打印',
scanBox: null,
table: { minWidth: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '最后打印时间'
},
// —— 时间信息 ——
create_at: {
key: 'create_at',
label: '创建时间',
scanBox: null,
table: { minWidth: 170, sortable: true },
slot: { type: 'text', format: 'datetime' },
detailLabel: '创建时间'
},
createdAtStart: {
key: 'createdAtStart',
label: '创建时间',
scanBox: { type: 'datetimerange', group: SCANBOX_GROUPS.time },
table: null,
slot: null
},
// —— 操作列 ——
// operation: {
// key: 'operation',
// label: '操作',
// scanBox: null,
// table: { minWidth: 120, fixed: 'right', align: 'center' },
// slot: { type: 'operation' }
// }
}
// ============================================================
// 三、ColumnSlotConfig / OperationButtonConfig / Detail 类型
// ============================================================
export interface ColumnSlotConfig {
type: 'tag' | 'text' | 'default' | 'operation'
tagType?: string | Record<string, string>
tagResolver?: string
translateField?: string
format?: 'datetime'
}
export interface OperationButtonConfig {
key: string
label: string
type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | ''
actionType: 'form' | 'action'
formKey?: string
formTitle?: string
formWidth?: string
paramMap?: Record<string, string>
extraParams?: Record<string, any>
disabledOnField?: string
confirmMessage?: string
confirmTitle?: string
confirmType?: 'warning' | 'danger' | 'info'
confirmButtonText?: string
}
export interface DetailFieldConfig {
key: string
label?: string
span?: number
renderType?: 'text' | 'tag' | 'pre'
tagType?: string | Record<string, string>
tagResolver?: string
translateField?: string
}
export interface DetailSectionConfig {
title: string
columnCount: number
fields: DetailFieldConfig[]
}
export interface DetailTabConfig {
name: string
label: string
componentKey: string
component?: Component
}
// ============================================================
// 四、TabPageApiConfig
// ============================================================
export type ApiMethod = (...args: any[]) => Promise<any>
export type ApiSource = 'api' | 'list'
export type ComponentApiConfig = { source: 'list' } | ApiMethod
export interface TabPageApiConfig {
list: ApiMethod
detail?: ComponentApiConfig
log?: ComponentApiConfig
export?: ApiMethod
exportProgress?: ApiMethod
scanBoxOptions?: Record<string, ApiMethod>
toolbar?: Record<string, ApiMethod>
parseListResponse?: (res: any) => { list: any[]; total: number }
buildListParams?: (params: {
pagination: { page: number; pageSize: number }
conditions: Record<string, any>
sort?: { prop: string; order: string }
}) => Record<string, any>
}
// ============================================================
// 五、TabPageRawConfig / TabPageConfig
// ============================================================
export interface TabPageRawConfig {
name: string
label: string
scanBoxCacheKey: string
scanBoxFieldKeys: string[]
tableColumnKeys: string[]
upperTableDefaults: {
title: string
enableColumnConfig?: boolean
showIndex?: boolean
showSelection?: boolean
emptyText?: string
}
detailTabs?: { name: string; label: string; componentKey: string }[]
detailSections: {
title: string
columnCount: number
fieldKeys: string[]
}[]
api?: TabPageApiConfig
operationButtons?: OperationButtonConfig[]
}
export interface TabPageConfig {
name: string
label: string
scanBoxCacheKey: string
scanBoxFields: Record<string, any>[]
upperTable: {
title: string
enableColumnConfig: boolean
showIndex: boolean
showSelection: boolean
emptyText: string
columns: Record<string, any>[]
}
columnSlots: Record<string, ColumnSlotConfig>
detailConfig: DetailSectionConfig[]
detailTabs: DetailTabConfig[]
api?: TabPageApiConfig
operationButtons?: OperationButtonConfig[]
}
// ============================================================
// 六、resolveTabConfig
// ============================================================
export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig {
const scanBoxFields: Record<string, any>[] = []
for (const key of raw.scanBoxFieldKeys) {
const def = FIELD_DICT[key]
if (!def || !def.scanBox) continue
scanBoxFields.push({
label: def.label,
value: def.key,
type: def.scanBox.type,
options: def.scanBox.options ? [...def.scanBox.options] : undefined,
group: def.scanBox.group,
multiple: def.scanBox.multiple,
filterable: def.scanBox.filterable,
required: (def.scanBox as any).required
})
}
const columns: Record<string, any>[] = []
for (const key of raw.tableColumnKeys) {
const def = FIELD_DICT[key]
if (!def || !def.table) continue
columns.push({
prop: def.key,
label: def.label,
...def.table
})
}
const columnSlots: Record<string, ColumnSlotConfig> = {}
for (const key of raw.tableColumnKeys) {
const def = FIELD_DICT[key]
if (!def || !def.slot) continue
columnSlots[def.key] = { ...def.slot }
}
const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({
title: sec.title,
columnCount: sec.columnCount,
fields: sec.fieldKeys
.map((key): DetailFieldConfig | null => {
const def = FIELD_DICT[key]
if (!def) return null
return {
key: def.key,
label: def.detailLabel ?? def.label,
translateField: def.slot?.translateField,
tagResolver: def.slot?.tagResolver,
tagType: def.slot?.tagType,
renderType: def.slot?.type === 'tag' ? 'tag' : 'text'
}
})
.filter((f): f is DetailFieldConfig => f !== null)
}))
const detailTabs: DetailTabConfig[] = raw.detailTabs
? raw.detailTabs.map((tab) => ({
name: tab.name,
label: tab.label,
componentKey: tab.componentKey,
component: COMPONENT_REGISTRY[tab.componentKey]
}))
: [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }]
return {
name: raw.name,
label: raw.label,
scanBoxCacheKey: raw.scanBoxCacheKey,
scanBoxFields,
upperTable: {
title: raw.upperTableDefaults.title,
enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true,
showIndex: raw.upperTableDefaults.showIndex ?? true,
showSelection: raw.upperTableDefaults.showSelection ?? true,
emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据',
columns
},
columnSlots,
detailConfig,
detailTabs,
api: raw.api,
operationButtons: raw.operationButtons
}
}
// ============================================================
// 七、buildWhereConditions(对齐 waybill.warehouse.list 接口文档)
// ============================================================
/** ScanBox 字段 key → API where 字段名(snake_case → camelCase) */
const WHERE_FIELD_MAP: Record<string, string> = {
waybill_code: 'waybillCode',
main_waybill_code: 'mainWaybillCode',
order_no: 'orderNo',
order_id: 'orderId',
store_name: 'storeId',
logistics_code: 'logisticsCode',
logistics_interface_id: 'logisticsInterfaceId',
platform_code: 'platformCode',
is_back: 'isBack',
is_intercept: 'isIntercept',
is_galaxy_receive: 'isGalaxyReceive',
package_material_id: 'packageMaterialId',
waybill_type: 'waybillType',
}
/** API where 字段期望类型(用于值类型转换) */
const WHERE_FIELD_TYPE: Record<string, 'string' | 'number' | 'boolean'> = {
orderId: 'number',
storeId: 'number',
logisticsInterfaceId: 'number',
packageMaterialId: 'number',
status: 'number',
hasWeighingWeight: 'boolean',
}
/** 将 ScanBox 值转换为 API 期望类型 */
function coerceValue(value: any, apiKey: string): any {
const targetType = WHERE_FIELD_TYPE[apiKey]
if (!targetType) return value
if (targetType === 'number') {
if (Array.isArray(value)) return value.map((v: any) => Number(v))
return Number(value)
}
if (targetType === 'boolean') {
if (Array.isArray(value)) return value.map((v: any) => v === 'true' || v === '1' || v === true || v === 1)
return value === 'true' || value === '1' || value === true || value === 1
}
return value
}
export function buildWhereConditions(rawConditions: Record<string, any>): Record<string, any> {
const where: Record<string, any> = {}
for (const [key, cond] of Object.entries(rawConditions || {})) {
// 从 ScanBox 结构化条件 { value, operator, field, type, isMultiple } 中提取值
let value: any
if (cond && typeof cond === 'object' && !Array.isArray(cond) && 'operator' in cond) {
if (['isnull', 'isnotnull'].includes(cond.operator)) continue
value = cond.value
} else {
value = cond
}
// 跳过空值
if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
continue
}
// createdAtStart 日期时间范围 → where.createdAt = { operator: 'between', value: [start, end] }
if (key === 'createdAtStart' && Array.isArray(value)) {
const [start, end] = value
if (start && end) {
where.createdAt = { operator: 'between', value: [start, end] }
}
continue
}
// 字段名映射(snake_case → camelCase)
const apiKey = WHERE_FIELD_MAP[key] || key
// 类型转换(对齐 API 参数类型:number / boolean)
value = coerceValue(value, apiKey)
// filterParamMap 值映射(仅单值)
const def = FIELD_DICT[key]
if (def?.filterParamMap && !Array.isArray(value)) {
const mapped = def.filterParamMap[String(value)]
if (mapped !== undefined) {
where[apiKey] = mapped
continue
}
}
// 扁平传值(string / number / boolean / array)
where[apiKey] = value
}
return where
}
// ============================================================
// 八、工具栏按钮系统
// ============================================================
export interface ToolbarButtonConfig {
key: string
label: string
category: 'common' | 'function' | 'basic'
size?: '' | 'default' | 'small' | 'large'
type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger'
plain?: boolean
loadingKey?: string
disabledKey?: string
action: string
dynamicLabelKey?: string
onlyForTabs?: string[]
buttonType?: 'default' | 'dropdown'
dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }>
formKey?: string
}
export const TOOLBAR_BUTTONS: Record<string, ToolbarButtonConfig> = {
refresh: {
key: 'refresh',
label: '刷新',
category: 'common',
type: 'primary',
size: 'small',
loadingKey: 'loading',
action: 'loadData'
},
export: {
key: 'export',
label: '导出',
category: 'common',
size: 'small',
loadingKey: 'exportLoading',
action: 'handleExportSelected',
buttonType: 'dropdown',
dropdownOptions: [
{ label: '导出选中', action: 'handleExportSelected' },
{ label: '导出全部', action: 'handleExportAll', divided: true }
]
},
columnConfig: {
key: 'columnConfig',
label: '字段设置',
category: 'basic',
size: 'small',
action: 'openColumnConfigPanel'
},
toggleDetail: {
key: 'toggleDetail',
label: '显示详情',
category: 'basic',
dynamicLabelKey: 'detailToggleLabel',
size: 'small',
action: 'toggleDetailVisible'
}
}
export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] {
return Object.values(TOOLBAR_BUTTONS).filter((btn) => {
if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false
if (!PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false
return true
})
}
// ============================================================
// 九、tabPages — 运单列表标签页
// ============================================================
export const tabPages: TabPageRawConfig[] = [
{
name: 'waybill-list',
label: '运单列表',
scanBoxCacheKey: 'waybill-warehouse-list',
scanBoxFieldKeys: [
'waybill_code',
'main_waybill_code',
'keyword',
'waybill_type',
'order_no',
'order_id',
'store_name',
'logistics_code',
'logistics_interface_id',
'platform_code',
'status',
'package_material_id',
'hasWeighingWeight',
'is_back',
'is_intercept',
'is_galaxy_receive',
'createdAtStart'
],
tableColumnKeys: [
'waybill_code',
'main_waybill_code',
'waybill_type',
'order_no',
'order_id',
'source_order_codes',
'business_key',
'warehouse_name',
'store_remark_name',
'logistics_code',
'logistics_name',
'logistics_interface_name',
'platform_code',
'package_material_name',
'status',
'status_text',
'is_back',
'is_intercept',
'is_galaxy_receive',
'weighing_weight',
'weighing_weight_display',
'print_count',
'last_print_at',
'create_at',
'operation'
],
upperTableDefaults: {
title: '运单列表(仓库侧)',
showSelection: true
},
detailTabs: [
{ name: 'detail', label: '运单明细', componentKey: 'DetailPanel' }
],
detailSections: [
{
title: '运单基础信息',
columnCount: 3,
fieldKeys: [
'waybill_code', 'main_waybill_code', 'waybill_type',
'order_id', 'order_no', 'business_key',
'order_type', 'wave_no'
]
},
{
title: '仓库/货主',
columnCount: 2,
fieldKeys: ['warehouse_name', 'store_name']
},
{
title: '物流信息',
columnCount: 3,
fieldKeys: [
'logistics_code', 'logistics_name', 'logistics_interface_id',
'logistics_interface_name', 'platform_code'
]
},
{
title: '包裹信息',
columnCount: 3,
fieldKeys: [
'package_material_id', 'package_material_name', 'pack_status',
'pack_quantity', 'pack_at', 'packer_name'
]
},
{
title: '重量与打印',
columnCount: 3,
fieldKeys: [
'weighing_weight', 'weighing_weight_display',
'print_count', 'last_print_at'
]
},
{
title: '运单状态',
columnCount: 3,
fieldKeys: [
'status', 'status_text', 'is_back',
'is_intercept', 'is_galaxy_receive'
]
},
{
title: '时间信息',
columnCount: 2,
fieldKeys: ['create_at']
}
],
api: {
list: waybillWarehouseList as ApiMethod,
detail: { source: 'list' } as ComponentApiConfig,
export: waybillWarehouseExport as ApiMethod,
exportProgress: waybillWarehouseExportTaskProgress as ApiMethod,
parseListResponse(res: any) {
const data = res?.data ?? res
return {
list: data?.list ?? data?.data ?? [],
total: data?.pagination?.total ?? data?.total ?? 0
}
},
buildListParams({ pagination, conditions, sort }) {
const where = buildWhereConditions(conditions)
const params: Record<string, any> = {
pagination: { page: pagination.page, pageSize: pagination.pageSize },
where
}
if (sort?.prop) {
params.sort = {
field: sort.prop,
order: sort.order === 'ascending' ? 'asc' : 'desc'
}
}
return params
}
},
operationButtons: [
{
key: 'viewDetail',
label: '查看详情',
actionType: 'action',
type: 'primary'
}
]
}
]
// ============================================================
// 十、向后兼容导出
// ============================================================
export const templateTabs = tabPages.map((t) => ({
name: t.name,
label: t.label,
scanBoxCacheKey: t.scanBoxCacheKey
}))