| | |
| | | * len=1表示读取4位,len=2表示读取8位,len=8表示读取32位 |
| | | * 使用len=1读取4位数据(如果标签是4位) |
| | | */ |
| | | const readLen = 1; // 读取长度:1个Word = 4个字符 |
| | | const readLen = 8; // 读取长度:1个Word = 4个字符 |
| | | uhfModel.readTagWithoutFilter(1, 2, readLen, "00000000", (ret) => { |
| | | isScanning = false; |
| | | console.log('[RFIDInputHelper] readTagWithoutFilter result:', ret); |
| | |
| | | |
| | | // 只填入有焦点的输入框,如果没有焦点则不填入 |
| | | if (focusedField) { |
| | | console.log(`[RFIDInputHelper] 填入有焦点的输入框 ${focusedField}:`, epc); |
| | | vm[focusedField] = epc; |
| | | // 根据字段类型截断RFID数据长度 |
| | | let finalEpc = epc; |
| | | const fieldLengthMap = { |
| | | 'barcode': 8, // 托盘码:保留前8位 |
| | | 'matnr': 16, // 物料码/物料号:保留前16位 |
| | | 'sourceSite': 9, // 暂存位:保留前9位 |
| | | 'locNo': 7 // 库位号:保留前7位 |
| | | }; |
| | | |
| | | if (fieldLengthMap[focusedField]) { |
| | | const maxLength = fieldLengthMap[focusedField]; |
| | | if (finalEpc.length > maxLength) { |
| | | console.log(`[RFIDInputHelper] ${focusedField}字段数据长度(${finalEpc.length}位)超过限制(${maxLength}位),截取前${maxLength}位`); |
| | | finalEpc = finalEpc.substring(0, maxLength); |
| | | } |
| | | } |
| | | |
| | | console.log(`[RFIDInputHelper] 填入有焦点的输入框 ${focusedField}:`, finalEpc); |
| | | vm[focusedField] = finalEpc; |
| | | // 触发input事件,确保页面逻辑能响应 |
| | | if (vm.$nextTick) { |
| | | vm.$nextTick(() => { |