优化物料编码无需点击

This commit is contained in:
zc
2026-03-19 11:30:10 +08:00
parent 7b57bb9b05
commit c4303b4d5f

View File

@@ -57,8 +57,9 @@
<div class="form-item"> <div class="form-item">
<a-form-item label="物料编码"> <a-form-item label="物料编码">
<a-input <a-input
ref="materialCodeInput"
v-model="formData.inputMaterialCode" v-model="formData.inputMaterialCode"
placeholder="请点击此处确保光标闪烁,使用扫码枪扫描物料编码" placeholder="请点击此处确保光标闪烁,且输入法为英文状态,使用扫码枪扫描物料编码"
@keydown="handleKeyDown" @keydown="handleKeyDown"
@input="handleMaterialCodeChange" @input="handleMaterialCodeChange"
/> />
@@ -309,6 +310,8 @@ const cameraStatus = ref<'connected' | 'connecting' | 'disconnected' | 'error'>(
// 视频元素引用 // 视频元素引用
const cameraVideo = ref<HTMLVideoElement | null>(null) const cameraVideo = ref<HTMLVideoElement | null>(null)
// 物料编码输入框引用
const materialCodeInput = ref<any>(null)
// FLV播放器实例 // FLV播放器实例
let player: any = null let player: any = null
@@ -552,6 +555,13 @@ onMounted(async () => {
// 添加时间戳参数,避免浏览器缓存 // 添加时间戳参数,避免浏览器缓存
imgData.imgUrl = `${imgData.baseUrl}?t=${Date.now()}` imgData.imgUrl = `${imgData.baseUrl}?t=${Date.now()}`
}, 1000) }, 1000)
// 页面加载后自动聚焦到物料编码输入框
nextTick(() => {
if (materialCodeInput.value) {
materialCodeInput.value.focus()
}
})
}) })
// 组件卸载时 // 组件卸载时
@@ -872,6 +882,13 @@ const handleBackToFirst = () => {
// 离开称重页面时关闭WebSocket连接 // 离开称重页面时关闭WebSocket连接
closeWebSocket() closeWebSocket()
// 回到第一步后自动聚焦到物料编码输入框
nextTick(() => {
if (materialCodeInput.value) {
materialCodeInput.value.focus()
}
})
} }
// 计算重量 // 计算重量