|
@@ -21,7 +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'
|
|
|
+ import {printTempl} from '@/libs/printTools.js'
|
|
|
export default {
|
|
|
components: { partList, kkPrinter },
|
|
|
data() {
|
|
@@ -81,51 +81,21 @@
|
|
|
this.allChecked = val
|
|
|
},
|
|
|
printOnce(opt,tsc,blesdk,data){
|
|
|
- if(this.isParinting){
|
|
|
- return
|
|
|
- }
|
|
|
- this.isParinting = true
|
|
|
const _this = this
|
|
|
const dealer = this.$store.state.vuex_userData
|
|
|
- let top = 10 // 距离顶部10点像素
|
|
|
- const left = 8 // 距离左边
|
|
|
- const lightHeight = 24 // 行高3mm,1mm = 8点
|
|
|
- const pageW = 40 // 页签宽度mm
|
|
|
- const pageH = 30 // 页签高度mm
|
|
|
- const maxFontNums = Math.floor((pageW*8-left*2)/lightHeight) // 每行最多字体数
|
|
|
- let rightTop = 0
|
|
|
- let rightLeft = (Math.floor(maxFontNums*0.6)+1)*lightHeight
|
|
|
- // 初始化打印机
|
|
|
- const command = tsc.jpPrinter.createNew()
|
|
|
- command.init()
|
|
|
- command.setSize(pageW, pageH) // 标签纸张宽高,单位mm
|
|
|
- command.setGap(2) // 标签上下间距,单位mm
|
|
|
- command.setCls() // 清除缓冲区数据
|
|
|
- // 经销商文字高度,是否换行
|
|
|
- top = textFormat(command,dealer.orgName,maxFontNums,left,top,lightHeight,"center",1)
|
|
|
- // 数字货架名称文字
|
|
|
- top = top+10
|
|
|
- rightTop = top
|
|
|
- const lwidth = Math.floor(maxFontNums*0.6)
|
|
|
- top = textFormat(command,this.basicInfoData.shelfInfo.shelfName,lwidth,left,top,lightHeight,"left",1)
|
|
|
- // 产品编码
|
|
|
- top = top+10
|
|
|
- top = textFormat(command,data.productCode,lwidth,left,top,lightHeight,"left",1)
|
|
|
- // 产品名称
|
|
|
- top = top+10
|
|
|
- top = textFormat(command,data.product.name,lwidth,left,top,lightHeight,"left",1)
|
|
|
- // 时间,打印人
|
|
|
- top = top+10
|
|
|
- top = textFormat(command,this.$u.timeFormat(this.timestamp, 'yyyy-mm-dd hh:MM')+" "+this.$store.state.vuex_userData.userNameCN,lwidth,left,top,lightHeight,"left",1)
|
|
|
- // 货位号
|
|
|
- textFormat(command,data.shelfPlaceCode,maxFontNums-lwidth,rightLeft,rightTop,lightHeight,"center",1)
|
|
|
- // 二维码
|
|
|
- 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())
|
|
|
+ // 60*40 打印模板
|
|
|
+ const command = printTempl(tsc,{
|
|
|
+ dealerName: dealer.orgName,
|
|
|
+ shelfName: this.basicInfoData.shelfInfo.shelfName || '',
|
|
|
+ productCode: data.productCode || '',
|
|
|
+ productName: data.product.name || '',
|
|
|
+ shelfPlaceCode: data.shelfPlaceCode || '',
|
|
|
+ currentInven: data.printQty,
|
|
|
+ printDate: this.$u.timeFormat(this.timestamp, 'yyyy-mm-dd hh:MM'),
|
|
|
+ printUser: dealer.userNameCN,
|
|
|
+ barCode: `dealerSn=${dealer.orgSn}&shelfSn=${data.shelfSn}&productSn=${data.productSn}&productCode=${data.productCode}&shelfPlaceCode=${data.shelfPlaceCode}&shelfPlaceSn=${data.shelfPlaceSn}`
|
|
|
+ })
|
|
|
+ // 开始批量打印
|
|
|
blesdk.senBlData(
|
|
|
opt.deviceId,
|
|
|
opt.serviceId,
|
|
@@ -143,10 +113,14 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- // 打印
|
|
|
+ // 批量打印
|
|
|
startPrint(opt,tsc,blesdk){
|
|
|
const result =this.$refs.partList.getAllChecked()
|
|
|
if(result.length){
|
|
|
+ if(this.isParinting){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isParinting = true
|
|
|
this.printOnce(opt,tsc,blesdk,result[this.printIndex])
|
|
|
}else{
|
|
|
this.toashMsg("请选择产品!")
|