1
This commit is contained in:
parent
1706b927e7
commit
6274ce1407
BIN
dist.tar.gz
BIN
dist.tar.gz
Binary file not shown.
116
src/api/inbox/inbox.ts
Normal file
116
src/api/inbox/inbox.ts
Normal file
@ -0,0 +1,116 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
const v = '1.0'
|
||||
|
||||
// ============================================================
|
||||
// 站内信模块 API
|
||||
// ============================================================
|
||||
|
||||
/** 站内信列表查询参数 */
|
||||
export interface InboxListParams {
|
||||
direction?: string // 消息方向筛选:inbound(收件)/ outbound(回信)
|
||||
pushStatus?: number // 推送状态筛选:0=待推送 1=推送中 2=已送达 3=失败
|
||||
targetChannel?: string // 目标渠道筛选:wecom / dingtalk / feishu / warehouse_api / webhook
|
||||
keyword?: string // 关键词搜索,模糊匹配 ext_id 和 ref_code
|
||||
page?: number // 页码,默认 1
|
||||
pageSize?: number // 每页数量,默认 20,最大 200
|
||||
}
|
||||
|
||||
/** 站内信消息列表(inbox.list) */
|
||||
export function inboxList(data: InboxListParams = {}) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'inbox.list',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 站内信消息详情(inbox.detail) */
|
||||
export function inboxDetail(id: number) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'inbox.detail',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data: { id },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 站内信对话链查询(inbox.thread) */
|
||||
export function inboxThread(id: number) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'inbox.thread',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data: { id },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 站内信回信参数 */
|
||||
export interface InboxReplyParams {
|
||||
parentId: number // 原消息ID(回信指向的原消息)
|
||||
targetChannel: string // 目标渠道:wecom / dingtalk / feishu / warehouse_api / webhook
|
||||
targetType?: string // 目标类型:im / api / webhook,默认继承原消息的 target_type
|
||||
extData?: Record<string, unknown> // 透传数据,默认继承原消息的 ext_data
|
||||
flags?: Record<string, unknown> // 处理标记
|
||||
}
|
||||
|
||||
/** 系统回信(inbox.reply) */
|
||||
export function inboxReply(data: InboxReplyParams) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'inbox.reply',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 手动重推失败消息(inbox.retry) */
|
||||
export function inboxRetry(id: number) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'inbox.retry',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data: { id },
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** 站内信推送统计(inbox.stats) */
|
||||
export function inboxStats(direction?: string) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'inbox.stats',
|
||||
v,
|
||||
timestamp: Date.now()
|
||||
},
|
||||
data: direction !== undefined ? { direction } : {},
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
@ -10,6 +10,12 @@ export type OrderListParams = {
|
||||
page_size?: number
|
||||
size?: number
|
||||
}
|
||||
/**
|
||||
* 统一 where 条件对象(推荐 { operator, value, type } 标准结构,历史简写自动标准化)。
|
||||
* - 禁止传入 warehouse_id / warehouseId(由后端根据当前登录仓库上下文自动注入)。
|
||||
* - 虚拟字段:buyer_message_has(买家留言筛选,value=true 有留言/value=false 无留言)、
|
||||
* express_numbers / waybill_codes(运单号筛选)。
|
||||
*/
|
||||
where?: Record<string, any>
|
||||
sort?: {
|
||||
sortField?: string
|
||||
@ -28,7 +34,9 @@ export type OrderListPagination = {
|
||||
hasNext?: boolean
|
||||
}
|
||||
|
||||
/** order.list 响应 data 结构 */
|
||||
/** order.list 响应 data 结构
|
||||
* - list 每条 raw 行数据新增 store_remark(货主备注)字段
|
||||
*/
|
||||
export type OrderWorkbenchListResponse = {
|
||||
list: any[]
|
||||
pagination: OrderListPagination
|
||||
|
||||
@ -398,20 +398,73 @@ export type WaveStrategyQuickScanTaskProgressResponse = {
|
||||
duration_ms?: number
|
||||
}
|
||||
|
||||
/** order.wave.waveStrategyFallbackOrderList where 白名单字段 */
|
||||
export type WaveStrategyFallbackOrderListWhere = {
|
||||
/** 订单 ID(等值匹配) */
|
||||
id?: string | number
|
||||
/** 发货单号(模糊匹配),兼容 deliveryNo */
|
||||
delivery_no?: string
|
||||
deliveryNo?: string
|
||||
/** 运单号(模糊匹配),兼容 trackingNo */
|
||||
tracking_no?: string
|
||||
trackingNo?: string
|
||||
/** 商品种类数下限 */
|
||||
items_count_min?: number
|
||||
/** 商品种类数上限 */
|
||||
items_count_max?: number
|
||||
/** 商品总数下限 */
|
||||
items_total_min?: number
|
||||
/** 商品总数上限 */
|
||||
items_total_max?: number
|
||||
/** 系统物流名称(模糊匹配) */
|
||||
sys_logistics_name?: string
|
||||
/** 货主名称(模糊匹配) */
|
||||
store_name?: string
|
||||
/** 货主(等值匹配) */
|
||||
owner_name?: string
|
||||
/** 省份(模糊匹配) */
|
||||
province?: string
|
||||
/** 系统平台名称(模糊匹配) */
|
||||
sys_platform_name?: string
|
||||
/** 买家留言筛选(虚拟字段:true=有留言,false=无留言) */
|
||||
buyer_message_has?: boolean
|
||||
/** 禁止传入 */
|
||||
warehouse_id?: never
|
||||
warehouseId?: never
|
||||
}
|
||||
|
||||
export type WaveStrategyFallbackOrderListParams = {
|
||||
/** 分页参数,仅支持 page / pageSize */
|
||||
pagination?: {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
currentPage?: number
|
||||
page_size?: number
|
||||
size?: number
|
||||
}
|
||||
where?: Record<string, any>
|
||||
/**
|
||||
* 筛选白名单字段。
|
||||
* 仅支持上述 where 类型中声明的字段,禁止传入 warehouse_id / warehouseId。
|
||||
* 若传入未列出的字段或禁止字段,接口返回 400。
|
||||
*/
|
||||
where?: WaveStrategyFallbackOrderListWhere
|
||||
}
|
||||
|
||||
/** 不符合波次策略订单行;含接口新增的 item_snapshot(商品名称*数量|…) */
|
||||
/** 不符合波次策略订单行(回退候选订单简要列表)。
|
||||
* 该接口内置固定筛选:step != 0、wave_id = 0、wave_scan_result = 2。
|
||||
* - item_snapshot:商品名称*数量拼接快照(如 "商品A*2|商品B*1")
|
||||
*/
|
||||
export type WaveStrategyFallbackOrderListRow = Record<string, unknown> & {
|
||||
id?: number | string
|
||||
delivery_no?: string
|
||||
tracking_no?: string
|
||||
sys_logistics_name?: string
|
||||
store_name?: string
|
||||
owner_name?: string
|
||||
province?: string
|
||||
sys_platform_name?: string
|
||||
items_count?: number | string
|
||||
items_total?: number | string
|
||||
buyer_message?: string
|
||||
item_snapshot?: string
|
||||
store_remark?: string
|
||||
}
|
||||
|
||||
export type WaveStrategyFallbackOrderListPagination = {
|
||||
|
||||
@ -1209,7 +1209,7 @@ export const deliveryTimeRangeScanField = scanBasicField({ label: '配送时间'
|
||||
export const placeOrderTimeRangeScanField = scanBasicField({ label: '下单时间', value: 'place_order_time', type: 'datetimerange' })
|
||||
export const isUrgencyScanField = scanBasicField({ label: '是否紧急', value: 'is_urgency', type: 'select', options: isUrgencyFilterOptions })
|
||||
export const buyerMessageHasScanField = scanBasicField({ label: '有无留言', value: 'buyer_message_has', type: 'select', options: buyerMessageHasFilterOptions })
|
||||
export const buyerMessageScanField = scanBasicField({ label: '买家留言', value: 'buyer_message', type: 'text' })
|
||||
export const buyerMessageScanField = scanBasicField({ label: '留言', value: 'buyer_message', type: 'text', defaultOperator: 'like' })
|
||||
|
||||
/** 可复用 ScanBox 字段片段(工作流程) */
|
||||
export const orderStatusScanField = (options: Array<{ label: string; value: string }>) =>
|
||||
@ -1324,44 +1324,54 @@ export function fillStoreScanFieldOptions(availableFields: any[], rawStores: any
|
||||
if (field) field.options = mapStoreListToSelectOptions(rawStores)
|
||||
}
|
||||
|
||||
// === ScanBox 筛选分组常量 ===
|
||||
const SCAN_QUICK_FILTER_GROUP = '快速筛选'
|
||||
const SCAN_ORDER_INFO_GROUP = '订单信息'
|
||||
const SCAN_PROCESS_STATUS_GROUP = '流程状态'
|
||||
const SCAN_RECEIVING_INFO_GROUP = '收货信息'
|
||||
const SCAN_TIME_GROUP = '时间'
|
||||
|
||||
// deliveryOrder相关配置
|
||||
export const deliveryAvailableFields = [
|
||||
// 基础信息
|
||||
storeScanField,
|
||||
orderIdScanField,
|
||||
orderQuickSearchScanField,
|
||||
// deliveryOrderCodeScanField,
|
||||
sourceOrderCodesScanField,
|
||||
orderFlagScanField,
|
||||
waveAssignmentScanField,
|
||||
waveNoScanField,
|
||||
shopNickScanField,
|
||||
sysPlatformNameScanField,
|
||||
receiverNameScanField,
|
||||
receiverMobileScanField,
|
||||
buyerMessageHasScanField,
|
||||
buyerMessageScanField,
|
||||
logisticsNameScanField,
|
||||
expressCompanyScanField,
|
||||
waybillCodesScanField,
|
||||
isUrgencyScanField,
|
||||
createAtRangeScanField,
|
||||
payTimeRangeScanField,
|
||||
deliveryTimeRangeScanField,
|
||||
// 工作流程(按订单作业顺序,对齐 deliveryColumns 状态列)
|
||||
orderStatusScanField(pendingOrderStatusFilterOptions),
|
||||
syncStatusScanField,
|
||||
inspectionStatusScanField,
|
||||
recheckStatusScanField,
|
||||
storageStatusScanField,
|
||||
postStatusScanField,
|
||||
outboundStatusScanField,
|
||||
pickStatusScanField,
|
||||
packStatusScanField,
|
||||
printStatusScanField,
|
||||
claimStatusScanField,
|
||||
lockStatusScanField,
|
||||
interceptStatusScanField,
|
||||
// 快速筛选
|
||||
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
// 订单信息
|
||||
{ ...orderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...waybillCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 流程状态
|
||||
{ ...orderStatusScanField(pendingOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...outboundStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...inspectionStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...storageStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...postStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...claimStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...lockStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...interceptStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
// 订单信息
|
||||
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sysPlatformNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 收货信息
|
||||
{ ...receiverNameScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...receiverMobileScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
// 时间
|
||||
{ ...createAtRangeScanField, group: SCAN_TIME_GROUP },
|
||||
{ ...payTimeRangeScanField, group: SCAN_TIME_GROUP },
|
||||
{ ...deliveryTimeRangeScanField, group: SCAN_TIME_GROUP },
|
||||
]
|
||||
|
||||
/** upper-table 列点击复制:`copy` 仅复制;`copyQr` 复制并弹出快递单号二维码 */
|
||||
@ -1415,6 +1425,7 @@ export const deliveryColumns = applyOrderListCopyActions([
|
||||
{ prop: 'name', label: '收件人', width: '100' },
|
||||
{ prop: 'mobile', label: '电话', width: '120' },
|
||||
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
|
||||
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
|
||||
{ prop: 'province', label: '省份', width: '90' },
|
||||
{ prop: 'city', label: '城市', width: '90' },
|
||||
{ prop: 'area', label: '区/县', width: '90' },
|
||||
@ -1498,10 +1509,7 @@ export const deliverybuttonList: any[] = [
|
||||
|
||||
/** deliveryOrder */
|
||||
export const deliveryOrderToolbarButtonKeys = [
|
||||
'refresh',
|
||||
'deliveryExport',
|
||||
'columnConfig',
|
||||
'toggleDetail',
|
||||
...simpleListToolbarButtonKeys,
|
||||
'batchPrint',
|
||||
'allocateSubOrderNumber',
|
||||
]
|
||||
@ -1509,27 +1517,30 @@ export const deliveryOrderToolbarButtons = pickToolbarButtons(deliveryOrderToolb
|
||||
|
||||
// revieworder相关配置
|
||||
export const reviewAvailableFields = [
|
||||
// 基础信息
|
||||
storeScanField,
|
||||
orderIdScanField,
|
||||
orderQuickSearchScanField,
|
||||
// deliveryOrderCodeScanField,
|
||||
sourceOrderCodesScanField,
|
||||
waveAssignmentScanField,
|
||||
waveNoScanField,
|
||||
shopNickScanField,
|
||||
sysPlatformCodeScanField,
|
||||
receiverNameScanField,
|
||||
receiverMobileScanField,
|
||||
buyerMessageHasScanField,
|
||||
buyerMessageScanField,
|
||||
expressCompanyScanField,
|
||||
isUrgencyScanField,
|
||||
createAtRangeScanField,
|
||||
// 工作流程(按订单作业顺序)
|
||||
orderStatusScanField(reviewOrderStatusFilterOptions),
|
||||
syncStatusScanField,
|
||||
recheckStatusScanField,
|
||||
// 快速筛选
|
||||
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
// 订单信息
|
||||
{ ...orderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 流程状态
|
||||
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...orderStatusScanField(reviewOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
|
||||
// 订单信息
|
||||
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sysPlatformCodeScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 收货信息
|
||||
{ ...receiverNameScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...receiverMobileScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
// 时间
|
||||
{ ...createAtRangeScanField, group: SCAN_TIME_GROUP },
|
||||
]
|
||||
|
||||
export const reviewColums = applyOrderListCopyActions([
|
||||
@ -1554,6 +1565,7 @@ export const reviewColums = applyOrderListCopyActions([
|
||||
{ prop: 'operate_time', label: '审核时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'create_at', label: '创建时间', width: '165', formatter: orderTimeFormatter },
|
||||
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
|
||||
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
|
||||
])
|
||||
|
||||
export const reviewOrderDetail = [
|
||||
@ -1658,39 +1670,42 @@ export const outboundToolbarButtons = pickToolbarButtons(outboundToolbarButtonKe
|
||||
|
||||
// pendingOrder相关配置
|
||||
export const pendingAvailableFields = [
|
||||
// 基础信息
|
||||
storeScanField,
|
||||
orderIdScanField,
|
||||
pendingOrderQuickSearchScanField,
|
||||
// pendingOrderCodeScanField,
|
||||
sourceOrderCodesScanField,
|
||||
orderFlagScanField,
|
||||
waveAssignmentScanField,
|
||||
waveNoScanField,
|
||||
shopNickScanField,
|
||||
sysPlatformNameScanField,
|
||||
logisticsNameScanField,
|
||||
expressCompanyScanField,
|
||||
waybillCodesScanField,
|
||||
receiverNameScanField,
|
||||
receiverMobileScanField,
|
||||
receiverProvinceScanField,
|
||||
receiverCityScanField,
|
||||
receiverAreaScanField,
|
||||
buyerMessageHasScanField,
|
||||
buyerMessageScanField,
|
||||
isUrgencyScanField,
|
||||
placeOrderTimeRangeScanField,
|
||||
createAtRangeScanField,
|
||||
// 工作流程(按订单作业顺序)
|
||||
orderStatusScanField(pendingOrderStatusFilterOptions),
|
||||
syncStatusScanField,
|
||||
recheckStatusScanField,
|
||||
storageStatusScanField,
|
||||
postStatusScanField,
|
||||
pickStatusScanField,
|
||||
packStatusScanField,
|
||||
printStatusScanField,
|
||||
// 快速筛选
|
||||
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
// 订单信息
|
||||
{ ...pendingOrderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...waybillCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 流程状态
|
||||
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...storageStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...postStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...orderStatusScanField(pendingOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
|
||||
// 订单信息
|
||||
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sysPlatformNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 收货信息
|
||||
{ ...receiverNameScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...receiverMobileScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...receiverProvinceScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...receiverCityScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...receiverAreaScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
// 时间
|
||||
{ ...placeOrderTimeRangeScanField, group: SCAN_TIME_GROUP },
|
||||
{ ...createAtRangeScanField, group: SCAN_TIME_GROUP },
|
||||
]
|
||||
|
||||
export const pendingCloums = [
|
||||
@ -1704,6 +1719,7 @@ export const pendingCloums = [
|
||||
{ prop: 'name', label: '收件人', width: '110' },
|
||||
{ prop: 'mobile', label: '电话', width: '120' },
|
||||
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
|
||||
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
|
||||
{ prop: 'is_urgency', label: '是否紧急', width: '100' },
|
||||
{ prop: 'sync_status', label: '同步状态', width: '100' },
|
||||
{ prop: 'storage_status', label: '储位状态', width: '100' },
|
||||
@ -1711,7 +1727,7 @@ export const pendingCloums = [
|
||||
{ prop: 'pick_status', label: '拣货状态', width: '100' },
|
||||
{ prop: 'pack_status', label: '打包状态', width: '100' },
|
||||
{ prop: 'intercept_status', label: '拦截状态', width: '100', tag: true },
|
||||
{ prop: 'express_numbers', label: '运单号', width: '160', formatter: waybillCodesFormatter },
|
||||
{ prop: 'express_numbers', label: '快递单号', width: '160', formatter: waybillCodesFormatter },
|
||||
{ prop: 'items_count', label: '商品种类', width: '100' },
|
||||
{ prop: 'items_total', label: '商品总数', width: '100' },
|
||||
{ prop: 'items_weight', label: '商品重量(g)', width: '110' },
|
||||
@ -1738,6 +1754,7 @@ export const ORDER_LIST_FIELD_LABELS: Record<string, string> = {
|
||||
order_type: '订单类型',
|
||||
buyer_nick: '买家昵称',
|
||||
buyer_message: '买家留言',
|
||||
seller_message: '卖家留言',
|
||||
pre_delivery_order_code: '前置单号',
|
||||
delivery_time: '配送时间',
|
||||
items_weight: '商品重量(g)',
|
||||
@ -1928,18 +1945,21 @@ export const workbenchStatusOptions = [
|
||||
]
|
||||
|
||||
export const workbenchAvailableFields = [
|
||||
// 基础信息
|
||||
orderIdScanField,
|
||||
deliveryOrderCodeScanField,
|
||||
sourceOrderCodesScanField,
|
||||
waveAssignmentScanField,
|
||||
waveNoScanField,
|
||||
buyerNickScanField,
|
||||
buyerMessageHasScanField,
|
||||
buyerMessageScanField,
|
||||
isUrgencyScanField,
|
||||
// 工作流程
|
||||
orderStatusScanField(workbenchStatusOptions),
|
||||
// 快速筛选
|
||||
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
// 订单信息
|
||||
{ ...deliveryOrderCodeScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 流程状态
|
||||
{ ...orderStatusScanField(workbenchStatusOptions), group: SCAN_PROCESS_STATUS_GROUP },
|
||||
// 订单信息
|
||||
{ ...buyerNickScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 收货信息
|
||||
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
]
|
||||
|
||||
export const workbenchColumns = applyOrderListCopyActions([
|
||||
@ -1955,6 +1975,7 @@ export const workbenchColumns = applyOrderListCopyActions([
|
||||
{ prop: 'name', label: '收件人', minWidth: 100 },
|
||||
{ prop: 'mobile', label: '电话', minWidth: 120 },
|
||||
{ prop: 'buyer_message', label: '买家留言', minWidth: 180 },
|
||||
{ prop: 'seller_message', label: '卖家留言', minWidth: 180 },
|
||||
{ prop: 'is_urgency', label: '是否紧急', minWidth: 100 },
|
||||
{ prop: 'status', label: '订单状态', minWidth: 120, formatter: (row: any) => translateOrderField('status', row.status) },
|
||||
{ prop: 'sync_status', label: '同步状态', minWidth: 110 },
|
||||
@ -1988,33 +2009,35 @@ export const workbenchBadgeItems = [
|
||||
|
||||
// expectionOrder相关配置
|
||||
export const expectionOrderAvailableFields = [
|
||||
// 基础信息
|
||||
storeScanField,
|
||||
orderIdScanField,
|
||||
orderQuickSearchScanField,
|
||||
// exceptionOrderCodeScanField,
|
||||
// deliveryOrderCodeScanField,
|
||||
sourceOrderCodesScanField,
|
||||
orderFlagScanField,
|
||||
waveAssignmentScanField,
|
||||
waveNoScanField,
|
||||
logisticsNameScanField,
|
||||
expressCompanyScanField,
|
||||
expressCodeScanField,
|
||||
buyerMessageHasScanField,
|
||||
buyerMessageScanField,
|
||||
isUrgencyScanField,
|
||||
createAtRangeScanField,
|
||||
// 工作流程(按订单作业顺序)
|
||||
orderStatusScanField(exceptionOrderStatusFilterOptions),
|
||||
syncStatusScanField,
|
||||
recheckStatusScanField,
|
||||
storageStatusScanField,
|
||||
postStatusScanField,
|
||||
pickStatusScanField,
|
||||
packStatusScanField,
|
||||
printStatusScanField,
|
||||
interceptStatusScanField,
|
||||
// 快速筛选
|
||||
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
// 订单信息
|
||||
{ ...orderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCodeScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 流程状态
|
||||
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...storageStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...postStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...interceptStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...orderStatusScanField(exceptionOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
|
||||
// 订单信息
|
||||
{ ...orderFlagScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...logisticsNameScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 收货信息
|
||||
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
// 时间
|
||||
{ ...createAtRangeScanField, group: SCAN_TIME_GROUP },
|
||||
]
|
||||
|
||||
export const expectionColumns = [
|
||||
@ -2036,6 +2059,7 @@ export const expectionColumns = [
|
||||
{ prop: 'name', label: '收件人', width: '110' },
|
||||
{ prop: 'mobile', label: '电话', width: '120' },
|
||||
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
|
||||
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
|
||||
{ prop: 'logistics_name', label: '快递', width: '120' },
|
||||
{ prop: 'pre_delivery_order_code', label: '前置单号', width: '140' },
|
||||
{ prop: 'order_flag', label: '订单标记', minWidth: '260' },
|
||||
@ -2101,28 +2125,29 @@ export const expectionOrderbuttonList: any[] = [
|
||||
|
||||
// deliveryException相关配置
|
||||
export const archiveAvailableFields = [
|
||||
// 基础信息
|
||||
storeScanField,
|
||||
orderIdScanField,
|
||||
orderQuickSearchScanField,
|
||||
// exceptionOrderCodeScanField,
|
||||
// deliveryOrderCodeScanField,
|
||||
sourceOrderCodesScanField,
|
||||
waveAssignmentScanField,
|
||||
waveNoScanField,
|
||||
shopNickScanField,
|
||||
expressCompanyScanField,
|
||||
receiverNameScanField,
|
||||
receiverMobileScanField,
|
||||
buyerMessageHasScanField,
|
||||
buyerMessageScanField,
|
||||
isUrgencyScanField,
|
||||
// 工作流程(按订单作业顺序)
|
||||
orderStatusScanField(archiveOrderStatusFilterOptions),
|
||||
syncStatusScanField,
|
||||
outboundStatusScanField,
|
||||
pickStatusScanField,
|
||||
packStatusScanField,
|
||||
// 快速筛选
|
||||
{ ...storeScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...isUrgencyScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
{ ...waveAssignmentScanField, group: SCAN_QUICK_FILTER_GROUP },
|
||||
// 订单信息
|
||||
{ ...orderQuickSearchScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...orderIdScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...waveNoScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...sourceOrderCodesScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 流程状态
|
||||
{ ...orderStatusScanField(archiveOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...syncStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...outboundStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
// 订单信息
|
||||
{ ...shopNickScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
{ ...expressCompanyScanField, group: SCAN_ORDER_INFO_GROUP },
|
||||
// 收货信息
|
||||
{ ...receiverNameScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...receiverMobileScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageHasScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
{ ...buyerMessageScanField, group: SCAN_RECEIVING_INFO_GROUP },
|
||||
]
|
||||
|
||||
export const archiveColumns = applyOrderListCopyActions([
|
||||
@ -2137,6 +2162,7 @@ export const archiveColumns = applyOrderListCopyActions([
|
||||
{ prop: 'name', label: '收件人', width: '120' },
|
||||
{ prop: 'mobile', label: '电话', width: '120' },
|
||||
{ prop: 'buyer_message', label: '买家留言', minWidth: '180' },
|
||||
{ prop: 'seller_message', label: '卖家留言', minWidth: '180' },
|
||||
{ prop: 'items_weight', label: '商品重量(g)', width: '110' },
|
||||
{ prop: 'logistics_name', label: '快递', width: '120' },
|
||||
{ prop: 'status', label: '订单状态', width: '100', formatter: (row: any) => translateOrderField('status', row.status) },
|
||||
|
||||
@ -270,7 +270,8 @@ function sanitizeFallbackOrderWhere(where: Record<string, any>) {
|
||||
store_name: 'store_name',
|
||||
owner_name: 'owner_name',
|
||||
province: 'province',
|
||||
sys_platform_name: 'sys_platform_name'
|
||||
sys_platform_name: 'sys_platform_name',
|
||||
buyer_message_has: 'buyer_message_has'
|
||||
}
|
||||
const nextWhere: Record<string, any> = {}
|
||||
Object.keys(where || {}).forEach((key) => {
|
||||
|
||||
@ -3243,7 +3243,8 @@ function sanitizeFallbackOrderWhere(where: Record<string, any>) {
|
||||
store_name: 'store_name',
|
||||
owner_name: 'owner_name',
|
||||
province: 'province',
|
||||
sys_platform_name: 'sys_platform_name'
|
||||
sys_platform_name: 'sys_platform_name',
|
||||
buyer_message_has: 'buyer_message_has'
|
||||
}
|
||||
const nextWhere: Record<string, any> = {}
|
||||
Object.keys(where || {}).forEach((key) => {
|
||||
|
||||
@ -30,61 +30,92 @@
|
||||
</el-select>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-select
|
||||
v-model="printSettings.defaultPrinter"
|
||||
placeholder="请选择默认打印机"
|
||||
size="small"
|
||||
filterable
|
||||
clearable
|
||||
:loading="printerLoading"
|
||||
@change="handleDefaultPrinterChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in printerOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button size="small" :loading="printerLoading" @click="loadPrinterOptions">
|
||||
刷新打印机
|
||||
</el-button>
|
||||
<div class="wave-print-printer-section">
|
||||
<div class="wave-print-printer-section__header">
|
||||
<span class="wave-print-printer-section__title">默认打印机</span>
|
||||
<el-button size="small" text :loading="printerLoading" @click="loadPrinterOptions">
|
||||
<el-icon><Refresh /></el-icon>
|
||||
刷新
|
||||
</el-button>
|
||||
<el-input
|
||||
v-if="printerOptions.length > 8"
|
||||
v-model="printerSearchKeyword"
|
||||
size="small"
|
||||
placeholder="搜索打印机…"
|
||||
clearable
|
||||
class="wave-print-printer-search"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="printerLoading" class="wave-print-printer-grid__loading">
|
||||
<el-icon class="is-loading"><Loading /></el-icon>
|
||||
<span>加载打印机列表…</span>
|
||||
</div>
|
||||
<el-scrollbar v-else-if="filteredPrinterOptions.length > 0" max-height="160px">
|
||||
<div class="wave-print-printer-grid">
|
||||
<div
|
||||
v-for="item in filteredPrinterOptions"
|
||||
:key="item.value"
|
||||
class="wave-print-printer-tile"
|
||||
:class="{ 'is-selected': printSettings.defaultPrinter === item.value }"
|
||||
@click="handleDefaultPrinterChange(item.value)"
|
||||
>
|
||||
<span class="wave-print-printer-tile__icon">
|
||||
<el-icon><Printer /></el-icon>
|
||||
</span>
|
||||
<span class="wave-print-printer-tile__name">{{ item.label }}</span>
|
||||
<span v-if="printSettings.defaultPrinter === item.value" class="wave-print-printer-tile__check">
|
||||
<el-icon><Check /></el-icon>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<div v-else class="wave-print-printer-grid__empty">
|
||||
<span>未获取到本机打印机,请确认打印组件已连接后点击"刷新打印机"</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<section v-if="printMode === 'browser' && uniqueExpressList.length > 0" class="wave-print-express-printers">
|
||||
<div class="wave-print-express-printers__header">
|
||||
<span class="wave-print-express-printers__title">快递打印机(留空则使用默认打印机)</span>
|
||||
<span class="wave-print-express-printers__title">快递打印机(点击选中,留空则使用默认打印机)</span>
|
||||
</div>
|
||||
<div class="wave-print-express-printers__table">
|
||||
<div class="wave-print-express-printers__row wave-print-express-printers__row--head">
|
||||
<div class="wave-print-express-printers__cell wave-print-express-printers__cell--express">快递</div>
|
||||
<div class="wave-print-express-printers__cell wave-print-express-printers__cell--printer">打印机</div>
|
||||
</div>
|
||||
<div class="wave-print-express-printers__list">
|
||||
<div
|
||||
v-for="item in uniqueExpressList"
|
||||
:key="item.key"
|
||||
class="wave-print-express-printers__row"
|
||||
class="wave-print-express-item"
|
||||
>
|
||||
<div class="wave-print-express-printers__cell wave-print-express-printers__cell--express">
|
||||
{{ item.label }}
|
||||
</div>
|
||||
<div class="wave-print-express-printers__cell wave-print-express-printers__cell--printer">
|
||||
<el-select
|
||||
v-model="expressPrinterOverrides[item.key]"
|
||||
placeholder="同默认打印机"
|
||||
<div class="wave-print-express-item__header">
|
||||
<span class="wave-print-express-item__label">{{ item.label }}</span>
|
||||
<el-button
|
||||
v-if="expressPrinterOverrides[item.key]"
|
||||
size="small"
|
||||
filterable
|
||||
clearable
|
||||
:loading="printerLoading"
|
||||
text
|
||||
type="warning"
|
||||
@click="expressPrinterOverrides[item.key] = ''"
|
||||
>
|
||||
<el-option
|
||||
v-for="printer in printerOptions"
|
||||
清除
|
||||
</el-button>
|
||||
</div>
|
||||
<el-scrollbar v-if="filteredPrinterOptions.length > 0" max-height="120px">
|
||||
<div class="wave-print-printer-grid wave-print-printer-grid--compact">
|
||||
<div
|
||||
v-for="printer in filteredPrinterOptions"
|
||||
:key="`${item.key}-${printer.value}`"
|
||||
:label="printer.label"
|
||||
:value="printer.value"
|
||||
/>
|
||||
</el-select>
|
||||
class="wave-print-printer-tile wave-print-printer-tile--compact"
|
||||
:class="{ 'is-selected': expressPrinterOverrides[item.key] === printer.value }"
|
||||
@click="expressPrinterOverrides[item.key] = expressPrinterOverrides[item.key] === printer.value ? '' : printer.value"
|
||||
>
|
||||
<span class="wave-print-printer-tile__name">{{ printer.label }}</span>
|
||||
<span v-if="expressPrinterOverrides[item.key] === printer.value" class="wave-print-printer-tile__check">
|
||||
<el-icon><Check /></el-icon>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<div v-else class="wave-print-printer-grid__empty">
|
||||
暂无可选打印机
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -127,7 +158,17 @@
|
||||
{{ platform.platform_name }}
|
||||
<span class="wave-platform-card__code">{{ platform.platform_display }}</span>
|
||||
</div>
|
||||
<el-tag size="small" type="warning">订单 {{ platform.order_count }}</el-tag>
|
||||
<div class="wave-platform-card__actions">
|
||||
<el-tag
|
||||
v-if="printMode === 'browser' && getPlatformComponentName(platform)"
|
||||
:type="isComponentConnected(getPlatformComponentName(platform)!) ? 'success' : 'danger'"
|
||||
size="small"
|
||||
effect="plain"
|
||||
>
|
||||
{{ getPlatformComponentName(platform) }}{{ isComponentConnected(getPlatformComponentName(platform)!) ? '' : '(未连接)' }}
|
||||
</el-tag>
|
||||
<el-tag size="small" type="warning">订单 {{ platform.order_count }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
@ -204,11 +245,14 @@
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visibleProxy = false">关闭</el-button>
|
||||
<el-button type="primary" plain size="default" @click="printerComponentConnectionVisible = true">
|
||||
打印组件连接
|
||||
</el-button>
|
||||
<el-button-group>
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="printMode === 'station' ? stationPrinting : browserPrinting"
|
||||
:disabled="!payload || (printMode === 'station' ? (!printSettings.station || !hasWaveGroups) : !hasWaveGroups)"
|
||||
:disabled="!payload || (printMode === 'station' ? (!printSettings.station || !hasWaveGroups) : (!hasWaveGroups || !allComponentsConnected))"
|
||||
@click="handlePrint"
|
||||
>
|
||||
打印
|
||||
@ -231,12 +275,24 @@
|
||||
</el-dropdown>
|
||||
</el-button-group>
|
||||
</template>
|
||||
|
||||
<el-dialog
|
||||
v-model="printerComponentConnectionVisible"
|
||||
title="打印组件连接"
|
||||
width="720px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
>
|
||||
<printer-component-connection-panel />
|
||||
</el-dialog>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Check, Loading, Printer, Refresh } from '@element-plus/icons-vue'
|
||||
import type { WavePlatformPrintDataPayload } from '@/api/order.print/orderprint'
|
||||
import { unlockWavePlatformPrintDataByGroup } from '@/api/order.print/orderprint'
|
||||
import * as stationApi from '@/api/print/print'
|
||||
@ -252,8 +308,11 @@ import {
|
||||
collectWavePlatformPrintComponents,
|
||||
fetchConnectedComponentPrinters,
|
||||
sendWavePlatformBrowserPrint,
|
||||
resolveComponentName,
|
||||
resolvePlatformComponent,
|
||||
type BrowserWavePrintItemResult
|
||||
} from '../config/print'
|
||||
import PrinterComponentConnectionPanel from './PrinterComponentConnectionPanel.vue'
|
||||
|
||||
const WAVE_PRINT_STATION_STORAGE_KEY = 'wave_platform_print_station_id'
|
||||
const WAVE_PRINT_DEFAULT_PRINTER_STORAGE_KEY = 'wave_platform_print_default_printer'
|
||||
@ -292,6 +351,7 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
const printRootRef = ref<HTMLElement | null>(null)
|
||||
const printerComponentConnectionVisible = ref(false)
|
||||
|
||||
// 模块级缓存:打印台列表不常变,弹窗关闭再打开时复用
|
||||
let _cachedStationOptions: StationOption[] | null = null
|
||||
@ -310,6 +370,7 @@ const stationPrinting = ref(false)
|
||||
const browserPrinting = ref(false)
|
||||
const printerLoading = ref(false)
|
||||
const printerOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const printerSearchKeyword = ref('')
|
||||
const expressPrinterOverrides = reactive<Record<string, string>>({})
|
||||
/** print.send express 的 requestCode,同一次弹窗会话内保持不变 */
|
||||
const expressRequestCode = ref('')
|
||||
@ -412,6 +473,7 @@ watch(
|
||||
unlockingPlatformKey.value = ''
|
||||
unlockAllLoading.value = false
|
||||
expressRequestCode.value = buildExpressRequestCode()
|
||||
usePrinterComponentStore().refreshFromRuntime()
|
||||
void (async () => {
|
||||
resetExpressPrinterOverrides()
|
||||
await loadStationOptions()
|
||||
@ -425,6 +487,13 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
/** 打印组件连接面板关闭后刷新连接状态 */
|
||||
watch(printerComponentConnectionVisible, (nowOpen) => {
|
||||
if (!nowOpen) {
|
||||
usePrinterComponentStore().refreshFromRuntime()
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.payload,
|
||||
() => {
|
||||
@ -495,8 +564,44 @@ const uniqueExpressList = computed<ExpressPrinterRow[]>(() => {
|
||||
return [...map.values()]
|
||||
})
|
||||
|
||||
/** 搜索过滤后的打印机列表 */
|
||||
const filteredPrinterOptions = computed(() => {
|
||||
const keyword = printerSearchKeyword.value.trim().toLowerCase()
|
||||
if (!keyword) return printerOptions.value
|
||||
return printerOptions.value.filter(
|
||||
(item) => item.label.toLowerCase().includes(keyword) || item.value.toLowerCase().includes(keyword)
|
||||
)
|
||||
})
|
||||
|
||||
const browserPrintHint = computed(() => getBrowserPrintUsageHint())
|
||||
|
||||
/** 当前波次数据涉及的打印组件名(去重) */
|
||||
const requiredComponents = computed<string[]>(() => {
|
||||
if (!props.payload?.waveGroups) return []
|
||||
return collectWavePlatformPrintComponents(props.payload.waveGroups as unknown[])
|
||||
})
|
||||
|
||||
/** 检查指定打印组件是否已连接 */
|
||||
function isComponentConnected(name: string): boolean {
|
||||
return usePrinterComponentStore().isConnected(name)
|
||||
}
|
||||
|
||||
/** 根据平台信息解析对应的打印组件名 */
|
||||
function getPlatformComponentName(platform: WaveGroupPlatform): string | null {
|
||||
const componentHint = ''
|
||||
const component =
|
||||
resolveComponentName(componentHint) ??
|
||||
resolvePlatformComponent(platform.platform, platform.platform_name)
|
||||
return component
|
||||
}
|
||||
|
||||
/** 所有需要的打印组件是否全部已连接 */
|
||||
const allComponentsConnected = computed(() => {
|
||||
const components = requiredComponents.value
|
||||
if (components.length === 0) return true
|
||||
return components.every((name) => isComponentConnected(name))
|
||||
})
|
||||
|
||||
function toText(v: unknown, fallback = '—'): string {
|
||||
if (v === null || v === undefined) return fallback
|
||||
const s = String(v).trim()
|
||||
@ -876,9 +981,6 @@ async function handleStationChange(val: string | number) {
|
||||
return
|
||||
}
|
||||
saveStationId(stationId)
|
||||
if (printMode.value === 'browser') {
|
||||
await loadComputerPrintersForStation(stationId).then((names) => mergePrinterOptionNames(names))
|
||||
}
|
||||
}
|
||||
|
||||
function resetExpressPrinterOverrides() {
|
||||
@ -901,32 +1003,8 @@ function mergePrinterOptionNames(names: string[]) {
|
||||
printerOptions.value = [...merged.values()].sort((a, b) => a.label.localeCompare(b.label, 'zh-CN'))
|
||||
}
|
||||
|
||||
const _printerCache = new Map<string, Promise<string[]>>()
|
||||
|
||||
async function loadComputerPrintersForStation(stationId: string): Promise<string[]> {
|
||||
const station = stationOptions.value.find((item) => item.stationId === stationId)
|
||||
const computerId = String(station?.computer_id_legacy || '').trim()
|
||||
if (!computerId) return []
|
||||
// 缓存 Promise 防止并发竞态,同一 computerId 并发调用共享同一个请求
|
||||
if (_printerCache.has(computerId)) return _printerCache.get(computerId)!
|
||||
const promise = (async () => {
|
||||
try {
|
||||
const res: any = await stationApi.getComputerPrinter(computerId)
|
||||
if (!isApiSuccess(res)) return [] as string[]
|
||||
const root = res?.data
|
||||
const printerList = Array.isArray(root) ? root : Array.isArray(root?.list) ? root.list : []
|
||||
return printerList
|
||||
.map((item: any) => String(item?.name ?? item?.printerName ?? item ?? '').trim())
|
||||
.filter(Boolean)
|
||||
} catch {
|
||||
return [] as string[]
|
||||
}
|
||||
})()
|
||||
_printerCache.set(computerId, promise)
|
||||
return promise
|
||||
}
|
||||
|
||||
async function loadPrinterOptions() {
|
||||
printerSearchKeyword.value = ''
|
||||
printerLoading.value = true
|
||||
try {
|
||||
usePrinterComponentStore().refreshFromRuntime()
|
||||
@ -934,14 +1012,11 @@ async function loadPrinterOptions() {
|
||||
const componentNames = Array.isArray(waveGroups) && waveGroups.length
|
||||
? collectWavePlatformPrintComponents(waveGroups)
|
||||
: undefined
|
||||
console.log('[loadPrinterOptions] 开始加载打印机', { componentNames, waveGroupCount: Array.isArray(waveGroups) ? waveGroups.length : 0 })
|
||||
const componentResult = await fetchConnectedComponentPrinters(componentNames)
|
||||
console.log('[loadPrinterOptions] fetchConnectedComponentPrinters 返回', { printers: componentResult.printers, defaultPrinter: componentResult.defaultPrinter })
|
||||
mergePrinterOptionNames(componentResult.printers)
|
||||
|
||||
const stationId = String(printSettings.station || '').trim()
|
||||
if (stationId) {
|
||||
const computerPrinters = await loadComputerPrintersForStation(stationId)
|
||||
mergePrinterOptionNames(computerPrinters)
|
||||
}
|
||||
console.log('[loadPrinterOptions] 合并后 printerOptions', printerOptions.value.map(p => p.value))
|
||||
|
||||
if (!printSettings.defaultPrinter) {
|
||||
const saved = getSavedDefaultPrinter()
|
||||
@ -951,9 +1026,19 @@ async function loadPrinterOptions() {
|
||||
printSettings.defaultPrinter = componentResult.defaultPrinter
|
||||
}
|
||||
}
|
||||
console.log('[loadPrinterOptions] 最终默认打印机', printSettings.defaultPrinter || '(无)')
|
||||
|
||||
if (!printerOptions.value.length) {
|
||||
ElMessage.warning('未获取到本机打印机,请确认打印组件已连接后点击「刷新打印机」')
|
||||
// 京东组件不支持 getPrinters 查询,已连接时不弹警告
|
||||
const store = usePrinterComponentStore()
|
||||
const hasConnectedComponent = (componentNames ?? []).some(
|
||||
(name) => store.isConnected(name)
|
||||
)
|
||||
const statusList = (componentNames ?? []).map(name => ({ name, connected: store.isConnected(name) }))
|
||||
console.log('[loadPrinterOptions] 打印机列表为空,组件连接状态', { statusList, hasConnectedComponent })
|
||||
if (!hasConnectedComponent) {
|
||||
ElMessage.warning('未获取到本机打印机,请确认打印组件已连接后点击「刷新打印机」')
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
ElMessage.warning('加载本机打印机失败')
|
||||
@ -964,6 +1049,13 @@ async function loadPrinterOptions() {
|
||||
|
||||
function handleDefaultPrinterChange(val: string | number) {
|
||||
const printer = String(val || '').trim()
|
||||
if (printer === printSettings.defaultPrinter) {
|
||||
// 点击已选中的打印机 → 取消选中
|
||||
printSettings.defaultPrinter = ''
|
||||
clearSavedDefaultPrinter()
|
||||
return
|
||||
}
|
||||
printSettings.defaultPrinter = printer
|
||||
if (!printer) {
|
||||
clearSavedDefaultPrinter()
|
||||
return
|
||||
@ -1037,15 +1129,25 @@ async function notifyLockAfterBrowserPrint(
|
||||
}
|
||||
|
||||
/** 精简 waveGroups 数据,移除 print.send 不需要的字段(仅移除 contents 内的 config) */
|
||||
/** 精简 waveGroups 数据,移除 print.send 不需要的字段。京东(JD)云打印组件需保留 contents 内 config,跳过精简。 */
|
||||
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 platform = String(p.platform ?? '').trim()
|
||||
const platform_name = String(p.platform_name ?? '').trim()
|
||||
const sys_logistics_code = String(p.sys_logistics_code ?? p.logistics_code ?? '').trim()
|
||||
/** 京东平台需保留 config(京东云打印组件依赖) */
|
||||
const isJdPlatform =
|
||||
platform === 'jd' || platform === 'JD' || platform === 'jingdong' ||
|
||||
platform_name === '京东' ||
|
||||
sys_logistics_code === 'JD' || sys_logistics_code === 'jd'
|
||||
const orders = Array.isArray(p.orders)
|
||||
? p.orders.map((o: any) => {
|
||||
if (!o || typeof o !== 'object') return o
|
||||
if (isJdPlatform) return o
|
||||
const contents = Array.isArray(o.contents)
|
||||
? o.contents.map((c: any) => {
|
||||
if (!c || typeof c !== 'object') return c
|
||||
@ -1348,7 +1450,7 @@ async function printReport() {
|
||||
gap: 10px;
|
||||
margin-bottom: 8px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
align-items: flex-start;
|
||||
|
||||
.el-select {
|
||||
min-width: 240px;
|
||||
@ -1356,61 +1458,174 @@ async function printReport() {
|
||||
}
|
||||
}
|
||||
|
||||
.wave-print-express-printers {
|
||||
margin-bottom: 12px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 6px;
|
||||
background: #fafafa;
|
||||
/* ========== 打印机平铺选择 ========== */
|
||||
.wave-print-printer-section {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 8px;
|
||||
background: #fafbfc;
|
||||
overflow: hidden;
|
||||
|
||||
&__header {
|
||||
padding: 8px 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.wave-print-printer-search {
|
||||
max-width: 200px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.wave-print-printer-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 6px;
|
||||
padding: 10px 12px;
|
||||
|
||||
&--compact {
|
||||
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
||||
padding: 6px 8px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
&__loading,
|
||||
&__empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 28px 12px;
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
}
|
||||
|
||||
.wave-print-printer-tile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
user-select: none;
|
||||
position: relative;
|
||||
|
||||
&:hover {
|
||||
border-color: #409eff;
|
||||
background: #ecf5ff;
|
||||
box-shadow: 0 1px 4px rgba(64, 158, 255, 0.15);
|
||||
}
|
||||
|
||||
&.is-selected {
|
||||
border-color: #409eff;
|
||||
background: #ecf5ff;
|
||||
box-shadow: 0 0 0 1px #409eff inset;
|
||||
}
|
||||
|
||||
&--compact {
|
||||
padding: 6px 10px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 6px;
|
||||
background: #f0f2f5;
|
||||
color: #606266;
|
||||
flex-shrink: 0;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
&__name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
color: #303133;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
&__check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: #409eff;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&.is-selected &__icon {
|
||||
background: #d9ecff;
|
||||
color: #409eff;
|
||||
}
|
||||
}
|
||||
|
||||
/* ========== 快递打印机区域 ========== */
|
||||
.wave-print-express-printers {
|
||||
margin-bottom: 12px;
|
||||
|
||||
&__header {
|
||||
padding: 0 0 8px;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&__table {
|
||||
padding: 8px 10px 10px;
|
||||
&__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
&__row {
|
||||
.wave-print-express-item {
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 8px;
|
||||
background: #fafbfc;
|
||||
overflow: hidden;
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&--head {
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
justify-content: space-between;
|
||||
padding: 7px 12px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
&__cell {
|
||||
&--express {
|
||||
flex: 0 0 180px;
|
||||
font-size: 12px;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
&--printer {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.el-select {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
&__label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1559,4 +1774,45 @@ async function printReport() {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* ========== 底部操作栏 ========== */
|
||||
.wave-print-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&__right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ========== 打印组件连接状态 ========== */
|
||||
.wave-print-component-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
min-width: 0;
|
||||
|
||||
&__label {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@ -1433,14 +1433,32 @@ function shouldAlignPrinterViaComponent(component: string): boolean {
|
||||
return '';
|
||||
}
|
||||
|
||||
/** 从任意值中查找京东云打印载荷(支持嵌套 JSON 字符串解析) */
|
||||
function findJingdongCloudPrintPayload(raw: unknown): Record<string, unknown> | null {
|
||||
const direct = asRecord(raw);
|
||||
if (direct && isJingdongCloudPrintPayload(direct)) return direct;
|
||||
|
||||
// 尝试解析字符串为 JSON(后端可能将 JD 载荷作为 JSON 字符串返回)
|
||||
if (typeof raw === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
const rec = asRecord(parsed);
|
||||
if (rec && isJingdongCloudPrintPayload(rec)) return rec;
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
if (!Array.isArray(raw)) return null;
|
||||
for (const item of raw) {
|
||||
const rec = asRecord(item);
|
||||
if (rec && isJingdongCloudPrintPayload(rec)) return rec;
|
||||
// 数组元素也可能是 JSON 字符串
|
||||
if (typeof item === 'string') {
|
||||
try {
|
||||
const parsed = JSON.parse(item);
|
||||
const parsedRec = asRecord(parsed);
|
||||
if (parsedRec && isJingdongCloudPrintPayload(parsedRec)) return parsedRec;
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1526,10 +1544,30 @@ function shouldAlignPrinterViaComponent(component: string): boolean {
|
||||
return applyJingdongPrinterToPayload(payload, options.printer ?? '');
|
||||
}
|
||||
}
|
||||
/** 京东打印数据可能嵌套在 contents 项内的 config / data 中 */
|
||||
const contents = order.contents;
|
||||
if (Array.isArray(contents)) {
|
||||
for (const rawContent of contents) {
|
||||
const content = asRecord(rawContent);
|
||||
if (!content) continue;
|
||||
if (isJingdongCloudPrintPayload(content)) {
|
||||
return applyJingdongPrinterToPayload(content, options.printer ?? '');
|
||||
}
|
||||
for (const contentKey of ['config', 'data', 'print_data', 'express_data']) {
|
||||
const nestedPayload = findJingdongCloudPrintPayload(content[contentKey]);
|
||||
if (nestedPayload) {
|
||||
return applyJingdongPrinterToPayload(nestedPayload, options.printer ?? '');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 无预构建京东载荷时,从订单中提取 printData 字符串。
|
||||
* 按 order_count 限制提取数量,避免同一面单被拆成多个任务。 */
|
||||
const printData: string[] = [];
|
||||
const orderCount = Number(platformRec.order_count ?? 0) || (Array.isArray(rawOrders) ? rawOrders.length : 0) || 1;
|
||||
if (Array.isArray(rawOrders)) {
|
||||
rawOrders.forEach((rawOrder) => {
|
||||
const order = asRecord(rawOrder);
|
||||
@ -1541,8 +1579,13 @@ function shouldAlignPrinterViaComponent(component: string): boolean {
|
||||
const uniquePrintData = [...new Set(printData.filter(Boolean))];
|
||||
if (!uniquePrintData.length) return null;
|
||||
|
||||
/** 按实际订单数截断 printData:每个订单取第一个有效面单数据,避免一个面单生成多个任务 */
|
||||
const cappedPrintData = orderCount > 0 && uniquePrintData.length > orderCount
|
||||
? uniquePrintData.slice(0, orderCount)
|
||||
: uniquePrintData;
|
||||
|
||||
return buildJingdongCloudPrintPayload({
|
||||
printData: uniquePrintData,
|
||||
printData: cappedPrintData,
|
||||
tempUrl: extractJingdongTempUrl(platformRec, rawOrders),
|
||||
requestCode: options.requestCode,
|
||||
printer: options.printer,
|
||||
@ -1552,8 +1595,13 @@ function shouldAlignPrinterViaComponent(component: string): boolean {
|
||||
|
||||
function buildJingdongGetPrintersRequest(requestId: string): Record<string, unknown> {
|
||||
return {
|
||||
orderType: 'GET_PRINTERS',
|
||||
key: requestId,
|
||||
orderType: 'GET_Printers',
|
||||
pin: '',
|
||||
parameters: {
|
||||
tempUrl: '',
|
||||
printName: '',
|
||||
printData: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -1677,18 +1725,23 @@ export async function queryComponentPrinterList(
|
||||
const eventName =
|
||||
COMPONENT_GET_PRINTERS_EVENT[componentName] ??
|
||||
(isJingdongComponent(componentName) ? 'jingdongMessage' : undefined);
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" eventName: ${eventName || '(无)'}`)
|
||||
if (!eventName) return null;
|
||||
|
||||
const jingdong = isJingdongComponent(componentName);
|
||||
|
||||
try {
|
||||
const { printerComponents } = await import('@/core/printerRuntime');
|
||||
if (!printerComponents.isComponentOpen(componentName)) {
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" WebSocket 未 OPEN,返回 null`)
|
||||
return null;
|
||||
}
|
||||
|
||||
const reqId = requestID || `wave-${componentName}-getPrinters-${Date.now()}`;
|
||||
const useJingdongProtocol = isJingdongComponent(componentName);
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 发送 getPrinters, reqId: ${reqId}`)
|
||||
const response = await new Promise<Record<string, unknown> | null>((resolve) => {
|
||||
const timeout = setTimeout(() => {
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 超时 (${timeoutMs}ms)`)
|
||||
printerComponents.off(eventName, onMessage);
|
||||
resolve(null);
|
||||
}, timeoutMs);
|
||||
@ -1700,16 +1753,21 @@ export async function queryComponentPrinterList(
|
||||
try {
|
||||
parsed = JSON.parse(text) as Record<string, unknown>;
|
||||
} catch {
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 收到非 JSON:`, text.substring(0, 200))
|
||||
return;
|
||||
}
|
||||
if (!parsed) return;
|
||||
|
||||
if (useJingdongProtocol) {
|
||||
if (!isJingdongGetPrintersResponse(parsed, reqId)) return;
|
||||
if (jingdong) {
|
||||
const isJdMatch = isJingdongGetPrintersResponse(parsed, reqId);
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" JD 响应匹配`, { code: parsed.code, success: parsed.success, isJdMatch, keys: Object.keys(parsed) })
|
||||
if (!isJdMatch) return;
|
||||
} else {
|
||||
const cmd = String(parsed.cmd ?? '');
|
||||
const rid = String(parsed.requestID ?? parsed.requetID ?? parsed.requestId ?? '');
|
||||
if (cmd !== 'getPrinters' || rid !== reqId) return;
|
||||
const isStandardMatch = cmd === 'getPrinters' && rid === reqId;
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 收到消息`, { cmd, rid, expectedReqId: reqId, isMatch: isStandardMatch, keys: Object.keys(parsed) })
|
||||
if (!isStandardMatch) return;
|
||||
}
|
||||
|
||||
clearTimeout(timeout);
|
||||
@ -1718,25 +1776,34 @@ export async function queryComponentPrinterList(
|
||||
};
|
||||
|
||||
printerComponents.on(eventName, onMessage);
|
||||
printerComponents.sendMessage(
|
||||
componentName,
|
||||
JSON.stringify(
|
||||
useJingdongProtocol
|
||||
? buildJingdongGetPrintersRequest(reqId)
|
||||
: {
|
||||
requestID: reqId,
|
||||
requetID: reqId,
|
||||
requestId: reqId,
|
||||
version: '1.0',
|
||||
cmd: 'getPrinters',
|
||||
},
|
||||
),
|
||||
);
|
||||
if (jingdong) {
|
||||
printerComponents.sendMessage(
|
||||
componentName,
|
||||
JSON.stringify(buildJingdongGetPrintersRequest(reqId)),
|
||||
);
|
||||
} else {
|
||||
printerComponents.sendMessage(
|
||||
componentName,
|
||||
JSON.stringify({
|
||||
requestID: reqId,
|
||||
requetID: reqId,
|
||||
requestId: reqId,
|
||||
version: '1.0',
|
||||
cmd: 'getPrinters',
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (!response) return null;
|
||||
return parseComponentGetPrintersResponse(response, useJingdongProtocol);
|
||||
} catch {
|
||||
if (!response) {
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 无响应,返回 null`)
|
||||
return null;
|
||||
}
|
||||
const parsed = parseComponentGetPrintersResponse(response, jingdong);
|
||||
console.log(`[queryComponentPrinterList] 组件 "${componentName}" 解析结果:`, parsed)
|
||||
return parsed;
|
||||
} catch (err) {
|
||||
console.error(`[queryComponentPrinterList] 组件 "${componentName}" 异常:`, err)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1750,12 +1817,16 @@ export async function fetchConnectedComponentPrinters(
|
||||
componentNames?.length
|
||||
? componentNames
|
||||
: DEFAULT_PRINTER_COMPONENTS.map((item) => item.name);
|
||||
console.log('[fetchConnectedComponentPrinters] 目标组件', targets)
|
||||
const merged = new Set<string>();
|
||||
let defaultPrinter = '';
|
||||
|
||||
for (const componentName of targets) {
|
||||
if (!printerComponents.isComponentOpen(componentName)) continue;
|
||||
const isOpen = printerComponents.isComponentOpen(componentName)
|
||||
console.log(`[fetchConnectedComponentPrinters] 组件 "${componentName}" WebSocket OPEN: ${isOpen}`)
|
||||
if (!isOpen) continue;
|
||||
const result = await queryComponentPrinterList(componentName);
|
||||
console.log(`[fetchConnectedComponentPrinters] 组件 "${componentName}" queryComponentPrinterList 返回:`, result)
|
||||
if (!result) continue;
|
||||
result.printers.forEach((name) => merged.add(name));
|
||||
if (!defaultPrinter && result.defaultPrinter) {
|
||||
@ -1767,6 +1838,7 @@ export async function fetchConnectedComponentPrinters(
|
||||
if (!defaultPrinter && printers.length) {
|
||||
defaultPrinter = printers[0] ?? '';
|
||||
}
|
||||
console.log('[fetchConnectedComponentPrinters] 最终结果', { printers, defaultPrinter })
|
||||
return { printers, defaultPrinter };
|
||||
}
|
||||
|
||||
|
||||
@ -326,7 +326,7 @@ import {
|
||||
apiAppRegenerateSecret,
|
||||
type ApiAppItem,
|
||||
type ApiAppFlatResponse
|
||||
} from '@/api/system/apiApp'
|
||||
} from '@/api/apiapp/apiapp'
|
||||
|
||||
defineOptions({ name: 'ApiOpenInterface' })
|
||||
|
||||
|
||||
@ -37,6 +37,10 @@ export const expressInterfaceListFieldOrder = [
|
||||
'ispickup',
|
||||
'shipperno',
|
||||
'is_share',
|
||||
'quantity',
|
||||
'recycled_quantity',
|
||||
'cancel_quantity',
|
||||
'allocated_quantity',
|
||||
'ext_data'
|
||||
] as const
|
||||
|
||||
@ -76,7 +80,11 @@ export const expressInterfaceFieldLabels: Record<string, string> = {
|
||||
express_name: '关联快递',
|
||||
express_platform_label: '快递平台',
|
||||
express_polyapi_extra_info: 'PolyAPI 扩展',
|
||||
express_pdd_code: '拼多多编码'
|
||||
express_pdd_code: '拼多多编码',
|
||||
quantity: '可用面单数量',
|
||||
recycled_quantity: '已回收面单数量',
|
||||
cancel_quantity: '已取消面单数量',
|
||||
allocated_quantity: '已分配面单数量'
|
||||
}
|
||||
|
||||
const DETAIL_KEY_ORDER = [...expressInterfaceListFieldOrder]
|
||||
@ -128,6 +136,34 @@ export const expressInterfaceColumns: ExpressInterfaceColumn[] = [
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.weight)
|
||||
},
|
||||
{
|
||||
prop: 'quantity',
|
||||
label: '可用面单数量',
|
||||
width: 100,
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.quantity)
|
||||
},
|
||||
{
|
||||
prop: 'recycled_quantity',
|
||||
label: '已回收面单',
|
||||
width: 96,
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.recycled_quantity)
|
||||
},
|
||||
{
|
||||
prop: 'cancel_quantity',
|
||||
label: '已取消面单',
|
||||
width: 96,
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.cancel_quantity)
|
||||
},
|
||||
{
|
||||
prop: 'allocated_quantity',
|
||||
label: '已分配面单',
|
||||
width: 96,
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.allocated_quantity)
|
||||
},
|
||||
{
|
||||
prop: 'is_enabled',
|
||||
label: '状态',
|
||||
@ -187,6 +223,34 @@ export const expressInterfaceWarehouseColumns: ExpressInterfaceColumn[] = [
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.can_use_count)
|
||||
},
|
||||
{
|
||||
prop: 'quantity',
|
||||
label: '可用面单数量',
|
||||
width: 100,
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.quantity)
|
||||
},
|
||||
{
|
||||
prop: 'recycled_quantity',
|
||||
label: '已回收面单',
|
||||
width: 96,
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.recycled_quantity)
|
||||
},
|
||||
{
|
||||
prop: 'cancel_quantity',
|
||||
label: '已取消面单',
|
||||
width: 96,
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.cancel_quantity)
|
||||
},
|
||||
{
|
||||
prop: 'allocated_quantity',
|
||||
label: '已分配面单',
|
||||
width: 96,
|
||||
align: 'right',
|
||||
formatter: (row) => formatExpressInterfaceNumber(row.allocated_quantity)
|
||||
},
|
||||
{
|
||||
prop: 'weight',
|
||||
label: '默认重量',
|
||||
@ -402,6 +466,10 @@ export function extractPlainWhereValue(where: Record<string, unknown>, key: stri
|
||||
export function formatExpressInterfaceData(list: Record<string, any>[] = []) {
|
||||
return (list || []).map((item) => ({
|
||||
...item,
|
||||
quantity: item.quantity ?? 0,
|
||||
recycled_quantity: item.recycled_quantity ?? 0,
|
||||
cancel_quantity: item.cancel_quantity ?? 0,
|
||||
allocated_quantity: item.allocated_quantity ?? 0,
|
||||
express_name: item.express?.name || '',
|
||||
express_platform_label: item.express?.platform ?? '',
|
||||
shop_name: item.shop_name || item.shop?.custom_name || item.shop?.shop_name || ''
|
||||
@ -634,7 +702,7 @@ export function formatExpressInterfaceFormDisplayValue(
|
||||
}
|
||||
return String(val)
|
||||
}
|
||||
if (['can_use_count', 'weight', 'weight_type', 'id', 'warehouse_id', 'share_id'].includes(key)) {
|
||||
if (['can_use_count', 'weight', 'weight_type', 'id', 'warehouse_id', 'share_id', 'quantity', 'recycled_quantity', 'cancel_quantity', 'allocated_quantity'].includes(key)) {
|
||||
return formatExpressInterfaceNumber(val)
|
||||
}
|
||||
return formatExpressInterfaceCell(val)
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
<el-button size="small" type="primary" :loading="loading" @click="loadData">刷新</el-button>
|
||||
<el-button size="small" @click="openColumnConfigPanel">字段设置</el-button>
|
||||
<el-button type="success" size="small" @click="openCreate">新增接口配置</el-button>
|
||||
<el-button size="small" :disabled="selectedRows.length === 0" @click="handleCopySelected">复制</el-button>
|
||||
<!-- <el-tag size="small" type="info">共 {{ pagination.total }} 条</el-tag> -->
|
||||
<span v-if="viewMode === 'warehouse' && warehouseContextHint" class="toolbar-hint">
|
||||
{{ warehouseContextHint }}
|
||||
@ -50,10 +51,12 @@
|
||||
:show-pagination="viewMode === 'paged'"
|
||||
:show-index="true"
|
||||
:show-actions="true"
|
||||
:show-selection="true"
|
||||
:loading="loading"
|
||||
:query-time="queryTime"
|
||||
row-key="id"
|
||||
@current-change="handleRowClick"
|
||||
@selection-change="handleSelectionChange"
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
@refresh="loadData"
|
||||
@ -417,6 +420,11 @@
|
||||
<el-input :model-value="String(formData.can_use_count)" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="dialogMode === 'edit'">
|
||||
<el-form-item label="可用面单数量">
|
||||
<el-input :model-value="String(formData.quantity ?? 0)" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="打印模板">
|
||||
<el-select
|
||||
@ -618,6 +626,46 @@ const list = ref<ExpressInterfaceRecord[]>([])
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||
const currentConditionRaw = ref<any>(null)
|
||||
const selectedId = ref<number | null>(null)
|
||||
const selectedRows = ref<ExpressInterfaceRecord[]>([])
|
||||
|
||||
function handleSelectionChange(rows: ExpressInterfaceRecord[]) {
|
||||
selectedRows.value = rows || []
|
||||
}
|
||||
|
||||
async function handleCopySelected() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请先勾选需要复制的记录')
|
||||
return
|
||||
}
|
||||
const headers = ['配置名称', '可用面单数量', '已回收面单', '已取消面单', '已分配面单']
|
||||
const lines = [headers.join('\t')]
|
||||
selectedRows.value.forEach((row) => {
|
||||
const name = String(row.name ?? '--').trim()
|
||||
const quantity = row.quantity ?? 0
|
||||
const recycled = row.recycled_quantity ?? 0
|
||||
const cancel = row.cancel_quantity ?? 0
|
||||
const allocated = row.allocated_quantity ?? 0
|
||||
lines.push([name, quantity, recycled, cancel, allocated].join('\t'))
|
||||
})
|
||||
const text = lines.join('\n')
|
||||
try {
|
||||
if (navigator.clipboard?.writeText) {
|
||||
await navigator.clipboard.writeText(text)
|
||||
} else {
|
||||
const textarea = document.createElement('textarea')
|
||||
textarea.value = text
|
||||
textarea.style.position = 'fixed'
|
||||
textarea.style.opacity = '0'
|
||||
document.body.appendChild(textarea)
|
||||
textarea.select()
|
||||
document.execCommand('copy')
|
||||
document.body.removeChild(textarea)
|
||||
}
|
||||
ElMessage.success(`已复制 ${selectedRows.value.length} 条记录`)
|
||||
} catch {
|
||||
ElMessage.error('复制失败,请重试')
|
||||
}
|
||||
}
|
||||
|
||||
const columns = computed(() =>
|
||||
viewMode.value === 'paged' ? expressInterfaceColumns : expressInterfaceWarehouseColumns
|
||||
@ -1008,6 +1056,7 @@ async function loadData() {
|
||||
if (selectedId.value && !list.value.some((r) => Number(r.id) === selectedId.value)) {
|
||||
selectedId.value = null
|
||||
}
|
||||
selectedRows.value = []
|
||||
} catch {
|
||||
list.value = []
|
||||
pagination.total = 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user