diff --git a/dist.tar.gz b/dist.tar.gz index c1fbd45a..3b4c6635 100644 Binary files a/dist.tar.gz and b/dist.tar.gz differ diff --git a/src/api/order.packing/packing.ts b/src/api/order.packing/packing.ts index 462e870e..71951140 100644 --- a/src/api/order.packing/packing.ts +++ b/src/api/order.packing/packing.ts @@ -66,3 +66,64 @@ export function packingDetail(data: PackingDetailParams): Promise { isSystemApi: true, } as any) } + +/** order.packing.setEndTime 请求参数 */ +export type PackingSetEndTimeParams = { + /** 打包任务ID(必填) */ + id: number + /** 结束时间 ISO 8601 格式(必填)。前端默认值:若任务已有结束时间→当前时间;无结束时间→开始时间+5分钟 */ + end_time: string +} + +/** order.packing.setEndTime 响应 */ +export type PackingSetEndTimeResponse = { + id: number + end_time: string + status: number +} + +/** order.packing.setEndTime:设置打包任务结束时间。若任务状态不是已完成则同步更新状态。 */ +export function packingSetEndTime(data: PackingSetEndTimeParams): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.packing.setEndTime', + v, + timestamp: new Date().getTime(), + }, + data, + isSystemApi: true, + } as any) +} + +/** order.packing.forceRecord 请求参数 */ +export type PackingForceRecordParams = { + /** 打包任务ID(必填) */ + id: number +} + +/** order.packing.forceRecord 响应 */ +export type PackingForceRecordResponse = { + pack_task_id: number + computer_id: number + print_service_url: string + print_service_request: { pack_task_id: number } + print_service_response: { status: number; headers: Record; data: unknown } + print_service_error?: string | null +} + +/** order.packing.forceRecord:强制重新录制打包任务视频。将任务推送到录制电脑,通过打印服务触发重新录制。 */ +export function packingForceRecord(data: PackingForceRecordParams): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.packing.forceRecord', + v, + timestamp: new Date().getTime(), + }, + data, + isSystemApi: true, + } as any) +} diff --git a/src/api/order.recheckorder/recheckOrder.ts b/src/api/order.recheckorder/recheckOrder.ts index 4b3c249b..33b56172 100644 --- a/src/api/order.recheckorder/recheckOrder.ts +++ b/src/api/order.recheckorder/recheckOrder.ts @@ -383,6 +383,7 @@ export type RecheckOrderSingleListItem = { items_total?: number items_weight?: number | string weight_type?: string + waybill_code?: string status?: string create_at?: string pick_time?: string diff --git a/src/api/order/order.ts b/src/api/order/order.ts index 38de35e7..e32af589 100644 --- a/src/api/order/order.ts +++ b/src/api/order/order.ts @@ -250,9 +250,81 @@ export function orderBindExpressPackageMaterialByWaybill( } as any) } +/** order.pendingOrder.allocateSubOrderNumber 请求参数 */ +export type PendingOrderAllocateSubOrderNumberParams = { + /** 订单 ID,必须为正整数 */ + order_id: number + /** 子单号数量,>= 1。business_key 从 2 开始递增 */ + sub_order_count: number +} + +/** order.pendingOrder.allocateSubOrderNumber 响应 data */ +export type PendingOrderAllocateSubOrderNumberData = { + task_id: string + order_id: number + status: string + progress: number + message: string + result: Record +} + +/** order.pendingOrder.allocateSubOrderNumber:分配子单号(异步任务模式) */ +export function orderModulePendingOrderAllocateSubOrderNumber( + data: PendingOrderAllocateSubOrderNumberParams +): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.pendingOrder.allocateSubOrderNumber', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true + } as any) +} + +/** order.pendingOrder.allocateSubOrderNumberProgress 请求参数 */ +export type PendingOrderAllocateSubOrderNumberProgressParams = { + /** 任务 ID(必填),支持 task_id 或 taskId */ + task_id: string + /** 子单号业务ID(可选),支持 business_key 或 businessKey */ + business_key?: number +} + +/** order.pendingOrder.allocateSubOrderNumberProgress 响应 data */ +export type PendingOrderAllocateSubOrderNumberProgressData = { + task_id: string + order_id: number + status: string + progress: number + message: string + result: Record +} + +/** order.pendingOrder.allocateSubOrderNumberProgress:查询子单号分配任务进度 */ +export function orderModulePendingOrderAllocateSubOrderNumberProgress( + data: PendingOrderAllocateSubOrderNumberProgressParams +): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.pendingOrder.allocateSubOrderNumberProgress', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true + } as any) +} + export const orderModule = { waveBatchList: orderModuleWaveBatchList, pendingOrderDownloadCreateTemplate: orderModulePendingOrderDownloadCreateTemplate, pendingOrderManualWaybill: orderModulePendingOrderManualWaybill, - bindExpressPackageMaterialByWaybill: orderBindExpressPackageMaterialByWaybill + bindExpressPackageMaterialByWaybill: orderBindExpressPackageMaterialByWaybill, + pendingOrderAllocateSubOrderNumber: orderModulePendingOrderAllocateSubOrderNumber, + pendingOrderAllocateSubOrderNumberProgress: orderModulePendingOrderAllocateSubOrderNumberProgress } diff --git a/src/api/order/packing/index.ts b/src/api/order/packing/index.ts index aa6840e2..afc03ac5 100644 --- a/src/api/order/packing/index.ts +++ b/src/api/order/packing/index.ts @@ -116,3 +116,74 @@ export function packingGet(id: number): Promise<{ isSystemApi: true } as any) } + +/** order.packing.setEndTime 请求参数 */ +export type PackingSetEndTimeParams = { + /** 打包任务ID(必填) */ + id: number + /** 结束时间 ISO 8601 格式(必填) */ + end_time: string +} + +/** order.packing.setEndTime 响应 */ +export type PackingSetEndTimeResponse = { + id: number + end_time: string + status: number +} + +/** + * 设置打包任务结束时间 + * 若任务状态不是已完成(2),则同步更新状态为已完成 + */ +export function packingSetEndTime(data: PackingSetEndTimeParams): Promise<{ + code: number + message: string + data: PackingSetEndTimeResponse +}> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.packing.setEndTime', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +/** order.packing.forceRecord 请求参数 */ +export type PackingForceRecordParams = { + /** 打包任务ID(必填) */ + id: number +} + +/** order.packing.forceRecord 响应 */ +export type PackingForceRecordResponse = { + pack_task_id: number + computer_id: number +} + +/** + * 强制重新录制打包任务视频 + * 将任务推送到录制电脑,通过打印服务触发重新录制 + */ +export function packingForceRecord(data: PackingForceRecordParams): Promise<{ + code: number + message: string + data: PackingForceRecordResponse +}> { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.packing.forceRecord', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} diff --git a/src/api/print_computer/print_computer.ts b/src/api/printer.station/print_computer.ts similarity index 100% rename from src/api/print_computer/print_computer.ts rename to src/api/printer.station/print_computer.ts diff --git a/src/views/data/newpackingflow/components/VideoButton.vue b/src/views/data/newpackingflow/components/VideoButton.vue index 2ffa0e4b..03c3695b 100644 --- a/src/views/data/newpackingflow/components/VideoButton.vue +++ b/src/views/data/newpackingflow/components/VideoButton.vue @@ -18,6 +18,7 @@ import { VideoCameraFilled } from '@element-plus/icons-vue' export interface VideoItem { id: number video_url: string + status?: string camera_id?: number camera_name?: string } diff --git a/src/views/data/packingflow/components/VideoButton.vue b/src/views/data/packingflow/components/VideoButton.vue index 2ffa0e4b..03c3695b 100644 --- a/src/views/data/packingflow/components/VideoButton.vue +++ b/src/views/data/packingflow/components/VideoButton.vue @@ -18,6 +18,7 @@ import { VideoCameraFilled } from '@element-plus/icons-vue' export interface VideoItem { id: number video_url: string + status?: string camera_id?: number camera_name?: string } diff --git a/src/views/data/packingflow/components/VideoListDialog.vue b/src/views/data/packingflow/components/VideoListDialog.vue index aa9ec7c8..5d12d169 100644 --- a/src/views/data/packingflow/components/VideoListDialog.vue +++ b/src/views/data/packingflow/components/VideoListDialog.vue @@ -15,7 +15,8 @@ v-for="(video, index) in videos" :key="video.id ?? index" class="video-item" - @click="$emit('play', video)" + :class="{ 'video-item--disabled': !video.video_url }" + @click="video.video_url && $emit('play', video)" >
@@ -28,15 +29,26 @@ 摄像头ID: {{ video.camera_id ?? '—' }} | 录像ID: {{ video.id }} +
- 播放 + 播放 + 录像不可用 + 不可播放
@@ -53,6 +65,7 @@ defineProps<{ defineEmits<{ 'update:visible': [value: boolean] play: [video: VideoItem] + 'force-record': [] }>() @@ -83,6 +96,23 @@ defineEmits<{ transform: translateY(-1px); } +.video-item--disabled { + cursor: default; + opacity: 0.7; +} + +.video-item--disabled:hover { + border-color: #ebeef5; + background: #fff; + box-shadow: none; + transform: none; +} + +.video-item--disabled .video-item__thumb { + background: linear-gradient(135deg, #f5f7fa 0%, #e4e7ed 100%); + color: #c0c4cc; +} + .video-item__thumb { width: 56px; height: 56px; @@ -131,4 +161,23 @@ defineEmits<{ .empty-hint { padding: 40px 0; } + +.dialog-footer { + display: flex; + justify-content: space-between; + align-items: center; +} + +.video-item__status { + font-size: 13px; + white-space: nowrap; +} + +.video-item__status--unavailable { + color: #f56c6c; +} + +.video-item__status--unplayable { + color: #c0c4cc; +} diff --git a/src/views/data/packingflow/index.vue b/src/views/data/packingflow/index.vue index 944ecf09..805392ed 100644 --- a/src/views/data/packingflow/index.vue +++ b/src/views/data/packingflow/index.vue @@ -1,5 +1,5 @@ + + + + + @@ -148,6 +204,7 @@ v-model:visible="videoListVisible" :videos="currentVideos" @play="handlePlayVideo" + @force-record="handleVideoListForceRecord" /> @@ -155,15 +212,61 @@ v-model:visible="playerVisible" :video="playingVideo" /> + + + + + + {{ operatingRow?.id ?? '—' }} + + + + {{ statusLabel(operatingRow?.status) }} + + + + + + + + - diff --git a/src/views/data/packingflow/packingflow-config.ts b/src/views/data/packingflow/packingflow-config.ts new file mode 100644 index 00000000..1529d676 --- /dev/null +++ b/src/views/data/packingflow/packingflow-config.ts @@ -0,0 +1,233 @@ +import dayjs from 'dayjs' + +// ============================================================================= +// 类型定义 +// ============================================================================= + +export interface StatusConfigItem { + text: string + tagType: 'info' | 'warning' | 'success' | 'danger' | '' +} + +export type StatusConfigMap = Record + +export interface PackModeConfigItem { + text: string + tagType: 'info' | 'warning' | 'success' | 'danger' | '' +} + +// ============================================================================= +// 状态配置 +// ============================================================================= + +/** 任务状态映射 */ +export const statusConfig: StatusConfigMap = { + 0: { text: '待处理', tagType: 'info' }, + 1: { text: '打包中', tagType: 'warning' }, + 2: { text: '已完成', tagType: 'success' }, + 3: { text: '异常', tagType: 'danger' } +} + +/** 打包模式映射 */ +export const packModeConfig: Record = { + 1: { text: '散单', tagType: 'info' }, + 2: { text: '团购', tagType: 'warning' } +} + +// ============================================================================= +// 辅助函数 +// ============================================================================= + +/** 根据状态码获取文本 */ +export function getStatusLabel(status: any): string { + const s = Number(status) + return statusConfig[s]?.text ?? '—' +} + +/** 根据状态码获取标签类型 */ +export function getStatusTagType(status: any): 'info' | 'warning' | 'success' | 'danger' | '' { + const s = Number(status) + return statusConfig[s]?.tagType ?? 'info' +} + +/** 获取打包模式文本 */ +export function getPackModeLabel(mode: any): string { + const m = Number(mode) + return packModeConfig[m]?.text ?? '—' +} + +/** 获取打包模式标签类型 */ +export function getPackModeTagType(mode: any): 'info' | 'warning' | 'success' | 'danger' | '' { + const m = Number(mode) + return packModeConfig[m]?.tagType ?? 'info' +} + +/** 从 expresses 数组提取运单号,兜底取顶层 waybill_code */ +export function getWaybill(row: any): string { + if (row.expresses && row.expresses.length) { + return row.expresses.map((e: any) => e.waybill_code).filter(Boolean).join(',') + } + return row.waybill_code || '' +} + +/** 从 expresses 数组提取快递接口名称 */ +export function getExpressInfo(row: any): string { + if (row.expresses && row.expresses.length) { + return row.expresses + .map((e: any) => e.logistics_interface_name || e.logistics_name || '—') + .filter(Boolean) + .join(',') + } + return '—' +} + +/** 判断是否包含录像:1=包含, 2=不包含 */ +export function resolveHasVideo(row: any): number { + return row.videos && row.videos.length > 0 ? 1 : 2 +} + +/** 判断录像是否可用:1=可用(有video_url且非failed), 2=不可用 */ +export function resolveVideoEnable(row: any): number { + if (!row.videos || !row.videos.length) return 2 + return row.videos.some((v: any) => v.video_url && v.status !== 'failed') ? 1 : 2 +} + +/** 包含录像状态映射 */ +export const hasVideoConfig: Record = { + 1: { text: '有', tagType: 'success' }, + 2: { text: '无', tagType: 'danger' } +} + +/** 录像可用状态映射 */ +export const videoEnableConfig: Record = { + 1: { text: '可用', tagType: 'success' }, + 2: { text: '不可用', tagType: 'info' } +} + +// ============================================================================= +// 表格列定义 +// ============================================================================= + +export const packingColumns = [ + { prop: 'id', label: '任务ID', width: 90 }, + { prop: 'order_id', label: '订单ID', width: 100 }, + { prop: 'waybill_code', label: '运单号', minWidth: 160, copyAction: 'copy' as const, copyValue: (row: any) => getWaybill(row), formatter: (row: any) => getWaybill(row) || '—' }, + { prop: 'wave_no', label: '波次号', minWidth: 140, copyAction: 'copy' as const }, + { prop: 'operator_text', label: '打包员', width: 100 }, + { prop: 'workbench_info', label: '工作台', width: 120, formatter: (row: any) => row.workbench_name || '—' }, + { prop: 'pack_quantity', label: '打包数量', width: 100, sortable: true }, + { prop: 'pack_mode', label: '打包模式', width: 100 }, + { prop: 'status', label: '任务状态', width: 100 }, + { prop: 'start_time', label: '开始时间', width: 170, sortable: true, formatter: (row: any) => row.start_time ? dayjs(row.start_time).format('YYYY-MM-DD HH:mm:ss') : '—' }, + { prop: 'end_time', label: '结束时间', width: 170, sortable: true, formatter: (row: any) => row.end_time ? dayjs(row.end_time).format('YYYY-MM-DD HH:mm:ss') : '—' }, + { prop: 'create_time', label: '创建时间', width: 170, sortable: true, formatter: (row: any) => row.create_time ? dayjs(row.create_time).format('YYYY-MM-DD HH:mm:ss') : '—' }, + { prop: 'update_time', label: '更新时间', width: 170, sortable: true, formatter: (row: any) => row.update_time ? dayjs(row.update_time).format('YYYY-MM-DD HH:mm:ss') : '—' }, + { prop: 'express_info', label: '快递信息', minWidth: 140, formatter: (row: any) => getExpressInfo(row) }, + { prop: 'has_video', label: '包含录像', width: 90 }, + { prop: 'video_enable', label: '录像可用', width: 90 }, + { prop: 'videos', label: '录像', width: 110 }, + { prop: 'operation', label: '操作', width: 140, fixed: 'right' } +] + +// ============================================================================= +// ScanBox 筛选字段分组 +// ============================================================================= + +export const PACKING_SCAN_FIELD_GROUPS = { + basic: '基础信息', + workflow: '流程状态', +} as const + +type PackingScanFieldGroupKey = keyof typeof PACKING_SCAN_FIELD_GROUPS + +function packingScanField( + group: G, + field: Record +) { + return { ...field, group: PACKING_SCAN_FIELD_GROUPS[group] } +} + +// ============================================================================= +// ScanBox 筛选字段配置 +// ============================================================================= + +/** 筛选字段配置(不含需要组件引用的仓库字段,由页面注入) */ +export const baseAvailableFields = [ + packingScanField('basic', { + label: '快捷搜索', + value: 'quickWhere', + type: 'text' as const, + placeholder: '运单号/波次号' + }), + packingScanField('basic', { + label: '打包模式', + value: 'pack_mode', + type: 'select' as const, + options: [ + { label: '全部', value: undefined }, + { label: '散单', value: 1 }, + { label: '团购', value: 2 } + ] + }), + packingScanField('basic', { + label: '运单号', + value: 'waybill_code', + type: 'text' as const + }), + packingScanField('basic', { + label: '波次号', + value: 'wave_no', + type: 'text' as const + }), + packingScanField('basic', { + label: '订单ID', + value: 'order_id', + type: 'text' as const + }), + packingScanField('workflow', { + label: '任务状态', + value: 'status', + type: 'select' as const, + options: [ + { label: '全部', value: undefined }, + { label: '待处理', value: 0 }, + { label: '打包中', value: 1 }, + { label: '已完成', value: 2 }, + { label: '异常', value: 3 } + ] + }), + packingScanField('workflow', { + label: '包含录像', + value: 'has_video', + type: 'select' as const, + options: [ + { label: '全部', value: undefined }, + { label: '有', value: 1 }, + { label: '无', value: 2 } + ] + }), + packingScanField('workflow', { + label: '录像可用', + value: 'video_enable', + type: 'select' as const, + options: [ + { label: '全部', value: undefined }, + { label: '可用', value: 1 }, + { label: '不可用', value: 2 } + ] + }), +] + +/** 创建完整筛选字段(注入仓库选择组件) */ +export function createAvailableFields(warehouseComponent: any): any[] { + return [ + packingScanField('basic', { + label: '仓库', + value: 'warehouse_id', + type: 'custom', + component: warehouseComponent, + props: { width: '100%' } + }), + ...baseAvailableFields + ] +} diff --git a/src/views/order/orderManagement/config/order-common-config.ts b/src/views/order/orderManagement/config/order-common-config.ts index 70a319ff..d4a18e46 100644 --- a/src/views/order/orderManagement/config/order-common-config.ts +++ b/src/views/order/orderManagement/config/order-common-config.ts @@ -767,7 +767,7 @@ export const orderDetailFullSections: OrderDetailSectionConfig[] = [ title: '流程与状态', column: 4, fields: [ - { prop: 'status', label: '订单状态', tag: true, formatter: (row: any) => translateOrderField('status', row.status) }, + { prop: 'status', label: '订单状态', tag: true }, { prop: 'step', label: '流程步骤' }, { prop: 'sync_status', label: '同步状态', tag: true }, { prop: 'inspection_status', label: '审核状态', tag: true }, @@ -866,7 +866,7 @@ export const orderDetailCompactSections: OrderDetailSectionConfig[] = [ { prop: 'create_channel', label: '来源' }, { prop: 'shop_nick', label: '店铺名称' }, { prop: 'buyer_nick', label: '买家昵称' }, - { prop: 'status', label: '订单状态', tag: true, formatter: (row: any) => translateOrderField('status', row.status) }, + { prop: 'status', label: '订单状态', tag: true }, { prop: 'source_order_codes', label: '平台交易单号' }, { prop: 'is_urgency', label: '是否紧急', tag: true }, { prop: 'seller_nick', label: '卖家昵称' }, diff --git a/src/views/storage/receiving/index.vue b/src/views/storage/receiving/index.vue index 63e653c3..45e680ca 100644 --- a/src/views/storage/receiving/index.vue +++ b/src/views/storage/receiving/index.vue @@ -152,6 +152,19 @@ business-type="RECEIPT" /> + + @@ -313,6 +326,7 @@ import UpperTable from '@/components/UpperTable/index.vue' import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue' import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config' import BatchReceivingPrintDialog from '@/components/BatchReceivingPrintDialog.vue' +import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue' import Details from './component/DetailsPanel.vue' import StorageComp from './component/Storage.vue' import Logs from './component/Logs.vue' @@ -334,7 +348,7 @@ import { addReceivingFields, receivingToolbarButtons, } from './receiving-config' -import * as XLSX from 'xlsx' +import { useAsyncExportTask } from '@/composables/useAsyncExportTask' import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane' import { safeInvoke } from '@/utils/safe-invoke' @@ -360,6 +374,20 @@ const { upperPaneStyle, } = useVerticalSplitPane({ defaultLowerPercent: 40 }) +const { + exportLoading, + exportDialogVisible, + exportTaskProgress, + exportProgressPercent, + exportProgressStatus, + exportStatusLabel, + submitExportTask +} = useAsyncExportTask({ + storageKey: 'storage:receiving:exportTaskId', + submitExport: (payload) => receivingApi.exportReceiving(payload as any), + queryProgress: (params) => receivingApi.exportReceivingTaskProgress(params) +}) + const upperPaneFullStyle = computed(() => ({ flex: '1 1 auto', minHeight: '0', @@ -370,7 +398,6 @@ const activeTab = ref('details') const list = ref([]) const loading = ref(false) -const exportLoading = ref(false) const quickPutawayLoading = ref(false) const reviewLoading = ref(false) const queryTime = ref(0) @@ -449,11 +476,11 @@ const toolbarActionMap: Record void> = { void loadData() }, handleCreateReceiving: () => handleCreateReceiving(), - handleExportWaybill: () => { - void handleExport('waybill') + handleExportSelected: () => { + void handleExportSelected() }, - handleExportItem: () => { - void handleExport('item') + handleExportAll: () => { + void handleExportAll() }, openColumnConfigPanel: () => openColumnConfigPanel(), toggleDetailVisible: () => toggleDetailVisible(), @@ -1465,112 +1492,33 @@ async function handleQuickPutaway() { } } -async function handleExport(mode: 'waybill' | 'item' = 'waybill') { - if (selectionRows.value.length === 0) { +// 导出相关 —— 使用异步任务模式 +function buildExportPayload() { + if (currentCondition.value && currentCondition.value !== 'reset') { + return { where: normalizeToWhere(currentCondition.value) } + } + return { where: normalizeToWhere({}) } +} + +function buildExportSelectedPayload() { + const ids = selectionRows.value.map((item: any) => item.id) + return { + where: { + id: { operator: 'in', value: ids } + } + } +} + +async function handleExportSelected() { + if (!selectionRows.value.length) { ElMessage.warning('请先勾选要导出的收货单') return } - exportLoading.value = true - try { - const allExportData: any[] = [] + await submitExportTask(buildExportSelectedPayload()) +} - for (const row of selectionRows.value) { - const productExportData: any[] = [] - const receivingExportData: any[] = [] - - receivingExportData.push({ - '收货单号': row.receiving_number, - '收货状态': statusConfig[row.status as keyof typeof statusConfig]?.text || row.status || '', - '匹配状态': detailStatusConfig[row.detail_status as keyof typeof detailStatusConfig]?.text || row.detail_status || '', - '入库状态': storageStatusConfig[row.storage_status as keyof typeof storageStatusConfig]?.text || row.storage_status || '', - '货主': row.store_name || '', - '商品种类': row.total_items ?? '', - '总数量': row.total_quantity ?? '', - '总箱数': row.total_boxes ?? '', - '总托盘数': row.total_pallets ?? '', - '车牌号': row.license_plate || '', - '物流单号': row.tracking_number || '', - '来货方式': deliveryMethodConfig[row.delivery_method as keyof typeof deliveryMethodConfig]?.text || row.delivery_method || '', - '装卸方式': loadingMethodConfig[row.loading_method as keyof typeof loadingMethodConfig]?.text || row.loading_method || '', - '创建人': row.creator_name || '', - '收货开始': row.receiving_start_time || '', - '收货结束': row.receiving_end_time || '', - '创建时间': row.created_at || '', - '备注': row.remark || '' - }) - - if (mode === 'item') { - try { - const res: any = await receivingApi.getReceivingDetail({ - id: row.id, - pagination: { page: 1, pageSize: 10000 } - }) - - if (res && res.code === 200 && res.data) { - const receivingData = res.data.receiving || {} - const detailList = Array.isArray(receivingData.details) - ? receivingData.details - : Array.isArray(res.data.list) - ? res.data.list - : Array.isArray(res.data.details) - ? res.data.details - : [] - - detailList.forEach((item: any) => { - productExportData.push({ - '收货单号': row.receiving_number, - '货主': row.store_name || '', - '商品名称': item.product_name || '', - '条码': item.barcode || '', - '匹配状态': item.system_product_id ? '已匹配' : '未匹配', - '实收数量': item.actual_quantity ?? '', - '箱数': item.box_quantity ?? '', - '箱规': item.boxes_per_pallet ?? '', - '重量(g)': item.weight ?? '', - '批次号': item.batch_number || '', - '生产日期': item.production_date || '', - '有效期': item.expiry_date || '', - '入库状态': storageStatusConfig[item.storage_status as keyof typeof storageStatusConfig]?.text || item.storage_status || '', - '库位': item.space_id || '', - '备注': item.remark || '' - }) - }) - } - } catch (e) { - console.warn(`获取收货单 ${row.receiving_number} 商品明细失败,跳过`, e) - } - } - - const rowExportData = mode === 'item' - ? (productExportData.length > 0 ? productExportData : receivingExportData) - : receivingExportData - allExportData.push(...rowExportData) - } - - if (allExportData.length === 0) { - ElMessage.warning('没有可导出的数据') - return - } - - const hasProductDetail = mode === 'item' && allExportData.some((row) => '商品名称' in row) - const sheetName = hasProductDetail ? '收货单商品明细' : '收货单摘要' - const suffix = mode === 'item' ? '-含明细' : '' - const fileName = selectionRows.value.length === 1 - ? `${selectionRows.value[0].receiving_number}${suffix}.xlsx` - : `收货单导出_${Date.now()}${suffix}.xlsx` - - const ws = XLSX.utils.json_to_sheet(allExportData) - const wb = XLSX.utils.book_new() - XLSX.utils.book_append_sheet(wb, ws, sheetName) - XLSX.writeFile(wb, fileName) - - ElMessage.success('导出完成') - } catch (e) { - console.error('导出 Excel 失败:', e) - ElMessage.error('导出失败') - } finally { - exportLoading.value = false - } +async function handleExportAll() { + await submitExportTask(buildExportPayload()) } diff --git a/src/views/storage/receiving/receiving-config.ts b/src/views/storage/receiving/receiving-config.ts index 7a83e11f..20b3f6c8 100644 --- a/src/views/storage/receiving/receiving-config.ts +++ b/src/views/storage/receiving/receiving-config.ts @@ -548,11 +548,11 @@ export const receivingToolbarButtons: ToolbarButtonConfig[] = [ label: '导出', size: 'small', loadingKey: 'exportLoading', - action: 'handleExportWaybill', + action: 'handleExportSelected', buttonType: 'dropdown', dropdownOptions: [ - { label: '不含明细', action: 'handleExportWaybill' }, - { label: '含明细', action: 'handleExportItem', divided: true } + { label: '导出选中', action: 'handleExportSelected' }, + { label: '导出全部', action: 'handleExportAll', divided: true } ] }, { key: 'columnConfig', label: '字段设置', size: 'small', action: 'openColumnConfigPanel' }, diff --git a/src/views/storage/report/index.vue b/src/views/storage/report/index.vue index f7360362..c24a07da 100644 --- a/src/views/storage/report/index.vue +++ b/src/views/storage/report/index.vue @@ -1,7 +1,8 @@