feat(order): 波次/订单新增「确认打印状态」「领料状态」,波次页支持扫码确认打印
波次:注册全局扫码事件(src/composables/useBarcodeScan.ts),长度超过 8 位的面单号提交 order.wave.confirmPrintScan 整波确认打印,切页/失活自动摘除监听;tab 区新增「确认打印未领单 N」角标,order.wave.confirmPrintUnclaimedWaveCount 长轮询实时刷新(离开页面停止、回到页面重新轮询);列表新增确认打印状态/领料状态筛选、列与明细展示 订单:列表补齐「确认打印状态」(confirm_print_status) 与「领料状态」(claim_status) 列;ScanBox 流程状态组新增两项筛选(待处理/待出库/待处理异常/配送订单);导出字段白名单新增「领料状态」「确认打印状态」(流程状态分组,52 → 54);claim_status 文案由「认领」统一为「领料」
This commit is contained in:
parent
648a6eb86c
commit
bf9bba5059
@ -1266,7 +1266,100 @@ export function orderWaveBatchRemoveOrders(
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** order.wave.confirmPrintScan 入参:扫描波次内任一订单的面单号确认打印 */
|
||||
export type WaveConfirmPrintScanParams = {
|
||||
/** 面单号/运单号(必填,用于定位订单及所属波次) */
|
||||
waybill_no: string
|
||||
}
|
||||
|
||||
/** order.wave.confirmPrintScan 业务 data */
|
||||
export type WaveConfirmPrintScanResponse = {
|
||||
/** 扫描的面单号 */
|
||||
waybill_no?: string
|
||||
/** 面单号匹配到的订单ID */
|
||||
matched_order_id?: number
|
||||
/** 波次ID */
|
||||
wave_id?: number
|
||||
/** 波次编码 */
|
||||
wave_no?: string
|
||||
/** 波次下总订单数 */
|
||||
total_order_count?: number
|
||||
/** 波次下拦截订单数(跳过确认) */
|
||||
intercepted_order_count?: number
|
||||
/** 已确认打印订单数(confirm_print_status='fin') */
|
||||
confirmed_order_count?: number
|
||||
/** 本次新增确认订单数(仅 status=confirmed 时返回) */
|
||||
newly_confirmed_order_count?: number
|
||||
/** confirmed=本次完成确认 / already_confirmed=已全部确认 */
|
||||
status: 'confirmed' | 'already_confirmed' | string
|
||||
}
|
||||
|
||||
/**
|
||||
* order.wave.confirmPrintScan:扫描波次内任一订单的面单号,将该波次下全部已打印(print_status='fin')
|
||||
* 且非拦截订单批量置 confirm_print_status='fin',并写订单操作日志(ORDER_CONFIRM_PRINT)。
|
||||
* - 拦截订单跳过(不确认、不阻断);
|
||||
* - 波次下存在未打印订单(print_status != 'fin')时阻断:返回 unprinted_order_count;
|
||||
* - 全部已确认时重复扫描返回 status=already_confirmed。
|
||||
*/
|
||||
export function orderWaveConfirmPrintScan(
|
||||
data: WaveConfirmPrintScanParams
|
||||
): Promise<WaveConfirmPrintScanResponse & { code?: number; message?: string; data?: Partial<WaveConfirmPrintScanResponse>; unprinted_order_count?: number }> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'order.wave.confirmPrintScan',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
/** order.wave.confirmPrintUnclaimedWaveCount 入参:长轮询上次数量 */
|
||||
export type WaveConfirmPrintUnclaimedWaveCountParams = {
|
||||
/**
|
||||
* 上次返回的数量(长轮询游标):
|
||||
* 不传 → 立即返回当前值(status=current);传入且与当前值不同 → 立即返回新值(status=changed);
|
||||
* 相同 → 挂起等待,最长 60 秒(期间变化立即返回 changed,超时重查后返回 timeout)。
|
||||
*/
|
||||
last_count?: number
|
||||
}
|
||||
|
||||
/** order.wave.confirmPrintUnclaimedWaveCount 业务 data */
|
||||
export type WaveConfirmPrintUnclaimedWaveCountResponse = {
|
||||
/** 已确认打印(confirm_print_status='fin')但未领单(claim_status != 'fin')订单涉及的波次数量 */
|
||||
count: number
|
||||
/** current=直接返回当前值 / changed=数量已变化 / timeout=等待超时后返回当前值 */
|
||||
status: 'current' | 'changed' | 'timeout' | string
|
||||
}
|
||||
|
||||
/**
|
||||
* order.wave.confirmPrintUnclaimedWaveCount:查询「已确认打印但未领单」波次数量,支持长轮询。
|
||||
* 注意:长轮询最长挂起 60 秒,超过请求层默认 10 秒超时,故单独放开 timeout。
|
||||
*/
|
||||
export function orderWaveConfirmPrintUnclaimedWaveCount(
|
||||
data: WaveConfirmPrintUnclaimedWaveCountParams = {}
|
||||
): Promise<WaveConfirmPrintUnclaimedWaveCountResponse & { code?: number; message?: string; data?: Partial<WaveConfirmPrintUnclaimedWaveCountResponse> }> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'order.wave.confirmPrintUnclaimedWaveCount',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true,
|
||||
// 长轮询最长等待 60 秒(请求层默认 10 秒会提前中断)
|
||||
timeout: 70000
|
||||
} as any)
|
||||
}
|
||||
|
||||
export const orderWave = {
|
||||
confirmPrintScan: orderWaveConfirmPrintScan,
|
||||
confirmPrintUnclaimedWaveCount: orderWaveConfirmPrintUnclaimedWaveCount,
|
||||
wavePickTaskList: orderWaveWavePickTaskList,
|
||||
wavePickTaskCancel: orderWaveWavePickTaskCancel,
|
||||
wavePickTaskCancelSelf: orderWaveWavePickTaskCancelSelf,
|
||||
|
||||
@ -34,6 +34,17 @@ export type WaveBatchListWhere = {
|
||||
express_assignment_status?: 'unassigned' | 'partially_assigned' | 'assigned'
|
||||
/** 英文枚举:unprinted | partially_printed | printed */
|
||||
print_assignment_status?: 'unprinted' | 'partially_printed' | 'printed'
|
||||
/**
|
||||
* 确认打印状态(仅 eq,不区分大小写)。英文枚举:unconfirmed | partially_confirmed | confirmed
|
||||
* 判定按波次下订单 confirm_print_status='fin' 聚合:0=unconfirmed,>0 且 <总数=partially_confirmed,=总数且>0=confirmed。
|
||||
* 注意:列表返回的是中文文案(未确认打印/部分确认打印/已确认打印),与筛选入参是两套。
|
||||
*/
|
||||
confirm_print_assignment_status?: 'unconfirmed' | 'partially_confirmed' | 'confirmed'
|
||||
/**
|
||||
* 领料状态(仅 eq,不区分大小写)。英文枚举:unclaimed | claimed(二态),也兼容中文 未领料/已领料。
|
||||
* 注意:列表返回的是中文文案(未领料/已领料)。
|
||||
*/
|
||||
claim_assignment_status?: 'unclaimed' | 'claimed'
|
||||
/** 英文枚举:unpicked | partially_picked | picked */
|
||||
pick_assignment_status?: 'unpicked' | 'partially_picked' | 'picked'
|
||||
/** 中文:未分配 | 部分分配 | 已分配 */
|
||||
@ -88,6 +99,14 @@ export type WaveBatchListItem = Record<string, unknown> & {
|
||||
storage_assignment_status?: string
|
||||
express_assignment_status?: string
|
||||
print_assignment_status?: string
|
||||
/** 确认打印状态:接口返回中文(未确认打印/部分确认打印/已确认打印),筛选下发英文枚举 */
|
||||
confirm_print_assignment_status?: string
|
||||
/** 领料状态:接口返回中文(未领料/已领料),筛选下发英文枚举 unclaimed/claimed */
|
||||
claim_assignment_status?: string
|
||||
/** 领料时间(未领料时通常为 null) */
|
||||
claim_time?: string | null
|
||||
/** 领料人 */
|
||||
claim_operator?: string
|
||||
/** 按订单 pick_status 聚合:未拣货/部分拣货/已拣货/拣货异常 */
|
||||
pick_assignment_status?: string
|
||||
/** 0 普通波次,1 管理后台策略任务,2 PDA 策略任务 */
|
||||
|
||||
196
src/composables/useBarcodeScan.ts
Normal file
196
src/composables/useBarcodeScan.ts
Normal file
@ -0,0 +1,196 @@
|
||||
import { onActivated, onDeactivated, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
/**
|
||||
* 全局扫码枪监听(键盘楔入)
|
||||
*
|
||||
* 扫码枪 = 键盘设备:连续快速输入 + 回车(部分型号不带回车)。因此用「字符间隔 / 整段时长」
|
||||
* 区分扫码枪与人工输入,判定为扫码后回调 onScan(code)。
|
||||
*
|
||||
* 参考实现:`views/express/returnUnpackwork/index.vue` 的扫码缓冲(同项目内保持一致的判定口径:
|
||||
* 字符停顿 300~380ms 视为一次输入结束;人工打字间隔普遍 > 120ms)。
|
||||
*/
|
||||
|
||||
/** 一段扫码允许的最大总时长(毫秒):超过视为人工输入 */
|
||||
const MAX_SEGMENT_MS = 1800
|
||||
/** 单个字符最大平均间隔(毫秒):人工打字普遍 > 120ms,超过不按扫码处理 */
|
||||
const MAX_AVG_INTERVAL_MS = 120
|
||||
/** 字符停顿超过该毫秒数视为一次输入结束(扫码枪无停顿,不带回车也能结束) */
|
||||
const IDLE_FLUSH_MS = 380
|
||||
/** 默认最小长度:长度超过 8 位(即 >= 9)才按扫码处理 */
|
||||
const DEFAULT_MIN_LENGTH = 9
|
||||
|
||||
/** 修饰键:不进入缓冲,也不中断当前段(扫码枪输出大写字母/符号会带 Shift) */
|
||||
const MODIFIER_KEYS = new Set(['Shift', 'CapsLock', 'Control', 'Alt', 'Meta', 'AltGraph', 'Dead'])
|
||||
|
||||
export interface UseBarcodeScanOptions {
|
||||
/** 扫码完成回调(仅在判定为扫码时触发) */
|
||||
onScan: (code: string) => void
|
||||
/** 判定为扫码的最小长度,默认 9(即「长度超过 8 位」) */
|
||||
minLength?: number
|
||||
/** 采集开关:返回 false 时本段按键不采集(如请求处理中) */
|
||||
enabled?: () => boolean
|
||||
/** 弹窗/抽屉(.el-overlay)内不采集,默认 true:避免扫码字符污染弹窗表单、误触发业务 */
|
||||
ignoreInsideDialog?: boolean
|
||||
/** 字符停顿多少毫秒视为一次输入结束,默认 380 */
|
||||
idleFlushMs?: number
|
||||
}
|
||||
|
||||
/** 判定为可写入条码的输入元素 */
|
||||
function isEditableElement(el: Element | null): el is HTMLInputElement | HTMLTextAreaElement {
|
||||
if (!el) return false
|
||||
const tag = el.tagName?.toUpperCase()
|
||||
return tag === 'INPUT' || tag === 'TEXTAREA'
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册全局扫码事件。
|
||||
*
|
||||
* - 监听 window keydown(捕获阶段);长度达到 minLength、整段耗时 <= 1800ms、平均字符间隔 <= 120ms
|
||||
* 才判定为扫码 → onScan(code)。
|
||||
* - 无需回车:字符停顿超过 idleFlushMs 自动结束;扫码枪回车的立即结束(并阻止该回车继续触发默认行为)。
|
||||
* - 扫码字符仍会写入焦点输入框(不 preventDefault,避免破坏正常打字),判定为扫码后回滚该输入框内容。
|
||||
* - 生命周期:挂载/激活时注册,卸载/失活时移除——keep-alive 页面切到其他页面会走 onDeactivated,
|
||||
* 同样会摘掉监听,切页后不会在后台响应扫码。
|
||||
*/
|
||||
export function useBarcodeScan(options: UseBarcodeScanOptions) {
|
||||
const {
|
||||
onScan,
|
||||
minLength = DEFAULT_MIN_LENGTH,
|
||||
enabled,
|
||||
ignoreInsideDialog = true,
|
||||
idleFlushMs = IDLE_FLUSH_MS
|
||||
} = options
|
||||
|
||||
let listening = false
|
||||
let buffer = ''
|
||||
let segmentStartAt = 0
|
||||
let lastCharAt = 0
|
||||
let idleTimer: ReturnType<typeof setTimeout> | null = null
|
||||
/** 扫码期间被持续写入的焦点输入框 + 扫码前的值(判定为扫码后回滚) */
|
||||
let rollbackEl: HTMLInputElement | HTMLTextAreaElement | null = null
|
||||
let rollbackValue = ''
|
||||
|
||||
function clearIdleTimer() {
|
||||
if (idleTimer !== null) {
|
||||
clearTimeout(idleTimer)
|
||||
idleTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
/** 清空当前段(缓冲 + 停顿计时 + 回滚快照) */
|
||||
function clearSegment() {
|
||||
buffer = ''
|
||||
segmentStartAt = 0
|
||||
lastCharAt = 0
|
||||
rollbackEl = null
|
||||
rollbackValue = ''
|
||||
clearIdleTimer()
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚扫码期间写入焦点输入框的字符。
|
||||
* 直接赋值不会触发 input 事件,需手动派发以同步 v-model(否则 Vue 状态仍是脏值,重渲染会再写回)。
|
||||
*/
|
||||
function rollbackFocusedInput() {
|
||||
const el = rollbackEl
|
||||
const value = rollbackValue
|
||||
if (!el || !el.isConnected) return
|
||||
if (el.value === value) return
|
||||
el.value = value
|
||||
el.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
}
|
||||
|
||||
/** 结束当前段:判定为扫码则回滚输入框并回调 onScan */
|
||||
function flushSegment(): boolean {
|
||||
clearIdleTimer()
|
||||
const code = buffer.replace(/\s+/g, '')
|
||||
const durationMs = segmentStartAt ? Math.max(0, lastCharAt - segmentStartAt) : 0
|
||||
const avgIntervalMs = durationMs / Math.max(code.length - 1, 1)
|
||||
const scannerLike = buffer.length > 0
|
||||
&& code.length >= minLength
|
||||
&& durationMs <= MAX_SEGMENT_MS
|
||||
&& avgIntervalMs <= MAX_AVG_INTERVAL_MS
|
||||
|
||||
if (scannerLike) rollbackFocusedInput()
|
||||
clearSegment()
|
||||
if (!scannerLike) return false
|
||||
|
||||
onScan(code)
|
||||
return true
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
// 输入法组合 / 长按重复 / 页面不可见 时一律不参与判定
|
||||
if (event.isComposing || event.repeat || document.hidden) return
|
||||
|
||||
if (enabled && !enabled()) {
|
||||
if (buffer) clearSegment()
|
||||
return
|
||||
}
|
||||
|
||||
const key = event.key
|
||||
|
||||
// 回车:结束当前段;判定为扫码时阻止回车继续触发输入框/表单默认行为
|
||||
if (key === 'Enter') {
|
||||
if (!buffer) return
|
||||
if (flushSegment()) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (MODIFIER_KEYS.has(key)) return
|
||||
|
||||
// 其它功能键(Tab / Backspace / 方向键 / Esc 等)中断当前段,避免两次输入被拼成一段
|
||||
if (key.length !== 1) {
|
||||
clearSegment()
|
||||
return
|
||||
}
|
||||
|
||||
const target = (event.target instanceof Element ? event.target : document.activeElement) as Element | null
|
||||
if (ignoreInsideDialog && target?.closest?.('.el-overlay')) return
|
||||
|
||||
const now = Date.now()
|
||||
if (!buffer) {
|
||||
segmentStartAt = now
|
||||
// 记录焦点输入框内容:扫码字符会实时写入输入框,判定为扫码后再回滚
|
||||
const active = document.activeElement
|
||||
rollbackEl = isEditableElement(active) ? active : null
|
||||
rollbackValue = rollbackEl ? rollbackEl.value : ''
|
||||
}
|
||||
lastCharAt = now
|
||||
buffer += key
|
||||
|
||||
clearIdleTimer()
|
||||
idleTimer = setTimeout(() => {
|
||||
flushSegment()
|
||||
}, idleFlushMs)
|
||||
}
|
||||
|
||||
/** 注册监听(重复调用安全) */
|
||||
function start() {
|
||||
if (listening) return
|
||||
window.addEventListener('keydown', handleKeydown, true)
|
||||
listening = true
|
||||
}
|
||||
|
||||
/** 摘除监听并清理缓冲(切页/弹窗期间不残留扫码状态) */
|
||||
function stop() {
|
||||
if (!listening) {
|
||||
clearSegment()
|
||||
return
|
||||
}
|
||||
window.removeEventListener('keydown', handleKeydown, true)
|
||||
listening = false
|
||||
clearSegment()
|
||||
}
|
||||
|
||||
onMounted(start)
|
||||
onUnmounted(stop)
|
||||
// keep-alive 页面切换到其他页面走的是 onDeactivated(不触发 onUnmounted),需一并摘除
|
||||
onActivated(start)
|
||||
onDeactivated(stop)
|
||||
|
||||
return { start, stop }
|
||||
}
|
||||
@ -127,9 +127,15 @@ export const COMMON_TRANSLATIONS: Record<string, Record<string, string>> = {
|
||||
warehouse: '已锁定',
|
||||
store: '已锁定'
|
||||
},
|
||||
/** 领料状态(订单 claim_status,与波次列表同源):none=未领料 / fin=已领料 */
|
||||
claim_status: {
|
||||
none: '未认领',
|
||||
fin: '已认领'
|
||||
none: '未领料',
|
||||
fin: '已领料'
|
||||
},
|
||||
/** 确认打印状态(订单 confirm_print_status):none=未确认打印 / fin=已确认打印 */
|
||||
confirm_print_status: {
|
||||
none: '未确认打印',
|
||||
fin: '已确认打印'
|
||||
},
|
||||
sended_status: {
|
||||
none: '未发货',
|
||||
@ -266,6 +272,10 @@ export const COMMON_TAG_TYPES: Record<string, Record<string, string>> = {
|
||||
none: 'info',
|
||||
fin: 'success'
|
||||
},
|
||||
confirm_print_status: {
|
||||
none: 'info',
|
||||
fin: 'success'
|
||||
},
|
||||
sended_status: {
|
||||
none: 'info',
|
||||
padding: 'warning',
|
||||
@ -354,10 +364,11 @@ export type OrderExportColumnOption = {
|
||||
}
|
||||
|
||||
/**
|
||||
* order.export 全部可导出字段(共 52 个,对齐接口枚举):
|
||||
* order.export 全部可导出字段(共 54 个,对齐接口枚举):
|
||||
* 仅 waybill 模式输出:系统订单号、外部订单号、平台单号、抓取波次号、商品明细;
|
||||
* 仅 item 模式输出:订单ID、订单号、外部单号、波次号、仓库商品名称、商品条码、商品图片、数量;
|
||||
* 其余为两种模式通用。
|
||||
* 流程状态分组含「领料状态」(claim_status) /「确认打印状态」(confirm_print_status),中文表头须与后端 order.export 枚举一致。
|
||||
*/
|
||||
export const ORDER_EXPORT_ALL_COLUMNS: OrderExportColumnOption[] = [
|
||||
// ===== 订单信息 =====
|
||||
@ -411,6 +422,8 @@ export const ORDER_EXPORT_ALL_COLUMNS: OrderExportColumnOption[] = [
|
||||
{ label: '复核完成状态', modes: ['waybill', 'item'], group: '流程状态' },
|
||||
{ label: '配货状态', modes: ['waybill', 'item'], group: '流程状态' },
|
||||
{ label: '打包状态', modes: ['waybill', 'item'], group: '流程状态' },
|
||||
{ label: '领料状态', modes: ['waybill', 'item'], group: '流程状态' },
|
||||
{ label: '确认打印状态', modes: ['waybill', 'item'], group: '流程状态' },
|
||||
// ===== 时间信息 =====
|
||||
{ label: '创建时间', modes: ['waybill', 'item'], group: '时间信息' },
|
||||
{ label: '支付时间', modes: ['waybill', 'item'], group: '时间信息' },
|
||||
@ -979,10 +992,11 @@ export const orderDetailFullSections: OrderDetailSectionConfig[] = [
|
||||
{ prop: 'pick_status', label: '拣货状态', tag: true },
|
||||
{ prop: 'pack_status', label: '打包状态', tag: true },
|
||||
{ prop: 'print_status', label: '打印状态', tag: true },
|
||||
{ prop: 'confirm_print_status', label: '确认打印状态', tag: true },
|
||||
{ prop: 'sended_status', label: '发货状态', tag: true },
|
||||
{ prop: 'claim_status', label: '认领状态', tag: true },
|
||||
{ prop: 'claim_operator_id', label: '认领操作人ID' },
|
||||
{ prop: 'claim_operator', label: '认领操作人' },
|
||||
{ prop: 'claim_status', label: '领料状态', tag: true },
|
||||
{ prop: 'claim_operator_id', label: '领料操作人ID' },
|
||||
{ prop: 'claim_operator', label: '领料操作人' },
|
||||
{ prop: 'grab_operator_id', label: '抢单操作人ID' },
|
||||
{ prop: 'grab_operator', label: '抢单操作人' },
|
||||
{ prop: 'lock_status', label: '锁定状态', tag: true },
|
||||
@ -1094,6 +1108,7 @@ export const orderDetailCompactSections: OrderDetailSectionConfig[] = [
|
||||
{ prop: 'pick_status', label: '拣货状态', tag: true },
|
||||
{ prop: 'pack_status', label: '打包状态', tag: true },
|
||||
{ prop: 'print_status', label: '打印状态', tag: true },
|
||||
{ prop: 'confirm_print_status', label: '确认打印状态', tag: true },
|
||||
{ prop: 'intercept_status', label: '拦截状态', tag: true },
|
||||
{ prop: 'lock_status', label: '锁定状态', tag: true }
|
||||
]
|
||||
@ -1368,8 +1383,14 @@ export const inspectionStatusFilterOptions = [
|
||||
]
|
||||
|
||||
export const claimStatusFilterOptions = [
|
||||
{ label: '未认领', value: 'none' },
|
||||
{ label: '已认领', value: 'fin' },
|
||||
{ label: '未领料', value: 'none' },
|
||||
{ label: '已领料', value: 'fin' },
|
||||
]
|
||||
|
||||
/** 确认打印状态(订单 confirm_print_status):none=未确认打印 / fin=已确认打印 */
|
||||
export const confirmPrintStatusFilterOptions = [
|
||||
{ label: '未确认打印', value: 'none' },
|
||||
{ label: '已确认打印', value: 'fin' },
|
||||
]
|
||||
|
||||
/** 锁定状态(待处理等订单页):只区分是否锁定。未锁定 = eq none,已锁定 = ne none(覆盖 warehouse/store 等所有非 none 值) */
|
||||
@ -1491,8 +1512,9 @@ export const postStatusScanField = scanWorkflowField({ label: '快递状态', va
|
||||
export const pickStatusScanField = scanWorkflowField({ label: '拣货状态', value: 'pick_status', type: 'select', options: pickStatusFilterOptions })
|
||||
export const packStatusScanField = scanWorkflowField({ label: '打包状态', value: 'pack_status', type: 'select', options: packStatusFilterOptions })
|
||||
export const printStatusScanField = scanWorkflowField({ label: '打印状态', value: 'print_status', type: 'select', options: printStatusFilterOptions })
|
||||
export const confirmPrintStatusScanField = scanWorkflowField({ label: '确认打印状态', value: 'confirm_print_status', type: 'select', options: confirmPrintStatusFilterOptions })
|
||||
export const outboundStatusScanField = scanWorkflowField({ label: '数据归档', value: 'outbound_status', type: 'select', options: outboundStatusFilterOptions })
|
||||
export const claimStatusScanField = scanWorkflowField({ label: '认领状态', value: 'claim_status', type: 'select', options: claimStatusFilterOptions })
|
||||
export const claimStatusScanField = scanWorkflowField({ label: '领料状态', value: 'claim_status', type: 'select', options: claimStatusFilterOptions })
|
||||
export const lockStatusScanField = scanWorkflowField({ label: '锁定状态', value: 'lock_status', type: 'select', options: lockStatusFilterOptions })
|
||||
export const interceptStatusScanField = scanWorkflowField({ label: '拦截状态', value: 'intercept_status', type: 'select', options: interceptStatusFilterOptions })
|
||||
/** 是否拦截(待处理 / 异常订单):否 = eq none,是 = ne none */
|
||||
@ -1636,6 +1658,7 @@ export const deliveryAvailableFields = [
|
||||
{ ...storageStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...postStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...confirmPrintStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...claimStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
@ -1723,9 +1746,10 @@ export const deliveryColumns = applyOrderListCopyActions([
|
||||
{ prop: 'storage_status', label: '储位状态', width: '90' },
|
||||
{ prop: 'post_status', label: '快递状态', width: '90' },
|
||||
{ prop: 'print_status', label: '打印状态', width: '100' },
|
||||
{ prop: 'confirm_print_status', label: '确认打印状态', width: '110' },
|
||||
{ prop: 'pick_status', label: '拣货状态', width: '90' },
|
||||
{ prop: 'pack_status', label: '打包状态', width: '90' },
|
||||
{ prop: 'claim_status', label: '认领状态', width: '100' },
|
||||
{ prop: 'claim_status', label: '领料状态', width: '100' },
|
||||
{ prop: 'lock_status', label: '锁定状态', width: '100' },
|
||||
{ prop: 'intercept_status', label: '拦截状态', width: '100', tag: true },
|
||||
{ prop: 'logistics_name', label: '快递', width: '120' },
|
||||
@ -1998,6 +2022,8 @@ export const pendingAvailableFields = [
|
||||
{ ...pickStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...packStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...confirmPrintStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...claimStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...lockStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...interceptFlagScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...orderStatusScanField(pendingOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
|
||||
@ -2054,6 +2080,8 @@ export const ORDER_LIST_FIELD_LABELS: Record<string, string> = {
|
||||
...Object.fromEntries(pendingCloums.map((col) => [col.prop, col.label])),
|
||||
recheck_status: '复核状态',
|
||||
print_status: '打印状态',
|
||||
confirm_print_status: '确认打印状态',
|
||||
claim_status: '领料状态',
|
||||
outbound_status: '数据归档',
|
||||
inspection_status: '审核状态',
|
||||
order_code: '发货单号',
|
||||
@ -2077,27 +2105,29 @@ export function applyOrderListColumnLabels<T extends { prop: string; label: stri
|
||||
})
|
||||
}
|
||||
|
||||
/** 待处理订单列表标准列:在基础列上补全复核、打印列 */
|
||||
/** 列表列插入:在 afterProp 之后插入(列已存在则跳过;找不到锚点则追加到末尾) */
|
||||
function insertOrderColumnAfter(
|
||||
source: Array<Record<string, any>>,
|
||||
col: Record<string, any> & { prop: string },
|
||||
afterProp: string
|
||||
) {
|
||||
if (source.some((item) => String(item?.prop || '') === col.prop)) return
|
||||
const insertAfterIndex = source.findIndex((item) => String(item?.prop || '') === afterProp)
|
||||
if (insertAfterIndex >= 0) {
|
||||
source.splice(insertAfterIndex + 1, 0, col)
|
||||
} else {
|
||||
source.push(col)
|
||||
}
|
||||
}
|
||||
|
||||
/** 待处理订单列表标准列:在基础列上补全复核、打印、确认打印、领料列 */
|
||||
export function buildPendingStyleColumns(baseColumns: ReadonlyArray<{ prop: string; label: string; [key: string]: any }> = pendingCloums) {
|
||||
const source = applyOrderListColumnLabels(Array.isArray(baseColumns) ? [...baseColumns] : [])
|
||||
const recheckColumn = { prop: 'recheck_status', label: ORDER_LIST_FIELD_LABELS.recheck_status, width: '100' }
|
||||
if (!source.some((col) => String(col?.prop || '') === 'recheck_status')) {
|
||||
const insertAfterIndex = source.findIndex((col) => String(col?.prop || '') === 'sync_status')
|
||||
if (insertAfterIndex >= 0) {
|
||||
source.splice(insertAfterIndex + 1, 0, recheckColumn)
|
||||
} else {
|
||||
source.push(recheckColumn)
|
||||
}
|
||||
}
|
||||
if (!source.some((col) => String(col?.prop || '') === 'print_status')) {
|
||||
const printColumn = { prop: 'print_status', label: ORDER_LIST_FIELD_LABELS.print_status, width: '100' }
|
||||
const insertAfterIndex = source.findIndex((col) => String(col?.prop || '') === 'post_status')
|
||||
if (insertAfterIndex >= 0) {
|
||||
source.splice(insertAfterIndex + 1, 0, printColumn)
|
||||
} else {
|
||||
source.push(printColumn)
|
||||
}
|
||||
}
|
||||
insertOrderColumnAfter(source, { prop: 'recheck_status', label: ORDER_LIST_FIELD_LABELS.recheck_status, width: '100' }, 'sync_status')
|
||||
insertOrderColumnAfter(source, { prop: 'print_status', label: ORDER_LIST_FIELD_LABELS.print_status, width: '100' }, 'post_status')
|
||||
// 确认打印紧接打印状态,领料紧随其后(三者同为一个打印/领料流程链)
|
||||
insertOrderColumnAfter(source, { prop: 'confirm_print_status', label: ORDER_LIST_FIELD_LABELS.confirm_print_status, width: '110' }, 'print_status')
|
||||
insertOrderColumnAfter(source, { prop: 'claim_status', label: ORDER_LIST_FIELD_LABELS.claim_status, width: '100' }, 'confirm_print_status')
|
||||
return applyOrderListCopyActions(source)
|
||||
}
|
||||
|
||||
@ -2388,6 +2418,8 @@ export const expectionOrderAvailableFields = [
|
||||
{ ...interceptFlagScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...recheckStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...printStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...confirmPrintStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...claimStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...lockStatusScanField, group: SCAN_PROCESS_STATUS_GROUP },
|
||||
{ ...orderStatusScanField(exceptionOrderStatusFilterOptions), group: SCAN_PROCESS_STATUS_GROUP },
|
||||
// 收货信息
|
||||
|
||||
@ -85,6 +85,12 @@
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-confirm_print_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('confirm_print_status', row.confirm_print_status))">
|
||||
{{ translateOrderField('confirm_print_status', row.confirm_print_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-pick_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('pick_status', row.pick_status))">
|
||||
{{ translateOrderField('pick_status', row.pick_status) }}
|
||||
|
||||
@ -98,6 +98,18 @@
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-confirm_print_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('confirm_print_status', row.confirm_print_status))">
|
||||
{{ translateOrderField('confirm_print_status', row.confirm_print_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-claim_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('claim_status', row.claim_status))">
|
||||
{{ translateOrderField('claim_status', row.claim_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-pick_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('pick_status', row.pick_status))">
|
||||
{{ translateOrderField('pick_status', row.pick_status) }}
|
||||
|
||||
@ -79,6 +79,18 @@
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-confirm_print_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('confirm_print_status', row.confirm_print_status))">
|
||||
{{ translateOrderField('confirm_print_status', row.confirm_print_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-claim_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('claim_status', row.claim_status))">
|
||||
{{ translateOrderField('claim_status', row.claim_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-pick_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('pick_status', row.pick_status))">
|
||||
{{ translateOrderField('pick_status', row.pick_status) }}
|
||||
|
||||
@ -87,6 +87,18 @@
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-confirm_print_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('confirm_print_status', row.confirm_print_status))">
|
||||
{{ translateOrderField('confirm_print_status', row.confirm_print_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-claim_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('claim_status', row.claim_status))">
|
||||
{{ translateOrderField('claim_status', row.claim_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-pick_status="{ row }">
|
||||
<span :class="getStatusTextClass(getTagType('pick_status', row.pick_status))">
|
||||
{{ translateOrderField('pick_status', row.pick_status) }}
|
||||
|
||||
@ -113,6 +113,18 @@
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-confirm_print_assignment_status="{ row }">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.confirm_print_assignment_status))">
|
||||
{{ formatWaveConfirmPrintAssignmentStatusLabel(row.confirm_print_assignment_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-claim_assignment_status="{ row }">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.claim_assignment_status))">
|
||||
{{ formatWaveClaimAssignmentStatusLabel(row.claim_assignment_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-pick_assignment_status="{ row }">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.pick_assignment_status))">
|
||||
{{ formatWavePickAssignmentStatusLabel(row.pick_assignment_status) }}
|
||||
@ -903,6 +915,8 @@ import {
|
||||
unwrapWavePlatformPrintPayload,
|
||||
formatWaveExpressAssignmentStatusLabel,
|
||||
formatWavePrintAssignmentStatusLabel,
|
||||
formatWaveConfirmPrintAssignmentStatusLabel,
|
||||
formatWaveClaimAssignmentStatusLabel,
|
||||
formatWavePickAssignmentStatusLabel,
|
||||
formatWaveReviewAssignmentStatusLabel,
|
||||
formatWaveSyncAssignmentStatusLabel,
|
||||
|
||||
@ -113,6 +113,18 @@
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-confirm_print_assignment_status="{ row }">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.confirm_print_assignment_status))">
|
||||
{{ formatWaveConfirmPrintAssignmentStatusLabel(row.confirm_print_assignment_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-claim_assignment_status="{ row }">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.claim_assignment_status))">
|
||||
{{ formatWaveClaimAssignmentStatusLabel(row.claim_assignment_status) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #column-pick_assignment_status="{ row }">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.pick_assignment_status))">
|
||||
{{ formatWavePickAssignmentStatusLabel(row.pick_assignment_status) }}
|
||||
@ -501,6 +513,8 @@ import {
|
||||
unwrapWavePlatformPrintPayload,
|
||||
formatWaveExpressAssignmentStatusLabel,
|
||||
formatWavePrintAssignmentStatusLabel,
|
||||
formatWaveConfirmPrintAssignmentStatusLabel,
|
||||
formatWaveClaimAssignmentStatusLabel,
|
||||
formatWavePickAssignmentStatusLabel,
|
||||
formatWaveReviewAssignmentStatusLabel,
|
||||
formatWaveSyncAssignmentStatusLabel,
|
||||
|
||||
@ -53,6 +53,16 @@
|
||||
{{ formatWavePrintAssignmentStatusLabel(row.print_assignment_status) }}
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="确认打印状态">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.confirm_print_assignment_status))">
|
||||
{{ formatWaveConfirmPrintAssignmentStatusLabel(row.confirm_print_assignment_status) }}
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="领料状态">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.claim_assignment_status))">
|
||||
{{ formatWaveClaimAssignmentStatusLabel(row.claim_assignment_status) }}
|
||||
</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="拣货状态">
|
||||
<span :class="getStatusTextClass(getWaveAssignmentAggregateTagType(row.pick_assignment_status))">
|
||||
{{ formatWavePickAssignmentStatusLabel(row.pick_assignment_status) }}
|
||||
@ -103,6 +113,8 @@ import {
|
||||
formatWaveExpressAssignmentStatusLabel,
|
||||
formatWavePickAssignmentStatusLabel,
|
||||
formatWavePrintAssignmentStatusLabel,
|
||||
formatWaveConfirmPrintAssignmentStatusLabel,
|
||||
formatWaveClaimAssignmentStatusLabel,
|
||||
formatWaveReviewAssignmentStatusLabel,
|
||||
formatWaveSyncAssignmentStatusLabel,
|
||||
formatWaveSource,
|
||||
|
||||
@ -161,6 +161,34 @@ export const waveAvailableFields = [
|
||||
{ label: '已打印', value: 'printed' },
|
||||
]
|
||||
}), group: WAVE_SCAN_PROCESS_STATUS_GROUP },
|
||||
{
|
||||
// order.wave.batchList where:仅 eq,英文枚举 unconfirmed/partially_confirmed/confirmed
|
||||
// (列表返回的是中文文案 未确认打印/部分确认打印/已确认打印,与筛选入参是两套)
|
||||
...scanWorkflowField({
|
||||
label: '确认打印状态',
|
||||
value: 'confirm_print_assignment_status',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '未确认打印', value: 'unconfirmed' },
|
||||
{ label: '部分确认打印', value: 'partially_confirmed' },
|
||||
{ label: '已确认打印', value: 'confirmed' },
|
||||
]
|
||||
}),
|
||||
group: WAVE_SCAN_PROCESS_STATUS_GROUP
|
||||
},
|
||||
{
|
||||
// order.wave.batchList where:仅 eq,英文枚举 unclaimed/claimed(二态),也兼容中文 未领料/已领料
|
||||
...scanWorkflowField({
|
||||
label: '领料状态',
|
||||
value: 'claim_assignment_status',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '未领料', value: 'unclaimed' },
|
||||
{ label: '已领料', value: 'claimed' },
|
||||
]
|
||||
}),
|
||||
group: WAVE_SCAN_PROCESS_STATUS_GROUP
|
||||
},
|
||||
{ ...scanWorkflowField({
|
||||
label: '拣货状态',
|
||||
value: 'pick_assignment_status',
|
||||
@ -394,6 +422,8 @@ export const waveBatchColumns = applyWaveListCopyActions([
|
||||
{ prop: 'storage_assignment_status', label: '库位分配', minWidth: 120 },
|
||||
{ prop: 'express_assignment_status', label: '快递分配', minWidth: 120 },
|
||||
{ prop: 'print_assignment_status', label: '打印状态', minWidth: 110 },
|
||||
{ prop: 'confirm_print_assignment_status', label: '确认打印状态', minWidth: 120 },
|
||||
{ prop: 'claim_assignment_status', label: '领料状态', minWidth: 110 },
|
||||
{ prop: 'pick_assignment_status', label: '拣货状态', minWidth: 110 },
|
||||
{ prop: 'review_assignment_status', label: '复核状态', minWidth: 110 },
|
||||
{ prop: 'sync_assignment_status', label: '同步状态', minWidth: 110 },
|
||||
@ -422,6 +452,10 @@ export const waveWhereAllowedFieldList = [
|
||||
'storage_assignment_status',
|
||||
'express_assignment_status',
|
||||
'print_assignment_status',
|
||||
// 确认打印状态(order.wave.batchList where 仅 eq,英文枚举 unconfirmed/partially_confirmed/confirmed)
|
||||
'confirm_print_assignment_status',
|
||||
// 领料状态(order.wave.batchList where 仅 eq,英文枚举 unclaimed/claimed,二态)
|
||||
'claim_assignment_status',
|
||||
'pick_assignment_status',
|
||||
'review_assignment_status',
|
||||
// 同步状态(order.wave.batchList where 仅 eq,英文枚举 unsynced/partially_synced/synced)
|
||||
@ -465,6 +499,24 @@ const wavePrintAssignmentStatusLabelMap: Record<string, string> = {
|
||||
已打印: '已打印'
|
||||
}
|
||||
|
||||
/** 确认打印状态:接口返回中文(未确认打印/部分确认打印/已确认打印),where 筛选传英文枚举 */
|
||||
const waveConfirmPrintAssignmentStatusLabelMap: Record<string, string> = {
|
||||
unconfirmed: '未确认打印',
|
||||
partially_confirmed: '部分确认打印',
|
||||
confirmed: '已确认打印',
|
||||
未确认打印: '未确认打印',
|
||||
部分确认打印: '部分确认打印',
|
||||
已确认打印: '已确认打印'
|
||||
}
|
||||
|
||||
/** 领料状态:接口返回中文(未领料/已领料),where 筛选传英文枚举(二态) */
|
||||
const waveClaimAssignmentStatusLabelMap: Record<string, string> = {
|
||||
unclaimed: '未领料',
|
||||
claimed: '已领料',
|
||||
未领料: '未领料',
|
||||
已领料: '已领料'
|
||||
}
|
||||
|
||||
const wavePickAssignmentStatusLabelMap: Record<string, string> = {
|
||||
unpicked: '未拣货',
|
||||
partially_picked: '部分拣货',
|
||||
@ -513,6 +565,18 @@ export function formatWavePrintAssignmentStatusLabel(value: string | number | nu
|
||||
return wavePrintAssignmentStatusLabelMap[key] ?? wavePrintAssignmentStatusLabelMap[key.toLowerCase()] ?? key
|
||||
}
|
||||
|
||||
export function formatWaveConfirmPrintAssignmentStatusLabel(value: string | number | null | undefined): string {
|
||||
if (value === undefined || value === null || value === '') return '—'
|
||||
const key = String(value).trim()
|
||||
return waveConfirmPrintAssignmentStatusLabelMap[key] ?? waveConfirmPrintAssignmentStatusLabelMap[key.toLowerCase()] ?? key
|
||||
}
|
||||
|
||||
export function formatWaveClaimAssignmentStatusLabel(value: string | number | null | undefined): string {
|
||||
if (value === undefined || value === null || value === '') return '—'
|
||||
const key = String(value).trim()
|
||||
return waveClaimAssignmentStatusLabelMap[key] ?? waveClaimAssignmentStatusLabelMap[key.toLowerCase()] ?? key
|
||||
}
|
||||
|
||||
export function formatWavePickAssignmentStatusLabel(value: string | number | null | undefined): string {
|
||||
if (value === undefined || value === null || value === '') return '—'
|
||||
const key = String(value).trim()
|
||||
@ -542,9 +606,21 @@ export function getWaveAssignmentAggregateTagType(value: string | number | null
|
||||
if (v === 'unassigned' || v === 'unprinted' || v === 'unsynced' || v === 'unreviewed' || v === 'unpicked') return 'info'
|
||||
if (v === 'partially_assigned' || v === 'partially_printed' || v === 'partially_synced' || v === 'partially_reviewed' || v === 'partially_picked') return 'warning'
|
||||
if (v === 'assigned' || v === 'printed' || v === 'synced' || v === 'reviewed' || v === 'picked') return 'success'
|
||||
// 确认打印状态:unconfirmed | partially_confirmed | confirmed
|
||||
if (v === 'unconfirmed') return 'info'
|
||||
if (v === 'partially_confirmed') return 'warning'
|
||||
if (v === 'confirmed') return 'success'
|
||||
// 领料状态:unclaimed | claimed
|
||||
if (v === 'unclaimed') return 'info'
|
||||
if (v === 'claimed') return 'success'
|
||||
const text = String(value ?? '')
|
||||
if (text.includes('异常') || text.includes('失败') || text.includes('超时')) return 'danger'
|
||||
if (text.includes('处理中')) return 'warning'
|
||||
if (text.includes('未确认')) return 'info'
|
||||
if (text.includes('部分确认')) return 'warning'
|
||||
if (text.includes('已确认')) return 'success'
|
||||
if (text.includes('未领料')) return 'info'
|
||||
if (text.includes('已领料')) return 'success'
|
||||
if (text.includes('已分配') || text.includes('完成') || text.includes('已打印') || text.includes('已拣货')) return 'success'
|
||||
if (text.includes('部分')) return 'warning'
|
||||
if (text.includes('未分配') || text.includes('未打印') || text.includes('未拣货')) return 'info'
|
||||
|
||||
@ -13,7 +13,16 @@
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div class="tabs-header-action">
|
||||
<!-- <el-button size="small">操作按钮</el-button> -->
|
||||
<!-- 已确认打印未领单波次数量(order.wave.confirmPrintUnclaimedWaveCount 长轮询实时刷新) -->
|
||||
<el-tooltip
|
||||
content="已确认打印(confirm_print_status=fin)但未领单(claim_status != fin)的波次数量,实时刷新"
|
||||
placement="bottom"
|
||||
>
|
||||
<span class="unclaimed-print-chip" :class="{ 'is-active': confirmPrintUnclaimedWaveCount > 0 }">
|
||||
<span class="chip-label">确认打印未领单</span>
|
||||
<em class="chip-count">{{ confirmPrintUnclaimedWaveCount }}</em>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<el-tabs
|
||||
v-model="activeTab"
|
||||
@ -75,8 +84,9 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed, markRaw, onMounted } from 'vue'
|
||||
import { ref, watch, computed, markRaw, onMounted, onUnmounted, onActivated, onDeactivated } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useExperimentalStore } from '@/stores/modules/experimental'
|
||||
import { Sort } from '@element-plus/icons-vue'
|
||||
@ -88,6 +98,8 @@ import FallbackOrderListPanel from './FallbackOrderListPanel.vue'
|
||||
import WaveStrategyListPanel from './WaveStrategyListPanel.vue'
|
||||
import WavePickTaskListPanel from './WavePickTaskListPanel.vue'
|
||||
import { safeInvoke } from '@/utils/safe-invoke'
|
||||
import { orderWaveConfirmPrintScan, orderWaveConfirmPrintUnclaimedWaveCount } from '@/api/order.wave/orderwave'
|
||||
import { useBarcodeScan } from '@/composables/useBarcodeScan'
|
||||
import { WAVE_PAGE_CONFIG } from './config/wave-config'
|
||||
|
||||
const route = useRoute()
|
||||
@ -234,6 +246,135 @@ watch(activeTab, (name) => {
|
||||
safeInvoke(() => syncActiveTabToUrl(String(name)))
|
||||
})
|
||||
|
||||
// ============================================================
|
||||
// 扫码确认打印(全局扫码事件)
|
||||
// ============================================================
|
||||
/**
|
||||
* 波次管理页注册全局扫码事件:扫描波次内任一订单的面单号(长度超过 8 位)→
|
||||
* order.wave.confirmPrintScan(与领单 pick.waveClaimScan 操作一致):把该波次下全部已打印
|
||||
* (print_status='fin')且非拦截的订单批量置 confirm_print_status='fin',并写订单操作日志
|
||||
* (ORDER_CONFIRM_PRINT)。
|
||||
* - 拦截订单跳过(不确认、不阻断);波次下存在未打印订单时后端阻断并给出提示;
|
||||
* - 波次下订单已全部确认时重复扫描返回 already_confirmed;
|
||||
* - 监听随页面生命周期注册/移除:切到其他页面(keep-alive 页面走 onDeactivated)立即摘除监听,
|
||||
* 不会在后台继续响应扫码。
|
||||
*/
|
||||
const confirmPrintScanPending = ref(false)
|
||||
|
||||
async function handleConfirmPrintScan(waybillNo: string) {
|
||||
if (confirmPrintScanPending.value) return
|
||||
confirmPrintScanPending.value = true
|
||||
try {
|
||||
const res = await orderWaveConfirmPrintScan({ waybill_no: waybillNo })
|
||||
// 兼容 data 嵌套与顶层平铺两种返回
|
||||
const data = res?.data ?? res
|
||||
const waveLabel = data?.wave_no ? `波次 ${data.wave_no}` : '该波次'
|
||||
if (data?.status === 'already_confirmed') {
|
||||
ElMessage.info(`${waveLabel}(${waybillNo})订单已全部确认打印`)
|
||||
return
|
||||
}
|
||||
const detail = [
|
||||
`本次确认打印 ${Number(data?.newly_confirmed_order_count ?? 0)} 单`,
|
||||
data?.total_order_count ? `共 ${data.total_order_count} 单` : '',
|
||||
data?.intercepted_order_count ? `跳过拦截 ${data.intercepted_order_count} 单` : ''
|
||||
].filter(Boolean).join(',')
|
||||
ElMessage.success(`${waveLabel}(${waybillNo})确认打印成功:${detail}`)
|
||||
} catch {
|
||||
// 请求层已统一提示(存在未打印订单阻断 / 订单未分配波次 / 未查询到该面单号等)
|
||||
} finally {
|
||||
confirmPrintScanPending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
useBarcodeScan({
|
||||
// 长度超过 8 位(>=9)才提交确认打印接口,短条码(指令/库位等)一律忽略
|
||||
minLength: 9,
|
||||
// 处理中不采集,避免连扫时并发重复提交
|
||||
enabled: () => !confirmPrintScanPending.value,
|
||||
onScan: (code) => { void handleConfirmPrintScan(code) }
|
||||
})
|
||||
|
||||
// ============================================================
|
||||
// 确认打印未领单波次数量(tab 区展示,长轮询实时刷新)
|
||||
// ============================================================
|
||||
/**
|
||||
* order.wave.confirmPrintUnclaimedWaveCount 长轮询:
|
||||
* - 不带 last_count 立即返回当前值(status=current);带 last_count 则挂起等待变化(最长 60 秒);
|
||||
* - 确认打印 / 领单成功会递增统计版本号,挂起中的请求 1 秒内发现变化并返回新值(status=changed);
|
||||
* - 生命周期:进入波次页(mounted / keep-alive activated)开始轮询,离开页面(unmounted / deactivated)
|
||||
* 立即停止,挂起中的响应按「轮询代数」作废;回到波次页重新轮询(先不带 last_count 取当前值)。
|
||||
*/
|
||||
const confirmPrintUnclaimedWaveCount = ref(0)
|
||||
/** 长轮询基线(上次返回的 count);null = 下次请求不带 last_count,立即取当前值 */
|
||||
let unclaimedCountBaseline: number | null = null
|
||||
/** 轮询代数:启动/停止时自增,用于丢弃上一轮挂起中(离开页面后)的响应 */
|
||||
let unclaimedCountGeneration = 0
|
||||
let unclaimedCountPolling = false
|
||||
/** 连续失败上限:权限/仓库上下文等错误不会自愈,停止轮询避免反复弹提示(切页回来会重新尝试) */
|
||||
const UNCLAIMED_COUNT_MAX_FAILURES = 3
|
||||
/** 请求失败后的重试间隔 */
|
||||
const UNCLAIMED_COUNT_RETRY_MS = 10000
|
||||
|
||||
function delay(ms: number) {
|
||||
// 注意:本目录 eslint 未声明浏览器全局,用 globalThis 取定时器避免 no-undef
|
||||
return new Promise<void>((resolve) => { globalThis.setTimeout(resolve, ms) })
|
||||
}
|
||||
|
||||
async function pollConfirmPrintUnclaimedWaveCount() {
|
||||
// 单页模式不渲染 tab 区,无需轮询;已在轮询时重复调用直接忽略
|
||||
if (unclaimedCountPolling || singlePage) return
|
||||
const generation = ++unclaimedCountGeneration
|
||||
unclaimedCountPolling = true
|
||||
/** 本轮是否仍然有效(离开页面会使代数自增) */
|
||||
const isCurrent = () => unclaimedCountPolling && generation === unclaimedCountGeneration
|
||||
let failures = 0
|
||||
|
||||
while (isCurrent()) {
|
||||
try {
|
||||
const res = await orderWaveConfirmPrintUnclaimedWaveCount(
|
||||
unclaimedCountBaseline === null ? {} : { last_count: unclaimedCountBaseline }
|
||||
)
|
||||
if (!isCurrent()) break
|
||||
// 兼容 data 嵌套与顶层平铺两种返回
|
||||
const data = res?.data ?? res
|
||||
const next = Number(data?.count)
|
||||
if (Number.isFinite(next) && next >= 0) {
|
||||
confirmPrintUnclaimedWaveCount.value = next
|
||||
unclaimedCountBaseline = next
|
||||
}
|
||||
failures = 0
|
||||
} catch {
|
||||
// 错误已由请求层统一提示,这里只做退避重试
|
||||
if (!isCurrent()) break
|
||||
failures += 1
|
||||
if (failures >= UNCLAIMED_COUNT_MAX_FAILURES) {
|
||||
console.warn('[wave] 确认打印未领单数量轮询连续失败,已暂停;切换页面后重新尝试')
|
||||
break
|
||||
}
|
||||
await delay(UNCLAIMED_COUNT_RETRY_MS)
|
||||
}
|
||||
}
|
||||
|
||||
// 正常退出(连续失败暂停)时也清空基线:下次启动先立即取一次当前值
|
||||
if (generation === unclaimedCountGeneration) {
|
||||
unclaimedCountPolling = false
|
||||
unclaimedCountBaseline = null
|
||||
}
|
||||
}
|
||||
|
||||
/** 停止轮询:挂起中的请求结果不再写回,回到页面时重新取一次当前值 */
|
||||
function stopConfirmPrintUnclaimedWaveCountPoll() {
|
||||
unclaimedCountGeneration += 1
|
||||
unclaimedCountPolling = false
|
||||
unclaimedCountBaseline = null
|
||||
}
|
||||
|
||||
onMounted(() => { void pollConfirmPrintUnclaimedWaveCount() })
|
||||
// 切到其他页面即停止刷新;keep-alive 页面走 onDeactivated(不触发 onUnmounted)
|
||||
onUnmounted(stopConfirmPrintUnclaimedWaveCountPoll)
|
||||
onActivated(() => { void pollConfirmPrintUnclaimedWaveCount() })
|
||||
onDeactivated(stopConfirmPrintUnclaimedWaveCountPoll)
|
||||
|
||||
onMounted(() => {
|
||||
applySavedTabOrder()
|
||||
})
|
||||
@ -267,9 +408,42 @@ onMounted(() => {
|
||||
height: 38px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/* 已确认打印未领单波次数量(tab 区常显;>0 时高亮提醒) */
|
||||
.unclaimed-print-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
height: 22px;
|
||||
padding: 0 10px;
|
||||
border-radius: 11px;
|
||||
font-size: 12px;
|
||||
line-height: 22px;
|
||||
color: #606266;
|
||||
background: #f4f4f5;
|
||||
border: 1px solid #e9e9eb;
|
||||
cursor: default;
|
||||
|
||||
.chip-count {
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
color: #d48806;
|
||||
background: rgba(230, 162, 60, 0.1);
|
||||
border-color: rgba(230, 162, 60, 0.35);
|
||||
|
||||
.chip-count {
|
||||
color: #d48806;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 标签排序入口(tab 区域左侧,样式对齐 order/orderManagement) */
|
||||
.tab-sort-entry {
|
||||
position: absolute;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user