diff --git a/src/views/weightManage/index.vue b/src/views/weightManage/index.vue index dd13b07..75bc99b 100644 --- a/src/views/weightManage/index.vue +++ b/src/views/weightManage/index.vue @@ -57,8 +57,9 @@
@@ -73,7 +74,7 @@
- 图片展示( // 视频元素引用 const cameraVideo = ref(null) +// 物料编码输入框引用 +const materialCodeInput = ref(null) // FLV播放器实例 let player: any = null @@ -546,12 +549,19 @@ let imageRefreshTimer: any = null // 组件挂载时 onMounted(async () => { await loadFlvJs() - + // 启动图片自动刷新,每秒更新一次 imageRefreshTimer = setInterval(() => { // 添加时间戳参数,避免浏览器缓存 imgData.imgUrl = `${imgData.baseUrl}?t=${Date.now()}` }, 1000) + + // 页面加载后自动聚焦到物料编码输入框 + nextTick(() => { + if (materialCodeInput.value) { + materialCodeInput.value.focus() + } + }) }) // 组件卸载时 @@ -714,7 +724,7 @@ const handleKeyDown = (event: KeyboardEvent) => { isScanning = true // } } - + // 更新上次输入时间 lastInputTime = currentTime } @@ -872,6 +882,13 @@ const handleBackToFirst = () => { // 离开称重页面时关闭WebSocket连接 closeWebSocket() + + // 回到第一步后自动聚焦到物料编码输入框 + nextTick(() => { + if (materialCodeInput.value) { + materialCodeInput.value.focus() + } + }) } // 计算重量