|
|
|
@ -2457,7 +2457,8 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
showPrice() { |
|
|
|
showPrice() { |
|
|
|
let that = this; |
|
|
|
if (this.khName == '') { |
|
|
|
this.tui.toast('请选择客户!') |
|
|
|
return |
|
|
|
@ -2496,7 +2497,19 @@ |
|
|
|
} else { |
|
|
|
this.tui.toast('请选择发货方式!') |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
let printHeight = 800 |
|
|
|
this.carList.forEach(function(value, key) { |
|
|
|
printHeight += 30 |
|
|
|
value.stockLogList.forEach(function(value1, key1) { |
|
|
|
printHeight += 30 |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.printTotal = printHeight |
|
|
|
that.bufferData = [] |
|
|
|
let strCmd = this.getPrintData() |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
this.$refs.showPopup.open() |
|
|
|
}, |
|
|
|
//点击底部开单按钮 |
|
|
|
@ -2592,235 +2605,110 @@ |
|
|
|
// }); |
|
|
|
// }, |
|
|
|
//打印小票 |
|
|
|
onPrint(opt) { |
|
|
|
let that = this; |
|
|
|
this.goSell('print') |
|
|
|
let strCmd = '' |
|
|
|
that.yNum = 150 |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLSETMAG(2, 2) |
|
|
|
blesdk.addCPCLSETBOLD('bold') |
|
|
|
strCmd += blesdk.addCPCLLocation(2); |
|
|
|
strCmd += blesdk.addCPCLText('0', '30', '24', '0', 0, uni.getStorageSync('shopName')) |
|
|
|
|
|
|
|
strCmd += blesdk.addCPCLSETMAG(1, 1) |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', '100', '24', '0', 0, '客户:' + this.khName.name) |
|
|
|
// strCmd += blesdk.addCPCLText('280', '100', '24', '0', 0, this.sales.id) |
|
|
|
strCmd += blesdk.addCPCLText('0', '130', '24', '0', 0, '销售:' + this.createByName) |
|
|
|
strCmd += blesdk.addCPCLText('280', '130', '24', '0', 0, '日期:' + this.formatDate(new Date(), |
|
|
|
'YYYY-MM-DD')) //+ |
|
|
|
strCmd += blesdk.addCPCLText('0', '150', '24', '0', 0, |
|
|
|
'=========================================================') |
|
|
|
|
|
|
|
this.carList.forEach(function(value, key) { |
|
|
|
if (that.countPrint() < that.printTotal) { |
|
|
|
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '0', 0, value.productName + '(' + |
|
|
|
value.productSn + ')') |
|
|
|
} else { |
|
|
|
that.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, value.productName + |
|
|
|
'(' + |
|
|
|
value.productSn + ')') |
|
|
|
|
|
|
|
} |
|
|
|
value.stockLogList.forEach(function(value1, key1) { |
|
|
|
if (that.countPrint() < that.printTotal) { |
|
|
|
strCmd += blesdk.addCPCLText('0', that.yNum, '24', '0', 0, '□ ' + (that |
|
|
|
.slicePrint( |
|
|
|
key1)) + '*' + value1.productCount) |
|
|
|
strCmd += blesdk.addCPCLText('240', that.yNum, '24', '0', 0, '单价:' + value |
|
|
|
.discountAmount) |
|
|
|
strCmd += blesdk.addCPCLText('400', that.yNum, '24', '0', 0, '总价:' + (value |
|
|
|
.discountAmount * value1.productCount)) |
|
|
|
} else { |
|
|
|
that.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', (that.yNum += 30), '24', '0', 0, '□ ' + (that |
|
|
|
.slicePrint(key1)) + '*' + value1.productCount) |
|
|
|
strCmd += blesdk.addCPCLText('240', that.yNum, '24', '0', 0, '单价:' + value |
|
|
|
.discountAmount) |
|
|
|
strCmd += blesdk.addCPCLText('400', that.yNum, '24', '0', 0, '总价:' + (value |
|
|
|
.discountAmount * value1.productCount)) |
|
|
|
} |
|
|
|
}) |
|
|
|
async onPrint(opt) { |
|
|
|
let that = this; |
|
|
|
await this.goSell('print') |
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
uni.hideLoading(); |
|
|
|
that.$refs.showPopup.close() |
|
|
|
that.bufferData = [] |
|
|
|
that.clearAll1() |
|
|
|
uni.switchTab({ |
|
|
|
url: '/pages/index/index' |
|
|
|
}); |
|
|
|
}) |
|
|
|
if (that.countPrint() < that.printTotal) { |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, |
|
|
|
'===============================================================') |
|
|
|
} else { |
|
|
|
this.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
this.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, |
|
|
|
'===============================================================') |
|
|
|
|
|
|
|
} |
|
|
|
if (that.countPrint() < that.printTotal) { |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '总数量:' + this.totalAmount) |
|
|
|
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '总金额:' + this.shouldPay) |
|
|
|
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '应收:' + this.relPrice) |
|
|
|
} else { |
|
|
|
this.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
this.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', (this.yNum += 30), '24', '0', 0, '总数量:' + this.totalAmount) |
|
|
|
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '总金额:' + this.shouldPay) |
|
|
|
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '应收:' + this.relPrice) |
|
|
|
|
|
|
|
} |
|
|
|
if (that.countPrint() < that.printTotal) { |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '实收:' + this.priceOk) |
|
|
|
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '欠款:' + (this.relPrice - this.priceOk) |
|
|
|
.toFixed(2)) |
|
|
|
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '其他费用:' + (this.otherExpense == '' ? 0 : |
|
|
|
this.otherExpense)) |
|
|
|
} else { |
|
|
|
this.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
this.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', (this.yNum += 30), '24', '0', 0, '实收:' + this.priceOk) |
|
|
|
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '欠款:' + (this.relPrice - this.priceOk) |
|
|
|
.toFixed(2)) |
|
|
|
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '其他费用:' + (this.otherExpense == '' ? 0 : |
|
|
|
this.otherExpense)) |
|
|
|
|
|
|
|
} |
|
|
|
if (Math.ceil(Number(this.remark.length) / 20) * 30 + this.yNum < that.printTotal) { |
|
|
|
if (this.remark.length > 20) { |
|
|
|
let position = 20; |
|
|
|
let part1 = this.remark.substring(0, position); |
|
|
|
let part2 = this.remark.substring(position); |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '备注:' + part1) |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, part2) |
|
|
|
} else { |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '备注:' + this.remark) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
this.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
this.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
if (this.remark.length > 20) { |
|
|
|
let position = 20; |
|
|
|
let part1 = this.remark.substring(0, position); |
|
|
|
let part2 = this.remark.substring(position); |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '备注:' + part1) |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, part2) |
|
|
|
} else { |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '备注:' + this.remark) |
|
|
|
} |
|
|
|
} |
|
|
|
if (that.countPrint() < that.printTotal) { |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, |
|
|
|
'===============================================================') |
|
|
|
} else { |
|
|
|
this.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
this.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, |
|
|
|
'===============================================================') |
|
|
|
|
|
|
|
} |
|
|
|
//店铺地址 |
|
|
|
if (that.countPrint() < that.printTotal) { |
|
|
|
strCmd += blesdk.addCPCLText('0', this.countPrint(), '24', '0', 0, '店铺地址:' + uni.getStorageSync( |
|
|
|
'shopAddress')) |
|
|
|
} else { |
|
|
|
this.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
this.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', (that.yNum += 30), '24', '0', 0, '店铺地址:' + uni.getStorageSync( |
|
|
|
'shopAddress')) |
|
|
|
} |
|
|
|
//店铺电话 |
|
|
|
if (that.countPrint() < that.printTotal) { |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '店铺电话:' + uni.getStorageSync( |
|
|
|
'username')) |
|
|
|
} else { |
|
|
|
that.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', (that.yNum += 30), '24', '0', 0, '店铺电话:' + uni.getStorageSync( |
|
|
|
'username')) |
|
|
|
}, |
|
|
|
getPrintData(){ |
|
|
|
let that = this; |
|
|
|
let strCmd = '' |
|
|
|
that.yNum = 300 |
|
|
|
strCmd = blesdk.CreatCPCLPage(1000, this.printTotal, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLSETMAG(2, 2) |
|
|
|
blesdk.addCPCLSETBOLD('bold') |
|
|
|
strCmd += blesdk.addCPCLLocation(2); |
|
|
|
strCmd += blesdk.addCPCLText('0', '30', '24', '0', 0, '') |
|
|
|
strCmd += blesdk.addCPCLSETMAG(2, 2) |
|
|
|
blesdk.addCPCLSETBOLD('bold') |
|
|
|
strCmd += blesdk.addCPCLLocation(2); |
|
|
|
strCmd += blesdk.addCPCLText('0', '110', '24', '0', 0, uni.getStorageSync('shopName')) |
|
|
|
|
|
|
|
strCmd += blesdk.addCPCLSETMAG(1, 1) |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
blesdk.addCPCLSETBOLD('bold') |
|
|
|
strCmd += blesdk.addCPCLText('0', '190', '24', '0', 0, '客户:' + that.khName.name) |
|
|
|
strCmd += blesdk.addCPCLSETMAG(1, 1) |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLText('0', '240', '24', '0', 0, '销售员:' + that.createByName) |
|
|
|
strCmd += blesdk.addCPCLText('500', '240', '24', '0', 0, '日期:' + that.formatDate(new Date(), |
|
|
|
'YYYY-MM-DD')) //+ |
|
|
|
strCmd += blesdk.addCPCLText('0', '300', '24', '0', 0, |
|
|
|
'=====================================================================================') |
|
|
|
|
|
|
|
that.carList.forEach(function(value, key) { |
|
|
|
strCmd += blesdk.addCPCLText('0', that.yNum += 30, '24', '0', 0, value.productName + '(' + |
|
|
|
value.productSn + ')') |
|
|
|
value.stockLogList.forEach(function(value1, key1) { |
|
|
|
strCmd += blesdk.addCPCLText('0', that.yNum += 30, '24', '0', 0, '□ ' + (that |
|
|
|
.slicePrint(key1))) |
|
|
|
strCmd += blesdk.addCPCLText('220', that.yNum, '24', '0', 0, '数量:'+ value1.productCount) |
|
|
|
strCmd += blesdk.addCPCLText('400', that.yNum, '24', '0', 0, '单价:' + value |
|
|
|
.discountAmount) |
|
|
|
strCmd += blesdk.addCPCLText('650', that.yNum, '24', '0', 0, '总价:' + (value |
|
|
|
.discountAmount * value1.productCount)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, |
|
|
|
'==========================================================================================') |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '总数量:' + that.totalAmount) |
|
|
|
strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '总金额:' + that.shouldPay) |
|
|
|
strCmd += blesdk.addCPCLText('630', that.yNum, '24', '0', 0, '应收:' + that.relPrice) |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '实收:' + that.priceOk) |
|
|
|
strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '欠款:' + (that.relPrice - that.priceOk) |
|
|
|
.toFixed(2)) |
|
|
|
strCmd += blesdk.addCPCLText('630', that.yNum, '24', '0', 0, '其他费用:' + (that.otherExpense == '' ? 0 : |
|
|
|
that.otherExpense)) |
|
|
|
if(that.remark != ''){ |
|
|
|
if (that.remark.length > 20) { |
|
|
|
let position = 20; |
|
|
|
let part1 = that.remark.substring(0, position); |
|
|
|
let part2 = that.remark.substring(position); |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '备注:' + part1) |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, part2) |
|
|
|
} else { |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '备注:' + that.remark) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if(this.qrArr.length != 0){ |
|
|
|
|
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, |
|
|
|
'=========================================================================================') |
|
|
|
//店铺地址 |
|
|
|
|
|
|
|
strCmd += blesdk.addCPCLSETMAG(1, 1) |
|
|
|
strCmd += blesdk.addCPCLText('0', (that.yNum += 30), '24', '0', 0, '店铺地址:' + uni.getStorageSync( |
|
|
|
'shopAddress')) |
|
|
|
|
|
|
|
//店铺电话 |
|
|
|
|
|
|
|
strCmd += blesdk.addCPCLSETMAG(1, 1) |
|
|
|
strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '店铺电话:' + uni.getStorageSync( |
|
|
|
'username')) |
|
|
|
|
|
|
|
if(that.qrArr.length != 0){ |
|
|
|
//店铺微信/微信收款/支付宝收款/收款码收款(店铺,微信,支付,收款) |
|
|
|
for (let i = 0; i < this.qrArr.length; i++) { |
|
|
|
for (let i = 0; i < that.qrArr.length; i++) { |
|
|
|
|
|
|
|
//店铺二维码 |
|
|
|
console.log(that.qrArr[i]) |
|
|
|
console.log(that.yNum) |
|
|
|
console.log(that.countWidth(i,600/that.qrArr.length)) |
|
|
|
if ((that.yNum + 200) < that.printTotal) { |
|
|
|
console.log('11111') |
|
|
|
strCmd += blesdk.addCPCLQRCode(that.countWidth(i,600/that.qrArr.length), (that.yNum + 50), that.qrArr[i].level, '2', 3, that.qrArr[i].path) //二维码 |
|
|
|
strCmd += blesdk.addCPCLText(that.countWidth(i,600/that.qrArr.length), (that.yNum + 180), '24', '0', 0, that.qrArr[i].name) |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
if(this.qrArr.length == (i+1)){ |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.log('2222') |
|
|
|
// that.yNum = 0 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
strCmd = '' |
|
|
|
strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
strCmd += blesdk.addCPCLQRCode(that.countWidth(i,600/that.qrArr.length) , 30, that.qrArr[i].level, '2', 3, that.qrArr[i].path) //二维码 |
|
|
|
strCmd += blesdk.addCPCLText(that.countWidth(i,600/that.qrArr.length), 180, '24', '0', 0, that.qrArr[i].name) |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
} |
|
|
|
console.log('11111') |
|
|
|
strCmd += blesdk.addCPCLQRCode(that.countWidth(i,1000/that.qrArr.length), (that.yNum + 80), that.qrArr[i].level, '2', 4, that.qrArr[i].path) //二维码 |
|
|
|
strCmd += blesdk.addCPCLSETMAG(1, 1) |
|
|
|
strCmd += blesdk.addCPCLText(that.countWidth(i,1000/that.qrArr.length), (that.yNum + 240), '24', '0', 0, that.qrArr[i].name) |
|
|
|
strCmd += blesdk.addCPCLLocation(0); |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
that.bufferData.push(strCmd); |
|
|
|
} |
|
|
|
|
|
|
|
uni.hideLoading(); |
|
|
|
this.$nextTick(() => { |
|
|
|
console.log('bufferData',that.bufferData) |
|
|
|
that.$refs.showPopup.close() |
|
|
|
that.bufferData = [] |
|
|
|
that.clearAll1() |
|
|
|
uni.switchTab({ |
|
|
|
url: '/pages/index/index' |
|
|
|
}); |
|
|
|
}) |
|
|
|
return strCmd; |
|
|
|
}, |
|
|
|
countWidth(num,len){ |
|
|
|
// if(num == 0){ |
|
|
|
@ -2831,11 +2719,11 @@ |
|
|
|
}, |
|
|
|
//计算打印机当前行高度 |
|
|
|
countPrint() { |
|
|
|
if ((this.yNum + 50) >= 1040) { |
|
|
|
return this.yNum += 50 |
|
|
|
} else { |
|
|
|
// if ((this.yNum + 50) >= 1040) { |
|
|
|
// return this.yNum += 50 |
|
|
|
// } else { |
|
|
|
return this.yNum += 30 |
|
|
|
} |
|
|
|
// } |
|
|
|
}, |
|
|
|
//截取 |
|
|
|
slicePrint(val) { |
|
|
|
|