diff --git a/dist.tar.gz b/dist.tar.gz index 3b4c6635..664644fc 100644 Binary files a/dist.tar.gz and b/dist.tar.gz differ diff --git a/src/api/order.pendingOrder/orderpendingOrder.ts b/src/api/order.pendingOrder/orderpendingOrder.ts index 93192251..585e54de 100644 --- a/src/api/order.pendingOrder/orderpendingOrder.ts +++ b/src/api/order.pendingOrder/orderpendingOrder.ts @@ -2,6 +2,8 @@ import request from "@/utils/request"; import { orderModulePendingOrderDownloadCreateTemplate, orderModulePendingOrderManualWaybill, + orderModulePendingOrderAllocateSubOrderNumber, + orderModulePendingOrderAllocateSubOrderNumberProgress, } from "@/api/order/order"; const v = "1.0"; @@ -11,10 +13,16 @@ export type { PendingOrderDownloadCreateTemplateResponse, PendingOrderManualWaybillParams, PendingOrderManualWaybillResponse, + PendingOrderAllocateSubOrderNumberParams, + PendingOrderAllocateSubOrderNumberData, + PendingOrderAllocateSubOrderNumberProgressParams, + PendingOrderAllocateSubOrderNumberProgressData, } from '@/api/order/order' export const orderPendingOrderDownloadCreateTemplate = orderModulePendingOrderDownloadCreateTemplate; export const orderPendingOrderManualWaybill = orderModulePendingOrderManualWaybill; +export const orderPendingOrderAllocateSubOrderNumber = orderModulePendingOrderAllocateSubOrderNumber; +export const orderPendingOrderAllocateSubOrderNumberProgress = orderModulePendingOrderAllocateSubOrderNumberProgress; export type OrderWhere = Record; export type OrderSort = { @@ -754,6 +762,8 @@ export type OrderPendingOrderApi = { batchLockTaskProgress: typeof orderPendingOrderBatchLockTaskProgress; batchUnlock: typeof orderPendingOrderBatchUnlock; batchUnlockTaskProgress: typeof orderPendingOrderBatchUnlockTaskProgress; + allocateSubOrderNumber: typeof orderPendingOrderAllocateSubOrderNumber; + allocateSubOrderNumberProgress: typeof orderPendingOrderAllocateSubOrderNumberProgress; }; export const orderPendingOrder: OrderPendingOrderApi = { @@ -787,4 +797,6 @@ export const orderPendingOrder: OrderPendingOrderApi = { batchLockTaskProgress: orderPendingOrderBatchLockTaskProgress, batchUnlock: orderPendingOrderBatchUnlock, batchUnlockTaskProgress: orderPendingOrderBatchUnlockTaskProgress, + allocateSubOrderNumber: orderPendingOrderAllocateSubOrderNumber, + allocateSubOrderNumberProgress: orderPendingOrderAllocateSubOrderNumberProgress, }; diff --git a/src/api/order.print/orderprint.ts b/src/api/order.print/orderprint.ts index fa8c980c..f4fc2639 100644 --- a/src/api/order.print/orderprint.ts +++ b/src/api/order.print/orderprint.ts @@ -93,3 +93,24 @@ export function getOrderPrintData(data: GetOrderPrintDataParams) { isSystemApi: true } as any) } + +export type GetPrintDataByWaybillCodesParams = { + /** 运单号数组(字符串数组,内部自动去重与归一化,必须为非空数组) */ + waybill_codes: string[] +} + +/** 按运单号数组拉取平台打印中间态数据(order.print.getPrintDataByWaybillCodes) + * 返回结构与 getOrderPrintData 一致 */ +export function getPrintDataByWaybillCodes(data: GetPrintDataByWaybillCodesParams) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.print.getPrintDataByWaybillCodes', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} diff --git a/src/api/order/order.ts b/src/api/order/order.ts index e32af589..583af3a3 100644 --- a/src/api/order/order.ts +++ b/src/api/order/order.ts @@ -320,11 +320,45 @@ export function orderModulePendingOrderAllocateSubOrderNumberProgress( } as any) } +/** order.pendingOrder.batchMarkPrinted 请求参数 */ +export type PendingOrderBatchMarkPrintedParams = { + /** 订单ID数组;优先级 order_ids > orderIds > ids */ + order_ids?: number[] + orderIds?: number[] + ids?: number[] +} + +/** order.pendingOrder.batchMarkPrinted 响应 data */ +export type PendingOrderBatchMarkPrintedData = { + /** 实际更新的订单数量(已打印的订单会被静默跳过,不计入) */ + updated_count: number + /** 请求的订单ID列表(原样回传) */ + ids: number[] +} + +/** order.pendingOrder.batchMarkPrinted:批量设置订单为已打印状态 */ +export function orderModulePendingOrderBatchMarkPrinted( + data: PendingOrderBatchMarkPrintedParams +): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'order.pendingOrder.batchMarkPrinted', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true + } as any) +} + export const orderModule = { waveBatchList: orderModuleWaveBatchList, pendingOrderDownloadCreateTemplate: orderModulePendingOrderDownloadCreateTemplate, pendingOrderManualWaybill: orderModulePendingOrderManualWaybill, bindExpressPackageMaterialByWaybill: orderBindExpressPackageMaterialByWaybill, pendingOrderAllocateSubOrderNumber: orderModulePendingOrderAllocateSubOrderNumber, - pendingOrderAllocateSubOrderNumberProgress: orderModulePendingOrderAllocateSubOrderNumberProgress + pendingOrderAllocateSubOrderNumberProgress: orderModulePendingOrderAllocateSubOrderNumberProgress, + pendingOrderBatchMarkPrinted: orderModulePendingOrderBatchMarkPrinted } diff --git a/src/api/printer.station/print_computer.ts b/src/api/printer.station/print_computer.ts index 06934dc0..c52adf8b 100644 --- a/src/api/printer.station/print_computer.ts +++ b/src/api/printer.station/print_computer.ts @@ -43,6 +43,7 @@ export function setRecording(data: { id: number recording_size_value: number recording_size_unit: string + remote_play_url?: string recording_directory: string }) { return request({ diff --git a/src/api/waybill.warehouse/index.ts b/src/api/waybill.warehouse/index.ts new file mode 100644 index 00000000..1e6f589d --- /dev/null +++ b/src/api/waybill.warehouse/index.ts @@ -0,0 +1,166 @@ +import request from '@/utils/request' + +const v = '1.0' + +// ============ waybill.warehouse.list ============ + +/** waybill.warehouse.list 的 where 筛选条件 */ +export type WaybillWarehouseListWhere = { + /** 运单号(模糊搜索) */ + waybillCode?: string + /** 主单号(精确匹配),与 waybillCode 互斥,同时传入时 mainWaybillCode 优先 */ + mainWaybillCode?: string + /** 订单ID(等值匹配) */ + orderId?: number + /** 订单号(模糊搜索,匹配 delivery_order_code 快照列) */ + orderNo?: string + /** 物流公司编码(等值匹配),如 SF/YT/STO/ZTO 等 */ + logisticsCode?: string + /** 物流接口ID(等值匹配) */ + logisticsInterfaceId?: number + /** 平台编码(等值匹配),如 PDD/DY/KS/JD/CAINIAO/SPH/XHS */ + platformCode?: string + /** 运单状态:0=未分配,1=已分配 */ + status?: number + /** 是否退回:Y/N */ + isBack?: string + /** 是否拦截:Y/N */ + isIntercept?: string + /** 是否星河签收:Y/N */ + isGalaxyReceive?: string + /** 包材ID(等值匹配) */ + packageMaterialId?: number + /** 是否已称重:true=weighing_weight>0,false=weighing_weight=0 */ + hasWeighingWeight?: boolean + /** 关键词搜索:同时匹配运单号、主单号、订单号 */ + keyword?: string + /** 创建时间起始,格式 YYYY-MM-DD */ + createdAtStart?: string + /** 创建时间截止,格式 YYYY-MM-DD */ + createdAtEnd?: string +} + +/** waybill.warehouse.list 排序参数 */ +export type WaybillWarehouseListSort = { + /** 排序字段:create_at / weighing_weight / id */ + field?: string + /** 排序方向:asc / desc,默认 desc */ + order?: 'asc' | 'desc' +} + +/** waybill.warehouse.list 请求参数 */ +export type WaybillWarehouseListParams = { + pagination?: { + page?: number + pageSize?: number + } + where?: WaybillWarehouseListWhere + sort?: WaybillWarehouseListSort +} + +/** waybill.warehouse.list:运单列表-仓库侧 */ +export function waybillWarehouseList( + data: WaybillWarehouseListParams = {} +): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'waybill.warehouse.list', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} + +// ============ waybill.warehouse.detail ============ + +/** waybill.warehouse.detail 请求参数 */ +export type WaybillWarehouseDetailParams = { + /** 运单记录ID(wms_order_express.id),与 waybillCode 二选一,waybillCode 优先 */ + id?: number + /** 运单号,与 id 二选一,waybillCode 优先 */ + waybillCode?: string +} + +/** waybill.warehouse.detail:运单详情-仓库侧 */ +export function waybillWarehouseDetail( + data: WaybillWarehouseDetailParams +): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'waybill.warehouse.detail', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true + } as any) +} + +// ============ waybill.warehouse.export ============ + +/** waybill.warehouse.export 请求参数 */ +export type WaybillWarehouseExportParams = { + where?: WaybillWarehouseListWhere + sort?: WaybillWarehouseListSort + /** 需要导出的字段列表,不传则导出全部字段 */ + exportFields?: string[] +} + +/** waybill.warehouse.export:运单导出-仓库侧(异步任务模式) */ +export function waybillWarehouseExport( + data: WaybillWarehouseExportParams = {} +): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'waybill.warehouse.export', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true + } as any) +} + +// ============ waybill.warehouse.exportTaskProgress ============ + +/** waybill.warehouse.exportTaskProgress 请求参数 */ +export type WaybillWarehouseExportTaskProgressParams = { + /** 异步导出任务ID(前缀 waybill_export_)。与 taskId 二选一,taskId 优先 */ + task_id?: string + /** 异步导出任务ID(别名,优先使用)。至少传入 taskId 或 task_id 之一 */ + taskId?: string +} + +/** waybill.warehouse.exportTaskProgress:运单导出进度查询-仓库侧 */ +export function waybillWarehouseExportTaskProgress( + data: WaybillWarehouseExportTaskProgressParams +): Promise { + return request({ + url: '/system', + method: 'post', + params: { + method: 'waybill.warehouse.exportTaskProgress', + v, + timestamp: Date.now() + }, + data, + isSystemApi: true + } as any) +} + +// ============ 模块导出 ============ + +export const waybillWarehouseModule = { + list: waybillWarehouseList, + detail: waybillWarehouseDetail, + export: waybillWarehouseExport, + exportTaskProgress: waybillWarehouseExportTaskProgress +} diff --git a/src/lang/en-US.ts b/src/lang/en-US.ts index ac6625da..4e767891 100644 --- a/src/lang/en-US.ts +++ b/src/lang/en-US.ts @@ -73,6 +73,16 @@ export default { // 'OwnerReceiving':'Owner Receiving', 'PackingFlow':'Packing Flow', 'printcomputer':'Print Computer', + 'waybill':'waybill', + '':'', + '':'', + '':'', + '':'', + '':'', + '':'', + '':'', + '':'', + '':'', }, "login": { "title": "Login", diff --git a/src/lang/zh-CN.ts b/src/lang/zh-CN.ts index 991c2744..7845b433 100644 --- a/src/lang/zh-CN.ts +++ b/src/lang/zh-CN.ts @@ -76,6 +76,16 @@ export default { 'WmsCameraServer':'录像服务器', 'PackingFlow':'打包流水', 'printcomputer':'打印电脑', + 'waybill':'运单', + '':'', + '':'', + '':'', + '':'', + '':'', + '':'', + '':'', + '':'', + '':'', }, "login": { "title": "登录", diff --git a/src/router/map.ts b/src/router/map.ts index 215dd9fb..c13bf94c 100644 --- a/src/router/map.ts +++ b/src/router/map.ts @@ -67,4 +67,5 @@ export const componentMap: Record = { 'video/camera/index': () => import('@/views/video/newcamara/index.vue'), 'data/packingflow': () => import('@/views/data/packingflow/index.vue'), 'system/setting/printcomputer/index':() => import('@/views/system/setting/printcomputer/index.vue'), + 'express/index':() => import('@/views/express/waybill/index.vue'), }; \ No newline at end of file diff --git a/src/views/express/waybill/components/ColumnCellRenderer.vue b/src/views/express/waybill/components/ColumnCellRenderer.vue new file mode 100644 index 00000000..8aa6b3a8 --- /dev/null +++ b/src/views/express/waybill/components/ColumnCellRenderer.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/views/express/waybill/components/OperationCellRenderer.vue b/src/views/express/waybill/components/OperationCellRenderer.vue new file mode 100644 index 00000000..a1190233 --- /dev/null +++ b/src/views/express/waybill/components/OperationCellRenderer.vue @@ -0,0 +1,175 @@ + + + + + + diff --git a/src/views/express/waybill/components/TabArea.vue b/src/views/express/waybill/components/TabArea.vue new file mode 100644 index 00000000..288ec6f1 --- /dev/null +++ b/src/views/express/waybill/components/TabArea.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/views/express/waybill/config/components/DetailPanel.vue b/src/views/express/waybill/config/components/DetailPanel.vue new file mode 100644 index 00000000..eb992d25 --- /dev/null +++ b/src/views/express/waybill/config/components/DetailPanel.vue @@ -0,0 +1,159 @@ + + + + + + diff --git a/src/views/express/waybill/config/components/LogPanel.vue b/src/views/express/waybill/config/components/LogPanel.vue new file mode 100644 index 00000000..0adae9f3 --- /dev/null +++ b/src/views/express/waybill/config/components/LogPanel.vue @@ -0,0 +1,227 @@ + + + + + + diff --git a/src/views/express/waybill/config/template-config.ts b/src/views/express/waybill/config/template-config.ts new file mode 100644 index 00000000..ef5d3352 --- /dev/null +++ b/src/views/express/waybill/config/template-config.ts @@ -0,0 +1,910 @@ +/** + * 【运单模块(仓库侧)】配置文件 — 基于 waveOrder2 架构设计 + * + * ===== 数据来源 ===== + * API: src/api/waybill.warehouse/index.ts + * - waybillWarehouseList → waybill.warehouse.list 运单列表 + * - waybillWarehouseDetail → waybill.warehouse.detail 运单详情 + * - waybillWarehouseExport → waybill.warehouse.export 运单导出 + */ + +import type { Component } from 'vue' +import DetailPanel from './components/DetailPanel.vue' +import LogPanel from './components/LogPanel.vue' +import { + waybillWarehouseList, + waybillWarehouseExport, + waybillWarehouseExportTaskProgress, +} from '@/api/waybill.warehouse' + +// ============================================================ +// 〇、全局页面配置 +// ============================================================ +export const PAGE_CONFIG = { + showTabArea: false, + singlePage: true, + enableDetailPanel: true +} + +// ============================================================ +// 〇-A、组件注册表 +// ============================================================ +export const COMPONENT_REGISTRY: Record = { + DetailPanel, + LogPanel +} + +// ============================================================ +// 〇-B、SCANBOX_GROUPS +// ============================================================ +export const SCANBOX_GROUPS = { + basic: '基础信息', + logistics: '物流信息', + status: '状态筛选', + time: '时间范围' +} as const + +// ============================================================ +// 一、FIELD_DICT — 运单字段预设表 +// ============================================================ + +export interface FieldDefinition { + key: string + label: string + scanBox: { + type: 'text' | 'select' | 'daterange' | 'number' + group?: string + options?: { label: string; value: any }[] + } | null + table: { + minWidth?: number + width?: number + fixed?: 'left' | 'right' | boolean + align?: 'left' | 'center' | 'right' + sortable?: boolean + showOverflowTooltip?: boolean + copyAction?: 'copy' | 'copyQr' + copyValue?: (row: any) => any + } | null + slot: { + type: 'tag' | 'text' | 'default' | 'operation' + tagType?: string | Record + tagResolver?: string + translateField?: string + format?: 'datetime' + } | null + detailLabel?: string + filterParamMap?: Record +} + +// ============================================================ +// VALUE_MAPS — 值翻译映射 +// ============================================================ +export const VALUE_MAPS: Record> = { + waybillStatus: { + '0': '未分配', '1': '已分配', + '未分配': '未分配', '已分配': '已分配' + }, + waybillType: { + '主单号': '主单号', '子单号': '子单号' + }, + yesNo: { + 'Y': '是', 'N': '否', + '是': '是', '否': '否' + }, + bool: { + '1': '是', '0': '否', + '是': '是', '否': '否', + 'true': '是', 'false': '否' + }, + packStatus: { + '未打包': '未打包', '已打包': '已打包', '打包中': '打包中' + } +} + +export function getOptions(field: string): { label: string; value: string }[] { + const map = VALUE_MAPS[field] + if (!map) return [] + const seen = new Set() + const opts: { label: string; value: string }[] = [] + const chineseKeys: [string, string][] = [] + const otherKeys: [string, string][] = [] + for (const [v, l] of Object.entries(map)) { + if (/^[\u4e00-\u9fa5]/.test(v)) { + chineseKeys.push([v, l]) + } else { + otherKeys.push([v, l]) + } + } + for (const [v, l] of [...chineseKeys, ...otherKeys]) { + if (!seen.has(l)) { + seen.add(l) + opts.push({ label: l, value: v }) + } + } + return opts +} + +export function translate(field: string, value: any): string { + const map = VALUE_MAPS[field] + if (!map) return String(value ?? '—') + return map[String(value)] ?? String(value ?? '—') +} + +export function formatTime(value: any): string { + if (!value) return '—' + try { + const d = new Date(value) + if (isNaN(d.getTime())) return String(value) + const pad = (n: number) => String(n).padStart(2, '0') + return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}` + } catch { + return String(value) + } +} + +// ============================================================ +// TAG_RESOLVERS — 标签颜色解析器 +// ============================================================ +export const TAG_RESOLVERS: Record string> = { + resolveWaybillStatusTag(v) { + if (v === undefined || v === null) return 'info' + const s = String(v) + if (s === '1' || s === '已分配') return 'success' + return 'info' + }, + resolveYesNoTag(v) { + if (v === undefined || v === null) return 'info' + if (v === 'Y' || v === '是' || v === true || v === 1 || v === '1') return 'warning' + return 'info' + }, + resolveWaybillTypeTag(v) { + if (v === undefined || v === null) return 'info' + if (v === '主单号') return 'primary' + if (v === '子单号') return 'warning' + return 'info' + }, + resolvePackStatusTag(v) { + if (v === undefined || v === null) return 'info' + if (v === '已打包') return 'success' + if (v === '打包中') return 'warning' + return 'info' + } +} + +// ============================================================ +// 二、FIELD_DICT 实例 — 运单字段定义 +// ============================================================ +export const FIELD_DICT: Record = { + // —— 基础信息 —— + waybill_code: { + key: 'waybill_code', + label: '运单号', + scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, + table: { minWidth: 170, fixed: 'left', copyAction: 'copy', showOverflowTooltip: true }, + slot: null, + detailLabel: '运单号' + }, + main_waybill_code: { + key: 'main_waybill_code', + label: '主单号', + scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, + table: { minWidth: 170, showOverflowTooltip: true }, + slot: null, + detailLabel: '主单号' + }, + waybill_type: { + key: 'waybill_type', + label: '运单类型', + scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: getOptions('waybillType') }, + table: { minWidth: 90, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveWaybillTypeTag', translateField: 'waybillType' }, + detailLabel: '运单类型' + }, + order_no: { + key: 'order_no', + label: '订单号', + scanBox: { type: 'text', group: SCANBOX_GROUPS.basic }, + table: { minWidth: 160, showOverflowTooltip: true }, + slot: null, + detailLabel: '订单号' + }, + order_id: { + key: 'order_id', + label: '订单ID', + scanBox: null, + table: { minWidth: 90, align: 'center' }, + slot: null, + detailLabel: '订单ID' + }, + business_key: { + key: 'business_key', + label: '业务键', + scanBox: null, + table: { minWidth: 80, align: 'center' }, + slot: null, + detailLabel: '业务键' + }, + warehouse_name: { + key: 'warehouse_name', + label: '仓库', + scanBox: null, + table: { minWidth: 120, showOverflowTooltip: true }, + slot: null, + detailLabel: '仓库名称' + }, + store_name: { + key: 'store_name', + label: '货主', + scanBox: { type: 'select', group: SCANBOX_GROUPS.basic, options: [] }, + table: { minWidth: 120, showOverflowTooltip: true }, + slot: null, + detailLabel: '货主名称' + }, + order_type: { + key: 'order_type', + label: '订单类型', + scanBox: null, + table: null, + slot: null, + detailLabel: '订单类型' + }, + wave_no: { + key: 'wave_no', + label: '波次号', + scanBox: null, + table: null, + slot: null, + detailLabel: '波次号' + }, + pack_quantity: { + key: 'pack_quantity', + label: '打包数量', + scanBox: null, + table: null, + slot: null, + detailLabel: '打包数量' + }, + pack_at: { + key: 'pack_at', + label: '打包时间', + scanBox: null, + table: null, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '打包时间' + }, + packer_name: { + key: 'packer_name', + label: '打包人', + scanBox: null, + table: null, + slot: null, + detailLabel: '打包人' + }, + // —— 物流信息 —— + logistics_code: { + key: 'logistics_code', + label: '物流编码', + scanBox: { type: 'select', group: SCANBOX_GROUPS.logistics, options: [] }, + table: { minWidth: 100, align: 'center' }, + slot: null, + detailLabel: '物流公司编码' + }, + logistics_name: { + key: 'logistics_name', + label: '物流公司', + scanBox: null, + table: { minWidth: 120, showOverflowTooltip: true }, + slot: null, + detailLabel: '物流公司' + }, + logistics_interface_id: { + key: 'logistics_interface_id', + label: '物流接口ID', + scanBox: null, + table: { minWidth: 110, align: 'center' }, + slot: null, + detailLabel: '物流接口ID' + }, + logistics_interface_name: { + key: 'logistics_interface_name', + label: '物流接口', + scanBox: null, + table: { minWidth: 120, showOverflowTooltip: true }, + slot: null, + detailLabel: '物流接口' + }, + platform_code: { + key: 'platform_code', + label: '平台', + scanBox: { type: 'select', group: SCANBOX_GROUPS.logistics, options: [] }, + table: { minWidth: 90, align: 'center' }, + slot: null, + detailLabel: '平台编码' + }, + // —— 包裹信息 —— + package_material_id: { + key: 'package_material_id', + label: '包材ID', + scanBox: null, + table: { minWidth: 90, align: 'center' }, + slot: null, + detailLabel: '包材ID' + }, + package_material_name: { + key: 'package_material_name', + label: '包材名称', + scanBox: null, + table: { minWidth: 110, showOverflowTooltip: true }, + slot: null, + detailLabel: '包材名称' + }, + pack_status: { + key: 'pack_status', + label: '打包状态', + scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('packStatus') }, + table: { minWidth: 90, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolvePackStatusTag', translateField: 'packStatus' }, + detailLabel: '打包状态' + }, + // —— 状态信息 —— + status: { + key: 'status', + label: '运单状态', + scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('waybillStatus') }, + table: { minWidth: 100, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveWaybillStatusTag', translateField: 'waybillStatus' }, + detailLabel: '运单状态', + filterParamMap: { '未分配': '0', '已分配': '1' } + }, + status_text: { + key: 'status_text', + label: '状态说明', + scanBox: null, + table: { minWidth: 100, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveWaybillStatusTag', translateField: 'waybillStatus' }, + detailLabel: '状态说明' + }, + is_back: { + key: 'is_back', + label: '是否退回', + scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('yesNo') }, + table: { minWidth: 100, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveYesNoTag', translateField: 'yesNo' }, + detailLabel: '是否退回' + }, + is_intercept: { + key: 'is_intercept', + label: '是否拦截', + scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('yesNo') }, + table: { minWidth: 100, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveYesNoTag', translateField: 'yesNo' }, + detailLabel: '是否拦截' + }, + is_galaxy_receive: { + key: 'is_galaxy_receive', + label: '揽收', + scanBox: { type: 'select', group: SCANBOX_GROUPS.status, options: getOptions('yesNo') }, + table: { minWidth: 100, align: 'center' }, + slot: { type: 'tag', tagResolver: 'resolveYesNoTag', translateField: 'yesNo' }, + detailLabel: '是否揽收' + }, + // —— 重量与打印 —— + weighing_weight: { + key: 'weighing_weight', + label: '称重(g)', + scanBox: null, + table: { minWidth: 90, align: 'center', sortable: true }, + slot: null, + detailLabel: '称重重量(g)' + }, + weighing_weight_display: { + key: 'weighing_weight_display', + label: '称重', + scanBox: null, + table: { minWidth: 100, align: 'center' }, + slot: null, + detailLabel: '称重重量' + }, + print_count: { + key: 'print_count', + label: '打印次数', + scanBox: null, + table: { minWidth: 90, align: 'center', sortable: true }, + slot: null, + detailLabel: '打印次数' + }, + last_print_at: { + key: 'last_print_at', + label: '最后打印', + scanBox: null, + table: { minWidth: 170, sortable: true }, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '最后打印时间' + }, + // —— 时间信息 —— + create_at: { + key: 'create_at', + label: '创建时间', + scanBox: null, + table: { minWidth: 170, sortable: true }, + slot: { type: 'text', format: 'datetime' }, + detailLabel: '创建时间' + }, + createdAtStart: { + key: 'createdAtStart', + label: '创建时间', + scanBox: { type: 'daterange', group: SCANBOX_GROUPS.time }, + table: null, + slot: null + }, + // —— 操作列 —— + operation: { + key: 'operation', + label: '操作', + scanBox: null, + table: { minWidth: 120, fixed: 'right', align: 'center' }, + slot: { type: 'operation' } + } +} + +// ============================================================ +// 三、ColumnSlotConfig / OperationButtonConfig / Detail 类型 +// ============================================================ +export interface ColumnSlotConfig { + type: 'tag' | 'text' | 'default' | 'operation' + tagType?: string | Record + tagResolver?: string + translateField?: string + format?: 'datetime' +} + +export interface OperationButtonConfig { + key: string + label: string + type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | '' + actionType: 'form' | 'action' + formKey?: string + formTitle?: string + formWidth?: string + paramMap?: Record + extraParams?: Record + disabledOnField?: string + confirmMessage?: string + confirmTitle?: string + confirmType?: 'warning' | 'danger' | 'info' + confirmButtonText?: string +} + +export interface DetailFieldConfig { + key: string + label?: string + span?: number + renderType?: 'text' | 'tag' | 'pre' + tagType?: string | Record + tagResolver?: string + translateField?: string +} + +export interface DetailSectionConfig { + title: string + columnCount: number + fields: DetailFieldConfig[] +} + +export interface DetailTabConfig { + name: string + label: string + componentKey: string + component?: Component +} + +// ============================================================ +// 四、TabPageApiConfig +// ============================================================ +export type ApiMethod = (...args: any[]) => Promise +export type ApiSource = 'api' | 'list' +export type ComponentApiConfig = { source: 'list' } | ApiMethod + +export interface TabPageApiConfig { + list: ApiMethod + detail?: ComponentApiConfig + log?: ComponentApiConfig + export?: ApiMethod + exportProgress?: ApiMethod + scanBoxOptions?: Record + toolbar?: Record + parseListResponse?: (res: any) => { list: any[]; total: number } + buildListParams?: (params: { + pagination: { page: number; pageSize: number } + conditions: Record + sort?: { prop: string; order: string } + }) => Record +} + +// ============================================================ +// 五、TabPageRawConfig / TabPageConfig +// ============================================================ +export interface TabPageRawConfig { + name: string + label: string + scanBoxCacheKey: string + scanBoxFieldKeys: string[] + tableColumnKeys: string[] + upperTableDefaults: { + title: string + enableColumnConfig?: boolean + showIndex?: boolean + showSelection?: boolean + emptyText?: string + } + detailTabs?: { name: string; label: string; componentKey: string }[] + detailSections: { + title: string + columnCount: number + fieldKeys: string[] + }[] + api?: TabPageApiConfig + operationButtons?: OperationButtonConfig[] +} + +export interface TabPageConfig { + name: string + label: string + scanBoxCacheKey: string + scanBoxFields: Record[] + upperTable: { + title: string + enableColumnConfig: boolean + showIndex: boolean + showSelection: boolean + emptyText: string + columns: Record[] + } + columnSlots: Record + detailConfig: DetailSectionConfig[] + detailTabs: DetailTabConfig[] + api?: TabPageApiConfig + operationButtons?: OperationButtonConfig[] +} + +// ============================================================ +// 六、resolveTabConfig +// ============================================================ +export function resolveTabConfig(raw: TabPageRawConfig): TabPageConfig { + const scanBoxFields: Record[] = [] + for (const key of raw.scanBoxFieldKeys) { + const def = FIELD_DICT[key] + if (!def || !def.scanBox) continue + scanBoxFields.push({ + label: def.label, + value: def.key, + type: def.scanBox.type, + options: def.scanBox.options ? [...def.scanBox.options] : undefined, + group: def.scanBox.group, + required: (def.scanBox as any).required + }) + } + + const columns: Record[] = [] + for (const key of raw.tableColumnKeys) { + const def = FIELD_DICT[key] + if (!def || !def.table) continue + columns.push({ + prop: def.key, + label: def.label, + ...def.table + }) + } + + const columnSlots: Record = {} + for (const key of raw.tableColumnKeys) { + const def = FIELD_DICT[key] + if (!def || !def.slot) continue + columnSlots[def.key] = { ...def.slot } + } + + const detailConfig: DetailSectionConfig[] = raw.detailSections.map((sec) => ({ + title: sec.title, + columnCount: sec.columnCount, + fields: sec.fieldKeys + .map((key): DetailFieldConfig | null => { + const def = FIELD_DICT[key] + if (!def) return null + return { + key: def.key, + label: def.detailLabel ?? def.label, + translateField: def.slot?.translateField, + tagResolver: def.slot?.tagResolver, + tagType: def.slot?.tagType, + renderType: def.slot?.type === 'tag' ? 'tag' : 'text' + } + }) + .filter((f): f is DetailFieldConfig => f !== null) + })) + + const detailTabs: DetailTabConfig[] = raw.detailTabs + ? raw.detailTabs.map((tab) => ({ + name: tab.name, + label: tab.label, + componentKey: tab.componentKey, + component: COMPONENT_REGISTRY[tab.componentKey] + })) + : [{ name: 'detail', label: '明细', componentKey: 'DetailPanel', component: COMPONENT_REGISTRY['DetailPanel'] }] + + return { + name: raw.name, + label: raw.label, + scanBoxCacheKey: raw.scanBoxCacheKey, + scanBoxFields, + upperTable: { + title: raw.upperTableDefaults.title, + enableColumnConfig: raw.upperTableDefaults.enableColumnConfig ?? true, + showIndex: raw.upperTableDefaults.showIndex ?? true, + showSelection: raw.upperTableDefaults.showSelection ?? true, + emptyText: raw.upperTableDefaults.emptyText ?? '暂无数据', + columns + }, + columnSlots, + detailConfig, + detailTabs, + api: raw.api, + operationButtons: raw.operationButtons + } +} + +// ============================================================ +// 七、buildWhereConditions +// ============================================================ +export function buildWhereConditions(rawConditions: Record): Record { + const where: Record = {} + for (const [key, cond] of Object.entries(rawConditions || {})) { + let value: any = undefined + if (cond && typeof cond === 'object' && 'operator' in cond) { + value = (cond as any).value + } else if (cond !== undefined && cond !== null && cond !== '') { + value = Array.isArray(cond) ? cond[0] ?? '' : cond + } + if (value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0)) { + continue + } + const def = FIELD_DICT[key] + if (def?.filterParamMap) { + const mapped = def.filterParamMap[String(value)] + if (mapped !== undefined) { + where[key] = mapped + continue + } + } + where[key] = value + } + return where +} + +// ============================================================ +// 八、工具栏按钮系统 +// ============================================================ +export interface ToolbarButtonConfig { + key: string + label: string + category: 'common' | 'function' | 'basic' + size?: '' | 'default' | 'small' | 'large' + type?: '' | 'primary' | 'success' | 'warning' | 'info' | 'danger' + plain?: boolean + loadingKey?: string + disabledKey?: string + action: string + dynamicLabelKey?: string + onlyForTabs?: string[] + buttonType?: 'default' | 'dropdown' + dropdownOptions?: Array<{ label: string; action: string; divided?: boolean }> + formKey?: string +} + +export const TOOLBAR_BUTTONS: Record = { + refresh: { + key: 'refresh', + label: '刷新', + category: 'common', + type: 'primary', + size: 'small', + loadingKey: 'loading', + action: 'loadData' + }, + export: { + key: 'export', + label: '导出', + category: 'common', + size: 'small', + loadingKey: 'exportLoading', + action: 'handleExportSelected', + buttonType: 'dropdown', + dropdownOptions: [ + { label: '导出选中', action: 'handleExportSelected' }, + { label: '导出全部', action: 'handleExportAll', divided: true } + ] + }, + columnConfig: { + key: 'columnConfig', + label: '字段设置', + category: 'basic', + size: 'small', + action: 'openColumnConfigPanel' + }, + toggleDetail: { + key: 'toggleDetail', + label: '显示详情', + category: 'basic', + dynamicLabelKey: 'detailToggleLabel', + size: 'small', + action: 'toggleDetailVisible' + } +} + +export function getTabToolbarButtons(tabName: string): ToolbarButtonConfig[] { + return Object.values(TOOLBAR_BUTTONS).filter((btn) => { + if (btn.onlyForTabs && !btn.onlyForTabs.includes(tabName)) return false + if (!PAGE_CONFIG.enableDetailPanel && btn.key === 'toggleDetail') return false + return true + }) +} + +// ============================================================ +// 九、tabPages — 运单列表标签页 +// ============================================================ +export const tabPages: TabPageRawConfig[] = [ + { + name: 'waybill-list', + label: '运单列表', + scanBoxCacheKey: 'waybill-warehouse-list', + scanBoxFieldKeys: [ + 'waybill_code', + 'main_waybill_code', + 'waybill_type', + 'store_name', + 'logistics_code', + 'platform_code', + 'status', + 'pack_status', + 'is_back', + 'is_intercept', + 'is_galaxy_receive', + 'createdAtStart' + ], + tableColumnKeys: [ + 'waybill_code', + 'main_waybill_code', + 'waybill_type', + 'order_no', + 'order_id', + 'business_key', + 'warehouse_name', + 'logistics_code', + 'logistics_name', + 'logistics_interface_name', + 'platform_code', + 'package_material_name', + 'pack_status', + 'status', + 'status_text', + 'is_back', + 'is_intercept', + 'is_galaxy_receive', + 'weighing_weight', + 'weighing_weight_display', + 'print_count', + 'last_print_at', + 'create_at', + 'operation' + ], + upperTableDefaults: { + title: '运单列表(仓库侧)', + showSelection: true + }, + detailTabs: [ + { name: 'detail', label: '运单明细', componentKey: 'DetailPanel' } + ], + detailSections: [ + { + title: '运单基础信息', + columnCount: 3, + fieldKeys: [ + 'waybill_code', 'main_waybill_code', 'waybill_type', + 'order_id', 'order_no', 'business_key', + 'order_type', 'wave_no' + ] + }, + { + title: '仓库/货主', + columnCount: 2, + fieldKeys: ['warehouse_name', 'store_name'] + }, + { + title: '物流信息', + columnCount: 3, + fieldKeys: [ + 'logistics_code', 'logistics_name', 'logistics_interface_id', + 'logistics_interface_name', 'platform_code' + ] + }, + { + title: '包裹信息', + columnCount: 3, + fieldKeys: [ + 'package_material_id', 'package_material_name', 'pack_status', + 'pack_quantity', 'pack_at', 'packer_name' + ] + }, + { + title: '重量与打印', + columnCount: 3, + fieldKeys: [ + 'weighing_weight', 'weighing_weight_display', + 'print_count', 'last_print_at' + ] + }, + { + title: '运单状态', + columnCount: 3, + fieldKeys: [ + 'status', 'status_text', 'is_back', + 'is_intercept', 'is_galaxy_receive' + ] + }, + { + title: '时间信息', + columnCount: 2, + fieldKeys: ['create_at'] + } + ], + api: { + list: waybillWarehouseList as ApiMethod, + detail: { source: 'list' } as ComponentApiConfig, + export: waybillWarehouseExport as ApiMethod, + exportProgress: waybillWarehouseExportTaskProgress as ApiMethod, + parseListResponse(res: any) { + const data = res?.data ?? res + return { + list: data?.list ?? data?.data ?? [], + total: data?.pagination?.total ?? data?.total ?? 0 + } + }, + buildListParams({ pagination, conditions, sort }) { + const where = buildWhereConditions(conditions) + if (conditions?.createdAtStart && Array.isArray(conditions.createdAtStart)) { + const [start, end] = conditions.createdAtStart + if (start) where.createdAtStart = start + if (end) where.createdAtEnd = end + } + const params: Record = { + pagination: { page: pagination.page, pageSize: pagination.pageSize }, + where + } + if (sort?.prop) { + params.sort = { + field: sort.prop, + order: sort.order === 'ascending' ? 'asc' : 'desc' + } + } + return params + } + }, + operationButtons: [ + { + key: 'viewDetail', + label: '查看详情', + actionType: 'action', + type: 'primary' + } + ] + } +] + +// ============================================================ +// 十、向后兼容导出 +// ============================================================ +export const templateTabs = tabPages.map((t) => ({ + name: t.name, + label: t.label, + scanBoxCacheKey: t.scanBoxCacheKey +})) diff --git a/src/views/express/waybill/index.vue b/src/views/express/waybill/index.vue new file mode 100644 index 00000000..bfa79286 --- /dev/null +++ b/src/views/express/waybill/index.vue @@ -0,0 +1,1013 @@ + + + + + + diff --git a/src/views/express/waybill/pages/ExampleFormDialog.vue b/src/views/express/waybill/pages/ExampleFormDialog.vue new file mode 100644 index 00000000..945481b8 --- /dev/null +++ b/src/views/express/waybill/pages/ExampleFormDialog.vue @@ -0,0 +1,107 @@ + + + + + + diff --git a/src/views/order/orderManagement/config/order-common-config.ts b/src/views/order/orderManagement/config/order-common-config.ts index fb913874..56702efd 100644 --- a/src/views/order/orderManagement/config/order-common-config.ts +++ b/src/views/order/orderManagement/config/order-common-config.ts @@ -387,6 +387,26 @@ export const ORDER_TOOLBAR_BUTTONS: Record = { loadingKey: 'resolveExceptionLoading', disabledKey: 'hasNoSelection', action: 'openResolveExceptionDialog' + }, + allocateSubOrderNumber: { + key: 'allocateSubOrderNumber', + label: '分配子单号', + size: 'small', + type: 'primary', + plain: true, + loadingKey: 'allocateSubOrderNumberLoading', + disabledKey: 'notSingleSelection', + action: 'openAllocateSubOrderNumberDialog' + }, + subWaybillPrint: { + key: 'subWaybillPrint', + label: '子单号打印', + size: 'small', + type: 'success', + plain: true, + loadingKey: 'subWaybillPrintLoading', + disabledKey: 'hasNoSelection', + action: 'handleSubWaybillPrint' } } @@ -1468,6 +1488,7 @@ export const deliverybuttonList: any[] = [ export const deliveryOrderToolbarButtonKeys = [ ...simpleListToolbarButtonKeys, 'batchPrint', + 'allocateSubOrderNumber', ] export const deliveryOrderToolbarButtons = pickToolbarButtons(deliveryOrderToolbarButtonKeys) @@ -1859,7 +1880,9 @@ export const pendingToolbarButtonKeys = [ 'batchLock', 'batchUnlock', 'batchPrint', - 'resolveException' + 'resolveException', + 'allocateSubOrderNumber', + 'subWaybillPrint' ] /** 页面级按钮列表:pendingOrder 直接消费,避免页面内重复拼装 */ diff --git a/src/views/order/orderManagement/deliveryOrder.vue b/src/views/order/orderManagement/deliveryOrder.vue index b588b458..a572c068 100644 --- a/src/views/order/orderManagement/deliveryOrder.vue +++ b/src/views/order/orderManagement/deliveryOrder.vue @@ -204,6 +204,16 @@ @print-success="onBatchPrintSuccess" /> + + (null) @@ -486,11 +498,13 @@ function openColumnConfigPanel() { const buttonLoadingMap = computed>(() => ({ exportLoading: exportLoading.value, exportSelectionLoading: exportSelectionLoading.value, - batchPrintLoading: batchPrintLoading.value + batchPrintLoading: batchPrintLoading.value, + allocateSubOrderNumberLoading: allocateSubOrderNumberLoading.value })) const buttonDisabledMap = computed>(() => ({ - hasNoSelection: selectionRows.value.length === 0 + hasNoSelection: selectionRows.value.length === 0, + notSingleSelection: selectionRows.value.length !== 1 })) const buttonLabelMap = computed>(() => ({ @@ -517,6 +531,70 @@ const { actionMap: toolbarActionMap } = createSimpleListToolbarController({ toolbarActionMap.handleBatchPrint = handleBatchPrint +// 分配子单号 +const allocateSubOrderNumberDialogVisible = ref(false) +const allocateSubOrderNumberLoading = ref(false) +const allocateSubOrderNumberOrderId = ref(null) +const allocateSubOrderNumberOrderCode = ref('') +const allocateSubOrderNumberCount = ref(1) + +function openAllocateSubOrderNumberDialog() { + const rows = selectionRows.value + if (rows.length !== 1) { + ElMessage.warning('请选择 1 条订单进行子单号分配') + return + } + const row = rows[0] || {} + const orderId = Number(row?.order_id ?? row?.id) + if (!orderId || !Number.isInteger(orderId) || orderId <= 0) { + ElMessage.error('未识别到有效订单ID') + return + } + allocateSubOrderNumberOrderId.value = orderId + allocateSubOrderNumberOrderCode.value = String(row?.delivery_order_code || '') + allocateSubOrderNumberCount.value = 1 + allocateSubOrderNumberDialogVisible.value = true +} + +async function submitAllocateSubOrderNumber() { + if (!allocateSubOrderNumberOrderId.value || allocateSubOrderNumberLoading.value) return + const sub_order_count = Math.max(1, Number(allocateSubOrderNumberCount.value) || 1) + allocateSubOrderNumberLoading.value = true + try { + const res = await orderPendingOrder.allocateSubOrderNumber({ + order_id: allocateSubOrderNumberOrderId.value, + sub_order_count + }) + const ok = res && (res.code === 1 || res.code === 200 || res.flag === 'success') + if (!ok) { + ElMessage.error(res?.message || '分配子单号失败') + return + } + const taskId = res?.data?.task_id || res?.task_id + ElMessage.success( + taskId + ? `分配子单号任务已受理(任务ID: ${taskId})` + : (res?.message || '分配子单号成功') + ) + allocateSubOrderNumberDialogVisible.value = false + upperTable.value?.clearSelection?.() + selectionRows.value = [] + await loadData() + } catch { + ElMessage.error('分配子单号失败') + } finally { + allocateSubOrderNumberLoading.value = false + } +} + +function resetAllocateSubOrderNumberDialog() { + allocateSubOrderNumberOrderId.value = null + allocateSubOrderNumberOrderCode.value = '' + allocateSubOrderNumberCount.value = 1 +} + +toolbarActionMap.openAllocateSubOrderNumberDialog = openAllocateSubOrderNumberDialog + function resolveButtonLoading(loadingKey?: string) { if (!loadingKey) return false return Boolean(buttonLoadingMap.value[loadingKey]) diff --git a/src/views/order/orderManagement/exceptionOrder.vue b/src/views/order/orderManagement/exceptionOrder.vue index 49442340..518d1ec8 100644 --- a/src/views/order/orderManagement/exceptionOrder.vue +++ b/src/views/order/orderManagement/exceptionOrder.vue @@ -361,6 +361,15 @@ + + >(() => ({ batchAsyncTaskLoading: batchAsyncTaskLoading.value, resolveExceptionLoading: resolveExceptionLoading.value, waveSingleFetchLoading: waveSingleFetchLoading.value, - batchPrintLoading: batchPrintLoading.value + batchPrintLoading: batchPrintLoading.value, + allocateSubOrderNumberLoading: allocateSubOrderNumberLoading.value })) const toolbarLayoutKey = computed(() => diff --git a/src/views/order/orderManagement/form/AllocateSubOrderNumberForm.vue b/src/views/order/orderManagement/form/AllocateSubOrderNumberForm.vue new file mode 100644 index 00000000..9289eba1 --- /dev/null +++ b/src/views/order/orderManagement/form/AllocateSubOrderNumberForm.vue @@ -0,0 +1,120 @@ + + + + + diff --git a/src/views/order/orderManagement/pendingOrder.vue b/src/views/order/orderManagement/pendingOrder.vue index 6de8e7cb..495efae7 100644 --- a/src/views/order/orderManagement/pendingOrder.vue +++ b/src/views/order/orderManagement/pendingOrder.vue @@ -326,6 +326,15 @@ + + + loadData() }) +const { + dialogVisible: subWaybillPrintDialogVisible, + loading: subWaybillPrintLoading, + errorMessage: subWaybillPrintErrorMessage, + payload: subWaybillPrintPayload, + requestMeta: subWaybillPrintRequestMeta, + resetState: resetSubWaybillPrintState, + handlePrint: handleSubWaybillPrint, + handleRefresh: handleSubWaybillPrintRefresh, + onPrintSuccess: onSubWaybillPrintSuccess +} = useSubWaybillPrint({ + getSelectionRows: () => selectionRows.value, + onPrintSuccess: () => loadData() +}) + useOrderListPageCleanup({ list, selectionRows, selectedOrderId, - onCleanup: resetBatchPrintState + onCleanup: () => { + resetBatchPrintState() + resetSubWaybillPrintState() + } }) async function loadData() { @@ -778,7 +815,11 @@ const { batchAsyncTaskOrderIds, batchAsyncTaskPhase, batchAsyncTaskProgress, - waveSingleFetchLoading + waveSingleFetchLoading, + allocateSubOrderNumberDialogVisible, + allocateSubOrderNumberLoading, + allocateSubOrderNumberOrderId, + allocateSubOrderNumberOrderCode }, submitStorageAllocate, submitUpdateOrderMeta, @@ -789,6 +830,7 @@ const { submitUpdateAddress, submitUpdateRemark, submitBatchAsyncTask, + submitAllocateSubOrderNumber, handleBatchQuickRecheckSuccess, closeAllocateExpressProgress, resetAllocateDialog, @@ -800,7 +842,8 @@ const { resetBatchQuickRecheckDialog, resetUpdateAddressDialog, resetUpdateRemarkDialog, - resetBatchAsyncTaskDialog + resetBatchAsyncTaskDialog, + resetAllocateSubOrderNumberDialog } = createPendingToolbarController({ loadData, handleExport, @@ -825,6 +868,7 @@ const { toolbarActionMap['openResolveExceptionDialog'] = openResolveExceptionDialog toolbarActionMap['handleBatchPrint'] = handleBatchPrint +toolbarActionMap['handleSubWaybillPrint'] = handleSubWaybillPrint const buttonLoadingMap = computed>(() => ({ exportLoading: exportLoading.value, @@ -841,7 +885,9 @@ const buttonLoadingMap = computed>(() => ({ batchAsyncTaskLoading: batchAsyncTaskLoading.value, resolveExceptionLoading: resolveExceptionLoading.value, waveSingleFetchLoading: waveSingleFetchLoading.value, - batchPrintLoading: batchPrintLoading.value + batchPrintLoading: batchPrintLoading.value, + allocateSubOrderNumberLoading: allocateSubOrderNumberLoading.value, + subWaybillPrintLoading: subWaybillPrintLoading.value })) const toolbarLayoutKey = computed(() => diff --git a/src/views/order/orderManagement/utils/toolbar-actions.ts b/src/views/order/orderManagement/utils/toolbar-actions.ts index c2264381..db63fc89 100644 --- a/src/views/order/orderManagement/utils/toolbar-actions.ts +++ b/src/views/order/orderManagement/utils/toolbar-actions.ts @@ -618,6 +618,71 @@ export function createPendingToolbarController(params: { const waveSingleFetchLoading = ref(false) + // 分配子单号 + const allocateSubOrderNumberDialogVisible = ref(false) + const allocateSubOrderNumberLoading = ref(false) + const allocateSubOrderNumberOrderId = ref(null) + const allocateSubOrderNumberOrderCode = ref('') + const allocateSubOrderNumberForm = reactive({ sub_order_count: 1 }) + + function openAllocateSubOrderNumberDialog() { + const rows = params.getSelectedRows() + if (rows.length !== 1) { + ElMessage.warning('请选择 1 条订单进行子单号分配') + return + } + const row = rows[0] || {} + const orderId = normalizePositiveIntId(row?.order_id ?? row?.id) + if (!orderId) { + ElMessage.error('未识别到有效订单ID') + return + } + allocateSubOrderNumberOrderId.value = orderId + allocateSubOrderNumberOrderCode.value = String(row?.delivery_order_code || '') + allocateSubOrderNumberForm.sub_order_count = 1 + allocateSubOrderNumberDialogVisible.value = true + } + + async function submitAllocateSubOrderNumber() { + if (!allocateSubOrderNumberOrderId.value || allocateSubOrderNumberLoading.value) return + const sub_order_count = Number(allocateSubOrderNumberForm.sub_order_count) || 1 + if (sub_order_count < 1) { + ElMessage.warning('子单号数量不能小于 1') + return + } + allocateSubOrderNumberLoading.value = true + try { + const res = await params.pendingApi.allocateSubOrderNumber({ + order_id: allocateSubOrderNumberOrderId.value, + sub_order_count + }) + const ok = res && (res.code === 1 || res.code === 200 || res.flag === 'success') + if (!ok) { + ElMessage.error(res?.message || '分配子单号失败') + return + } + const taskId = res?.data?.task_id || res?.task_id + ElMessage.success( + taskId + ? `分配子单号任务已受理(任务ID: ${taskId})` + : (res?.message || '分配子单号成功') + ) + allocateSubOrderNumberDialogVisible.value = false + params.clearSelection() + await params.loadData() + } catch { + ElMessage.error('分配子单号失败') + } finally { + allocateSubOrderNumberLoading.value = false + } + } + + function resetAllocateSubOrderNumberDialog() { + allocateSubOrderNumberOrderId.value = null + allocateSubOrderNumberOrderCode.value = '' + allocateSubOrderNumberForm.sub_order_count = 1 + } + async function handleWaveSingleFetchByIds() { const ids = params.getSelectedIds() if (!ids.length) { @@ -701,7 +766,8 @@ export function createPendingToolbarController(params: { openCloneOrderDialog, openSyncOrderIdsDialog, openBatchQuickRecheckDialog, - handleWaveSingleFetchByIds + handleWaveSingleFetchByIds, + openAllocateSubOrderNumberDialog }, getSelectedIds: params.getSelectedIds, pendingApi: params.pendingApi, @@ -1452,7 +1518,11 @@ export function createPendingToolbarController(params: { batchAsyncTaskOrderIds, batchAsyncTaskPhase, batchAsyncTaskProgress, - waveSingleFetchLoading + waveSingleFetchLoading, + allocateSubOrderNumberDialogVisible, + allocateSubOrderNumberLoading, + allocateSubOrderNumberOrderId, + allocateSubOrderNumberOrderCode }, submitStorageAllocate, submitUpdateOrderMeta, @@ -1463,6 +1533,7 @@ export function createPendingToolbarController(params: { submitUpdateAddress, submitUpdateRemark, submitBatchAsyncTask, + submitAllocateSubOrderNumber, handleBatchQuickRecheckSuccess, closeAllocateExpressProgress, resetAllocateDialog, @@ -1474,7 +1545,8 @@ export function createPendingToolbarController(params: { resetBatchQuickRecheckDialog, resetUpdateAddressDialog, resetUpdateRemarkDialog, - resetBatchAsyncTaskDialog + resetBatchAsyncTaskDialog, + resetAllocateSubOrderNumberDialog } } diff --git a/src/views/order/orderManagement/utils/use-sub-waybill-print.ts b/src/views/order/orderManagement/utils/use-sub-waybill-print.ts new file mode 100644 index 00000000..59be4004 --- /dev/null +++ b/src/views/order/orderManagement/utils/use-sub-waybill-print.ts @@ -0,0 +1,157 @@ +import { ref } from 'vue' +import { ElMessage } from 'element-plus' +import { + getPrintDataByWaybillCodes, + type WavePlatformPrintDataPayload +} from '@/api/order.print/orderprint' +import { unwrapWavePlatformPrintPayload } from '@/views/order/waveOrder/config/wave-config' +import { orderDetail } from '@/api/order.index/orderindex' +import { isOrderIndexApiSuccess, parseOrderDetailPayload, normalizeOrderExpressList } from '../utils/order-index-helpers' + +type SubWaybillPrintRequestMeta = { + waybill_codes: string[] + order_ids: Array +} + +type UseSubWaybillPrintOptions = { + getSelectionRows: () => any[] + onPrintSuccess?: () => void + emptySelectionMessage?: string +} + +function isPrintApiSuccess(code: unknown) { + return code === undefined || code === null || code === 1 || code === 200 || code === 0 +} + +function collectOrderIds(rows: any[]): number[] { + const ids: number[] = [] + const seen = new Set() + for (const row of rows) { + const id = Number(row?.id) + if (Number.isInteger(id) && id > 0 && !seen.has(id)) { + seen.add(id) + ids.push(id) + } + } + return ids +} + +export function useSubWaybillPrint(options: UseSubWaybillPrintOptions) { + const dialogVisible = ref(false) + const loading = ref(false) + const errorMessage = ref('') + const payload = ref(null) + const requestMeta = ref(null) + + function resetState() { + payload.value = null + requestMeta.value = null + errorMessage.value = '' + } + + /** 根据订单 ID 查询运单号(使用快递信息接口 orderDetail) */ + async function fetchWaybillCodes(orderIds: number[]): Promise { + const waybillCodes: string[] = [] + const seen = new Set() + + for (const id of orderIds) { + try { + const res: any = await orderDetail({ + id, + ids: [id], + tableType: 'order' + }) + if (!isOrderIndexApiSuccess(res)) continue + const data = parseOrderDetailPayload(res) + const expressList = normalizeOrderExpressList(data) + for (const item of expressList) { + const code = item?.waybill_code + if (code && !seen.has(code)) { + seen.add(code) + waybillCodes.push(code) + } + } + } catch { + // 单个订单查询失败继续 + } + } + return waybillCodes + } + + async function handlePrint() { + const rows = options.getSelectionRows() + if (!rows.length) { + ElMessage.warning(options.emptySelectionMessage || '请先勾选需要打印子单号的订单') + return + } + if (loading.value) return + + const orderIds = collectOrderIds(rows) + if (!orderIds.length) { + ElMessage.warning('当前勾选记录缺少可用的订单 ID') + return + } + + loading.value = true + errorMessage.value = '' + payload.value = null + + try { + // 1. 通过快递信息接口查询运单号 + const waybillCodes = await fetchWaybillCodes(orderIds) + if (!waybillCodes.length) { + throw new Error('未查询到选中订单的运单号,请确认订单已分配快递号') + } + + // 2. 获取打印数据 + const res: any = await getPrintDataByWaybillCodes({ waybill_codes: waybillCodes }) + if (!isPrintApiSuccess(res?.code)) { + throw new Error(res?.message || '获取打印数据失败') + } + payload.value = unwrapWavePlatformPrintPayload(res) + requestMeta.value = { waybill_codes: waybillCodes, order_ids: orderIds } + dialogVisible.value = true + ElMessage.success(res?.message || `已获取 ${waybillCodes.length} 个运单的打印数据`) + } catch (error: any) { + payload.value = null + errorMessage.value = error?.message || '获取打印数据失败' + dialogVisible.value = true + ElMessage.error(errorMessage.value) + } finally { + loading.value = false + } + } + + async function handleRefresh() { + const meta = requestMeta.value + if (!meta || !meta.waybill_codes.length) return + try { + const res: any = await getPrintDataByWaybillCodes({ waybill_codes: meta.waybill_codes }) + if (!isPrintApiSuccess(res?.code)) { + throw new Error(res?.message || '刷新打印数据失败') + } + payload.value = unwrapWavePlatformPrintPayload(res) + errorMessage.value = '' + } catch (error: any) { + payload.value = null + errorMessage.value = error?.message || '刷新打印数据失败' + ElMessage.error(errorMessage.value) + } + } + + function onPrintSuccess() { + options.onPrintSuccess?.() + } + + return { + dialogVisible, + loading, + errorMessage, + payload, + requestMeta, + resetState, + handlePrint, + handleRefresh, + onPrintSuccess + } +} diff --git a/src/views/order/waveOrder/component/WavePlatformPrintPreviewDialog.vue b/src/views/order/waveOrder/component/WavePlatformPrintPreviewDialog.vue index 7a5719f8..4e906c4a 100644 --- a/src/views/order/waveOrder/component/WavePlatformPrintPreviewDialog.vue +++ b/src/views/order/waveOrder/component/WavePlatformPrintPreviewDialog.vue @@ -241,6 +241,7 @@ import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint' import { unlockWavePlatformPrintDataByGroup } from '@/api/order.print/orderprint' import * as stationApi from '@/api/print/print' import type { PrintSendParams } from '@/api/print/print' +import { orderModule } from '@/api/order/order' import { getBrowserPrintUsageHint, getLoopbackPrinterAccessHint @@ -1035,6 +1036,40 @@ async function notifyLockAfterBrowserPrint( } } +/** 精简 waveGroups 数据,移除 print.send 不需要的字段 */ +function stripRedundantPrintFields(waveGroups: unknown[]): unknown[] { + return waveGroups.map((wg: any) => { + if (!wg || typeof wg !== 'object') return wg + const platforms = Array.isArray(wg.platforms) + ? wg.platforms.map((p: any) => { + if (!p || typeof p !== 'object') return p + const orders = Array.isArray(p.orders) + ? p.orders.map((o: any) => { + if (!o || typeof o !== 'object') return o + const contents = Array.isArray(o.contents) + ? o.contents.map((c: any) => { + if (!c || typeof c !== 'object') return c + const { config, ...rest } = c + return rest + }) + : o.contents + return { ...o, contents } + }) + : p.orders + const { + platform_name: _pn, + sys_logistics_name: _sln, + order_count: _oc, + order_ids: _oi, + ...restPlatform + } = p + return { ...restPlatform, orders } + }) + : wg.platforms + return { ...wg, platforms } + }) +} + async function printToStation() { if (!printSettings.station) { ElMessage.warning('请选择打印台') @@ -1063,7 +1098,7 @@ async function printToStation() { type: 'express', printStationId: sid, requestCode, - data: { waveGroups } + data: { waveGroups: stripRedundantPrintFields(waveGroups as unknown[]) } } const res: any = await stationApi.sendPrint(printPayload) if (res && (res.code === 0 || res.code === 200 || res.flag === 'success' || res.status === 'success')) { @@ -1104,6 +1139,42 @@ function clearSavedStationId() { } } +/** 从浏览器打印结果中提取成功打印的订单 ID 列表 */ +function collectPrintedOrderIds( + waveGroups: unknown[], + items: BrowserWavePrintItemResult[], +): number[] { + const successKeys = new Set( + items + .filter((item) => item.flag === 'success') + .map((item) => `${item.wave_id}::${item.platform}::${item.platform_name}`), + ) + if (!successKeys.size) return [] + + const orderIds: number[] = [] + for (const rawWave of waveGroups) { + const wave = rawWave as AnyRecord | null + if (!wave) continue + const wave_id = String(wave.wave_id ?? '') + const rawPlatforms = Array.isArray(wave.platforms) ? wave.platforms : [] + for (const rawPlatform of rawPlatforms) { + const p = rawPlatform as AnyRecord | null + if (!p) continue + const platform = String(p.platform ?? '').trim() + const platform_name = String(p.platform_name ?? platform).trim() || platform + if (!successKeys.has(`${wave_id}::${platform}::${platform_name}`)) continue + const ids = Array.isArray(p.order_ids) ? p.order_ids : [] + ids.forEach((id: any) => { + const num = Number(id) + if (Number.isFinite(num) && !orderIds.includes(num)) { + orderIds.push(num) + } + }) + } + } + return orderIds +} + async function printReport() { console.log('[wave browser print] printReport: 用户点击浏览器打印') @@ -1185,7 +1256,20 @@ async function printReport() { const lockResult = await notifyLockAfterBrowserPrint(waveGroups, result.items) console.log('[wave browser print] printReport: notifyLock 返回', lockResult) + // 锁定成功后,标记已打印订单 if (lockResult.ok) { + const printedOrderIds = collectPrintedOrderIds(waveGroups, result.items) + if (printedOrderIds.length > 0) { + try { + const markRes: any = await orderModule.pendingOrderBatchMarkPrinted({ order_ids: printedOrderIds }) + console.log('[wave browser print] printReport: batchMarkPrinted 返回', { + requested: printedOrderIds.length, + updated: markRes?.data?.updated_count ?? markRes?.updated_count ?? '?', + }) + } catch (markErr) { + console.warn('[wave browser print] printReport: batchMarkPrinted 失败', markErr) + } + } if (isPartial) { ElMessage.warning(`${result.message};${lockResult.message || '已成功分组订单已锁定'}`) console.warn('[wave browser print] failed groups:', result.items.filter((item) => item.flag === 'failure')) diff --git a/src/views/storage/entry/component/EntryBindingRelations.vue b/src/views/storage/entry/component/EntryBindingRelations.vue index 0ac064e1..7d14e794 100644 --- a/src/views/storage/entry/component/EntryBindingRelations.vue +++ b/src/views/storage/entry/component/EntryBindingRelations.vue @@ -152,6 +152,7 @@ type ReceivingBindingRow = { receiving_id?: number receiving_number: string status_label: string + storage_status_label: string created_at: string } diff --git a/src/views/storage/entry/index.vue b/src/views/storage/entry/index.vue index 2da7a9e4..c13a3073 100644 --- a/src/views/storage/entry/index.vue +++ b/src/views/storage/entry/index.vue @@ -154,7 +154,7 @@ size="small" @click.stop="handleReviewEntry(row)" > - 开始入库 + 推送到仓库 { const mapped: Record = {} - entrydetail.forEach((column) => { + entrydetail.forEach((column: any) => { const prop = String(column.prop) const label = column.label || prop const rawValue = item[prop] diff --git a/src/views/storage/receiving/index.vue b/src/views/storage/receiving/index.vue index 45e680ca..034daebd 100644 --- a/src/views/storage/receiving/index.vue +++ b/src/views/storage/receiving/index.vue @@ -1492,7 +1492,6 @@ async function handleQuickPutaway() { } } -// 导出相关 —— 使用异步任务模式 function buildExportPayload() { if (currentCondition.value && currentCondition.value !== 'reset') { return { where: normalizeToWhere(currentCondition.value) } diff --git a/src/views/storage/receiving/receiving-config.ts b/src/views/storage/receiving/receiving-config.ts index 20b3f6c8..de79a803 100644 --- a/src/views/storage/receiving/receiving-config.ts +++ b/src/views/storage/receiving/receiving-config.ts @@ -552,7 +552,7 @@ export const receivingToolbarButtons: ToolbarButtonConfig[] = [ buttonType: 'dropdown', dropdownOptions: [ { label: '导出选中', action: 'handleExportSelected' }, - { label: '导出全部', action: 'handleExportAll', divided: true } + { label: '导出全部', action: 'handleExportAll', divided: true }, ] }, { key: 'columnConfig', label: '字段设置', size: 'small', action: 'openColumnConfigPanel' },