|
@@ -112,21 +112,22 @@ export const printTempl = function(tsc,data){
|
|
|
}
|
|
|
|
|
|
// 格式化cpcl打印文本
|
|
|
-export const textCpclFormat = function(cpcl,text,maxFontNums,left,top,lightHeight,align,fontName,fontSize){
|
|
|
+export const textCpclFormat = function(cpcl,text,maxFontNums,left,top,lightHeight,align,fontName,fontSize,ellipsis=false){
|
|
|
let rowTop = top
|
|
|
- const maxNums = maxFontNums
|
|
|
+ const maxNums = maxFontNums*1.8
|
|
|
const rowHeight = lightHeight
|
|
|
- const textArr = getTextRows(text.replace(/\s+/g, ' '),maxNums*2)
|
|
|
- const rows = textArr.length
|
|
|
+ const textArr = getTextRows(text.replace(/\s+/g, ' '),maxNums)
|
|
|
+ const len = ellipsis ? 1 : textArr.length
|
|
|
let result = ''
|
|
|
- for(let i=0;i<rows;i++){
|
|
|
+ for(let i=0;i<len;i++){
|
|
|
+ const texts = !ellipsis||(textArr.length==1) ? textArr[i] : (textArr[i].substr(0,maxFontNums-3)+'...')
|
|
|
if(align=="center"){
|
|
|
result += cpcl.addCPCLLocation(2)
|
|
|
}
|
|
|
else{
|
|
|
result += cpcl.addCPCLLocation(0)
|
|
|
}
|
|
|
- result += cpcl.addCPCLText(left,rowTop,fontName,fontSize,0,textArr[i]);
|
|
|
+ result += cpcl.addCPCLText(left,rowTop,fontName,fontSize,0,texts);
|
|
|
rowTop = rowTop+rowHeight+5
|
|
|
}
|
|
|
return {result:result,top:rowTop}
|
|
@@ -139,19 +140,19 @@ export const printCpclTempl = function(cpcl,data){
|
|
|
const lightHeight = 24 // 行高3mm,1mm = 8点
|
|
|
const pageW = 60 // 页签宽度mm
|
|
|
const pageH = 40 // 页签高度mm
|
|
|
- const maxFontNums = Math.floor((pageW*8-left*4)/lightHeight) // 每行最多字体数
|
|
|
+ const maxFontNums = Math.floor((pageW*8-left*2)/lightHeight) // 每行最多字体数
|
|
|
const leftMaxFnums = Math.floor(maxFontNums*0.4)
|
|
|
const rightMaxFnums = leftMaxFnums + 2
|
|
|
let rightLeft = (leftMaxFnums+2)*lightHeight
|
|
|
// 初始化打印机
|
|
|
- let strCmd =cpcl.CreatCPCLPage(pageW*8,pageH*8,data.currentInven,0);
|
|
|
+ let strCmd =cpcl.CreatCPCLPage(pageW*8,pageH*8,data.currentInven,0,0);
|
|
|
// 经销商文字高度,是否换行
|
|
|
const a = textCpclFormat(cpcl,data.dealerName,maxFontNums,0,top,lightHeight,"center",'24',0);
|
|
|
top = a.top;
|
|
|
strCmd += a.result;
|
|
|
// 数字货架名称文字
|
|
|
top = top+10;
|
|
|
- const b = textCpclFormat(cpcl,data.shelfName,maxFontNums,0,top,lightHeight,"center",'24',0);
|
|
|
+ const b = textCpclFormat(cpcl,data.shelfName,maxFontNums,0,top,lightHeight,"center",'24',0,true);
|
|
|
top = b.top;
|
|
|
strCmd += b.result;
|
|
|
// 二维码
|