Commit bd79ca49 by wusiyi

Merge branch 'fix_1001679' into 'dev'

Fix 1001679

See merge request !287
parents 46551e46 157d3e5d
...@@ -2903,12 +2903,19 @@ const handleSeedingWall = (type: 'print' | 'sort') => { ...@@ -2903,12 +2903,19 @@ const handleSeedingWall = (type: 'print' | 'sort') => {
podOrderVisible.value = true podOrderVisible.value = true
} }
const printOrder = async ( /** LODOP 单例不可并发,打印串行 */
let printOrderChain: Promise<void> = Promise.resolve()
const printOrder = (
data: OrderData, data: OrderData,
callback: (status: boolean) => void, callback: (status: boolean) => void,
) => { ) => {
const run = async () => {
const lodop = getCLodop(null, null) const lodop = getCLodop(null, null)
if (!lodop) return if (!lodop) {
callback && callback(false)
return
}
lodop.PRINT_INIT('打印内容') lodop.PRINT_INIT('打印内容')
const printerIndex = lodop.SET_PRINTER_INDEX(sheetPrinter.value) const printerIndex = lodop.SET_PRINTER_INDEX(sheetPrinter.value)
console.log( console.log(
...@@ -2963,11 +2970,9 @@ const printOrder = async ( ...@@ -2963,11 +2970,9 @@ const printOrder = async (
console.log('PRINT_STATUS_OK:', jobCode, `ok: ${ok}`) console.log('PRINT_STATUS_OK:', jobCode, `ok: ${ok}`)
if (ok == 1) { if (ok == 1) {
console.log('打印成功') console.log('打印成功')
// 打印状态:成功
callback && callback(true) callback && callback(true)
return return
} }
// 如果打印状态表示未成功或者返回了空,继续获取任务是否存在
const exist = await lodopCall((lodop) => const exist = await lodopCall((lodop) =>
lodop.GET_VALUE('PRINT_STATUS_EXIST', jobCode), lodop.GET_VALUE('PRINT_STATUS_EXIST', jobCode),
) )
...@@ -2981,7 +2986,6 @@ const printOrder = async ( ...@@ -2981,7 +2986,6 @@ const printOrder = async (
) )
if (exist == 0) { if (exist == 0) {
console.log('任务不存在了', `exist:${exist}`) console.log('任务不存在了', `exist:${exist}`)
// 任务不存在了
callback && callback(true) callback && callback(true)
return return
} }
...@@ -2998,6 +3002,9 @@ const printOrder = async ( ...@@ -2998,6 +3002,9 @@ const printOrder = async (
lodop.PRINT() lodop.PRINT()
callback && callback(false) callback && callback(false)
} }
}
printOrderChain = printOrderChain.then(run, run)
} }
let _lodop: LODOPObject | null = null let _lodop: LODOPObject | null = null
let _lodopCallback: { [key: string]: (value: string) => void } = {} let _lodopCallback: { [key: string]: (value: string) => void } = {}
......
...@@ -1251,9 +1251,6 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => { ...@@ -1251,9 +1251,6 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => {
if (type === 'manual' && boxs.length > 0) { if (type === 'manual' && boxs.length > 0) {
nextTick(async () => { nextTick(async () => {
// 切换箱子至验货完成的箱子
boxChange.value = true
boxIndex.value = boxs[0] as number
const token = ++pickFinishedAlertToken const token = ++pickFinishedAlertToken
if (token > 1) { if (token > 1) {
ElMessageBox.close() ElMessageBox.close()
...@@ -1338,7 +1335,8 @@ const nextStep = async (callback: () => void) => { ...@@ -1338,7 +1335,8 @@ const nextStep = async (callback: () => void) => {
callback && callback() callback && callback()
}) })
} catch (error) { } catch (error) {
productionOrderRef.value.focus() // 取消打单完成时仍允许切换箱子 / 关闭弹窗
callback && callback()
console.error(error) console.error(error)
} }
} else { } else {
...@@ -1448,15 +1446,24 @@ const handlePrinterChange = (value: string) => { ...@@ -1448,15 +1446,24 @@ const handlePrinterChange = (value: string) => {
emit('set-printer', value) emit('set-printer', value)
} }
/** 已自动打印过的订单,避免 WS 回写清掉 printResult 后重复打印 */
const autoPrintedIds = new Set<number>()
const print = (data: OrderData, forcePrint = false, callback?: () => void) => { const print = (data: OrderData, forcePrint = false, callback?: () => void) => {
const _boxIndex = boxIndex.value const _boxIndex = boxIndex.value
const orderId = data.id
if (!forcePrint && data.printResult) { if (
!forcePrint &&
(data.printResult || (orderId != null && autoPrintedIds.has(orderId)))
) {
callback && callback() callback && callback()
return return
} }
if (!forcePrint && orderId != null) autoPrintedIds.add(orderId)
props.printOrder(data, (status: boolean) => { props.printOrder(data, (status: boolean) => {
if (!status && orderId != null) autoPrintedIds.delete(orderId)
callback && callback() callback && callback()
const item = podBoxList.value?.find((item) => item.box === _boxIndex) const item = podBoxList.value?.find((item) => item.box === _boxIndex)
if (item && item.data) { if (item && item.data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment