|
@@ -29,6 +29,7 @@
|
|
|
import { shelfDetail } from '@/api/shelf'
|
|
|
import kkPrinter from '@/components/kk-printer/index.vue';
|
|
|
import {textFormat} from '@/libs/printTools.js'
|
|
|
+ import moment from 'moment'
|
|
|
export default {
|
|
|
components:{
|
|
|
kkPrinter
|
|
@@ -38,7 +39,8 @@
|
|
|
infoData: null,
|
|
|
fromPage: '',
|
|
|
printInfo: null,
|
|
|
- printNum: 0
|
|
|
+ printNum: 0,
|
|
|
+ isParinting: false
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
@@ -64,7 +66,7 @@
|
|
|
// 获取打印内容
|
|
|
getPrintContent(){
|
|
|
const _this = this
|
|
|
- const myDate = new Date()
|
|
|
+ const nowDate = moment().format('YYYY-MM-DD HH:mm')
|
|
|
if(_this.fromPage == 'bdtq'){
|
|
|
_this.printInfo = {
|
|
|
dealerName: _this.$store.state.vuex_userData.orgName,
|
|
@@ -73,7 +75,7 @@
|
|
|
productName: _this.infoData.productEntity&&_this.infoData.productEntity.productName || '',
|
|
|
shelfPlaceCode: _this.infoData.shelfPlaceCode || '',
|
|
|
currentInven: _this.printNum,
|
|
|
- printDate: myDate.toLocaleDateString() +' '+myDate.getHours() +':'+myDate.getMinutes() +':'+myDate.getSeconds(),
|
|
|
+ printDate: nowDate,
|
|
|
printUser: _this.$store.state.vuex_userData.username,
|
|
|
barCode: `dealerSn=${_this.$store.state.vuex_userData.orgSn}&shelfSn=${_this.infoData.shelfSn}&productSn=${_this.infoData.productEntity&&_this.infoData.productEntity.productSn}&productCode=${_this.infoData.productEntity&&_this.infoData.productEntity.code}&shelfPlaceCode=${_this.infoData.shelfPlaceCode}&shelfPlaceSn=${_this.infoData.shelfPlaceSn}`
|
|
|
}
|
|
@@ -85,7 +87,7 @@
|
|
|
productName: _this.infoData.productName || '',
|
|
|
shelfPlaceCode: _this.infoData.shelfPlaceCode || '',
|
|
|
currentInven: _this.printNum,
|
|
|
- printDate: myDate.toLocaleDateString() +' '+myDate.getHours() +':'+myDate.getMinutes() +':'+myDate.getSeconds(),
|
|
|
+ printDate: nowDate,
|
|
|
printUser: _this.$store.state.vuex_userData.username,
|
|
|
barCode: `dealerSn=${_this.$store.state.vuex_userData.orgSn}&shelfSn=${_this.infoData.shelfSn}&productSn=${_this.infoData.productSn}&productCode=${_this.infoData.productCode}&shelfPlaceCode=${_this.infoData.shelfPlaceCode}&shelfPlaceSn=${_this.infoData.shelfPlaceSn}`
|
|
|
}
|
|
@@ -104,6 +106,10 @@
|
|
|
this.$refs.kkprinter.onPrintFail()
|
|
|
return
|
|
|
}
|
|
|
+ if(this.isParinting){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.isParinting = true
|
|
|
let top = 10 // 距离顶部10点像素
|
|
|
const left = 8 // 距离左边
|
|
|
const lightHeight = 24 // 行高3mm,1mm = 8点
|
|
@@ -111,7 +117,7 @@
|
|
|
const pageH = 30 // 页签高度mm
|
|
|
const maxFontNums = Math.floor((pageW*8-left*2)/lightHeight) // 每行最多字体数
|
|
|
let rightTop = 0
|
|
|
- let rightLeft = Math.floor(maxFontNums*0.6)*lightHeight
|
|
|
+ let rightLeft = (Math.floor(maxFontNums*0.6)+1)*lightHeight
|
|
|
// 初始化打印机
|
|
|
const command = tsc.jpPrinter.createNew()
|
|
|
command.init()
|
|
@@ -129,8 +135,11 @@
|
|
|
top = top+10
|
|
|
top = textFormat(command,this.printInfo.productCode,lwidth,left,top,lightHeight,"left",1)
|
|
|
// 产品名称
|
|
|
- top = top+5
|
|
|
+ top = top+10
|
|
|
top = textFormat(command,this.printInfo.productName,lwidth,left,top,lightHeight,"left",1)
|
|
|
+ // 打印人打印时间
|
|
|
+ top = top+10
|
|
|
+ top = textFormat(command,this.printInfo.printDate+' '+this.printInfo.printUser,lwidth,left,top,lightHeight,"left",1)
|
|
|
// 货位号
|
|
|
textFormat(command,this.printInfo.shelfPlaceCode,maxFontNums-lwidth,rightLeft,rightTop,lightHeight,"center",1)
|
|
|
// 二维码
|
|
@@ -144,6 +153,7 @@
|
|
|
onPrintSuccess(){
|
|
|
// uni.navigateBack()
|
|
|
this.$refs.kkprinter.onPrintSuccess()
|
|
|
+ this.isParinting = false
|
|
|
}
|
|
|
}
|
|
|
}
|