|
|
|
@ -296,13 +296,32 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<!-- 打印弹出 --> |
|
|
|
<uni-popup ref="printerPopup" background-color="#fff"> |
|
|
|
<view style="width: 500rpx;height: 300rpx;font-size: 36rpx;"> |
|
|
|
<view style="height: 80rpx;text-align: center;line-height: 80rpx;font-weight: bold;"> |
|
|
|
提示 |
|
|
|
</view> |
|
|
|
<view style="text-align: center;line-height: 50px;height: 100rpx;"> |
|
|
|
需要打印销售小票吗? |
|
|
|
</view> |
|
|
|
<view style="display: flex;height: 100rpx;margin-top: 20rpx;border-top: 1px solid #eee;position: relative;"> |
|
|
|
<view @tap='printChenel' style="width:250rpx;line-height: 100rpx;text-align: center;border-right: 1px solid #eee;"> |
|
|
|
暂不需要 |
|
|
|
</view> |
|
|
|
<kk-printer ref="kkprinter" :bufferData="bufferData" @onPrint="onPrint" style="width: 250rpx;height: 100rpx;line-height: 50px;color: #000;background:#088FEB;position: absolute;bottom: 0;text-align: center;right: 0;"></kk-printer> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
import util from '@/components/kk-printer/utils/util.js'; |
|
|
|
import * as blesdk from '@/components/kk-printer/utils/bluetoolth.js'; |
|
|
|
import kkPrinter from '@/components/kk-printer/index.vue'; |
|
|
|
export default { |
|
|
|
components: {}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
lsprice:0,//临时零售价 |
|
|
|
@ -318,6 +337,7 @@ |
|
|
|
keyList: [], |
|
|
|
temporaryList: [], |
|
|
|
zNum: 0, |
|
|
|
bufferData: '', |
|
|
|
zPrice:0, |
|
|
|
priceOk:'', //已收金额 |
|
|
|
value: 0, |
|
|
|
@ -389,8 +409,13 @@ |
|
|
|
pbAddress:'', |
|
|
|
carList1:[], |
|
|
|
radioType1:0, |
|
|
|
saleId:'' |
|
|
|
saleId:'', |
|
|
|
saleDetailList:[], |
|
|
|
yNum:150 |
|
|
|
} |
|
|
|
}, |
|
|
|
components: { |
|
|
|
kkPrinter |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
let that = this; |
|
|
|
@ -893,112 +918,194 @@ |
|
|
|
}) |
|
|
|
}, |
|
|
|
//点击底部开单按钮 |
|
|
|
goSell() { |
|
|
|
goSell() { |
|
|
|
console.log(this.carList) |
|
|
|
this.$refs.printerPopup.open('center') |
|
|
|
// console.log(this.khName) |
|
|
|
// console.log(this.lbgName) |
|
|
|
// console.log(this.wlName) |
|
|
|
if(this.khName == ''){ |
|
|
|
this.tui.toast('请选择客户!') |
|
|
|
return |
|
|
|
} |
|
|
|
if(this.xsyId ==''){ |
|
|
|
this.tui.toast('请选择销售员!') |
|
|
|
return |
|
|
|
} |
|
|
|
if(this.relPrice == (0 || '')){ |
|
|
|
this.tui.toast('请输入实收金额!') |
|
|
|
return |
|
|
|
}else if(this.priceOk==(0 || '')){ |
|
|
|
this.tui.toast('请输入已收金额!') |
|
|
|
return |
|
|
|
} |
|
|
|
if(this.carList.size == 0){ |
|
|
|
this.tui.toast('请添加商品!') |
|
|
|
return |
|
|
|
} |
|
|
|
if(this.radioType != ''){ |
|
|
|
if(this.radioType == 0 || this.radioType == 1 || this.radioType== 4){ |
|
|
|
if(this.wlName == ''){ |
|
|
|
this.tui.toast('请选择配送公司!') |
|
|
|
return |
|
|
|
} |
|
|
|
if(this.radioType1 == 0){ |
|
|
|
if(this.lbgName == ''){ |
|
|
|
this.tui.toast('请选择配送人员!') |
|
|
|
return |
|
|
|
} |
|
|
|
// if(this.khName == ''){ |
|
|
|
// this.tui.toast('请选择客户!') |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if(this.xsyId ==''){ |
|
|
|
// this.tui.toast('请选择销售员!') |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if(this.relPrice == (0 || '')){ |
|
|
|
// this.tui.toast('请输入实收金额!') |
|
|
|
// return |
|
|
|
// }else if(this.priceOk==(0 || '')){ |
|
|
|
// this.tui.toast('请输入已收金额!') |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if(this.carList.size == 0){ |
|
|
|
// this.tui.toast('请添加商品!') |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if(this.radioType != ''){ |
|
|
|
// if(this.radioType == 0 || this.radioType == 1 || this.radioType== 4){ |
|
|
|
// if(this.wlName == ''){ |
|
|
|
// this.tui.toast('请选择配送公司!') |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if(this.radioType1 == 0){ |
|
|
|
// if(this.lbgName == ''){ |
|
|
|
// this.tui.toast('请选择配送人员!') |
|
|
|
// return |
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
}else if(this.radioType== 3){ |
|
|
|
if(this.pbAddress == ''){ |
|
|
|
this.tui.toast('请输入拼包地址!') |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
this.tui.toast('请选择发货方式!') |
|
|
|
return |
|
|
|
} |
|
|
|
let obj = { |
|
|
|
orderByWorker: this.lbgName.workerId, |
|
|
|
saleId:this.saleId, |
|
|
|
sale: { |
|
|
|
// relPrice:, |
|
|
|
alreadyEarn: this.priceOk, //已付金额 |
|
|
|
realAmount: this.relPrice, //实收金额 |
|
|
|
noEarn: this.relPrice - this.priceOk, //欠款 |
|
|
|
totalAmount: this.shouldPay, //总金额 |
|
|
|
area: this.khName.area, |
|
|
|
city: this.khName.city, |
|
|
|
province: this.khName.province, |
|
|
|
payStatus: 1, |
|
|
|
receiveAddress: this.khName.address, |
|
|
|
userId:this.khName.userId, |
|
|
|
userName:this.khName.name, |
|
|
|
transportType: this.radioType1 == 1?2:this.radioType, //this.radioType |
|
|
|
discount: this.discountNum, |
|
|
|
createBy: this.xsyId, |
|
|
|
createByName:this.createByName, |
|
|
|
remark: this.remark, |
|
|
|
otherExpense:this.otherExpense ==''?0:this.otherExpense, //其他费用 |
|
|
|
shareAddress:this.pbAddress, |
|
|
|
transCompany: this.wlName.id, |
|
|
|
companyName:this.wlName.companyName, |
|
|
|
}, |
|
|
|
saleDetailList: [] |
|
|
|
} |
|
|
|
let purchaseDetails = []; |
|
|
|
this.carList.forEach(function(value, key) { |
|
|
|
console.log(value.stockLogList) |
|
|
|
value.stockLogList.forEach(function(values, keys) { |
|
|
|
let obj = { |
|
|
|
productCount: values, |
|
|
|
attributeList: keys |
|
|
|
} |
|
|
|
value.stockLogList1.push(obj) |
|
|
|
}) |
|
|
|
console.log(value) |
|
|
|
purchaseDetails.push(value) |
|
|
|
}) |
|
|
|
obj.saleDetailList = purchaseDetails; |
|
|
|
this.tui.request("/app/sale/buyNew", "post", obj, false, false).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: res.message, |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
setTimeout(res => { |
|
|
|
uni.redirectTo({ |
|
|
|
url: "/pages/index/order" |
|
|
|
}) |
|
|
|
}, 500) |
|
|
|
// } |
|
|
|
// }else if(this.radioType== 3){ |
|
|
|
// if(this.pbAddress == ''){ |
|
|
|
// this.tui.toast('请输入拼包地址!') |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }else{ |
|
|
|
// this.tui.toast('请选择发货方式!') |
|
|
|
// return |
|
|
|
// } |
|
|
|
// let obj = { |
|
|
|
// orderByWorker: this.lbgName.workerId, |
|
|
|
// saleId:this.saleId, |
|
|
|
// sale: { |
|
|
|
// // relPrice:, |
|
|
|
// alreadyEarn: this.priceOk, //已付金额 |
|
|
|
// realAmount: this.relPrice, //实收金额 |
|
|
|
// noEarn: this.relPrice - this.priceOk, //欠款 |
|
|
|
// totalAmount: this.shouldPay, //总金额 |
|
|
|
// area: this.khName.area, |
|
|
|
// city: this.khName.city, |
|
|
|
// province: this.khName.province, |
|
|
|
// payStatus: 1, |
|
|
|
// receiveAddress: this.khName.address, |
|
|
|
// userId:this.khName.userId, |
|
|
|
// userName:this.khName.name, |
|
|
|
// transportType: this.radioType1 == 1?2:this.radioType, //this.radioType |
|
|
|
// discount: this.discountNum, |
|
|
|
// createBy: this.xsyId, |
|
|
|
// createByName:this.createByName, |
|
|
|
// remark: this.remark, |
|
|
|
// otherExpense:this.otherExpense ==''?0:this.otherExpense, //其他费用 |
|
|
|
// shareAddress:this.pbAddress, |
|
|
|
// transCompany: this.wlName.id, |
|
|
|
// companyName:this.wlName.companyName, |
|
|
|
// }, |
|
|
|
// saleDetailList: [] |
|
|
|
// } |
|
|
|
// let purchaseDetails = []; |
|
|
|
// this.carList.forEach(function(value, key) { |
|
|
|
// console.log(value.stockLogList) |
|
|
|
// value.stockLogList.forEach(function(values, keys) { |
|
|
|
// let obj = { |
|
|
|
// productCount: values, |
|
|
|
// attributeList: keys |
|
|
|
// } |
|
|
|
// value.stockLogList1.push(obj) |
|
|
|
// }) |
|
|
|
// console.log(value) |
|
|
|
// purchaseDetails.push(value) |
|
|
|
// }) |
|
|
|
//this.saleDetailList = purchaseDetails; |
|
|
|
// obj.saleDetailList = purchaseDetails; |
|
|
|
// this.tui.request("/app/sale/buyNew", "post", obj, false, false).then((res) => { |
|
|
|
// if (res.code == 200) { |
|
|
|
// uni.showToast({ |
|
|
|
// title: "开单成功", |
|
|
|
// icon: 'none' |
|
|
|
// }) |
|
|
|
// setTimeout(res => { |
|
|
|
// this.$refs.printerPopup.open('center') |
|
|
|
// }, 1000) |
|
|
|
|
|
|
|
}else{ |
|
|
|
this.tui.toast(res.message) |
|
|
|
} |
|
|
|
}) |
|
|
|
// }else{ |
|
|
|
// this.tui.toast(res.message) |
|
|
|
// } |
|
|
|
// }) |
|
|
|
|
|
|
|
}, |
|
|
|
//打印取消按钮 |
|
|
|
printChenel(){ |
|
|
|
uni.redirectTo({ |
|
|
|
url: "/pages/index/order" |
|
|
|
}) |
|
|
|
}, |
|
|
|
//打印小票 |
|
|
|
onPrint(opt) { |
|
|
|
let that = this; |
|
|
|
//快递单600*1040 入库单440*320 8像素=1mm |
|
|
|
/** |
|
|
|
* 打印文字 |
|
|
|
* x: 文字方块左上角X座标,单位dot |
|
|
|
* y: 文字方块左上角Y座标,单位dot |
|
|
|
* fontName,fontSize: 字体,取值: 參考文檔 |
|
|
|
* rotation: 旋转 1-90度 2-180度 3-270度 其他-不旋转 |
|
|
|
* content: 文字内容 |
|
|
|
*/ |
|
|
|
let strCmd = blesdk.CreatCPCLPage(600, 1040, 1, 0); |
|
|
|
strCmd += blesdk.addCPCLSETMAG(2, 2) |
|
|
|
blesdk.addCPCLSETBOLD('bold') |
|
|
|
strCmd += blesdk.addCPCLLocation(2); //对齐指令 0-左对齐 1-右对齐 2-居中 |
|
|
|
strCmd += blesdk.addCPCLText('0', '30', '24', '0', 0, uni.getStorageSync('shopName')) |
|
|
|
|
|
|
|
strCmd += blesdk.addCPCLSETMAG(1, 1) |
|
|
|
strCmd += blesdk.addCPCLLocation(0); //对齐指令 0-左对齐 1-右对齐 2-居中 |
|
|
|
strCmd += blesdk.addCPCLText('0', '100', '24', '0', 0, '客户:'+this.khName.name) |
|
|
|
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){ |
|
|
|
strCmd += blesdk.addCPCLText('0', that.yNum+= 30, '24', '0', 0, value.productName+'('+value.productSn+')'+'折扣:'+(value.discount<10?value.discount:'无折扣')) |
|
|
|
value.stockLogList.forEach(function(value1,key1){ |
|
|
|
strCmd += blesdk.addCPCLText('0', that.yNum+= 30, '24', '0', 0,(that.slicePrint(key1))+'*'+value1) |
|
|
|
strCmd += blesdk.addCPCLText('200', that.yNum, '24', '0', 0, '单价:'+value.lsprice) |
|
|
|
strCmd += blesdk.addCPCLText('360', that.yNum, '24', '0', 0, '总价:'+(value.lsprice*value1)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
strCmd += blesdk.addCPCLText('0', this.yNum+=20, '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) |
|
|
|
strCmd += blesdk.addCPCLText('0', this.yNum+=30, '24', '0', 0, '实收:'+this.priceOk) |
|
|
|
strCmd += blesdk.addCPCLText('200', this.yNum, '24', '0', 0, '欠款:'+this.noPay) |
|
|
|
strCmd += blesdk.addCPCLText('400', this.yNum, '24', '0', 0, '其他费用:'+this.otherExpense) |
|
|
|
strCmd += blesdk.addCPCLText('0', this.yNum+=30, '24', '0', 0, '备注:'+this.remark) |
|
|
|
|
|
|
|
|
|
|
|
strCmd += blesdk.addCPCLLocation(0); //对齐指令 0-左对齐 1-右对齐 2-居中 |
|
|
|
strCmd += blesdk.addCPCLPrint(); |
|
|
|
this.bufferData = strCmd; |
|
|
|
}, |
|
|
|
//截取 |
|
|
|
slicePrint(val) { |
|
|
|
var name = '' |
|
|
|
if (typeof(val) == 'string') { |
|
|
|
let newObj = JSON.parse(val) |
|
|
|
for (let as in newObj) { |
|
|
|
name += newObj[as] + '/' |
|
|
|
} |
|
|
|
} |
|
|
|
return name; |
|
|
|
}, |
|
|
|
formatDate(date, fmt) { |
|
|
|
var o = { |
|
|
|
'M+': date.getMonth() + 1, //月份 |
|
|
|
'D+': date.getDate(), //日 |
|
|
|
'H+': date.getHours(), //小时 |
|
|
|
'm+': date.getMinutes(), //分 |
|
|
|
's+': date.getSeconds(), //秒 |
|
|
|
'q+': Math.floor((date.getMonth() + 3) / 3), //季度 |
|
|
|
'S': date.getMilliseconds() //毫秒 |
|
|
|
}; |
|
|
|
if (/(Y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); |
|
|
|
for (var k in o) |
|
|
|
if (new RegExp('(' + k + ')').test(fmt)) |
|
|
|
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))); |
|
|
|
return fmt; |
|
|
|
}, |
|
|
|
//编辑每一个的单价 |
|
|
|
clickPrice(index) { |
|
|
|
console.log(index) |
|
|
|
|