WEB/src/views/storage/receiving/receiving-config.ts
2026-03-20 09:03:44 +08:00

285 lines
11 KiB
TypeScript

export const statusConfig = {
receiving: { text: '收货中', tagType: 'warning' },
completed: { text: '已完成', tagType: 'success' },
cancelled: { text: '已作废', tagType: 'danger' }
}
export const detailStatusConfig = {
all_matched: { text: '全部匹配', tagType: 'success' },
partial_matched: { text: '部分匹配', tagType: 'warning' },
unmatched: { text: '未匹配', tagType: 'info' }
}
export const storageStatusConfig = {
all: { text: '全部入库', tagType: 'success' },
partial: { text: '部分入库', tagType: 'warning' },
none: { text: '未入库', tagType: 'info' }
}
export const deliveryMethodConfig: any = {
truck: { text: '货车', tagType: 'primary' },
express: { text: '快递', tagType: 'success' },
air_freight: { text: '空运', tagType: 'info' },
sea_freight: { text: '海运', tagType: 'warning' },
other: { text: '其他', tagType: '' }
}
export const loadingMethodConfig: any = {
with_pallet: { text: '带托盘', tagType: 'success' },
without_pallet: { text: '不带托盘', tagType: 'info' }
}
export const receivingColumns = [
{ prop: 'receiving_number', label: '收货单号', width: '160', fixed: 'left' },
{ prop: 'status', label: '收货状态', width: '100', align: 'center' },
{ prop: 'detail_status', label: '匹配状态', width: '100', align: 'center' },
{ prop: 'storage_status', label: '入库状态', width: '100', align: 'center' },
{ prop: 'store_name', label: '货主', width: '150' },
{ prop: 'creator_name', label: '创建人', width: '120' },
{ prop: 'delivery_method', label: '来货方式', width: '100', align: 'center' },
{ prop: 'loading_method', label: '装卸方式', width: '100', align: 'center' },
{ prop: 'license_plate', label: '车牌号', width: '120' },
{ prop: 'tracking_number', label: '物流单号', width: '180' },
{ prop: 'total_items', label: '商品种类', width: '100', align: 'right' },
{ prop: 'total_quantity', label: '总数量', width: '100', align: 'right' },
{ prop: 'total_boxes', label: '总箱数', width: '100', align: 'right' },
{ prop: 'total_pallets', label: '总托盘数', width: '100', align: 'right' },
{ prop: 'receiving_start_time', label: '收货开始', width: '150' },
{ prop: 'receiving_end_time', label: '收货结束', width: '150' },
{ prop: 'remark', label: '备注', minWidth: '150' },
{ prop: 'created_at', label: '创建时间', width: '160' },
{ prop: 'updated_at', label: '更新时间', width: '160' },
]
export const availableFields = [
{ value: 'receiving_number', label: '收货单号', type: 'text' },
{ value: 'status', label: '收货状态', type: 'select', options: Object.entries(statusConfig).map(([v, c]) => ({ value: v, label: c.text })) },
{ value: 'detail_status', label: '匹配状态', type: 'select', options: Object.entries(detailStatusConfig).map(([v, c]) => ({ value: v, label: c.text })) },
{ value: 'storage_status', label: '入库状态', type: 'select', options: Object.entries(storageStatusConfig).map(([v, c]) => ({ value: v, label: c.text })) },
{ value: 'store_id', label: '货主', type: 'select', filterable: true, options: [] },
{ value: 'delivery_method', label: '来货方式', type: 'select', options: Object.entries(deliveryMethodConfig).map(([v, c]: [string, any]) => ({ value: v, label: c.text })) },
{ value: 'loading_method',
label: '装卸方式',
type: 'select',
placeholder: '请选择装卸方式',
options: Object.entries(loadingMethodConfig).map(([value, config]: [string, any]) => ({
value,
label: (config as any).text
}))},
{
value: 'license_plate',
label: '车牌号',
type: 'text',
placeholder: '请输入车牌号',
operators: ['contains'],
defaultOperator: 'contains'
},
{
value: 'tracking_number',
label: '物流单号',
type: 'text',
placeholder: '请输入物流单号',
operators: ['contains'],
defaultOperator: 'contains'
},
// 数量范围筛选
{
value: 'total_items',
label: '商品种类',
type: 'number',
placeholder: '请输入商品种类数',
operators: ['eq', 'ne', 'gt', 'lt', 'ge', 'le', 'between'],
defaultOperator: 'ge'
},
{
value: 'total_quantity',
label: '总数量',
type: 'number',
placeholder: '请输入总数量',
operators: ['eq', 'ne', 'gt', 'lt', 'ge', 'le', 'between'],
defaultOperator: 'ge'
},
{
value: 'total_boxes',
label: '总箱数',
type: 'number',
placeholder: '请输入总箱数',
operators: ['eq', 'ne', 'gt', 'lt', 'ge', 'le', 'between'],
defaultOperator: 'ge'
},
{
value: 'total_pallets',
label: '总托盘数',
type: 'number',
placeholder: '请输入总托盘数',
operators: ['eq', 'ne', 'gt', 'lt', 'ge', 'le', 'between'],
defaultOperator: 'ge'
},
// 时间筛选
{
value: 'created_at',
label: '创建时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
},
{
value: 'updated_at',
label: '更新时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
},
{
value: 'receiving_start_time',
label: '收货开始时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
},
{
value: 'receiving_end_time',
label: '收货结束时间',
type: 'daterange',
startPlaceholder: '开始时间',
endPlaceholder: '结束时间'
},
// 创建人筛选
{
value: 'creator_id',
label: '创建人',
type: 'select',
placeholder: '请选择创建人',
filterable: true,
options: []
},
// 备注筛选
{
value: 'remark',
label: '备注',
type: 'text',
placeholder: '请输入备注关键词',
operators: ['contains'],
defaultOperator: 'contains'
},
// 录像设备
{
value: 'video_device_id',
label: '录像设备ID',
type: 'text',
placeholder: '请输入录像设备ID',
operators: ['eq', 'contains'],
defaultOperator: 'contains'
}
]
export const addReceving = [
{ prop: 'receiving_number', label: '收货单号', type: 'input' },
]
// 详情面板表单配置
export const detailpanel = [
{ prop: 'receiving_number', label: '收货单号', type: 'input', disabled: true },
{ prop: 'store_name', label: '货主', type: 'input', disabled: true },
{ prop: 'creator_name', label: '创建人', type: 'input', disabled: true },
{ prop: 'status', label: '收货状态', type: 'select' },
{ prop: 'detail_status', label: '匹配状态', type: 'select' },
{ prop: 'storage_status', label: '入库状态', type: 'select' },
{ prop: 'delivery_method', label: '来货方式', type: 'select' },
{ prop: 'loading_method', label: '装卸方式', type: 'select' },
{ prop: 'total_items', label: '商品种类', type: 'number' },
{ prop: 'total_quantity', label: '总数量', type: 'number' },
{ prop: 'total_boxes', label: '总箱数', type: 'number' },
{ prop: 'total_pallets', label: '总托盘数', type: 'number' },
{ prop: 'remark', label: '备注', type: 'textarea' },
]
export const productsnapshop = [
{prop: 'id', label: '系统商品ID', width: '160', fixed: 'left' },
{ prop: 'name', label: '商品名称', width: '160' },
{ prop: 'barcode', label: '商品条码', width: '160' },
{ prop: 'spec', label: '规格型号', width: '160' },
{prop: 'origin', label: '产地', width: '160' },
{ prop: 'brand', label: '品牌', width: '160' },
{ prop: 'module', label: '所属模块', width: '160' },
]
export const productdetail = [
{ prop: 'id', label: 'ID', width: '100' },
{ prop: 'product_name', label: '商品名称', width: '160', fixed: 'left' },
{ prop: 'barcode', label: '商品条码', width: '160' },
{ prop: 'product_snapshot', label: '商品信息快照', width: '160' },
{ prop: 'system_product_id', label: '关联系统商品ID', width: '160' },
{ prop: 'actual_quantity', label: '实际收货数量', width: '160' },
{ prop: 'box_quantity', label: '箱数', width: '160' },
{ prop: 'boxes_per_pallet', label: '箱规', width: '160' },
{ prop: 'pallet_quantity', label: '托盘数', width: '160' },
{ prop: 'receiving_time', label: '收货时间', width: '160' },
{ prop: 'receiving_status', label: '收货状态', width: '160' },
{ prop: 'storage_status', label: '入库状态', width: '160' },
{ prop: 'stored_quantity', label: '已入库数量', width: '160' },
{ prop: 'batch_number', label: '批次号', width: '160' },
{ prop: 'production_date', label: '生产日期', width: '160' },
{ prop: 'expiry_date', label: '保质期', width: '160' },
{ prop: 'remark', label: '备注', width: '160' },
{ prop: 'box_length', label: '箱长', width: '160' },
{ prop: 'box_width', label: '箱宽', width: '160' },
{ prop: 'box_height', label: '箱高', width: '160' },
{ prop: 'weight', label: '重量', width: '160' },
{ prop: 'space_id', label: '存放位置', width: '160' },
{ prop: 'creator_id', label: '创建人ID', width: '160' },
{ prop: 'updated_at', label: '更新时间', width: '160' },
{ prop: 'created_at', label: '创建时间', width: '160' },
]
export const productquick = [
{ prop: 'id', label: 'ID', width: '100' },
{ prop: 'product_name', label: '商品名称', width: '160', fixed: 'left' },
{ prop: 'barcode', label: '条码', width: '160' },
{ prop: 'actual_quantity', label: '实际收货数量', width: '160' },
{ prop: 'box_quantity', label: '箱数', width: '160' },
{ prop: 'storage_status', label: '入库状态', width: '160' },
{ prop: 'remark', label: '备注', width: '160' },
{ prop: 'box_length', label: '箱长', width: '160' },
{ prop: 'box_width', label: '箱宽', width: '160' },
{ prop: 'box_height', label: '箱高', width: '160' },
{ prop: 'space_id', label: '存放位置', width: '160' },
]
export const windowtopbar = [
{ label: '基本信息', key: 'basic' },
// { label: '商品信息', key: 'product' },
{ label: '操作日志', key: 'logs' }
]
export function formatReceivingData(list: any[] = []) {
return (list || []).map(item => ({
...item,
store_name: item.store?.store_remask || item['store.store_remask'] || '--',
creator_name: (() => {
try {
const s = JSON.parse(item.creator_snapshot || '{}')
return s.name || s.username || item.creator_id || '--'
} catch (e) {
return item.creator_id || '--'
}
})()
,
// 确保总箱数、总托盘数和更新时间字段存在并提供合理默认值
total_boxes: item.total_boxes ?? item.totalBoxes ?? ((item.details && Array.isArray(item.details)) ? item.details.reduce((sum: number, d: any) => sum + (d.box_count || d.boxes || 0), 0) : 0),
total_pallets: item.total_pallets ?? item.totalPallets ?? ((item.details && Array.isArray(item.details)) ? item.details.reduce((sum: number, d: any) => sum + (d.pallet_count || d.pallets || 0), 0) : 0),
updated_at: item.updated_at || item.updatedAt || item.update_time || item.last_modified || item.modified_at || item.updated || ''
}))
}