134 lines
6.3 KiB
TypeScript
134 lines
6.3 KiB
TypeScript
// status 实际值(接口存在拼写:pedding)
|
||
export const statusConfig: Record<string, { text: string; tagType: string }> = {
|
||
pedding: { text: '待出库', tagType: 'warning' },
|
||
pending: { text: '待出库', tagType: 'warning' },
|
||
processing: { text: '出库中', tagType: 'primary' },
|
||
completed: { text: '已完成', tagType: 'success' },
|
||
cancelled: { text: '已作废', tagType: 'danger' }
|
||
}
|
||
|
||
// sync_status 实际值(接口存在拼写:padding)
|
||
export const syncStatusConfig: Record<string, { text: string; tagType: string }> = {
|
||
padding: { text: '待同步', tagType: 'info' },
|
||
pending: { text: '待同步', tagType: 'info' },
|
||
success: { text: '同步成功', tagType: 'success' },
|
||
failed: { text: '同步失败', tagType: 'danger' }
|
||
}
|
||
|
||
// 时间格式化函数
|
||
export function formatDateTime(dateStr: string): string {
|
||
if (!dateStr) return '--'
|
||
try {
|
||
const date = new Date(dateStr)
|
||
if (isNaN(date.getTime())) return '--'
|
||
const year = date.getFullYear()
|
||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||
const day = String(date.getDate()).padStart(2, '0')
|
||
const hours = String(date.getHours()).padStart(2, '0')
|
||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||
} catch (e) {
|
||
return '--'
|
||
}
|
||
}
|
||
|
||
export const entryColums = [
|
||
{ prop: 'delivery_order_code', label: '出库单号', width: '180', fixed: 'left' },
|
||
{ prop: 'status', label: '出库状态', width: '100', align: 'center' },
|
||
{ prop: 'sync_status', label: '同步状态', width: '100', align: 'center' },
|
||
{ prop: 'order_type', label: '单据类型', width: '100' },
|
||
{ prop: 'source_platform_name', label: '来源平台', width: '110' },
|
||
{ prop: 'buyer_nick', label: '买家', width: '130' },
|
||
{ prop: 'name', label: '收货人', width: '100' },
|
||
{ prop: 'mobile', label: '联系电话', width: '130' },
|
||
{ prop: 'logistics_name', label: '物流公司', width: '130' },
|
||
{ prop: 'express_code', label: '运单号', width: '150' },
|
||
{ prop: 'items_count', label: '商品种类', width: '90', align: 'right' },
|
||
{ prop: 'items_total', label: '商品总数', width: '90', align: 'right' },
|
||
{ prop: 'place_order_time', label: '下单时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.place_order_time) },
|
||
{ prop: 'updated_at', label: '更新时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.updated_at) }
|
||
]
|
||
|
||
export const availableFields = [
|
||
{ value: 'delivery_order_code', label: '出库单号', type: 'text' },
|
||
{ value: 'status', label: '出库状态', type: 'select', options: [
|
||
{ value: 'pedding', label: '待出库' },
|
||
{ value: 'processing', label: '出库中' },
|
||
{ value: 'completed', label: '已完成' },
|
||
{ value: 'cancelled', label: '已作废' }
|
||
]},
|
||
{ value: 'sync_status', label: '同步状态', type: 'select', options: [
|
||
{ value: 'padding', label: '待同步' },
|
||
{ value: 'success', label: '同步成功' },
|
||
{ value: 'failed', label: '同步失败' }
|
||
]},
|
||
{ value: 'store_id', label: '货主', type: 'select', multiple: true, filterable: true, options: [] },
|
||
{ value: 'order_type', label: '单据类型', type: 'select', options: [
|
||
{ label: '交易出库', value: 'JYCK' },
|
||
{ label: '调拨出库', value: 'TRANSFER' },
|
||
{ label: '退货出库', value: 'RETURN' },
|
||
{ label: '其他出库', value: 'OTHER' }
|
||
]},
|
||
{ value: 'buyer_nick', label: '买家', type: 'text' },
|
||
{ value: 'mobile', label: '联系电话', type: 'text' },
|
||
{ value: 'logistics_code', label: '物流公司', type: 'text' },
|
||
{ value: 'express_code', label: '运单号', type: 'text' },
|
||
{ value: 'place_order_time', label: '下单时间', type: 'daterange', startPlaceholder: '开始时间', endPlaceholder: '结束时间' }
|
||
]
|
||
|
||
// 详情面板表单配置
|
||
export const detailpanel = [
|
||
{ prop: 'delivery_order_code', label: '出库单号', type: 'input', disabled: true },
|
||
{ prop: 'order_type', label: '单据类型', type: 'input', disabled: true },
|
||
{ prop: 'status', label: '出库状态', type: 'select', disabled: true },
|
||
{ prop: 'source_platform_name', label: '来源平台', type: 'input', disabled: true },
|
||
{ prop: 'buyer_nick', label: '买家', type: 'input', disabled: true },
|
||
{ prop: 'name', label: '收货人', type: 'input', disabled: true },
|
||
{ prop: 'mobile', label: '联系电话', type: 'input', disabled: true },
|
||
{ prop: 'logistics_name', label: '物流公司', type: 'input' },
|
||
{ prop: 'express_code', label: '运单号', type: 'input' },
|
||
{ prop: 'province', label: '省', type: 'input', disabled: true },
|
||
{ prop: 'city', label: '市', type: 'input', disabled: true },
|
||
{ prop: 'detail_address', label: '详细地址', type: 'input', disabled: true }
|
||
]
|
||
|
||
export const productColumns = [
|
||
{ prop: 'item_code', label: '商品编码', width: '150', fixed: 'left' },
|
||
{ prop: 'item_name', label: '商品名称', minWidth: '180' },
|
||
{ prop: 'sku_property', label: '规格', width: '120' },
|
||
{ prop: 'barcode', label: '条码', width: '140' },
|
||
{ prop: 'plan_qty', label: '计划数量', width: '100', align: 'right' },
|
||
{ prop: 'actual_qty', label: '实际出库', width: '100', align: 'right' },
|
||
{ prop: 'stock_unit', label: '单位', width: '80' },
|
||
{ prop: 'batch_no', label: '批次号', width: '130' },
|
||
{ prop: 'remark', label: '备注', minWidth: '120' }
|
||
]
|
||
|
||
export function formatStockoutListItems(list: any[] = []) {
|
||
return (list || []).map(item => {
|
||
const snap = item.item_snapshot || {}
|
||
return {
|
||
...item,
|
||
item_code: item.item_code || snap.item_code || '',
|
||
item_name: item.item_name || snap.item_name || '',
|
||
sku_property: item.sku_property ?? snap.sku_property ?? '',
|
||
barcode: item.barcode ?? snap.barcode ?? '',
|
||
stock_unit: item.stock_unit ?? snap.stock_unit ?? '',
|
||
actual_qty: item.actual_qty ?? item.actual_quantity ?? '',
|
||
batch_no: item.batch_no ?? '',
|
||
remark: item.remark ?? ''
|
||
}
|
||
})
|
||
}
|
||
|
||
export function formatStockoutData(list: any[] = []) {
|
||
return (list || []).map(item => ({
|
||
...item,
|
||
status: item.status || 'pedding',
|
||
sync_status: item.sync_status || 'padding',
|
||
// 接口返回 create_at,统一为 created_at
|
||
created_at: item.created_at || item.create_at
|
||
}))
|
||
}
|