|
@@ -121,13 +121,12 @@ export const textCpclFormat = function(cpcl,text,maxFontNums,left,top,lightHeigh
|
|
|
let result = ''
|
|
|
for(let i=0;i<rows;i++){
|
|
|
if(align=="center"){
|
|
|
- const ltxt = textArr[i]
|
|
|
- const ltlen = getBytesCount(ltxt)/2
|
|
|
- result += cpcl.addCPCLText(left+((maxNums-ltlen)/2)*rowHeight-2,rowTop,fontName,fontSize,0,ltxt);
|
|
|
+ result += cpcl.addCPCLLocation(2)
|
|
|
}
|
|
|
else{
|
|
|
- result += cpcl.addCPCLText(left,rowTop,fontName,fontSize,0,textArr[i]);
|
|
|
+ result += cpcl.addCPCLLocation(0)
|
|
|
}
|
|
|
+ result += cpcl.addCPCLText(left,rowTop,fontName,fontSize,0,textArr[i]);
|
|
|
rowTop = rowTop+rowHeight+5
|
|
|
}
|
|
|
return {result:result,top:rowTop}
|
|
@@ -135,7 +134,7 @@ export const textCpclFormat = function(cpcl,text,maxFontNums,left,top,lightHeigh
|
|
|
// 60 * 40 尺寸模板 cpcl 指令
|
|
|
export const printCpclTempl = function(cpcl,data){
|
|
|
console.log(cpcl)
|
|
|
- let top = 32 // 距离顶部
|
|
|
+ let top = 24 // 距离顶部
|
|
|
const left = 8 // 距离左边
|
|
|
const lightHeight = 24 // 行高3mm,1mm = 8点
|
|
|
const pageW = 60 // 页签宽度mm
|
|
@@ -143,37 +142,42 @@ export const printCpclTempl = function(cpcl,data){
|
|
|
const maxFontNums = Math.floor((pageW*8-left*4)/lightHeight) // 每行最多字体数
|
|
|
const leftMaxFnums = Math.floor(maxFontNums*0.4)
|
|
|
const rightMaxFnums = leftMaxFnums + 1
|
|
|
- let rightLeft = (leftMaxFnums+2.5)*lightHeight
|
|
|
+ let rightLeft = (leftMaxFnums+2)*lightHeight
|
|
|
// 初始化打印机
|
|
|
let strCmd =cpcl.CreatCPCLPage(pageW*8,pageH*8,data.currentInven,0);
|
|
|
// 经销商文字高度,是否换行
|
|
|
- const a = textCpclFormat(cpcl,data.dealerName,maxFontNums,left,top,lightHeight,"center",'55',0);
|
|
|
+ const a = textCpclFormat(cpcl,data.dealerName,maxFontNums,left,top,lightHeight,"center",'55',1);
|
|
|
top = a.top;
|
|
|
strCmd += a.result;
|
|
|
// 数字货架名称文字
|
|
|
top = top+10;
|
|
|
- const b = textCpclFormat(cpcl,data.shelfName,maxFontNums,left,top,lightHeight,"center",'55',0);
|
|
|
+ const b = textCpclFormat(cpcl,data.shelfName,maxFontNums,left,top,lightHeight,"center",'55',1);
|
|
|
top = b.top;
|
|
|
strCmd += b.result;
|
|
|
// 二维码
|
|
|
top = top+15;
|
|
|
- strCmd += cpcl.addCPCLQRCode(left*6,top,'M', 2, 6, data.barCode);
|
|
|
+ strCmd += cpcl.addCPCLLocation(0);
|
|
|
+ strCmd += cpcl.addCPCLQRCode(left*6,top,'M', 3, 5, data.barCode);
|
|
|
// 货位号
|
|
|
- const c = textCpclFormat(cpcl,data.shelfPlaceCode,rightMaxFnums,rightLeft,top,lightHeight,"left",'7',6);
|
|
|
+ strCmd += cpcl.addCPCLSETMAG(4,4);
|
|
|
+ const c = textCpclFormat(cpcl,data.shelfPlaceCode,rightMaxFnums,rightLeft,top,lightHeight,"left",'7',0);
|
|
|
const rightTop = c.top;
|
|
|
strCmd += c.result;
|
|
|
// 产品编码
|
|
|
- top = rightTop + 1;
|
|
|
- const d = textCpclFormat(cpcl,data.productCode,rightMaxFnums,rightLeft,top,lightHeight,"left",'3',0);
|
|
|
+ top = rightTop + 65;
|
|
|
+ strCmd += cpcl.addCPCLSETMAG(1,1);
|
|
|
+ const d = textCpclFormat(cpcl,data.productCode,rightMaxFnums,rightLeft,top,lightHeight,"left",'7',0);
|
|
|
top = d.top;
|
|
|
strCmd += d.result;
|
|
|
// 打印人打印时间
|
|
|
- top = top+6;
|
|
|
+ top = top+4;
|
|
|
+ strCmd += cpcl.addCPCLSETMAG(1,1);
|
|
|
const e = textCpclFormat(cpcl,data.printDate,rightMaxFnums,rightLeft,top,lightHeight,"left",'7',0);
|
|
|
top = e.top;
|
|
|
strCmd += e.result;
|
|
|
strCmd += cpcl.addCPCLPrint();
|
|
|
console.log(strCmd)
|
|
|
+ console.log(gbk.strToGBKByte(strCmd))
|
|
|
return gbk.strToGBKByte(strCmd);
|
|
|
}
|
|
|
|