更新200mm打印

This commit is contained in:
2026-07-23 14:49:31 +08:00
parent 23aed5f512
commit ed099e0f4f
4 changed files with 55 additions and 31 deletions
+2 -2
View File
@@ -2,8 +2,8 @@
"name" : "危废数据终端",
"appid" : "__UNI__F18DD0A",
"description" : "",
"versionName" : "1.0.8",
"versionCode" : 108,
"versionName" : "1.0.9",
"versionCode" : 109,
"transformPx" : false,
/* 5+App */
"app-plus" : {
+12 -5
View File
@@ -130,11 +130,18 @@ export default {
const sizeCmd = this.commandType === 'CPCL'
? `SIZE ${this.paperWidth}mm ${this.paperHeight}mm`
: `SIZE ${this.paperWidth} mm ${this.paperHeight} mm`
const placeholders = {
'TSPL': `输入TSPL指令,如:\n${sizeCmd}\nGAP 2 mm\nCLS\nTEXT 50 50 "4" 0 1 1 "Hello"\nPRINT`,
'CPCL': `输入CPCL指令,如:\n! 0 200 200 240 1\n${sizeCmd}\nGAP 2mm\nTEXT 4 0 10 10 EN Hello\nPRINT`
// TSPL 分支保持原样
if (this.commandType !== 'CPCL') {
return `输入TSPL指令,如:\n${sizeCmd}\nGAP 2 mm\nCLS\nTEXT 50 50 "4" 0 1 1 "Hello"\nPRINT`
}
return placeholders[this.commandType] || '输入打印指令...'
// CPCL200x200 用大标签配置,其余尺寸用默认小标签配置
const isLargeLabel = this.paperWidth === 200 && this.paperHeight === 200
const cpclHeader = isLargeLabel ? '! 0 200 200 1600 1' : '! 0 200 200 240 1'
const cpclGap = isLargeLabel ? 'GAP-SENSE' : 'GAP 2mm'
return `输入CPCL指令,如:\n${cpclHeader}\n${sizeCmd}\n${cpclGap}\nTEXT 4 0 10 10 EN Hello\nPRINT`
}
},
onLoad() {
@@ -318,7 +325,7 @@ export default {
riqi: new Date().toISOString().split('T')[0],
zhongliang: '10kg',
beizhu: '测试备注',
biaoshi: '',
biaoshi: '',
qrcode: 'https://www.cswm.org.cn/qr/?code=7G6MOYELnFHZfF1Y0F8e6gjxR2K2pALNJJNhJSuOg17LV6IZfuDWUnF2qC3Rsdejs&type=WFBQ'
}
// 确保 service 使用当前的 commandType 和 paperSize
+1 -1
View File
@@ -154,7 +154,7 @@ export default {
'shibiema': this.previewData.szsbm || '', // 数字识别码
'danwei': this.previewData.dwmc || '', // 单位名称
'lianxi': (this.previewData.lxr || '') + ' ' + (this.previewData.lxrsj || ''), // 联系人
'riqi': this.previewData.cssj || '', // 产生时间
'riqi': (this.previewData.cssj || '').split(' ')[0], // 产生时间(仅日期)
'zhongliang': (this.previewData.csl || '') + ' ' + (this.previewData.jldw || ''), // 重量
'beizhu': this.previewData.wxtx || '-', // 备注 危险特征
'biaoshi': '', // 标识
+40 -23
View File
@@ -107,33 +107,33 @@ const PAPER_PRESETS = {
'200x200': {
labelWidth: 200,
labelHeight: 1600,
fontSize: 48,
lineHeight: 80,
cpcl: {
pageWidth: 1600, // PAGE-WIDTH200mm @200dpi = 1600 点),防止右半边被截断
gapSense: true, // 使用 GAP-SENSE 自动感应间隙(大标签更稳)
fields: [
{ x: 384, y: 200 }, // 名称
{ x: 384, y: 300 }, // 类别
{ x: 384, y: 400 }, // 代码
{ x: 960, y: 400 }, // 形态
{ x: 384, y: 500 }, // 主要成分
{ x: 384, y: 700 }, // 有害成分
{ x: 384, y: 896 }, // 注意
{ x: 432, y: 1072 }, // 识别码
{ x: 512, y: 1168 }, // 单位
{ x: 576, y: 1264 }, // 联系
{ x: 384, y: 1360 }, // 日期
{ x: 960, y: 1360 }, // 重量
{ x: 300, y: 1456 }, // 备注
{ x: 960, y: 700 } // 标识
{ x: 344, y: 256, mag: [2, 2], bold: 0.0, font: 1 }, // 名称
{ x: 344, y: 360, mag: [2, 2], bold: 0.0, font: 1 }, // 类别
{ x: 344, y: 448, mag: [2, 2], bold: 0.5, font: 0 }, // 代码(加粗)
{ x: 912, y: 448, mag: [2, 2], bold: 0.0, font: 1 }, // 形态
{ x: 344, y: 544, mag: [2, 2], bold: 0.5, font: 0 }, // 主要成分(加粗)
{ x: 344, y: 744, mag: [2, 2], bold: 0.5, font: 0 }, // 有害成分(A401 无,按左列节奏补)
{ x: 344, y: 936, mag: [2, 2], bold: 0.0, font: 1 }, // 注意
{ x: 392, y: 1128, mag: [2, 2], bold: 0.0, font: 1 }, // 识别码
{ x: 480, y: 1224, mag: [2, 2], bold: 0.0, font: 1 }, // 单位(A401 无,按左列节奏补)
{ x: 552, y: 1328, mag: [2, 2], bold: 0.0, font: 1 }, // 联系
{ x: 352, y: 1432, mag: [2, 2], bold: 0.5, font: 0 }, // 日期(加粗)
{ x: 912, y: 1432, mag: [2, 2], bold: 0.0, font: 1 }, // 重量
{ x: 240, y: 1528, mag: [2, 2], bold: 0.0, font: 1 }, // 备注
{ x: 1432, y: 544, mag: [4, 4], bold: 0.0, font: 1 } // 标识(√ 勾选,4 倍放大)
],
qrCode: { x: 1248, y: 1168, size: 4 }
qrCode: { x: 1220, y: 1224, size: 8, prefix: 'BARCODE QR' }
},
tspl: {
startX: 40,
startX: 56,
startY: 40,
lineHeight: 50,
fontSize: '4',
qrCode: { x: 300, y: 800, size: 5 }
qrCode: { x: 328, y: 776, size: 5 }
}
}
};
@@ -651,16 +651,33 @@ class BluetoothPrinterService {
commands.push(`! 0 200 200 ${labelHeight} 1`);
commands.push(sizeCmd);
// 200x200 等需要显式声明页宽(避免右半部分被截断);其余预设不输出
if (layout && layout.pageWidth) {
commands.push(`PAGE-WIDTH ${layout.pageWidth}`);
}
// 大标签用 GAP-SENSE 自动感应间隙;其余预设保持原有 GAP 2mm
if (layout && layout.gapSense) {
commands.push('GAP-SENSE');
} else {
commands.push(gapCmd);
}
fieldOrder.forEach((field, index) => {
if (data[field]) {
const { x, y } = conf[index];
commands.push(`T 1 0 ${x} ${y} ${data[field]}`);
const f = conf[index] || {};
const mag = f.mag || [1, 1]; // 默认 1 倍(兼容 100x100
const bold = (f.bold != null) ? f.bold : 0.0;
const font = f.font || 1;
commands.push(`SETMAG ${mag[0]} ${mag[1]}`);
commands.push(`SETBOLD ${bold}`);
commands.push(`T ${font} 0 ${f.x} ${f.y} ${data[field]}`);
}
});
if (data.qrcode) {
const qrc = (layout && layout.qrCode) || { x: 624, y: 584, size: 4 };
commands.push(`B QR ${qrc.x} ${qrc.y} M 2 U ${qrc.size}`);
const qrc = (layout && layout.qrCode) || { x: 624, y: 584, size: 4, prefix: 'B QR' };
const qrPrefix = qrc.prefix || 'B QR';
commands.push(`${qrPrefix} ${qrc.x} ${qrc.y} M 2 U ${qrc.size}`);
commands.push(`L0,${data.qrcode}\r\n`);
commands.push('ENDQR');
}