From 1e0f4d35a2d320d7cb75a61ab22b6471ab26adde Mon Sep 17 00:00:00 2001 From: QunSheng Lin <441785369@qq.com> Date: Tue, 15 Apr 2025 13:57:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=BD=8D=E7=BD=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=96=B9=E4=BE=BF=E6=93=8D=E4=BD=9C=20=E6=89=93?= =?UTF-8?q?=E5=8D=B0=E5=8F=96=E6=B6=88=E4=B8=80=E4=B8=AA=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84uf8=E5=BA=93=20=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=89=93=E5=8D=B0=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/components/bluetooth/bluetooth.axml | 18 ++++---- pages/components/bluetooth/bluetooth.js | 46 +++++++++++-------- pages/components/bluetooth/bluetooth.json | 8 +--- .../printTemplate/bluetooth/bluetooth.axml | 4 +- .../printTag/printTemplate/printTemplate.axml | 2 +- 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/pages/components/bluetooth/bluetooth.axml b/pages/components/bluetooth/bluetooth.axml index e0d2491..755f30e 100644 --- a/pages/components/bluetooth/bluetooth.axml +++ b/pages/components/bluetooth/bluetooth.axml @@ -13,6 +13,15 @@ + + + + 启动 + + 搜索 + + + @@ -41,15 +50,6 @@ - - - - 启动 - - 搜索 - - - diff --git a/pages/components/bluetooth/bluetooth.js b/pages/components/bluetooth/bluetooth.js index a61a83c..3c31b23 100644 --- a/pages/components/bluetooth/bluetooth.js +++ b/pages/components/bluetooth/bluetooth.js @@ -148,21 +148,27 @@ Component({ if (printdata && printdata.selectedItems && Array.isArray(printdata.selectedItems)) { // 遍历 selectedItems 数组 printdata.selectedItems.forEach((item) => { - // 输出当前遍历的 item - console.log('每个订单行数据item:', item); - // 检查 item 的 fineCode3Names 是否存在,并且是一个数组 - if (item.fineCode3Names && Array.isArray(item.fineCode3Names)) { - // 遍历 fineCode3Names 数组 - item.fineCode3Names.forEach((value) => { - // 拼接要打印的内容 - value = `name ${item.name[1]}.color ${item.color_id_2[1]}.code ${value}`; - // 去除中文和[]符号 - value = value.replace(/[\u4e00-\u9fa5\[\]]/g, ''); - allValuesToPrint.push(value); - }); - } + // 输出当前遍历的 item + console.log('每个订单行数据item:', item); + // 检查 item 的 fineCode3Names 是否存在,并且是一个数组 + if (item.fineCode3Names && Array.isArray(item.fineCode3Names)) { + // 遍历 fineCode3Names 数组 + item.fineCode3Names.forEach((value) => { + // 将可能的浮点数转换为文本 + const nameValue = typeof item.name === 'number'? item.name.toString() : item.name; + const colorValue = typeof item.color_id_2[1] === 'number'? item.color_id_2[1].toString() : item.color_id_2[1]; + const codeValue = typeof value === 'number'? value.toString() : value; + + // 拼接要打印的内容 + value = `name ${nameValue}.color ${colorValue}.code ${codeValue}`; + // 去除中文和[]符号 + value = value.replace(/[\u4e00-\u9fa5\[\]]/g, ''); + allValuesToPrint.push(value); + }); + } }); - } + } + const totalCodes = allValuesToPrint.length; @@ -180,8 +186,10 @@ Component({ TEXT 20,350,"2",0,1,1,"${code}" PRINT 1,1 `; - const encoder = new TextEncoder('utf-8'); - const commandBuffer = encoder.encode(command); + + // const encoder = new TextEncoder('utf-8'); + // const commandBuffer = encoder.encode(command); + const commandBuffer = Buffer.from(command, 'utf-8'); const hexValue = Array.from(commandBuffer) .map(byte => byte.toString(16).padStart(2, '0')) .join(''); @@ -211,9 +219,9 @@ Component({ TEXT 20,350,"2",0,1,1,"${currentCode}" PRINT 1,1 `; - const encoder = new TextEncoder('utf-8'); - const commandBuffer = encoder.encode(command); - + // const encoder = new TextEncoder('utf-8'); + // const commandBuffer = encoder.encode(command); + const commandBuffer = Buffer.from(command, 'utf-8'); // 将二进制数据转换为 hex 编码 const hexValue = Array.from(commandBuffer) .map(byte => byte.toString(16).padStart(2, '0')) diff --git a/pages/components/bluetooth/bluetooth.json b/pages/components/bluetooth/bluetooth.json index ec70dea..e91cc2c 100644 --- a/pages/components/bluetooth/bluetooth.json +++ b/pages/components/bluetooth/bluetooth.json @@ -1,9 +1,3 @@ { - "component": true, - "properties": { - "printdata": { - "type": "Object", - "value": {} - } - } + "component": true } \ No newline at end of file diff --git a/pages/deal/saleOrder/kanban/from/printTag/printTemplate/bluetooth/bluetooth.axml b/pages/deal/saleOrder/kanban/from/printTag/printTemplate/bluetooth/bluetooth.axml index dd8e47b..c26eb65 100644 --- a/pages/deal/saleOrder/kanban/from/printTag/printTemplate/bluetooth/bluetooth.axml +++ b/pages/deal/saleOrder/kanban/from/printTag/printTemplate/bluetooth/bluetooth.axml @@ -1,7 +1,7 @@ - + - + name:{{item.name || '无货号'}}. color: {{item.color_id_2 || '无色号'}} . code: {{item.fineCode || '无细码'}} diff --git a/pages/deal/saleOrder/kanban/from/printTag/printTemplate/printTemplate.axml b/pages/deal/saleOrder/kanban/from/printTag/printTemplate/printTemplate.axml index 8b131fd..bfa7614 100644 --- a/pages/deal/saleOrder/kanban/from/printTag/printTemplate/printTemplate.axml +++ b/pages/deal/saleOrder/kanban/from/printTag/printTemplate/printTemplate.axml @@ -8,7 +8,7 @@ 返回