按钮位置调整方便操作 打印取消一个无法使用的uf8库 预览测试打印成功
This commit is contained in:
parent
9116015e19
commit
1e0f4d35a2
@ -13,6 +13,15 @@
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
<view class="page-section-demo switch-list">
|
||||
<view class="switch-item">
|
||||
<!-- checked:是否被选中初始状态默认开关 onChange:checked 改变时触发,event.detail={value:checked}。 -->
|
||||
启动
|
||||
<switch onChange="switchopenBluetoothAdapter" aria-label="{{switchopenBluetoothAdapter ? 'switch opened' : 'switch closed'}}" />
|
||||
搜索
|
||||
<switch onChange="startBluetoothDevicesDiscovery" aria-label="{{startBluetoothDevicesDiscovery ? 'switch opened' : 'switch closed'}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="page">
|
||||
<view class="page-description"></view>
|
||||
<view class="page-section">
|
||||
@ -41,15 +50,6 @@
|
||||
</view>
|
||||
</view>
|
||||
<progress percent="{{percent}}" active/>
|
||||
<view class="page-section-demo switch-list">
|
||||
<view class="switch-item">
|
||||
<!-- checked:是否被选中初始状态默认开关 onChange:checked 改变时触发,event.detail={value:checked}。 -->
|
||||
启动
|
||||
<switch onChange="switchopenBluetoothAdapter" aria-label="{{switchopenBluetoothAdapter ? 'switch opened' : 'switch closed'}}" />
|
||||
搜索
|
||||
<switch onChange="startBluetoothDevicesDiscovery" aria-label="{{startBluetoothDevicesDiscovery ? 'switch opened' : 'switch closed'}}" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="page">
|
||||
<view class="page-description"></view>
|
||||
<view class="page-section">
|
||||
|
||||
@ -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'))
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
{
|
||||
"component": true,
|
||||
"properties": {
|
||||
"printdata": {
|
||||
"type": "Object",
|
||||
"value": {}
|
||||
}
|
||||
}
|
||||
"component": true
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<view>
|
||||
<bluetooth-component printdata="{{printdata}}" />
|
||||
<bluetooth-component/>
|
||||
<view a:for="{{fineCode3Names}}" a:key="*this" class="order-item" data-info="{{item.fineCode}}">
|
||||
<image class="image" src="../../../../../../../static/images/胜佳纺织.png" />
|
||||
<image class="image"/>
|
||||
<view class="order-details">
|
||||
name:{{item.name || '无货号'}}. color: {{item.color_id_2 || '无色号'}} . code: {{item.fineCode || '无细码'}}
|
||||
</view>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
</view>
|
||||
<navigator
|
||||
open-type="navigate"
|
||||
url="/pages/deal/saleOrder/kanban/saleOrderKanban"
|
||||
url="/pages/deal/deal"
|
||||
class="confirm-button"
|
||||
>
|
||||
返回
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user