diff --git a/pages/.DS_Store b/pages/.DS_Store
index 80e54b5..0975784 100644
Binary files a/pages/.DS_Store and b/pages/.DS_Store differ
diff --git a/pages/billing/changeGoods1.vue b/pages/billing/changeGoods1.vue
index c2f2f70..07706e2 100644
--- a/pages/billing/changeGoods1.vue
+++ b/pages/billing/changeGoods1.vue
@@ -4,7 +4,7 @@
-
+
@@ -173,7 +173,26 @@
-
+
+
+
+
@@ -685,9 +699,11 @@
lbgName: [], //拉包工姓名
carList: new Map(), //添加商品页传回来的商品信息
xsyId: '',
- shouldPay: 0,
+ shouldPay: 0,
+ returnPay:0,
totalAmount: 0,
- customPrice: 0, //选择自定义金额
+ customPrice: 0, //选择自定义金额
+ returnPrice:0,
remark: '',
pbAddress: '',
yanseList: new Map(),
@@ -727,11 +743,21 @@
kkPrinter
},
onHide(){
- console.log('1加载了啊')
+ console.log("1111")
this.recordState = false
+ setTimeout(res=>{
+ uni.closeBLEConnection({
+ deviceId:uni.getStorageSync('deviceId'),
+ success(res) {
+ console.log(res)
+ },fail(err){
+ console.log(err)
+ }
+ })
+ },5000)
+
},
onShow() {
- console.log('加载了啊')
this.recordState = false
// 初始化蓝牙模块
wx.openBluetoothAdapter({
@@ -870,23 +896,22 @@
},
handleData() {
let that = this;
-
for (let i = 0; i < this.carList1.length; i++) {
-
if (this.carList1[i].saleDetailQueryDTO) {
if (this.carList.size == 0) { //当前页没有数据
-
let obj = {
purchasePrice: this.carList1[i].price, //采购价
price: 0, //总价
discount: 10, //折扣
categoryId: this.carList1[i].categoryId,
unitPrice: this.carList1[i].unitPrice || 0, //单价
- discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
+ discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
+ returnPrice:this.carList1[i].wholesalePrice || 0,
disNoAmount: 0, //折前价,用于计算整体折扣
wholesalePrice: this.carList1[i].wholesalePrice, //批发价
lsprice: this.carList1[i].lsprice, //零售价
- productCount: 0, //总数量
+ productCount: 0, //总数量
+ returnCount:0, //退货数量
productId: this.carList1[i].id,
productName: this.carList1[i].productName,
productPicture: this.carList1[i].productPicture,
@@ -904,8 +929,13 @@
.saleDetailQueryDTO[m].stockCount
}
- obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, data1)
- obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount
+ obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, data1)
+ if(this.carList1[i].saleDetailQueryDTO[m].productCount < 0){ //退货数量
+ obj.returnCount += Math.abs(this.carList1[i].saleDetailQueryDTO[m].productCount)
+ }else{
+ obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount
+ }
+
}
this.carList.set(this.carList1[i].id, obj)
} else { //当前页有数据
@@ -952,10 +982,13 @@
this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i]
.saleDetailQueryDTO[
m].attributeList, data1)
+ }
+ if(this.carList1[i].saleDetailQueryDTO[m].productCount < 0){ //退货数量
+ this.carList.get(this.carList1[i].id).returnCount += Math.abs(this.carList1[i].saleDetailQueryDTO[m].productCount)
+ }else{
+ this.carList.get(this.carList1[i].id).productCount += this.carList1[i].saleDetailQueryDTO[m].productCount
}
- this.carList.get(this.carList1[i].id).productCount += this.carList1[i]
- .saleDetailQueryDTO[
- m].productCount
+
}
} else { //商品不同
let obj = {
@@ -963,12 +996,14 @@
price: 0,
discount: 10,
categoryId: this.carList1[i].categoryId,
- discountAmount: this.carList1[i].wholesalePrice || 0,
+ discountAmount: this.carList1[i].wholesalePrice || 0,
+ returnPrice: this.carList1[i].wholesalePrice || 0,
disNoAmount: 0, //折前价,用于计算整体折扣
unitPrice: this.carList1[i].unitPrice || 0, //单价
wholesalePrice: this.carList1[i].wholesalePrice, //批发价
lsprice: this.carList1[i].lsprice, //零售价
- productCount: 0,
+ productCount: 0,
+ returnCount:0,
productId: this.carList1[i].id,
productName: this.carList1[i].productName,
productPicture: this.carList1[i].productPicture,
@@ -990,8 +1025,12 @@
}
obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, data1)
- obj.name = this.carList1[i].saleDetailQueryDTO[m].name
- obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount
+ obj.name = this.carList1[i].saleDetailQueryDTO[m].name
+ if(this.carList1[i].saleDetailQueryDTO[m].productCount < 0){ //退货数量
+ obj.returnCount += Math.abs(this.carList1[i].saleDetailQueryDTO[m].productCount)
+ }else{
+ obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount
+ }
}
this.carList.set(this.carList1[i].id, obj)
}
@@ -1032,7 +1071,8 @@
setTimeout(res => {
uni.hideLoading();
}, 300)
- }
+ }
+ console.log('退货金额',this.carList)
},
invenRadio() {
@@ -1053,7 +1093,8 @@
productId: this.carList1[i].productId,
categoryId: this.carList1[i].categoryId,
unitPrice: this.carList1[i].wholesalePrice || 0, //单价
- discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
+ discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
+ returnPrice: this.carList1[i].wholesalePrice || 0,
disNoAmount: 0, //折前价,用于计算整体折扣
wholesalePrice: this.carList1[i].wholesalePrice, //批发价
lsprice: this.carList1[i].price, //零售价
@@ -1117,7 +1158,8 @@
categoryId: this.carList1[i].categoryId,
productId: this.carList1[i].productId,
unitPrice: this.carList1[i].wholesalePrice || 0, //单价
- discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
+ discountAmount: this.carList1[i].wholesalePrice || 0, //折后价
+ returnPrice: this.carList1[i].wholesalePrice || 0,
disNoAmount: 0, //折前价,用于计算整体折扣
wholesalePrice: this.carList1[i].wholesalePrice, //批发价
lsprice: this.carList1[i].price, //零售价
@@ -1676,9 +1718,10 @@
'实件': '10件',
'景': '#',
'警': '#',
- '颈': '#',
+ '颈': '#',
+ '括号':'货号'
};
- const regex = /(零|一|二|两|三|四|五|六|七|八|九|杠|刚|军色|叉|金色|井|时间|事件|世间|实践|实件|景|警|颈)/g;
+ const regex = /(零|一|二|两|三|四|五|六|七|八|九|杠|刚|军色|叉|金色|井|时间|事件|世间|实践|实件|景|警|颈|括号)/g;
return str.replace(regex, match => chineseNumToArabic[match]);
},
//编辑挂单信息
@@ -1711,6 +1754,9 @@
if(convertedStr.indexOf(',') == 0){
console.log('位置',convertedStr.indexOf(','))
convertedStr = convertedStr.substr(1)
+ }
+ if (convertedStr.startsWith("号")) {
+ convertedStr = "货号" + convertedStr.substr(1);
}
this.getMsg = convertedStr
this.tui.request("/app/sale/buyAi", "POST", {
@@ -1841,9 +1887,11 @@
await this.carList.forEach(function(value, key) {
that.index = value.productId || value.id
if (e == '0') { //零售
- value.discountAmount = value.lsprice
+ value.discountAmount = value.lsprice
+ value.returnPrice= value.lsprice
} else { //批发
- value.discountAmount = value.wholesalePrice
+ value.discountAmount = value.wholesalePrice
+ value.returnPrice= value.wholesalePrice
}
})
await this.getAllPrice()
@@ -1854,7 +1902,7 @@
this.$forceUpdate()
},
//商品上选择是零售价还是批发价
- checkPay(price) {
+ checkPay(price,returnPrice) {
if (price == undefined || price == null) {
this.tui.toast("暂无拿货记录")
@@ -1863,7 +1911,10 @@
let that = this;
let num = this.carList.get(this.index)
- num.discountAmount = price
+ num.discountAmount = price
+ if(returnPrice != ''){
+ num.returnPrice = returnPrice
+ }
num.unitPrice = price;
num.price = price * num.productCount;
this.$refs.inputDialog.close()
@@ -2239,7 +2290,8 @@
discount: 10, //折扣
unitPrice: 0, //单价
categoryId: carList1[i].categoryId,
- discountAmount: carList1[i].wholesalePrice || 0, //折后价
+ discountAmount: carList1[i].wholesalePrice || 0, //折后价
+ returnPrice: carList1[i].wholesalePrice || 0,
disNoAmount: 0, //折前价,用于计算整体折扣
wholesalePrice: carList1[i].wholesalePrice, //批发价
lsprice: carList1[i].lsprice, //零售价
@@ -2304,7 +2356,8 @@
purchasePrice: carList1[i].price, //采购价
price: 0,
discount: 10,
- discountAmount: carList1[i].wholesalePrice || 0,
+ discountAmount: carList1[i].wholesalePrice || 0,
+ returnPrice: carList1[i].wholesalePrice || 0,
disNoAmount: 0, //折前价,用于计算整体折扣
unitPrice: 0, //单价
categoryId: carList1[i].categoryId,
@@ -2424,6 +2477,9 @@
}
if(convertedStr.indexOf(',') == 0){
convertedStr = convertedStr.substr(1)
+ }
+ if (convertedStr.startsWith("号")) {
+ convertedStr = "货号" + convertedStr.substr(1);
}
if (that.voiceText == '' || that.voiceText == null) {
that.voiceText = convertedStr
@@ -2457,7 +2513,8 @@
}
}
},
- showPrice() {
+ showPrice() {
+ let that = this;
if (this.khName == '') {
this.tui.toast('请选择客户!')
return
@@ -2496,11 +2553,23 @@
} 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
+ this.bufferData = []
+ let strCmd = this.getPrintData()
+ strCmd += blesdk.addCPCLPrint();
+ this.bufferData.push(strCmd);
this.$refs.showPopup.open()
},
//点击底部开单按钮
- goSell(print) {
+ async goSell(print) {
let that = this;
uni.showLoading({
title: '加载中...'
@@ -2535,51 +2604,121 @@
companyName: this.wlName.shippingMethod || this.wlName.companyName,
companyPhone: this.wlName.mobile
},
- saleDetailList: []
+ saleDetailList: [],
+ saleReturnDTO:[]
}
- let purchaseDetails = [];
- this.carList.forEach(function(value, key) {
+ let purchaseDetails = [];
+ let returnList = [];
+
+ console.log('carList',this.carList)
+ await this.carList.forEach(function(value, key) {
+ let returnGoods = []
+ let goodsList = []
value.stockLogList.forEach(function(values, keys) {
- if (values <= 0) {
+ if (values.productCount == 0) {
that.tui.toast("商品数量不能为零!")
return;
+ }
+ console.log('values',values)
+ if(values.productCount < 0){
+ console.log()
+ let obj1 = {
+ productCount: values.productCount,
+ attributeList: keys
+ }
+ returnGoods.push(obj1)
+ }else{
+ let obj1 = {
+ productCount: values.productCount,
+ attributeList: keys
+ }
+ goodsList.push(obj1)
}
- let obj = {
- productCount: values.productCount,
- attributeList: keys
- }
- value.stockLogList1.push(obj)
+
+ })
+ that.$nextTick(()=>{
+ if(returnGoods.length > 0){
+ let data = {
+ categoryId: value.categoryId,
+ disNoAmount: value.disNoAmount,
+ discount: value.discount,
+ discountAmount: value.discountAmount,
+ lsprice: value.lsprice,
+ price: value.price,
+ productCount: value.productCount,
+ productId: value.productId,
+ productName: value.productName,
+ productPicture: value.productPicture,
+ productSn: value.productSn,
+ purchasePrice: value.purchasePrice,
+ returnCount: value.returnCount,
+ returnPrice: value.returnPrice,
+ stockLogList: value.stockLogList,
+ stockLogList1: returnGoods,
+ supplierName: value.supplierName,
+ unitPrice: value.unitPrice,
+ wholesalePrice: value.wholesalePrice
+ }
+ returnList.push(data)
+ }
+ if(goodsList.length > 0){
+ let data = {
+ categoryId: value.categoryId,
+ disNoAmount: value.disNoAmount,
+ discount: value.discount,
+ discountAmount: value.discountAmount,
+ lsprice: value.lsprice,
+ price: value.price,
+ productCount: value.productCount,
+ productId: value.productId,
+ productName: value.productName,
+ productPicture: value.productPicture,
+ productSn: value.productSn,
+ purchasePrice: value.purchasePrice,
+ returnCount: value.returnCount,
+ returnPrice: value.returnPrice,
+ stockLogList: value.stockLogList,
+ stockLogList1: goodsList,
+ supplierName: value.supplierName,
+ unitPrice: value.unitPrice,
+ wholesalePrice: value.wholesalePrice
+ }
+ purchaseDetails.push(data)
+ }
})
-
- purchaseDetails.push(value)
- })
- this.saleDetailList = purchaseDetails;
- obj.saleDetailList = purchaseDetails;
- let url = ''
- if (this.saleId != '') {
- url = '/app/sale/shareToBuyNew'
- } else {
- url = '/app/sale/buyNew'
- }
- this.tui.request(url, "post", obj, false, false).then((res) => {
- if (res.code == 200) {
- uni.showToast({
- title: "开单成功",
- icon: 'none'
- })
- if (print != 'print') {
- setTimeout(res => {
- this.$refs.showPopup.close()
- that.clearAll1()
- uni.switchTab({
- url: '/pages/index/index'
- });
- }, 1000)
- }
- } else {
- this.tui.toast(res.message)
- }
+ })
+ await that.$nextTick(()=>{
+ setTimeout(res=>{
+ obj.saleDetailList = purchaseDetails;
+ obj.saleReturnDTO = returnList;
+ let url = ''
+ if (this.saleId != '') {
+ url = '/app/sale/shareToBuyNew'
+ } else {
+ url = '/app/sale/buyNew'
+ }
+ this.tui.request(url, "post", obj, false, false).then((res) => {
+ if (res.code == 200) {
+ uni.showToast({
+ title: "开单成功",
+ icon: 'none'
+ })
+ if (print != 'print') {
+ setTimeout(res => {
+ this.$refs.showPopup.close()
+ that.clearAll1()
+ uni.switchTab({
+ url: '/pages/index/index'
+ });
+ }, 1000)
+ }
+ } else {
+ this.tui.toast(res.message)
+ }
+ })
+ },500)
})
+
setTimeout(res => {
uni.hideLoading();
}, 1000)
@@ -2591,236 +2730,111 @@
// url: '/pages/index/index'
// });
// },
- //打印小票
- 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))
- }
- })
- })
- 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'))
+ //打印小票
+ 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'
+ });
+ })
+ },
+ 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 +2845,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) {
@@ -2871,6 +2885,10 @@
this.wholesalePrice = this.carList.get(this.index).wholesalePrice
this.lsprice = this.carList.get(this.index).lsprice
this.$refs.inputDialog.open()
+ },
+ //输入商品自定义退货金额
+ changeReturnPay(e) {
+ this.returnPrice = e.detail.value
},
//输入商品自定义金额
changePay(e) {
@@ -2959,27 +2977,40 @@
let that = this;
this.shouldPay = 0
this.totalAmount = 0
-
+ that.returnPay = 0
this.carList.forEach(function(value, key) {
that.shouldPay = Number(that.shouldPay) + Number(value.price)
-
- that.totalAmount = that.totalAmount + value.productCount
+ that.returnPay = Number(that.returnPay) + (Number(value.returnPrice) * Math.abs(Number(value.returnCount)))
+ if(value.productCount > 0){
+ that.totalAmount = that.totalAmount + value.productCount
+ }
})
- that.shouldPay = that.shouldPay.toFixed(2)
+ that.shouldPay = that.shouldPay.toFixed(2)
+ that.returnPay = that.returnPay.toFixed(2)
this.relPrice = this.shouldPay
- this.priceOk = this.shouldPay
+ this.priceOk = this.shouldPay - that.returnPay
this.$forceUpdate()
- that.noPay = this.relPrice - (this.priceOk == '' ? 0 : this.priceOk)
+ that.noPay = this.relPrice - (this.priceOk == '' ? 0 : this.priceOk) - this.returnPay
that.noPay = that.noPay.toFixed(2)
},
//修改已选规格的数量
GoodsNumChange(e, index, index1) {
- let that = this;
- this.carList.get(index[0]).stockLogList.get(index1).productCount = e
- this.carList.get(index[0]).productCount = 0
+ let that = this;
+ if(e < 0){
+
+ this.carList.get(index[0]).stockLogList.get(index1).productCount = e
+ }else{
+ this.carList.get(index[0]).stockLogList.get(index1).productCount = e
+ }
+
+ this.carList.get(index[0]).productCount = 0
+ this.carList.get(index[0]).returnCount = 0
this.carList.get(index[0]).stockLogList.forEach(function(value, key) {
- that.carList.get(index[0]).productCount = that.carList.get(index[0]).productCount + value
- .productCount
+ if(value.productCount < 0){
+ that.carList.get(index[0]).returnCount = that.carList.get(index[0]).returnCount + Math.abs(value.productCount)
+ }else{
+ that.carList.get(index[0]).productCount = that.carList.get(index[0]).productCount + value.productCount
+ }
if (that.discountType == 0) { //单品折扣
// that.carList.get(index[0]).price = that.carList.get(index[0]).productCount * (that.carList.get(
// index[0]).discountAmount * (that.carList.get(index[0]).discount / 10))
diff --git a/pages/inventory/inventory.vue b/pages/inventory/inventory.vue
index 792b01e..e2e00ee 100644
--- a/pages/inventory/inventory.vue
+++ b/pages/inventory/inventory.vue
@@ -38,8 +38,8 @@
-
- 新增入库
+
+ 新增商品
更多
@@ -138,9 +138,6 @@
-
diff --git a/pages/inventory/inventoryDetail.vue b/pages/inventory/inventoryDetail.vue
index 706cdd7..8af60db 100644
--- a/pages/inventory/inventoryDetail.vue
+++ b/pages/inventory/inventoryDetail.vue
@@ -157,7 +157,7 @@
@confirm="changePrice">
-
+
{
+ uni.closeBLEConnection({
+ deviceId:uni.getStorageSync('deviceId'),
+ success(res) {
+ console.log(res)
+ },fail(err){
+ console.log(err)
+ }
+ })
+ },5000)
},
onLoad(option) {
// 初始化蓝牙模块