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 @@ - + + + + + 请输入拿货数量 + + + + + *您的此款商品只有一个规格,可直接输入拿货数量即可 + + + + 确认 + + + + @@ -228,7 +247,8 @@ components: {}, data() { return { - indexList: [], + indexList: [], + focus:false, pageNum: 1, //分页的页码 shopList: [], shopList1:[], @@ -238,17 +258,18 @@ shopId: '', //店铺id, checkbox: [], //需要分享的商品id temporaryNum: 0, - allChangeNum:0, + allChangeNum:0, + oneGoodsSpec:[], goodsDetail: [], attrNameList: [], temporaryList: [], isPlusAndMinus:false, carList: [], - evalue: [], attributeList: [], purchasePrice: 0, zPrice: 0, - zNum: 0, + zNum: 0, + goodsNum:'', storageType: '', carNum: 0, carType: 0, @@ -666,7 +687,7 @@ data = { categoryId: "", searchStr: this.searchName, - pageNum: this.pageNum, + pageNum: 1, pageSize: '10' } }else{ @@ -735,7 +756,6 @@ this.goodsList = [] this.allChangeNum = 0 this.checkGoods(item); - this.$refs.popup.open('bottom') } }, @@ -759,7 +779,7 @@ } await this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", { - categoryId: this.goodsDetail.categoryId + categoryId: this.goodsDetail.attrId }, false, true).then((res1) => { if (res1.code == 200) { if (typeof(res1.result) == 'string') { @@ -798,32 +818,45 @@ value: valueObj }) } - this.goodsDetail.attributeList = newArr; - for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { - let oldCheck = false - let oldValue = [] - for (var m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) { - if(this.goodsDetail.attributeList[i].value[m].isChecked == true){ - oldCheck = true - oldValue.push(this.goodsDetail.attributeList[i].value[m].value) - } - } - if(oldCheck){ - let specs1 = { - specs:[] + this.focus = false + if(newArr[0].value.length == 1 && newArr[1].value.length == 1){ + console.log('只有一个',newArr) + this.oneGoodsSpec = newArr + // this.oneGoodsToCarList(newArr) + this.$refs.goodsNumDialog.open('center') + this.$nextTick(() => { + this.focus = true + }) + }else{ + this.$refs.popup.open('bottom') + this.goodsDetail.attributeList = newArr; + for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { + let oldCheck = false + let oldValue = [] + for (var m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) { + if(this.goodsDetail.attributeList[i].value[m].isChecked == true){ + oldCheck = true + oldValue.push(this.goodsDetail.attributeList[i].value[m].value) + } } - - specs1.specs = oldValue - this.goodsList.push(specs1) - }else{ - let specs1 = { - specs:[] + if(oldCheck){ + let specs1 = { + specs:[] + } + + specs1.specs = oldValue + this.goodsList.push(specs1) + }else{ + let specs1 = { + specs:[] + } + this.goodsList.push(specs1) } - this.goodsList.push(specs1) + oldCheck = false + oldValue = [] } - oldCheck = false - oldValue = [] } + } } else { @@ -832,6 +865,64 @@ }).catch((res) => {}) this.getKCList(item.id); }, + oneGoodsToCarList(){ + let that = this; + // this.oneGoodsSpec //规格 + // this.goodsNum //数量 + this.evalue = [] + var value = [] + var name = '' + let value1 = "{" + name = this.oneGoodsSpec[0].value[0].value + '/' + this.oneGoodsSpec[1].value[0].value + value1 += '"'+this.oneGoodsSpec[0].name + '":"' + this.oneGoodsSpec[0].value[0].value + '",' + value1 += '"'+this.oneGoodsSpec[1].name + '":"' + this.oneGoodsSpec[1].value[0].value + '"' + value1 += "}" + value.push(value1) + this.evalue.push(name) + for (var i = 0; i < value.length; i++) { + this.attributeList = { + attributeList: value[i], + productCount: this.goodsNum, + productNum:0, + name: this.evalue[i], + price: this.goodsDetail.purchasePrice + } + this.temporaryList.push(this.attributeList); + } + let data = { + id: this.goodsDetail.id, + price: this.zPrice, + num: this.zNum, + categoryId:this.goodsDetail.categoryId, + productName: this.goodsDetail.productName, + productSn: this.goodsDetail.productSn, + productPicture: this.goodsDetail.productPicture, + supplierName: this.goodsDetail.supplierName, + saleDetailQueryDTO: this.temporaryList, + saleDetailQueryDTO1: [], + wholesalePrice: this.goodsDetail.wholesalePrice, + lsprice: this.goodsDetail.price + } + if (this.carList.length == 0) { + this.carList.push(data) + } else { + let aa = true; + for (let i = 0; i < this.carList.length; i++) { + if (this.carList[i].id == data.id) { + this.carList[i] = data + aa = false + } + } + if (aa) { + this.carList.push(data) + } + } + this.$nextTick(()=>{ + that.$refs.goodsNumDialog.close() + that.goodsNum = '' + }) + + }, //库存商品详情 getKCList(id) { this.yanseList = new Map() @@ -1229,7 +1320,8 @@ .content-right { flex: 1; - overflow-y: scroll; + overflow-y: scroll; + padding-bottom: 100rpx; } .right-box { @@ -1466,5 +1558,38 @@ .zuni-numbox .zuni-numbox--disabled { color: #c0c0c0 !important; cursor: not-allowed; + } + .add-popup-content { + align-items: center; + justify-content: center; + padding: 15px; + width: 500rpx; + height: 410rpx; + background-color: #fff; + } + + .add-popup-title { + font-size: 36rpx; + font-weight: bold; + text-align: center; + position: relative; + } + + .add-popup-container { + margin-top: 20rpx; + } + + .add-popup-bottom { + display: flex; + height: 80rpx; + color: #fff; + line-height: 80rpx; + margin-top: 30rpx; + } + + .add-popup-btn { + flex: 1; + text-align: center; + background: linear-gradient(90deg, #60F3FF, #088FEB); } \ No newline at end of file diff --git a/pages/index/checkShop.vue b/pages/index/checkShop.vue index 861355a..36e39c6 100644 --- a/pages/index/checkShop.vue +++ b/pages/index/checkShop.vue @@ -86,6 +86,7 @@ uni.setStorageSync('shopName', this.name) uni.setStorageSync('shopAddress', res.result.shopAddress) uni.setStorageSync('shopIcon', res.result.shopIcon) + uni.setStorageSync('type', res.result.userType) this.tui.toast('切换店铺成功', 2000, true) setTimeout(() => { uni.reLaunch({ diff --git a/pages/index/index.vue b/pages/index/index.vue index 3a84483..843b04a 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -135,7 +135,7 @@ - @@ -446,7 +460,7 @@ 暂无拿货历史 - 一键使用历史价格 + 一键使用历史价格 @@ -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) { // 初始化蓝牙模块