1
This commit is contained in:
parent
332ebac7b4
commit
cf39d2380d
@ -48,7 +48,7 @@
|
||||
v-if="!hasSelectedIntercept"
|
||||
size="small"
|
||||
type="warning"
|
||||
:disabled="!lastPrintWaveGroups"
|
||||
:disabled="!activeOrderId"
|
||||
:loading="reprintLoading"
|
||||
@click="handleReprint"
|
||||
>
|
||||
@ -439,12 +439,11 @@ async function handlePanelSelect(order: any) {
|
||||
const isPrintFirst = !recheckWorkflowMode.value || recheckWorkflowMode.value === 'print_first'
|
||||
if (isPrintFirst && !isReviewed && !isIntercept && Number.isFinite(orderId) && orderId > 0) {
|
||||
const printStatus = String((order as any)?.print_status ?? '').trim()
|
||||
if (printStatus !== 'fin' && !skipAutoPrintOnce.value) {
|
||||
if (printStatus !== 'fin') {
|
||||
const waveIds = isWave ? ((order as any)?.order_ids as Array<number | string> | undefined) : undefined
|
||||
await autoPrintForOrder(orderId, waveIds)
|
||||
}
|
||||
}
|
||||
skipAutoPrintOnce.value = false
|
||||
}
|
||||
|
||||
/** 播放提示音:type=success(短促高音), warning(低沉长音) */
|
||||
@ -1056,7 +1055,6 @@ const autoPrintingRef = ref(false)
|
||||
const reprintLoading = ref(false)
|
||||
const lastPrintWaveGroups = ref<unknown[] | null>(null)
|
||||
const lastPrintOrderId = ref<number | null>(null)
|
||||
const skipAutoPrintOnce = ref(false)
|
||||
|
||||
async function autoPrintForOrder(orderId: number, waveOrderIds?: Array<number | string>) {
|
||||
if (autoPrintingRef.value) return
|
||||
@ -1112,9 +1110,9 @@ async function autoPrintForOrder(orderId: number, waveOrderIds?: Array<number |
|
||||
}
|
||||
|
||||
async function handleReprint() {
|
||||
const waveGroups = lastPrintWaveGroups.value
|
||||
if (!waveGroups) {
|
||||
ElMessage.warning('暂无打印数据,请先完成一次打印')
|
||||
const currentId = activeOrderId.value
|
||||
if (currentId == null || currentId <= 0) {
|
||||
ElMessage.warning('未选中订单')
|
||||
return
|
||||
}
|
||||
const stationId = recheckPrintStationId.value
|
||||
@ -1125,9 +1123,26 @@ async function handleReprint() {
|
||||
if (reprintLoading.value) return
|
||||
reprintLoading.value = true
|
||||
try {
|
||||
const orderId = lastPrintOrderId.value ?? 0
|
||||
// 始终按当前选中订单拉取打印数据,不使用缓存
|
||||
const selectedRow = selectedOrderRow.value as any
|
||||
const waveIds = selectedRow?._is_wave ? (selectedRow?.order_ids as Array<number | string> | undefined) : undefined
|
||||
const queryIds = (waveIds && waveIds.length) ? waveIds : [currentId]
|
||||
const res: any = await getOrderPrintData({ order_ids: queryIds })
|
||||
if (res?.code !== undefined && res?.code !== null && res?.code !== 1 && res?.code !== 200 && res?.code !== 0) {
|
||||
throw new Error(res?.message || '获取打印数据失败')
|
||||
}
|
||||
const payload = unwrapWavePlatformPrintPayload(res)
|
||||
let waveGroups: unknown[] | null | undefined = payload.waveGroups
|
||||
if (!Array.isArray(waveGroups) || !waveGroups.length) {
|
||||
const innerData = res?.data
|
||||
waveGroups = Array.isArray(innerData?.list) ? innerData.list : undefined
|
||||
}
|
||||
if (!Array.isArray(waveGroups) || !waveGroups.length) {
|
||||
ElMessage.warning('未获取到可打印数据')
|
||||
return
|
||||
}
|
||||
const warehouseId = Number(userStore.user?.warehouse_id ?? userStore.user?.store_id ?? 0)
|
||||
const requestCode = `recheck-reprint-${warehouseId}-${orderId}-${Date.now()}`
|
||||
const requestCode = `recheck-reprint-${warehouseId}-${currentId}-${Date.now()}`
|
||||
const printRes: any = await stationApi.sendPrint({
|
||||
type: 'express',
|
||||
printStationId: stationId,
|
||||
@ -1491,7 +1506,6 @@ async function handleConfirm() {
|
||||
return status !== 'fin'
|
||||
})
|
||||
if (nextUnreviewed) {
|
||||
skipAutoPrintOnce.value = true
|
||||
handlePanelSelect(nextUnreviewed)
|
||||
} else {
|
||||
// 清除当前订单的扫描状态
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user