From 7b5687f082ab0d62f2cfd2f2ab390ef44c8ba6eb Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Fri, 1 Nov 2024 08:43:29 +0800 Subject: [PATCH] 11.1 --- package1/AI/voiceInventory.vue | 24 +- package1/index/order.vue | 12 +- package1/index/orderDetail.vue | 964 +++++++++++++++++++++++++++++--- package1/inventory/addGoods.vue | 4 +- package1/staff/addStaff.vue | 11 + 5 files changed, 940 insertions(+), 75 deletions(-) diff --git a/package1/AI/voiceInventory.vue b/package1/AI/voiceInventory.vue index d11aff2..71105ad 100644 --- a/package1/AI/voiceInventory.vue +++ b/package1/AI/voiceInventory.vue @@ -388,9 +388,9 @@ 规格 + style="width: 69%;display: inline-block;font-size: 30rpx;font-weight: bold;padding-left: 40rpx;">规格 库存 + style="font-size: 30rpx;color: #000;font-weight: bold;width: 25%;display: inline-block;text-align: center;">库存 - {{item.name}} - {{item.name}} + 无库存 @@ -813,6 +813,7 @@ snList: [], carList1: [], zhuImg: '', + zhuImgList: [], productNum: null, prefixRule: '', numRule: '', @@ -1376,10 +1377,20 @@ } }) } else { - this.addPageGoods(this.zhuImg, res1.result) + if(that.zhuImgList != [] && that.zhuImgList.length > 0){ + for (let i = 0; i < that.zhuImgList.length; i++) { + that.upLoadFile(that.zhuImgList[i], i + 1) + } + setTimeout(res => { + that.zhuImgList = [] + }, 2000) + + }else{ + this.addPageGoods(this.zhuImg, res1.result) + } that.getSnList() } - + } else { this.tui.toast(res.message) } @@ -7054,6 +7065,7 @@ } for (let i = 0; i < res.tempFiles.length; i++) { that.upLoadFile(res.tempFiles[i].tempFilePath, i + 1) + that.zhuImgList.push(res.tempFiles[i].tempFilePath) } }, fail(err) { diff --git a/package1/index/order.vue b/package1/index/order.vue index f0e93ee..36f41c5 100644 --- a/package1/index/order.vue +++ b/package1/index/order.vue @@ -62,7 +62,7 @@ 去开单 撤销 撤销并复制 - 重新开单 + 重新开单 删除订单 @@ -224,6 +224,16 @@ this.tui.toast(res.message) } }) + }, + // 重新开单订单 + async againOrder(item,type,index) { + let that = this; + await this.getReturnOrder(item.id) + await this.tui.modal("提示", "您确定要重新开单吗?", true, (res) => { + if (res) { + that.goSaleGoods(item) + } + }) }, // 取消订单 async cancelOrder(item,type,index) { diff --git a/package1/index/orderDetail.vue b/package1/index/orderDetail.vue index 8738754..1570d65 100644 --- a/package1/index/orderDetail.vue +++ b/package1/index/orderDetail.vue @@ -1,5 +1,8 @@ @@ -561,12 +609,16 @@ return { defaultText: '贴包单', radio1: 0, + isshanglu:true, isSizeHeng:false, + canvasshow:false, bigImg: [], shopId:uni.getStorageSync('shopId'), shopName:'', QrUrl: '', //二维码临时存放 newQRList: [], // 生成的二维码临时路径的数组 + newQRList1: [], // 生成的二维码临时路径的数组 + qrCodeImage:'', swiperDotIndex: 0, sex: [{ text: '是', @@ -589,6 +641,8 @@ order: {}, list: [], newData: [], + listHeng: [], + lettrList:['XS','S','M','L','XL','2XL','XXL','3XL','XXXL','4XL','XXXXL','5XL','XXXXXL','6XL','XXXXXXL','7XL','XXXXXXXL'], isReturn: false, orderByWorkerList: [], inventoryList: [], @@ -597,24 +651,46 @@ editNoPrice: false, newEarn: 0, shopRemark: [], + fontsmailDcl:0, isgys: true, printHeight: 0, + myCanvasHeight: '', + myCanvasWidth: '', isReturnPrice: 1, type: '', orderXd: [], collection: [], returnPrice: 0, shopMoblie: '', + smailSize:0, returnNum: 0, lbgName: [], returnAmount: 0, + smailDcl:1, shopData: [], changeA: '', sAmout: 0, yNum: 150, + picOk:false, printingMethod: '0', + printHeight1:0, + printWidth1:0, printTotal: 1040, deviceType: 'ios', + payType1: 1, + payTypeList: [{ + value: 1, + text: "切换样式" + }, { + value: 1, + text: "展示图片" + }, { + value: 0, + text: "表格样式" + }, { + value: 2, + text: "尺码横排" + }], qrArr: [], isShare: false, isDownKH: false, @@ -655,7 +731,7 @@ for (let as in newObj) { name += newObj[as] + '/' } - } + } return name; }, sliceJun(val){ @@ -663,6 +739,9 @@ if (typeof(val) == 'string') { name = val.replace(/均/g, '分') } + if(name == '分'){ + name = '分码' + } return name; }, maxNum(val) { @@ -673,18 +752,21 @@ } } }, - onShareAppMessage() { + async onShareAppMessage() { //禁止转发 // wx.updateShareMenu({ // isPrivateMessage: true, // success () { }, // fail () {} // }) + console.log(this.sales) + let titleText = this.shopName +' '+ this.sales.createTime.split(' ')[0]+'\n销售单' + const imageUrl = await this.senrPath() return { - title: this.shopName + '的采购单', - imageUrl: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/b28b3d46c21d4f60a334b25f56175cf3.jpg', + title:titleText, + imageUrl: imageUrl, path: '/package1/index/orderDetail?popleType=khName&id=' + this.sales.id + '&shopId=' +uni.getStorageSync('shopId') + '&shopName=' + this.shopName + '&shopOwnerPhone='+ this.shopOwnerPhone - } + } }, onShow() { // 初始化蓝牙模块 @@ -730,39 +812,146 @@ customerId: this.userId }, false, false).then((res) => { if (res.code == 200 && res.result != null && res.result != undefined) { + if (res.result.sale.status == '2') { + that.tui.toast('该订单已撤销') + } this.sales = res.result.sale if (res.result.dealingsRecord != null) { this.dealingsRecord = res.result.dealingsRecord } + this.list = res.result.saleDetailDTOList this.getChildrenPic() - for (var i = 0; i < this.list.length; i++) { - if (this.list[i].realPrice != '' && this.list[i].discountAmount == null) { - this.list[i].discountAmount = this.list[i].realPrice + for (var i = 0; i < that.list.length; i++) { + if (that.list[i].realPrice != '' && that.list[i].discountAmount == null) { + that.list[i].discountAmount = that.list[i].realPrice + } + var isZiMu = false + var isNumber = false + var colorList = new Map() + var sizeNumList = [] + let notNum = [] + if(that.list[i].stockLogList1.length > 0){ + for (var m = 0; m < that.list[i].stockLogList1.length; m++) { + var attr = that.list[i].stockLogList1[m].attributeList + var newObj = JSON.parse(attr) + for (var as in newObj) { + if(as == '尺码' && that.isLetterOrDigit(newObj[as].replace(/码/g, '')) == 'Letter'){ + isZiMu = true + } + if(as == '尺码' && that.isLetterOrDigit(newObj[as].replace(/码/g, '')) == 'Digit'){ + isNumber = true + } + if(as == '尺码' && sizeNumList.indexOf(newObj[as].replace(/码/g, '')) == -1){ + if(as == '尺码' && that.isLetterOrDigit(newObj[as].replace(/码/g, '')) == 'Digit'){ + sizeNumList.push(newObj[as].replace(/码/g, '')) + }else{ + if(notNum.indexOf(newObj[as].replace(/码/g, '')) == -1){ + notNum.push(newObj[as].replace(/码/g, '')) + } + } + + } + if(as == '颜色'){ + if(colorList.has(newObj[as])){ + colorList.get(newObj[as]).push(that.list[i].stockLogList1[m]) + }else{ + let listChild = [] + listChild.push(that.list[i].stockLogList1[m]) + colorList.set(newObj[as],listChild) + } + } + } + } + } + if(notNum.length > 0 ){ + sizeNumList = sizeNumList.concat(notNum) + } + var newStockList = [] + if(isNumber){ + sizeNumList = sizeNumList.sort((a, b) => a - b); + colorList.forEach(function(value, key) { + for(var j = 0; j < sizeNumList.length; j++){ + for (var m = 0; m < value.length; m++) { + var newObj = JSON.parse(value[m].attributeList) + var size = '' + var color = '' + for (var as in newObj) { + if(as == '尺码'){ + size = newObj[as].replace(/码/g, '') + } + } + if(size == sizeNumList[j]){ + newStockList.push(value[m]) + value.splice(m,1) + break + } + } + } + if(value.length > 0){ + newStockList = newStockList.concat(value) + } + }) + that.list[i].stockLogList1 = newStockList } + if(isZiMu){ + colorList.forEach(function(value, key) { + for(var j = 0; j < that.lettrList.length; j++){ + for (var m = 0; m < value.length; m++) { + var newObj = JSON.parse(value[m].attributeList) + var size = '' + var color = '' + for (var as in newObj) { + if(as == '尺码'){ + size = newObj[as].replace(/码/g, '') + } + } + if(size == that.lettrList[j]){ + newStockList.push(value[m]) + value.splice(m,1) + break + } + } + } + if(value.length > 0){ + newStockList = newStockList.concat(value) + } + }) + that.list[i].stockLogList1 = newStockList + } + for (var m = 0; m < this.list[i].stockLogList1.length; m++) { if (this.list[i].productCount == null) { this.list[i].productCount = this.list[i].stockLogList1[m].productCount } else { this.list[i].productCount += this.list[i].stockLogList1[m].productCount } + let hasBuy = '' + if(this.list[i].stockLogList1[m].isPurchasedBefore == 0 || (this.list[i].stockLogList1[m].isPurchasedBefore == 1&& this.sales.userName =='散客')){ + hasBuy = '【销】' + } + if(this.list[i].stockLogList1[m].isPurchasedBefore == 1 && this.sales.userName !='散客'){ + hasBuy = '【补】' + } + let tableData = { + productSn: hasBuy + this.list[i].productSn, + productName:this.list[i].productName, + productCount:this.list[i].stockLogList1[m].productCount, + attributeList:this.list[i].stockLogList1[m].attributeList, + discountAmount:this.list[i].discountAmount + } + that.listHeng.push(tableData) } this.list[i].chengben = this.list[i].productCount * this.list[i].purchasePrice - } - this.sales.zongchengben = 0 - for (var i = 0; i < this.list.length; i++) { - this.sales.zongchengben += this.list[i].chengben + + } this.newData = JSON.parse(JSON.stringify(this.list)) - this.sales.zongchengben = this.sales.zongchengben.toFixed(2) this.order = res.result.customer this.orderXd = res.result.orderXd this.shopData = res.result.shop this.splitTextIntoChunks(res.result.shop.shopAddress, 30) this.getReturnOrder(option.id) - if (res.result.sale.status == '2') { - this.tui.toast('该订单已撤销') - } } else { if (res.code == 500 && res.message == 'java.lang.NullPointerException') { @@ -794,7 +983,9 @@ } else { this.analysisQrCode() } - + /* setTimeout(ress=>{ + this.getData() + },4000) */ }, methods: { @@ -804,7 +995,428 @@ _this.$refs.qrcodePopup[i].crtQrCode() } }, + senrPath(){ + return new Promise(async (resolve, reject) => { + let that = this + uni.showLoading({ + title:'生成中...' + }) + const ctx = uni.createCanvasContext('myCanvas1', this); + //背景图 + let imgA = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/30cc553859944b1e9fa3ce2d87905612.png'; + uni.downloadFile({ + url: imgA, + success: (res2) => { + if (res2.statusCode === 200) { + // // 绘制第一张图片 + ctx.drawImage(res2.tempFilePath, 0, 0, 1515, 1210); + ctx.draw(true); + // 设置字体样式 + ctx.font = 'bold 80px SimSun'; + // 设置文字颜色 + ctx.fillStyle = '#FF5809'; + let beginHeight = 150 + if(that.sales.productCount != null && that.sales.productCount != ''){ + var textWidth = 350; + // 计算居中位置 + beginHeight += 100 + + // 绘制文字 + ctx.fillText('销售', textWidth, beginHeight); + ctx.draw(true) + // 设置字体样式 + ctx.font = 'bold 60px SimSun'; + // 设置文字颜色 + ctx.fillStyle = '#FF5809'; + beginHeight+=100 + var text = '总件数:'+that.sales.productCount+' 总金额:'+that.sales.totalAmount + // 绘制文字 + ctx.fillText(text, textWidth, beginHeight); + ctx.draw(true) + } + if(that.returnNum != null && that.returnNum != ''){ + beginHeight+=120 + var textWidth = 350; + // 绘制文字 + // 设置字体样式 + ctx.font = 'bold 80px SimSun'; + // 设置文字颜色 + ctx.fillStyle = '#FF5809'; + ctx.fillText('退货', textWidth, beginHeight); + ctx.draw(true) + beginHeight+=100 + // 设置字体样式 + ctx.font = 'bold 60px SimSun'; + // 设置文字颜色 + ctx.fillStyle = '#FF5809'; + var text = '总件数:'+that.returnNum+' 总金额:'+that.returnPrice + // 绘制文字 + ctx.fillText(text, textWidth, beginHeight); + ctx.draw(true) + } + if(that.sales.realAmount != null){ + var textWidth = 350; + beginHeight+=150 + // 绘制文字 + // 设置字体样式 + ctx.font = 'bold 80px SimSun'; + // 设置文字颜色 + ctx.fillStyle = 'black'; + ctx.fillText('本单应收:'+that.sales.realAmount, textWidth, beginHeight); + ctx.draw(true) + } + if(that.sales.alreadyEarn != null){ + beginHeight+=120 + var textWidth = 350; + // 绘制文字 + // 设置字体样式 + ctx.font = 'bold 80px SimSun'; + // 设置文字颜色 + ctx.fillStyle = 'black'; + ctx.fillText('本单实收:'+that.sales.alreadyEarn, textWidth, beginHeight); + ctx.draw(true) + beginHeight+=120 + } + + setTimeout(ress=>{ + uni.canvasToTempFilePath({ + x: 0, + y: 0, + width: 1515, + height: 1210, + destWidth: 1515, + destHeight: 1210, + canvasId: 'myCanvas1', + success: (res3) => { + uni.hideLoading() + return resolve(res3.tempFilePath) + } + }); + },500) + } + } + }); + }) + }, + returnRealSize(size){ + return Number((size / this.smailDcl).toFixed(2)) + }, + returnRealFontSize(size){ + if(Number((size - this.fontsmailDcl).toFixed(2)) < 0){ + return (18 - (this.smailSize * 1.2).toFixed(2)).toFixed(2) + }else if(Number((size - this.fontsmailDcl).toFixed(2)) < 12){ + return 12 + }else{ + return Number((size - this.fontsmailDcl).toFixed(2)) + } + }, + getData() { + let that = this + if(that.picOk){ + uni.showLoading({ + title:'图片绘制中...' + }) + }else{ + this.tui.toast('账单生成中...') + return + } + + let dataHeight = that.printHeight1 + this.canvasshow = true + const ctx = uni.createCanvasContext('myCanvas', this); + ctx.fillStyle ="#FFFFFF" + ctx.fillRect(0, 0, that.printWidth1, dataHeight) + + //店铺名 + // 设置字体样式 + ctx.font = 'bold '+ that.returnRealFontSize(120) +'px SimSun'; + // 设置文字颜色 + ctx.fillStyle = 'black'; + var text = this.shopName+' 销售单'; + var textWidth = ctx.measureText(text).width; + // 计算居中位置 + var x = (that.printWidth1 - textWidth) / 2; + // 绘制文字 + ctx.fillText(text, x, that.returnRealSize(300)); + ctx.draw(true) + + // 设置字体样式 + + ctx.font = 'bold '+ that.returnRealFontSize(60) +'px SimSun'; + + // 设置文字颜色 + ctx.fillStyle = 'black'; + // 客户 + ctx.fillText('客户:' + (that.order.name ? that.order.name : '散客'), that.returnRealSize(20), that.returnRealSize(500)) + ctx.fillText('单号:' + that.sales.id, that.returnRealSize(1450), that.returnRealSize(500)) + // 销售员 + ctx.fillText('销售员:' + that.sales.createByName, that.returnRealSize(20), that.returnRealSize(600)) + ctx.fillText('日期:' + that.sales.createTime, that.returnRealSize(1450), that.returnRealSize(600)) + // 横线 + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), that.returnRealSize(700)) + // 数据 + let printingMethod = '0' + if (printingMethod == '0') { + ctx.fillText('货号(名称)', that.returnRealSize(20), that.returnRealSize(800)) + ctx.fillText('规格', that.returnRealSize(1040), that.returnRealSize(800)) + ctx.fillText('数量', that.returnRealSize(1590), that.returnRealSize(800)) + ctx.fillText('单价', that.returnRealSize(1875), that.returnRealSize(800)) + ctx.fillText('总价', that.returnRealSize(2140), that.returnRealSize(800)) + // 横线 + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), that.returnRealSize(900)) + } + let dataheigth = that.returnRealSize(700) + let dataheigth1 = that.returnRealSize(900) + let moretime = 0 + let Xindex = 0 + for (var i = 0; i < that.newData.length; i++){ + if (printingMethod == '1') { + moretime+=140 + dataheigth += that.returnRealSize(100) + //货号 + if (that.newData[i].productName == that.newData[i].productSn) { + ctx.fillText(that.newData[i].productSn, that.returnRealSize(20), dataheigth) + } else { + ctx.fillText(that.newData[i].productSn + '(' + (that.newData[i].productName == null ? '' : that.newData[i].productName) + ')', that.returnRealSize(20), dataheigth) + } + dataheigth += that.returnRealSize(100) + //尺码头 + ctx.fillText('颜色', that.returnRealSize(20), dataheigth) + let startWith = that.returnRealSize(450) + for (let a = 0; a < that.newData[i].sizeList.length; a++) { + if ((that.shopId == '1820269107191353344' || that.shopId == '1818888277105709056') && that.newData[i].sizeList[a] == '均') { + that.newData[i].sizeList[a] = '分码' + } + ctx.fillText(that.newData[i].sizeList[a], startWith , dataheigth) + startWith += Math.floor(that.returnRealSize(1250) / 8) + } + ctx.fillText('数量', that.returnRealSize(1700), dataheigth) + ctx.fillText('单价', that.returnRealSize(1950), dataheigth) + ctx.fillText('总价', that.returnRealSize(2200), dataheigth) + let begin = 0 + that.newData[i].sizePrintList.forEach(function(value, key) { + moretime+=70 + dataheigth+=that.returnRealSize(100) + if ((that.shopId == '1820269107191353344' || that.shopId == '1818888277105709056') && key == '均色') { + key = '分色' + } + ctx.fillText(key, that.returnRealSize(20), dataheigth) + let childStartWith = that.returnRealSize(450) + let allCount = 0 + let discountAmount = 0 + for (let a = 0; a < that.newData[i].sizeList.length; a++) { + let printSizeCount = [] + if(that.newData[i].sizeList[a] == '分码'){ + that.newData[i].sizeList[a] = '均' + } + if (value.has(that.newData[i].sizeList[a])) { + printSizeCount = value.get(that.newData[i].sizeList[a]).split(':') + discountAmount = printSizeCount[1] == undefined ? '' : printSizeCount[1] + } + allCount += printSizeCount[0] == undefined ? 0 : Number(printSizeCount[0]) + that.newData[i].allCount = allCount + ctx.fillText(printSizeCount[0] == undefined ? '' : Number(printSizeCount[0]), childStartWith , dataheigth) + childStartWith += Math.floor(that.returnRealSize(1250) / 8) + } + ctx.fillText(allCount, that.returnRealSize(1700), dataheigth) + ctx.fillText(discountAmount, that.returnRealSize(1950), dataheigth) + ctx.fillText((allCount * discountAmount), that.returnRealSize(2200), dataheigth) + }) + // 横线 + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), dataheigth+=that.returnRealSize(100)) + }else{ + for (var m = 0; m < that.newData[i].stockLogList1.length; m++) { + moretime+=80 + dataheigth1 += that.returnRealSize(100) + if (that.newData[i].stockLogList1[m].isReturn) { + if (that.newData[i].productName == that.newData[i].productSn) { + ctx.fillText((Xindex += 1) + '.' + '【退】' + that.newData[i].productSn, that.returnRealSize(20) , dataheigth1) + } else { + ctx.fillText((Xindex += 1) + '.' + '【退】' + that.newData[i].productSn + '(' + (that.newData[i].productName == null ? '' : that.newData[i].productName) + ')', that.returnRealSize(20) , dataheigth1) + } + } else { + if (that.newData[i].productName == that.newData[i].productSn && that.order.name != '散客') { + if (that.newData[i].stockLogList1[m].isPurchasedBefore == 1) { //买过 + ctx.fillText((Xindex += 1) + '.' + '【补】' + that.newData[i].productSn, that.returnRealSize(20) , dataheigth1) + } else { // 0是没买过 + ctx.fillText((Xindex += 1) + '.' + '【销】' + that.newData[i].productSn, that.returnRealSize(20) , dataheigth1) + } + } else { + if (that.newData[i].stockLogList1[m].isPurchasedBefore == 1 && that.order.name != '散客') { //买过 + ctx.fillText((Xindex += 1) + '.' + '【补】' + that.newData[i].productSn + '(' + (that.newData[i].productName == null ? '' : that.newData[i].productName) + ')', that.returnRealSize(20) , dataheigth1) + } else { // 0是没买过 + ctx.fillText((Xindex += 1) + '.' + '【销】' + that.newData[i].productSn + '(' + (that.newData[i].productName == null ? '' : that.newData[i].productName) + ')', that.returnRealSize(20) , dataheigth1) + } + } + } + if (that.shopId == '1820269107191353344' || that.shopId == '1818888277105709056') { + if (that.newData[i].stockLogList1[m].attributeList.indexOf('均色') != -1) { + that.newData[i].stockLogList1[m].attributeList = that.newData[i].stockLogList1[m].attributeList.replace(/均色/g, '分色') + } + if (that.newData[i].stockLogList1[m].attributeList.indexOf('均码') != -1) { + that.newData[i].stockLogList1[m].attributeList = that.newData[i].stockLogList1[m].attributeList.replace(/均码/g, '分码') + } + } + ctx.fillText(that.slicePrint(that.newData[i].stockLogList1[m].attributeList), that.returnRealSize(1040) , dataheigth1) + ctx.fillText(that.newData[i].stockLogList1[m].productCount, that.returnRealSize(1590) , dataheigth1) + + if (that.newData[i].stockLogList1[m].isReturn) { + ctx.fillText(that.newData[i].stockLogList1[m].discountAmount, that.returnRealSize(1875) , dataheigth1) + ctx.fillText((that.newData[i].stockLogList1[m].discountAmount * that.newData[i].stockLogList1[m].productCount), that.returnRealSize(2140) , dataheigth1) + } else { + ctx.fillText(that.newData[i].discountAmount, that.returnRealSize(1875) , dataheigth1) + ctx.fillText((that.newData[i].discountAmount * that.newData[i].stockLogList1[m].productCount), that.returnRealSize(2140) , dataheigth1) + } + // 横线 + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), dataheigth1+=that.returnRealSize(100)) + } + } + } + let lastHeight = 0 + if (printingMethod == '1') { + lastHeight = dataheigth + }else{ + lastHeight = dataheigth1 + } + ctx.fillText('合计:', that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + ctx.fillText(that.sales.productCount + '件', that.returnRealSize(1700) , lastHeight) + ctx.fillText(that.sales.totalAmount, that.returnRealSize(2200) , lastHeight) + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), lastHeight+=that.returnRealSize(100)) + ctx.draw(true) + + // 设置字体样式 + ctx.font = 'bold '+that.returnRealFontSize(70)+'px SimSun'; + // 设置文字颜色 + ctx.fillStyle = 'black'; + ctx.fillText('本单应收:' + that.sales.realAmount + '(' + this.convertToChineseNumeral(that.sales.realAmount) + ')', that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + + if (that.dealingsRecord.lastDebtAmount >= 0) { + ctx.fillText('之前欠款:' + that.dealingsRecord.lastDebtAmount, that.returnRealSize(1700) , lastHeight) + } else if (that.dealingsRecord.lastDebtAmount < 0) { + ctx.fillText('之前余额:' + Math.abs(that.dealingsRecord.lastDebtAmount), that.returnRealSize(1700) , lastHeight) + } else { + ctx.fillText('之前欠款:0', that.returnRealSize(1700) , lastHeight) + } + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), lastHeight+=that.returnRealSize(100)) + ctx.fillText('本单实收:' + that.sales.alreadyEarn + '(' + this.convertToChineseNumeral(that.sales.alreadyEarn) + ')', that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + if (that.dealingsRecord.balanceDue >= 0) { + ctx.fillText('累计欠款:' + that.dealingsRecord.balanceDue, that.returnRealSize(1700) , lastHeight) + } else if (that.dealingsRecord.balanceDue < 0) { + ctx.fillText('累计余额:' + Math.abs(that.dealingsRecord.balanceDue), that.returnRealSize(1700) , lastHeight) + } else { + ctx.fillText('累计欠款:0', that.returnRealSize(1700) , lastHeight) + } + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), lastHeight+=that.returnRealSize(100)) + ctx.draw(true) + // 设置字体样式 + ctx.font = 'bold '+that.returnRealFontSize(60)+'px SimSun'; + // 设置文字颜色 + ctx.fillStyle = 'black'; + + if (that.sales.noEarn >= 0) { + ctx.fillText('本单欠款:' + (that.sales.noEarn), that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + } else { + ctx.fillText('本单余额:' + Math.abs(that.sales.noEarn), that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + } + if (that.returnPrice > 0) { + ctx.fillText('退货数量:' + that.returnNum, that.returnRealSize(900) , lastHeight) + ctx.fillText('退货金额:' + that.returnPrice, that.returnRealSize(1700) , lastHeight) + } + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), lastHeight+=that.returnRealSize(100)) + if (that.sales.remark) { + ctx.fillText('订单备注:' + that.sales.remark, that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), lastHeight+=that.returnRealSize(100)) + } + ctx.fillText('店铺地址:' + this.addressArr, that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + if (this.shopId == '1820391948796694529' || this.shopId == '1848966744035692545' || this.shopId == '1850038419279974400') { + ctx.fillText('店铺电话:' + this.jinjuPhone, that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + } else if (this.shopId == '1834512626093264897' || this.shopId == '1810179818189361152') { + ctx.fillText('店铺电话:13191998128', that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + } else { + ctx.fillText('店铺电话:' + (uni.getStorageSync('shopOwnerPhone') ? uni.getStorageSync('shopOwnerPhone') : uni.getStorageSync('username')), that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + } + if (this.sales.companyName != null) { + ctx.fillText('发货方式:' + this.sales.companyName + ' ' + this.sales.companyPhone, that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + } + if (this.shopRemark.length > 0) { + for (let i = 0; i < this.shopRemark.length; i++) { + ctx.fillText(this.shopRemark[i], that.returnRealSize(20) , lastHeight+=that.returnRealSize(100)) + } + } + ctx.fillText('-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------', that.returnRealSize(20), lastHeight+=that.returnRealSize(100)) + ctx.draw(true) + let begineidth = that.returnRealSize(20) + let wenheight = lastHeight + that.returnRealSize(150) + lastHeight+=that.returnRealSize(150) + let qrarr = [] + let data = { + name : '店铺微信', + path : 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/8e305338798c4152a89e3351eaf6c84e.png', + } + qrarr.push(data) + let data1 = { + name : '微信收款码', + path : 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/3456337911cd4c759e4237da6aefaa01.png', + } + qrarr.push(data1) + let data2 = { + name : '银行收款码', + path : 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/d3f594face1e432fb9b4a0e4fd8ed685.png', + } + qrarr.push(data2) + for(let a = 0;a < qrarr.length; a++){ + setTimeout(ress=>{ + uni.downloadFile({ + url: qrarr[a].path, + success: (res2) => { + if (res2.statusCode === 200) { + ctx.fillText(qrarr[a].name, begineidth , wenheight) + ctx.drawImage(res2.tempFilePath, begineidth,lastHeight , that.returnRealSize(500), that.returnRealSize(500)); + ctx.draw(true) + begineidth += that.returnRealSize(640) + } + } + }); + },800 * (a + 1) + moretime) + } + setTimeout(ress=>{ + uni.canvasToTempFilePath({ + x: 0, + y: 0, + width: this.printWidth1, + height: this.printHeight1, + destWidth: this.printWidth1, + destHeight: this.printHeight1, + canvasId: 'myCanvas', + success: (res3) => { + this.canvasshow = false + this.tempFilePath = res3.tempFilePath + uni.previewImage({ + urls: [res3.tempFilePath] + }) + uni.hideLoading() + } + }); + },1000 * qrarr.length + moretime) + }, + isLetterOrDigit(character) { + if (/[a-zA-Z]/.test(character)) { + return 'Letter'; + } else if (/[0-9]/.test(character)) { + return 'Digit'; + } else { + return 'Neither'; + } + }, + //切换样式 + payTypeChange(e) { + for (let i = 0; i < this.payTypeList.length; i++) { + if (this.payTypeList[i].value == e) { + this.payType1 = e; + } + } + }, //传入组件的方法 hideQrcode() { this.modal_qr = false; @@ -985,24 +1597,37 @@ getPrintHeight() { let that = this; this.printHeight = 960 - + this.printHeight1 = 1900 + this.printWidth1 = 2500 + let scale = 0 + uni.getSystemInfo({ + success(res) { + scale = res.devicePixelRatio + } + }) if(this.printingMethod == '1'){ if(that.shopId == '1822829636942434305' || that.shopId == '1818888277105709056'){ for (let i = 0; i < that.newData.length; i++) { + this.printHeight1 += 300 this.printHeight += 100 this.printHeight += that.newData[i].sizePrintList.size * 90 + this.printHeight1 += that.newData[i].sizePrintList.size * 100 } }else{ for (let i = 0; i < that.newData.length; i++) { + this.printHeight1 += 300 this.printHeight += 90 this.printHeight += that.newData[i].sizePrintList.size * 40 + this.printHeight1 += that.newData[i].sizePrintList.size * 100 } } }else{ + this.printHeight1 += 200 for (let i = 0; i < that.newData.length; i++) { this.printHeight += 40 for (let m = 0; m < that.newData[i].stockLogList1.length; m++) { + this.printHeight1 += 200 this.printHeight += 40 } } @@ -1010,14 +1635,30 @@ if (that.qrArr.length > 0) { this.printHeight += 360 + this.printHeight1 += 800 } if (that.shopRemark.length > 0) { this.printHeight += that.shopRemark.length * 40 + this.printHeight1 += that.shopRemark.length * 100 } if (that.sales.remark) { this.printHeight += 100 + this.printHeight1 += 100 } - }, + if(this.printHeight1 > 11600){ + this.smailSize = ((this.printHeight1 - 11600) / 505).toFixed(2) + } + this.smailDcl = (this.printHeight1 / 2500).toFixed(2) + this.fontsmailDcl = ((this.printHeight1 - 2500) / 100).toFixed(2) + this.printHeight1 = 2500 + this.myCanvasHeight = this.printHeight1+'px' + + this.printWidth1 = (this.printWidth1 / this.smailDcl).toFixed(2) + this.myCanvasWidth = this.printWidth1+'px' + setTimeout(res => { + that.picOk = true + }, 1000) + }, //生成二维码 getQRCode() { let that = this @@ -1031,6 +1672,7 @@ this.$refs.uqrcode.toTempFilePath({ success: res => { data.path = res.tempFilePath + that.newQRList1.push(data) that.newQRList.push(data) }, fail: err => { @@ -1059,6 +1701,7 @@ let strCmd = '' let pageNum = 1 let Xindex = 0 + console.log('newQRList',that.newQRList) if (this.printingMethod == '0') { that.yNum = 405 } else { @@ -1323,13 +1966,16 @@ if (that.newData[i].stockLogList1[m].isReturn) { strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .stockLogList1[m].discountAmount) + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] + .stockLogList1[m].discountAmount * that.newData[i].stockLogList1[m].productCount)) } else { strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .discountAmount) + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] + .discountAmount * that.newData[i].stockLogList1[m].productCount)) } - strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] - .discountAmount * that.newData[i].stockLogList1[m].productCount)) + } else { if (that.newData[i].stockLogList1[m].isReturn) { if (that.newData[i].productName == that.newData[i].productSn) { @@ -1395,13 +2041,15 @@ if (that.newData[i].stockLogList1[m].isReturn) { strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .stockLogList1[m].discountAmount) + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] + .stockLogList1[m].discountAmount * that.newData[i].stockLogList1[m].productCount)) } else { strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .discountAmount) + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] + .discountAmount * that.newData[i].stockLogList1[m].productCount)) } - - strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] - .discountAmount * that.newData[i].stockLogList1[m].productCount)) + } } @@ -1478,14 +2126,14 @@ if (that.newData[i].stockLogList1[m].isReturn) { strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .stockLogList1[m].discountAmount) + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] + .stockLogList1[m].discountAmount * that.newData[i].stockLogList1[m].productCount)) } else { strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .discountAmount) + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] + .discountAmount * that.newData[i].stockLogList1[m].productCount)) } - - strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] - .discountAmount * that.newData[i].stockLogList1[m].productCount)) - } else { if (that.newData[i].stockLogList1[m].isReturn) { if (that.newData[i].productName == that.newData[i].productSn) { @@ -1549,13 +2197,12 @@ if (that.newData[i].stockLogList1[m].isReturn) { strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .stockLogList1[m].discountAmount) + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i].stockLogList1[m].discountAmount * that.newData[i].stockLogList1[m].productCount)) } else { strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .discountAmount) + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i].discountAmount * that.newData[i].stockLogList1[m].productCount)) } - - strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] - .discountAmount * that.newData[i].stockLogList1[m].productCount)) } } @@ -2272,7 +2919,7 @@ //店铺电话 strCmd += blesdk.addCPCLSETMAG(1, 1) - if (this.shopId == '1820391948796694529') { + if (this.shopId == '1820391948796694529' || this.shopId == '1848966744035692545' || this.shopId == '1850038419279974400') { if (that.yNum + 64 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); @@ -2423,8 +3070,6 @@ strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += 40), that.qrArr[i].level, '2', 4, that.qrArr[i].path) //二维码 - - } else { strCmd += blesdk.addCPCLSETMAG(1, 1) strCmd += blesdk.addCPCLText(that.countWidth(i, 900 / that.qrArr.length), (that.yNum -= @@ -2433,7 +3078,6 @@ 40), that .qrArr[i].level, '2', 4, that.qrArr[i].path) //二维码 - } if (that.qrArr.length == (i + 1)) { strCmd += blesdk.addCPCLPrint(); @@ -2462,6 +3106,26 @@ return match.replace(charToFind, charToReplace); }); }, + convertImageToBitmap(imagePath) { + return new Promise((resolve, reject) => { + const ctx = uni.createCanvasContext('myCanvas1', this); + uni.getImageInfo({ + src: imagePath, + success: (res) => { + // 设置画布的宽高为图片的宽高 + ctx.width = res.width; + ctx.height = res.height; + // 绘制图片 + ctx.drawImage(res.path, 0, 0, res.width, res.height); + // 将绘制的内容转为位图数据 + ctx.getImageData(0, 0, res.width, res.height, (imageData) => { + resolve(imageData); + }, reject); + }, + fail: reject + }); + }); + }, goPrint(type) { let strCmd = '' strCmd = blesdk.CreatCPCLPage(1080, 1040, 1, 1); @@ -2574,6 +3238,14 @@ }); } }, + createQRCode(qrCodeText) { + const that = this + // 生成二维码图片 + QRCode.toDataURL(qrCodeText, { errorCorrectionLevel: 'H' }, function(err, url) { + if (err) console.error(err) + that.qrCodeImage = url + }) + }, xierushuju() { let that = this; //写入数据 @@ -2727,6 +3399,93 @@ for (let j = 0; j < res.result.saleDetailDTOList .length; j++) { + + var isZiMu = false + var isNumber = false + var colorList = new Map() + var sizeNumList = [] + if(res.result.saleDetailDTOList[j].stockLogList1.length > 0){ + for (var m = 0; m < res.result.saleDetailDTOList[j].stockLogList1.length; m++) { + var attr = res.result.saleDetailDTOList[j].stockLogList1[m].attributeList + var newObj = JSON.parse(attr) + for (var as in newObj) { + if(as == '尺码' && that.isLetterOrDigit(newObj[as].replace(/码/g, '')) == 'Letter'){ + isZiMu = true + } + if(as == '尺码' && that.isLetterOrDigit(newObj[as].replace(/码/g, '')) == 'Digit'){ + isNumber = true + } + if(as == '尺码' && sizeNumList.indexOf(newObj[as].replace(/码/g, '')) == -1){ + sizeNumList.push(newObj[as].replace(/码/g, '')) + } + if(as == '颜色'){ + if(colorList.has(newObj[as])){ + colorList.get(newObj[as]).push(res.result.saleDetailDTOList[j].stockLogList1[m]) + }else{ + let listChild = [] + listChild.push(res.result.saleDetailDTOList[j].stockLogList1[m]) + colorList.set(newObj[as],listChild) + } + } + } + } + } + var newStockList = [] + if(isNumber){ + sizeNumList = sizeNumList.sort((a, b) => a - b); + colorList.forEach(function(value, key) { + for(var j = 0; j < sizeNumList.length; j++){ + for (var m = 0; m < value.length; m++) { + var newObj = JSON.parse(value[m].attributeList) + var size = '' + var color = '' + for (var as in newObj) { + if(as == '尺码'){ + size = newObj[as].replace(/码/g, '') + } + } + if(size == sizeNumList[j]){ + newStockList.push(value[m]) + value.splice(m,1) + break + } + } + } + if(value.length > 0){ + newStockList = newStockList.concat(value) + } + }) + res.result.saleDetailDTOList[j].stockLogList1 = newStockList + } + if(isZiMu){ + colorList.forEach(function(value, key) { + for(var j = 0; j < that.lettrList.length; j++){ + for (var m = 0; m < value.length; m++) { + var newObj = JSON.parse(value[m].attributeList) + var size = '' + var color = '' + for (var as in newObj) { + if(as == '尺码'){ + size = newObj[as].replace(/码/g, '') + } + } + if(size == that.lettrList[j]){ + newStockList.push(value[m]) + value.splice(m,1) + break + } + } + } + if(value.length > 0){ + newStockList = newStockList.concat(value) + } + }) + res.result.saleDetailDTOList[j].stockLogList1 = newStockList + } + + + + let isTure = true res.result.saleDetailDTOList[j].productCount = 0 for (let m = 0; m < res.result.saleDetailDTOList[j] @@ -2739,6 +3498,14 @@ res.result.saleDetailDTOList[j].stockLogList1[ m].discountAmount = res.result .saleDetailDTOList[j].discountAmount + let tableData = { + productSn:'【退】'+res.result.saleDetailDTOList[j].productSn, + productName:res.result.saleDetailDTOList[j].productName, + productCount:res.result.saleDetailDTOList[j].stockLogList1[m].productCount, + attributeList:res.result.saleDetailDTOList[j].stockLogList1[m].attributeList, + discountAmount:res.result.saleDetailDTOList[j].discountAmount + } + that.listHeng.push(tableData) } for (let i = 0; i < that.newData.length; i++) { if (that.newData[i].productId == res.result @@ -2769,11 +3536,16 @@ } else { this.tui.toast(res.message) } + console.log('1111') }) setTimeout(res => { let that = this for (let i = 0; i < this.newData.length; i++) { that.newData[i].sizeList = [] + var isZiMu = false + var isNumber = false + var sizeNumList = [] + var notNum = [] that.newData[i].sizePrintList = new Map() for (let j = 0; j < that.newData[i].stockLogList1.length; j++) { let discountAmount = that.newData[i].discountAmount @@ -2815,7 +3587,59 @@ i].stockLogList1[j].productCount + ':' + discountAmount) } } + if(as == '尺码' && that.isLetterOrDigit(newObj[as].replace(/码/g, '')) == 'Letter'){ + isZiMu = true + } + if(as == '尺码' && that.isLetterOrDigit(newObj[as].replace(/码/g, '')) == 'Digit'){ + isNumber = true + } + if(as == '尺码' && sizeNumList.indexOf(newObj[as].replace(/码/g, '')) == -1){ + if(as == '尺码' && that.isLetterOrDigit(newObj[as].replace(/码/g, '')) == 'Digit'){ + sizeNumList.push(newObj[as].replace(/码/g, '')) + }else{ + if(notNum.indexOf(newObj[as].replace(/码/g, '')) == -1){ + notNum.push(newObj[as].replace(/码/g, '')) + } + } + + } + } + } + if(notNum.length > 0){ + sizeNumList = sizeNumList.concat(notNum) + } + if(isZiMu){ + let newStockList = [] + for(var j = 0; j < that.lettrList.length; j++){ + for (var m = 0; m < that.newData[i].sizeList.length; m++) { + if(that.newData[i].sizeList[m] == that.lettrList[j]){ + newStockList.push(that.newData[i].sizeList[m]) + that.newData[i].sizeList.splice(m,1) + break + } + } + } + if(that.newData[i].sizeList.length > 0){ + newStockList = newStockList.concat(that.newData[i].sizeList) + } + that.newData[i].sizeList = newStockList + } + if(isNumber){ + let newStockList = [] + sizeNumList = sizeNumList.sort((a, b) => a - b); + for(var j = 0; j < sizeNumList.length; j++){ + for (var m = 0; m < that.newData[i].sizeList.length; m++) { + if(that.newData[i].sizeList[m] == sizeNumList[j]){ + newStockList.push(that.newData[i].sizeList[m]) + that.newData[i].sizeList.splice(m,1) + break + } + } } + if(that.newData[i].sizeList.length > 0){ + newStockList = newStockList.concat(that.newData[i].sizeList) + } + that.newData[i].sizeList = newStockList } //this.newData[i].sizeList = [...new Set(this.newData[i].sizeList)] } @@ -3141,7 +3965,9 @@ - + .uni-select{ + border: none !important; + } @@ -3334,4 +4160,10 @@ background-color: #cee1fd; border-radius: 10px; } + .uni-table-td{ + font-size: 11px !important; + } + .uni-table-th{ + font-size: 11px !important; + } \ No newline at end of file diff --git a/package1/inventory/addGoods.vue b/package1/inventory/addGoods.vue index 50d0792..92587e1 100644 --- a/package1/inventory/addGoods.vue +++ b/package1/inventory/addGoods.vue @@ -93,7 +93,7 @@ - + @@ -971,7 +971,7 @@ } else { this.formData.purchasePrice = e.target.value console.log('改变', this.formData) - if (this.dataList.id) { + if (this.dataList.id == undefined) { uni.hideLoading() return } diff --git a/package1/staff/addStaff.vue b/package1/staff/addStaff.vue index 14bccb0..baee7c3 100644 --- a/package1/staff/addStaff.vue +++ b/package1/staff/addStaff.vue @@ -14,6 +14,7 @@ 保存 + @@ -30,6 +31,7 @@ }, username:'', id: '', + type:'', typeList: [{ value: 0, text: "管理员" @@ -96,6 +98,15 @@ }, (reason) => { }) + }, + deleteSubmit() { + let ids = [] + ids.push(this.id) + this.tui.request("/app/common/user/delByIds", "POST", { + ids: ids + }, false, true).then((res1) => { + uni.navigateBack() + }).catch((res) => {}) } } }