150 lines
4.5 KiB
TypeScript
150 lines
4.5 KiB
TypeScript
import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config'
|
|
|
|
export function formatDateTime(dateStr: string | null | undefined): string {
|
|
if (!dateStr) return '—'
|
|
return String(dateStr).replace('T', ' ').slice(0, 19)
|
|
}
|
|
|
|
export const transactionTypeConfig: Record<string, { text: string; tagType: string }> = {
|
|
INBOUND: { text: '入库', tagType: 'success' },
|
|
OUTBOUND: { text: '出库', tagType: 'danger' },
|
|
LOCK: { text: '锁定', tagType: 'warning' },
|
|
UNLOCK: { text: '解锁', tagType: 'info' },
|
|
ADJUST: { text: '调整', tagType: 'primary' },
|
|
TRANSFER: { text: '移库', tagType: 'primary' }
|
|
}
|
|
|
|
export const orderTypeConfig: Record<string, string> = {
|
|
ORDER: '订单',
|
|
DELIVERY_ORDER: '出库单',
|
|
RECEIVING: '收货单',
|
|
ENTRY_ORDER: '入库单',
|
|
INVENTORY: '盘点单',
|
|
RETURN: '退货单'
|
|
}
|
|
|
|
export const columns = [
|
|
{ prop: 'created_at', label: '流水时间', width: 160, sortable: true },
|
|
{ prop: 'transaction_type', label: '流水类型', width: 90 },
|
|
{ prop: 'stock_id', label: '商品ID', width: 90 },
|
|
{ prop: 'store_id', label: '货主ID', width: 90 },
|
|
{ prop: 'warehouse_id', label: '仓库ID', width: 90 },
|
|
{ prop: 'quantity', label: '变动数量', width: 90 },
|
|
{ prop: 'before_quantity', label: '变动前库存', width: 100 },
|
|
{ prop: 'after_quantity', label: '变动后库存', width: 100 },
|
|
{ prop: 'before_locked_quantity', label: '变动前锁定', width: 100 },
|
|
{ prop: 'after_locked_quantity', label: '变动后锁定', width: 100 },
|
|
{ prop: 'batch_no', label: '批次号', minWidth: 110 },
|
|
{ prop: 'order_type', label: '订单类型', width: 100 },
|
|
{ prop: 'order_no', label: '订单号', minWidth: 160 },
|
|
{ prop: 'order_id', label: '订单ID', width: 90 },
|
|
{ prop: 'operator_name', label: '操作人', width: 90 },
|
|
{ prop: 'remark', label: '备注', minWidth: 140 }
|
|
]
|
|
|
|
/** 商品流水主工具栏按钮 */
|
|
export const productflowToolbarButtons: ToolbarButtonConfig[] = [
|
|
{ key: 'refresh', label: '刷新', type: 'primary', size: 'small', loadingKey: 'loading', action: 'loadList' },
|
|
{ key: 'columnConfig', label: '字段设置', size: 'small', action: 'openColumnConfigPanel' },
|
|
{
|
|
key: 'toggleDetail',
|
|
label: '显示详情',
|
|
dynamicLabelKey: 'detailToggleLabel',
|
|
size: 'small',
|
|
action: 'toggleDetailVisible'
|
|
}
|
|
]
|
|
|
|
export const availableFields = [
|
|
{
|
|
label: '商品ID',
|
|
value: 'stock_id',
|
|
type: 'number',
|
|
placeholder: '请输入商品ID',
|
|
operators: ['eq'],
|
|
defaultOperator: 'eq'
|
|
},
|
|
{
|
|
label: '订单号',
|
|
value: 'order_no',
|
|
type: 'text',
|
|
placeholder: '请输入订单号',
|
|
operators: ['contains', 'eq'],
|
|
defaultOperator: 'eq'
|
|
},
|
|
{
|
|
label: '批次号',
|
|
value: 'batch_no',
|
|
type: 'text',
|
|
placeholder: '请输入批次号',
|
|
operators: ['contains', 'eq'],
|
|
defaultOperator: 'eq'
|
|
},
|
|
{
|
|
label: '操作人',
|
|
value: 'operator_name',
|
|
type: 'text',
|
|
placeholder: '请输入操作人',
|
|
operators: ['eq', 'contains'],
|
|
defaultOperator: 'eq'
|
|
},
|
|
{
|
|
label: '货主',
|
|
value: 'store_id',
|
|
type: 'select',
|
|
multiple: true,
|
|
filterable: true,
|
|
options: [] as Array<{ label: string; value: unknown }>
|
|
},
|
|
{
|
|
label: '流水时间',
|
|
value: 'created_at',
|
|
type: 'date',
|
|
operators: ['between', 'eq', 'gt', 'lt'],
|
|
defaultOperator: 'between'
|
|
},
|
|
{
|
|
label: '流水类型',
|
|
value: 'transaction_type',
|
|
type: 'select',
|
|
options: Object.entries(transactionTypeConfig).map(([value, cfg]) => ({
|
|
label: cfg.text,
|
|
value
|
|
}))
|
|
},
|
|
{
|
|
label: '订单类型',
|
|
value: 'order_type',
|
|
type: 'select',
|
|
options: Object.entries(orderTypeConfig).map(([value, label]) => ({
|
|
label,
|
|
value
|
|
}))
|
|
}
|
|
]
|
|
|
|
export function getTransactionTypeLabel(type: string): string {
|
|
return transactionTypeConfig[type]?.text || type || '—'
|
|
}
|
|
|
|
export function getTransactionTypeTag(type: string): string {
|
|
return transactionTypeConfig[type]?.tagType || 'info'
|
|
}
|
|
|
|
export function getOrderTypeLabel(type: string): string {
|
|
return orderTypeConfig[type] || type || '—'
|
|
}
|
|
|
|
export function formatQuantityDelta(row: {
|
|
quantity?: number
|
|
before_quantity?: number
|
|
after_quantity?: number
|
|
transaction_type?: string
|
|
}): number | undefined {
|
|
if (row.quantity !== undefined && row.quantity !== null) return row.quantity
|
|
const before = row.before_quantity
|
|
const after = row.after_quantity
|
|
if (before === undefined || after === undefined) return undefined
|
|
return after - before
|
|
}
|