|
@@ -21,6 +21,7 @@
|
|
|
import kkPrinter from '@/components/kk-printer/index.vue';
|
|
|
import { shelfReplenishDetail, shelfReplenishDetailList, shelfReplenishPrintSign } from '@/api/shelfReplenish'
|
|
|
import partList from '@/pages/common/partList.vue'
|
|
|
+ import {textFormat} from '@/libs/printTools.js'
|
|
|
export default {
|
|
|
components: { partList, kkPrinter },
|
|
|
data() {
|
|
@@ -79,35 +80,12 @@
|
|
|
allCheckedCallback(val){
|
|
|
this.allChecked = val
|
|
|
},
|
|
|
- textFormat(command,text,maxFontNums,left,top,lightHeight){
|
|
|
- const textLen = text.length
|
|
|
- console.log(textLen,maxFontNums)
|
|
|
- if(textLen > maxFontNums){
|
|
|
- const rows = Math.ceil(textLen/maxFontNums)
|
|
|
- console.log(rows)
|
|
|
- for(let i=0;i<rows;i++){
|
|
|
- top = top+i*lightHeight
|
|
|
- console.log(top)
|
|
|
- // 最后一行
|
|
|
- if(i==rows-1){
|
|
|
- const ltxt = text.substring(i*maxFontNums)
|
|
|
- const ltlen = ltxt.length
|
|
|
- command.setText(left+((maxFontNums-ltlen)/2)*lightHeight, top, "TSS24.BF2", 1, 1, ltxt)
|
|
|
- }else{
|
|
|
- command.setText(left, top, "TSS24.BF2", 1, 1, text.substring(i*maxFontNums,maxFontNums))
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- command.setText(left+((maxFontNums-textLen)/2)*lightHeight, top, "TSS24.BF2", 1, 1, text)
|
|
|
- }
|
|
|
- return top
|
|
|
- },
|
|
|
printOnce(opt,tsc,blesdk,data){
|
|
|
const _this = this
|
|
|
const dealer = this.$store.state.vuex_userData
|
|
|
console.log(opt,data,'opt')
|
|
|
let top = 10 // 距离顶部10点像素
|
|
|
- const left = 10 // 距离左边10点
|
|
|
+ const left = 32 // 距离左边
|
|
|
const lightHeight = 24 // 行高3mm,1mm = 8点
|
|
|
const pageW = 40 // 页签宽度mm
|
|
|
const pageH = 30 // 页签高度mm
|
|
@@ -121,28 +99,30 @@
|
|
|
command.setGap(2) // 标签上下间距,单位mm
|
|
|
command.setCls() // 清除缓冲区数据
|
|
|
// 经销商文字高度,是否换行
|
|
|
- top = this.textFormat(command,dealer.orgName,maxFontNums,left,top,lightHeight)
|
|
|
+ top = textFormat(command,dealer.orgName,maxFontNums,left,top,lightHeight,"center",1)
|
|
|
// 数字货架名称文字
|
|
|
- top = top+lightHeight+15
|
|
|
- top = this.textFormat(command,this.basicInfoData.shelfInfo.shelfName,Math.floor(maxFontNums*0.6),left,top,lightHeight)
|
|
|
+ top = top+10
|
|
|
rightTop = top
|
|
|
+ const lwidth = Math.floor(maxFontNums*0.6)
|
|
|
+ rightLeft = (lwidth + 1.5) * lightHeight
|
|
|
+ top = textFormat(command,this.basicInfoData.shelfInfo.shelfName,lwidth,left,top,lightHeight,"left",1)
|
|
|
// 产品编码
|
|
|
- top = top+lightHeight+15
|
|
|
- command.setText(left, top, "TSS24.BF2", 1, 1, data.productCode)
|
|
|
+ top = top+10
|
|
|
+ top = textFormat(command,data.productCode,lwidth,left,top,lightHeight,"left",1)
|
|
|
// 产品名称
|
|
|
- top = top+lightHeight+5
|
|
|
- top = this.textFormat(command,data.product.name,Math.floor(maxFontNums*0.6),left,top,lightHeight)
|
|
|
+ top = top+5
|
|
|
+ top = textFormat(command,data.product.name,lwidth,left,top,lightHeight,"left",1)
|
|
|
// 时间
|
|
|
- top = top+lightHeight+15
|
|
|
- command.setText(left, top, "TSS24.BF2", 1, 1, this.$u.timeFormat(this.timestamp, 'yyyy-mm-dd hh:MM'))
|
|
|
+ top = top+10
|
|
|
+ top = textFormat(command,this.$u.timeFormat(this.timestamp, 'yyyy-mm-dd hh:MM'),lwidth,left,top,lightHeight,"left",1)
|
|
|
// 货位号
|
|
|
- command.setText(rightLeft, rightTop, "TSS24.BF2", 1, 1, data.shelfPlaceCode)
|
|
|
+ textFormat(command,data.shelfPlaceCode,maxFontNums-lwidth,rightLeft,rightTop,lightHeight,"center",1)
|
|
|
// 二维码
|
|
|
- const qrtop = rightTop +lightHeight+15
|
|
|
+ const qrtop = rightTop +lightHeight+10
|
|
|
const qrcont = `dealerSn=${dealer.orgSn}&shelfSn=${data.shelfSn}&productCode=${data.productCode}&shelfPlaceCode=${data.shelfPlaceCode}&shelfPlaceSn=${data.shelfPlaceSn}`
|
|
|
command.setQR(rightLeft, qrtop, "L", 3, "A", qrcont)
|
|
|
command.setPagePrint(1,data.printQty) // 打印分数1,每个标签重发打印2次
|
|
|
- // -----------
|
|
|
+
|
|
|
console.log("开始打印了",command.getData())
|
|
|
blesdk.senBlData(
|
|
|
opt.deviceId,
|