|
@@ -38,7 +38,7 @@
|
|
|
import { clzConfirm, numberToFixed } from '@/libs/tools';
|
|
|
import kkPrinter from '@/components/kk-printer/index.vue';
|
|
|
import productList from './productList.vue'
|
|
|
- import {printTempl} from '@/libs/printTools.js'
|
|
|
+ import {printTempl,printCpclTempl} from '@/libs/printTools.js'
|
|
|
export default {
|
|
|
components: { productList, kkPrinter },
|
|
|
data() {
|
|
@@ -144,11 +144,10 @@
|
|
|
allCheckedCallback(val){
|
|
|
this.allChecked = val
|
|
|
},
|
|
|
- printOnce(opt,tsc,blesdk,data){
|
|
|
+ printOnce(opt,cmd,blesdk,data){
|
|
|
const _this = this
|
|
|
const dealer = this.$store.state.vuex_userData
|
|
|
- // 60*40 打印模板
|
|
|
- const command = printTempl(tsc,{
|
|
|
+ const paramsData = {
|
|
|
dealerName: dealer.orgName,
|
|
|
shelfName: this.basicInfoData.shelfName || '',
|
|
|
productCode: data.productCode || '',
|
|
@@ -158,18 +157,13 @@
|
|
|
printDate: this.$u.timeFormat(this.timestamp, 'yyyy-mm-dd hh:MM'),
|
|
|
printUser: dealer.userNameCN,
|
|
|
barCode: `${data.shelfSn}&${data.productCode}&${data.productSn}&${data.shelfPlaceSn}`
|
|
|
- })
|
|
|
- // 开始批量打印
|
|
|
- blesdk.senBlData(
|
|
|
- opt.deviceId,
|
|
|
- opt.serviceId,
|
|
|
- opt.writeId,
|
|
|
- command.getData(),
|
|
|
- function(){
|
|
|
+ }
|
|
|
+ // 打印成功后函数
|
|
|
+ const onPrintSuccess = function(){
|
|
|
const result =_this.$refs.productList.getAllChecked()
|
|
|
_this.printIndex = _this.printIndex + 1
|
|
|
if(_this.printIndex < result.length){
|
|
|
- _this.printOnce(opt,tsc,blesdk,result[_this.printIndex])
|
|
|
+ _this.printOnce(opt,cmd,blesdk,result[_this.printIndex])
|
|
|
}else{
|
|
|
_this.printIndex = 0
|
|
|
_this.$refs.kkprinter.onPrintSuccess()
|
|
@@ -185,14 +179,39 @@
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ // 开始批量打印
|
|
|
+ // tsc 指令 // 60*40 打印模板
|
|
|
+ console.log(cmd,cmd.type)
|
|
|
+ if(cmd.type&&cmd.type=='tsc'){
|
|
|
+ const command = printTempl(cmd,paramsData)
|
|
|
+ blesdk.senBlData(opt.deviceId, opt.serviceId, opt.writeId, command.getData(), onPrintSuccess, this.onPrintError);
|
|
|
+ }else{
|
|
|
+ const resultData = printCpclTempl(cmd,paramsData)
|
|
|
+ blesdk.sendDataToDevice({
|
|
|
+ deviceId: opt.deviceId,
|
|
|
+ serviceId: opt.serviceId,
|
|
|
+ characteristicId: opt.writeId,
|
|
|
+ value: resultData,
|
|
|
+ lasterSuccess: onPrintSuccess,
|
|
|
+ lasterError: this.onPrintError
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
closeConnect(){
|
|
|
this.isParinting = false
|
|
|
uni.hideLoading()
|
|
|
},
|
|
|
+ onPrintError(){
|
|
|
+ this.$refs.kkprinter.onPrintFail()
|
|
|
+ this.isParinting = false
|
|
|
+ this.show = false
|
|
|
+ uni.showToast({
|
|
|
+ title: '打印失败,请重试!'
|
|
|
+ })
|
|
|
+ },
|
|
|
// 批量打印
|
|
|
- startPrint(opt,tsc,blesdk){
|
|
|
+ startPrint(opt,cmd,blesdk){
|
|
|
const result =this.$refs.productList.getAllChecked()
|
|
|
console.log(result,result.length)
|
|
|
if(result.length){
|
|
@@ -204,7 +223,7 @@
|
|
|
mask: true,
|
|
|
title: '正在打印中,请勿息屏或退出应用!'
|
|
|
})
|
|
|
- this.printOnce(opt,tsc,blesdk,result[this.printIndex])
|
|
|
+ this.printOnce(opt,cmd,blesdk,result[this.printIndex])
|
|
|
}else{
|
|
|
this.toashMsg("请选择产品!")
|
|
|
this.$refs.kkprinter.onPrintFail()
|