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 productStorageStatusConfig: any = { all: { text: '全部入库', tagType: 'success', color: '#67C23A' }, partial: { text: '部分入库', tagType: 'warning', color: '#E6A23C' }, none: { text: '未入库', tagType: 'info', color: '#909399' } } // 格式化产品入库状态 export function formatProductStorageStatus(value: string): { text: string; config: any } { const config = productStorageStatusConfig[value] || productStorageStatusConfig.none return { text: config.text, config } } 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' } } // 收货单号的枚举配置(类似 statusConfig),用于在筛选中加载对应选项 export const receivingConfig: any = { eq: { text: '等于' }, ne: { text: '不等于' }, contains: { text: '包含' }, starts_with: { text: '开头为' }, like: { text: '模糊匹配' }, // 保留全部项定义以便未来扩展,但 availableFields 只会启用上面五个 ends_with: { text: '结尾为' }, // regex: { text: '正则匹配' } } // 数值字段通用配置,只开启常用的比较/范围操作 export const numberConfig: any = { operators: ['eq', 'ne', 'gt', 'lt', 'ge', 'le'], defaultOperator: 'ge' } // 时间格式化函数 export function formatDateTime(dateStr: string): string { if (!dateStr) return '--' try { const date = new Date(dateStr) if (isNaN(date.getTime())) return '--' // 转换为本地时间,格式:YYYY-MM-DD HH:mm:ss 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 receivingColumns = [ { prop: 'receiving_number', label: '收货单号', width: '110', fixed: 'left' }, { prop: 'images', label: '收货图片', width: '120', align: 'center', imgs: (row: any) => { return row.images || [] } }, { prop: 'status', label: '收货状态', width: '90', align: 'center' }, { prop: 'detail_status', label: '匹配状态', width: '90', align: 'center' }, { prop: 'storage_status', label: '入库状态', width: '90', align: 'center' }, { prop: 'store_name', label: '货主', width: '100' }, { prop: 'total_items', label: '商品种类', width: '90', align: 'right', sortable: true }, { prop: 'total_quantity', label: '总数量', width: '90', align: 'right', sortable: true }, { prop: 'total_boxes', label: '总箱数', width: '90', align: 'right', sortable: true }, { prop: 'total_pallets', label: '总托盘数', width: '90', align: 'right', sortable: true }, { prop: 'license_plate', label: '车牌号', width: '100' }, { prop: 'tracking_number', label: '物流单号', width: '120' }, { prop: 'video_device_id', label: '录像设备ID', width: '140' }, { prop: 'delivery_method', label: '来货方式', width: '90', align: 'center' }, { prop: 'loading_method', label: '装卸方式', width: '100', align: 'center' }, { prop: 'creator_name', label: '创建人', width: '100' }, { prop: 'receiving_start_time', label: '收货开始', width: '150', sortable: true, formatter: (row: any) => formatDateTime(row.receiving_start_time) }, { prop: 'receiving_end_time', label: '收货结束', width: '150', sortable: true, formatter: (row: any) => formatDateTime(row.receiving_end_time) }, { prop: 'created_at', label: '创建时间', width: '150', sortable: true, formatter: (row: any) => formatDateTime(row.created_at) }, { prop: 'updated_at', label: '更新时间', width: '150', sortable: true, formatter: (row: any) => formatDateTime(row.updated_at) }, { prop: 'remark', label: '备注', minWidth: '120' }, ] // receiving配置 export const availableFields = [ { value: 'receiving_number', label: '收货单号', type: 'text', placeholder: '请输入收货单号', // 可用操作符(后端 operator 名称):等于、不等于、包含、开头为、模糊匹配 operators: ['eq', 'ne', 'contains', 'starts_with', 'like'], defaultOperator: 'contains' }, { 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: numberConfig.operators, defaultOperator: numberConfig.defaultOperator }, { value: 'total_quantity', label: '总数量', type: 'number', placeholder: '请输入总数量', operators: numberConfig.operators, defaultOperator: numberConfig.defaultOperator }, { value: 'total_boxes', label: '总箱数', type: 'number', placeholder: '请输入总箱数', operators: numberConfig.operators, defaultOperator: numberConfig.defaultOperator }, { value: 'total_pallets', label: '总托盘数', type: 'number', placeholder: '请输入总托盘数', operators: numberConfig.operators, defaultOperator: numberConfig.defaultOperator }, // 时间筛选 { 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', disabled: true}, { 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: 'images', label: '图片', width: '120', align: 'center', fixed: 'left' }, { prop: 'product_name', label: '商品名称', width: '200', fixed: 'left' }, { prop: 'barcode', label: '条码', width: '150' }, { prop: 'match_status', label: '匹配状态', width: '100', align: 'center' }, { prop: 'actual_quantity', label: '收货数量', width: '100', align: 'right' }, { prop: 'box_quantity', label: '箱数', width: '100', align: 'right' }, { prop: 'boxes_per_pallet', label: '箱规', width: '100', align: 'right' }, { prop: 'batch_number', label: '批次号', width: '120' }, { prop: 'production_date', label: '生产日期', width: '120' }, { prop: 'expiry_date', label: '有效期', width: '120' }, { prop: 'storage_status', label: '入库', width: '80', align: 'center' }, { prop: 'space_id', label: '库位', width: '120' }, { prop: 'remark', label: '备注', minWidth: '150' }, { prop: 'actions', label: '操作', width: '100', align: 'center', fixed: 'right' }, ] export const windowtopbar = [ { label: '基本信息', key: 'basic' }, // { label: '商品信息', key: 'product' }, { label: '操作日志', key: 'logs' } ] // 打印配置表单 export const printFormConfig = [ { group: '基本信息', fields: [ { prop: 'delivery_method', label: '来货方式', type: 'select', options: Object.entries(deliveryMethodConfig).map(([v, c]: [string, any]) => ({ value: v, label: c.text })) }, { prop: 'license_plate', label: '车牌号', type: 'input' }, { prop: 'receiving_number', label: '收货单号', type: 'input' }, { prop: 'store_name', label: '货主', type: 'input' }, { prop: 'total_items', label: '总商品种类', type: 'number' }, { prop: 'total_quantity', label: '总商品数量', type: 'number' }, { prop: 'total_boxes', label: '总箱数', type: 'number' }, ]}, { group: '商品明细', fields: [ { prop: 'product_name', label: '商品名称', type: 'input' }, { prop: 'barcode', label: '商品条码', type: 'input' }, { prop: 'box_quantity', label: '箱数', type: 'number' }, { prop: 'boxes_per_pallet', label: '箱规', type: 'number' }, { prop: 'actual_quantity', label: '实际收货数量', type: 'number' }, { prop: 'remark', label: '明细备注', type: 'input' }, ]} ] export const printFormFields = [ ...(printFormConfig[0]?.fields || []), ...(printFormConfig[1]?.fields || []) ] 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 || '' })) } // 新建收货单配置 export const addReceivingFields = [ { prop: 'store_id', label: '货主', type: 'select', filterable: true, options: [] }, { prop: 'delivery_method', label: '来货方式', type: 'select', options: Object.entries(deliveryMethodConfig).map(([v, c]: [string, any]) => ({ value: v, label: c.text })) }, { prop: 'loading_method', label: '装卸方式', type: 'select', options: Object.entries(loadingMethodConfig).map(([v, c]: [string, any]) => ({ value: v, label: c.text })) }, // 新增可选的总箱数与总托盘数字段 { prop: 'total_boxes', label: '总箱数', type: 'input', placeholder: '请输入总箱数', optional: true }, { prop: 'total_pallets', label: '总托盘数', type: 'input', placeholder: '请输入总托盘数', optional: true }, { prop: 'license_plate', label: '车牌号', type: 'input' }, { prop: 'tracking_number', label: '物流单号', type: 'input' }, { prop: 'remark', label: '备注', type: 'textarea' } ]