|
@@ -51,12 +51,12 @@ export const textFormat = function(command,text,maxFontNums,left,top,lightHeight
|
|
|
if(align=="center"){
|
|
|
const ltxt = textArr[i]
|
|
|
const ltlen = getBytesCount(ltxt)/2*fontSize
|
|
|
- command.setText(left+((maxNums-ltlen)/2)*rowHeight, rowTop, "TSS24.BF2", fontSize, fontSize, ltxt)
|
|
|
+ command.setText(left+((maxNums-ltlen)/2)*rowHeight-2, rowTop, "TSS24.BF2", fontSize, fontSize, ltxt)
|
|
|
}
|
|
|
else{
|
|
|
command.setText(left, rowTop, "TSS24.BF2", fontSize, fontSize, textArr[i])
|
|
|
}
|
|
|
- rowTop = rowTop+rowHeight*fontSize+10
|
|
|
+ rowTop = rowTop+rowHeight*fontSize+5
|
|
|
}
|
|
|
return rowTop
|
|
|
}
|
|
@@ -72,15 +72,15 @@ export const printText = function(tsc,text){
|
|
|
}
|
|
|
// 60 * 40 尺寸模板
|
|
|
export const printTempl = function(tsc,data){
|
|
|
- let top = 24 // 距离顶部10点像素
|
|
|
+ let top = 48 // 距离顶部
|
|
|
const left = 8 // 距离左边
|
|
|
const lightHeight = 24 // 行高3mm,1mm = 8点
|
|
|
const pageW = 60 // 页签宽度mm
|
|
|
const pageH = 40 // 页签高度mm
|
|
|
const maxFontNums = Math.floor((pageW*8-left*2)/lightHeight) // 每行最多字体数
|
|
|
- const leftMaxFnums = Math.floor(maxFontNums*0.6)
|
|
|
- let rightTop = 0
|
|
|
- let rightLeft = (leftMaxFnums+1.2)*lightHeight
|
|
|
+ const leftMaxFnums = Math.floor(maxFontNums*0.4)
|
|
|
+ const rightMaxFnums = maxFontNums*0.5
|
|
|
+ let rightLeft = (leftMaxFnums+1.5)*lightHeight
|
|
|
// 初始化打印机
|
|
|
const command = tsc.jpPrinter.createNew()
|
|
|
command.init()
|
|
@@ -90,22 +90,48 @@ export const printTempl = function(tsc,data){
|
|
|
// 经销商文字高度,是否换行
|
|
|
top = textFormat(command,data.dealerName,maxFontNums,left,top,lightHeight,"center",1)
|
|
|
// 数字货架名称文字
|
|
|
- top = top+10
|
|
|
- rightTop = top
|
|
|
- // top = textFormat(command,data.shelfName,leftMaxFnums,left,top,lightHeight,"left",1)
|
|
|
- // 产品编码 + 产品名称
|
|
|
- // top = top+10
|
|
|
- top = textFormat(command,data.shelfName +'/'+ data.productCode + '/' + data.productName,leftMaxFnums,left,top,lightHeight,"left",1)
|
|
|
- // 产品名称
|
|
|
- // top = top+6
|
|
|
- // top = textFormat(command,data.productName,leftMaxFnums,left,top,lightHeight,"left",1)
|
|
|
- // 打印人打印时间
|
|
|
- top = top+10
|
|
|
- top = textFormat(command,data.printDate+' '+data.printUser,leftMaxFnums,left,top,lightHeight,"left",1)
|
|
|
+ top = top+30
|
|
|
+ // 二维码
|
|
|
+ command.setQR(left*3, top, "M", 5, "A", data.barCode)
|
|
|
// 货位号
|
|
|
- const qrtop = textFormat(command,data.shelfPlaceCode,maxFontNums-leftMaxFnums-1.2,rightLeft,rightTop,lightHeight,"center",2)
|
|
|
+ const rightTop = textFormat(command,data.shelfPlaceCode,rightMaxFnums,rightLeft,top,lightHeight,"left",4)
|
|
|
+ // 产品编码
|
|
|
+ top = rightTop
|
|
|
+ top = textFormat(command,data.productCode,rightMaxFnums,rightLeft,top,lightHeight,"left",1)
|
|
|
+ // 打印分数1,每个标签重发打印2次
|
|
|
+ command.setPagePrint(1,data.currentInven)
|
|
|
+ return command
|
|
|
+}
|
|
|
+
|
|
|
+// 40 * 30 尺寸模板
|
|
|
+export const printMiniTempl = function(tsc,data){
|
|
|
+ let top = 24 // 距离顶部
|
|
|
+ const left = 4 // 距离左边
|
|
|
+ const lightHeight = 24 // 行高3mm,1mm = 8点
|
|
|
+ const pageW = 40 // 页签宽度mm
|
|
|
+ const pageH = 30 // 页签高度mm
|
|
|
+ const maxFontNums = Math.floor((pageW*8-left*2)/lightHeight) // 每行最多字体数
|
|
|
+ const leftMaxFnums = Math.floor(maxFontNums*0.5)
|
|
|
+ const rightMaxFnums = Math.floor(maxFontNums*0.4)
|
|
|
+ let rightLeft = (leftMaxFnums+1)*lightHeight
|
|
|
+ // 初始化打印机
|
|
|
+ const command = tsc.jpPrinter.createNew()
|
|
|
+ command.init()
|
|
|
+ command.setSize(pageW, pageH) // 标签纸张宽高,单位mm
|
|
|
+ command.setGap(3) // 标签上下间距,单位mm
|
|
|
+ command.setCls() // 清除缓冲区数据
|
|
|
+ // 经销商文字高度,是否换行
|
|
|
+ top = textFormat(command,data.dealerName,maxFontNums,left,top,lightHeight,"center",1)
|
|
|
+ // 数字货架名称文字
|
|
|
+ top = top+10
|
|
|
// 二维码
|
|
|
- command.setQR(rightLeft, qrtop, "M", 5, "A", data.barCode)
|
|
|
- command.setPagePrint(1,data.currentInven) // 打印分数1,每个标签重发打印2次
|
|
|
+ command.setQR(left, top, "M", 5, "A", data.barCode)
|
|
|
+ // 货位号
|
|
|
+ const rightTop = textFormat(command,data.shelfPlaceCode,rightMaxFnums,rightLeft,top,lightHeight,"left",3)
|
|
|
+ // 产品编码
|
|
|
+ top = rightTop
|
|
|
+ top = textFormat(command,data.productCode,rightMaxFnums,rightLeft,top,lightHeight,"left",1)
|
|
|
+ // 打印分数1,每个标签重发打印2次
|
|
|
+ command.setPagePrint(1,data.currentInven)
|
|
|
return command
|
|
|
}
|