fix: 拆包 OSD 字幕清屏改为推「无任务」待命文字,默认开启并增加推送反馈
This commit is contained in:
parent
558aacbae1
commit
06029b6bb3
@ -850,15 +850,17 @@ function restoreCameraSelection() {
|
|||||||
// ==================== OSD 字幕推送 ====================
|
// ==================== OSD 字幕推送 ====================
|
||||||
// 拆包扫码时把「单号 + 商品条码」通过 camera.setOsd 推送到已选摄像头,叠加到监控画面
|
// 拆包扫码时把「单号 + 商品条码」通过 camera.setOsd 推送到已选摄像头,叠加到监控画面
|
||||||
const OSD_ENABLED_STORAGE_KEY = 'returnUnpackWork:osdEnabled'
|
const OSD_ENABLED_STORAGE_KEY = 'returnUnpackWork:osdEnabled'
|
||||||
const osdEnabled = ref(false)
|
const OSD_IDLE_TEXT = '无任务'
|
||||||
|
const osdEnabled = ref(true)
|
||||||
const lastScannedBarcode = ref('')
|
const lastScannedBarcode = ref('')
|
||||||
const osdPushing = ref(false)
|
const osdPushing = ref(false)
|
||||||
let lastOsdText: string | null = null
|
let lastOsdText: string | null = null
|
||||||
|
let osdNoCameraWarned = false
|
||||||
|
|
||||||
/** 当前应推送的字幕文本:单号:xxx(扫到商品条码后追加 商品条码:xxx) */
|
/** 当前应推送的字幕文本:单号:xxx(扫到商品条码后追加 商品条码:xxx);无拆包时显示待命文字 */
|
||||||
function buildOsdText(): string {
|
function buildOsdText(): string {
|
||||||
const waybill = String(createResult.value?.record?.waybill_code ?? waybillCode.value ?? '').trim()
|
const waybill = String(createResult.value?.record?.waybill_code ?? waybillCode.value ?? '').trim()
|
||||||
if (!waybill) return ''
|
if (!waybill) return OSD_IDLE_TEXT
|
||||||
return lastScannedBarcode.value
|
return lastScannedBarcode.value
|
||||||
? `单号:${waybill} 商品条码:${lastScannedBarcode.value}`
|
? `单号:${waybill} 商品条码:${lastScannedBarcode.value}`
|
||||||
: `单号:${waybill}`
|
: `单号:${waybill}`
|
||||||
@ -868,10 +870,16 @@ function buildOsdText(): string {
|
|||||||
async function pushOsdText(text?: string, force = false) {
|
async function pushOsdText(text?: string, force = false) {
|
||||||
if (!osdEnabled.value) return
|
if (!osdEnabled.value) return
|
||||||
const cameras = selectedCameras.value
|
const cameras = selectedCameras.value
|
||||||
if (!cameras.length) return
|
if (!cameras.length) {
|
||||||
const t = String(text ?? buildOsdText()).trim()
|
if (!osdNoCameraWarned) {
|
||||||
// 从未推过字幕时不主动推空文本(避免无意义请求)
|
osdNoCameraWarned = true
|
||||||
if (t === '' && (lastOsdText == null || lastOsdText === '')) return
|
ElMessage.warning('未选择摄像头,字幕未推送(点「摄像头设置」勾选)')
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 空文本 → 直接推「无任务」待命文字覆盖旧字幕
|
||||||
|
const raw = text != null ? String(text).trim() : buildOsdText()
|
||||||
|
const t = raw === '' ? OSD_IDLE_TEXT : raw
|
||||||
if (!force && t === lastOsdText) return
|
if (!force && t === lastOsdText) return
|
||||||
lastOsdText = t
|
lastOsdText = t
|
||||||
osdPushing.value = true
|
osdPushing.value = true
|
||||||
@ -880,7 +888,11 @@ async function pushOsdText(text?: string, force = false) {
|
|||||||
cameras.map((c) => setOsd({ id: c.id, text: t, x: -0.9, y: 0.8 }))
|
cameras.map((c) => setOsd({ id: c.id, text: t, x: -0.9, y: 0.8 }))
|
||||||
)
|
)
|
||||||
const okCount = results.filter((r) => r.status === 'fulfilled' && isOk(r.value)).length
|
const okCount = results.filter((r) => r.status === 'fulfilled' && isOk(r.value)).length
|
||||||
if (okCount === 0) lastOsdText = null
|
if (okCount === 0) {
|
||||||
|
lastOsdText = null
|
||||||
|
} else if (t) {
|
||||||
|
ElMessage.success(`字幕已推送:${t}`)
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
osdPushing.value = false
|
osdPushing.value = false
|
||||||
}
|
}
|
||||||
@ -1282,7 +1294,8 @@ function resetWorkState() {
|
|||||||
orderDetailData.value = null
|
orderDetailData.value = null
|
||||||
orderDetailItems.value = []
|
orderDetailItems.value = []
|
||||||
lastScannedBarcode.value = ''
|
lastScannedBarcode.value = ''
|
||||||
void pushOsdText('')
|
// 删除/取消/提交/清除后直接推「无任务」待命文字
|
||||||
|
void pushOsdText(OSD_IDLE_TEXT)
|
||||||
focusTarget.value = 'waybill'
|
focusTarget.value = 'waybill'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user