Browse Source

正式版,没有问题的最后一版提交

master
wangfukang 2 years ago
parent
commit
cfa6bd8e20
  1. BIN
      pages/.DS_Store
  2. 346
      pages/inventory/goodsList1.vue
  3. 2
      pages/inventory/inventoryDetail.vue

BIN
pages/.DS_Store

Binary file not shown.

346
pages/inventory/goodsList1.vue

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

2
pages/inventory/inventoryDetail.vue

@ -157,7 +157,7 @@
@confirm="changePrice"></uni-popup-dialog> @confirm="changePrice"></uni-popup-dialog>
</uni-popup> </uni-popup>
<view v-if="isPrint" class="bottom-btn"> <view v-if="isPrint" class="bottom-btn">
<kk-printer ref="kkprinter" :bufferData="bufferData" @onPrint="onPrint1" :printNum="printNum" :defaultText="'打印'"></kk-printer> <kk-printer ref="kkprinter" :bufferData="bufferData" @onPrint="onPrint" :printNum="printNum" :defaultText="'打印'"></kk-printer>
</view> </view>
<!-- 右下角悬浮按钮 --> <!-- 右下角悬浮按钮 -->
<uni-fab v-if="!isPrint" ref="fab" :content="content" :horizontal="horizontal" <uni-fab v-if="!isPrint" ref="fab" :content="content" :horizontal="horizontal"

Loading…
Cancel
Save