diff --git a/package1/.DS_Store b/package1/.DS_Store index 3663eb1..ce322fa 100644 Binary files a/package1/.DS_Store and b/package1/.DS_Store differ diff --git a/package1/AI/AIHangOrderList.vue b/package1/AI/AIHangOrderList.vue index ccc4af4..87b427a 100644 --- a/package1/AI/AIHangOrderList.vue +++ b/package1/AI/AIHangOrderList.vue @@ -55,9 +55,10 @@ - {{item.userName}} + 客户:{{item.userName}} - {{item.createTime}} + {{item.createTime}} + 操作人:{{item.createByName}} 识别中... @@ -68,9 +69,9 @@ - + 语音备注 扫码选货 去开单 @@ -88,7 +89,7 @@ - {{items.productName}}({{items.productSn}}) + 【销】{{items.productName}}({{items.productSn}}) 库存中没有货号为:0001的商品 @@ -141,7 +142,7 @@ style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"> - *长按“语音”按钮录入,系统将自动识别 @@ -304,6 +305,7 @@ attrNameList: [], temporaryList: [], carList: [], + returnList:new Map(), specsList: [], evalue: [], attributeList: [], @@ -832,7 +834,7 @@ } }) }, - goGoods(item){ + async goGoods(item){ var that = this; if(item.aiNotRecognition != '' && item.aiNotRecognition != null){ uni.showModal({ @@ -855,10 +857,49 @@ } }) }else{ - that.goSaleGoods(item) + await this.getReturnOrder(item.id) + uni.showModal({ + title: "提示", + content: '确认去开单吗?', + success: function(res) { + if (res.confirm) { + that.goSaleGoods(item) + } + } + }) } }, + async getReturnOrder(id) { + let that = this; + await this.tui.request("/app/return/list", "post", { + remark: 3, + saleId: id + }, false, false).then((res) => { + if (res.code == 200 && res.result != null && res.result != undefined) { + if (res.result != '') { + res.result.forEach(item => { + this.tui.request("/app/return/get/" + item.id, "GET", null, false,false).then((res) => { + if (res.code == 200 && res.result != null && res.result != undefined) { + for(let i=0;i {}) + }) + } + } else { + this.tui.toast(res.message) + } + }) + }, sliceMsg(val) { var name = '' if (typeof(val) == 'string') { @@ -872,69 +913,55 @@ //带参数跳转到开单页 goSaleGoods(item) { let dataList = [] - - if(item.saleDetailDTOList){ + if(item.saleDetailDTOList == null || item.saleDetailDTOList == ''){ + item.saleDetailDTOList = [] + } + this.returnList.forEach(function(value, key) { + item.saleDetailDTOList.push(value) + }) + if (item.saleDetailDTOList) { for (let i = 0; i < item.saleDetailDTOList.length; i++) { - + let obj = {} let attrMap = new Map() let newSaleDetailDTOList = [] let num = 0 - for(let m = 0; m < item.saleDetailDTOList[i].stockLogList1.length; m++){ - if(this.isInventory == true && item.aiFlag != "0"){ - if(item.saleDetailDTOList[i].stockLogList1[m].stockCount != null){ - if(attrMap.has(item.saleDetailDTOList[i].stockLogList1[m].attributeList) == true){ - let hasCount = attrMap.get(item.saleDetailDTOList[i].stockLogList1[m].attributeList) - newSaleDetailDTOList[hasCount].productCount = Number(newSaleDetailDTOList[hasCount].productCount) + Number(item.saleDetailDTOList[i].stockLogList1[m].productCount) - }else{ - item.saleDetailDTOList[i].stockLogList1[m].name = this.sliceMsg(item.saleDetailDTOList[i].stockLogList1[m].attributeList) - newSaleDetailDTOList.push(item.saleDetailDTOList[i].stockLogList1[m]) - attrMap.set(item.saleDetailDTOList[i].stockLogList1[m].attributeList,num) - num++ - } - } - }else{ - if(attrMap.has(item.saleDetailDTOList[i].stockLogList1[m].attributeList) == true){ - let hasCount = attrMap.get(item.saleDetailDTOList[i].stockLogList1[m].attributeList) - newSaleDetailDTOList[hasCount].productCount = Number(newSaleDetailDTOList[hasCount].productCount) + Number(item.saleDetailDTOList[i].stockLogList1[m].productCount) - }else{ - item.saleDetailDTOList[i].stockLogList1[m].name = this.sliceMsg(item.saleDetailDTOList[i].stockLogList1[m].attributeList) - newSaleDetailDTOList.push(item.saleDetailDTOList[i].stockLogList1[m]) - attrMap.set(item.saleDetailDTOList[i].stockLogList1[m].attributeList,num) - num++ - } + + for (let m = 0; m < item.saleDetailDTOList[i].stockLogList1.length; m++) { + if (attrMap.has(item.saleDetailDTOList[i].stockLogList1[m].attributeList) == true) { + let hasCount = attrMap.get(item.saleDetailDTOList[i].stockLogList1[m].attributeList) + newSaleDetailDTOList[hasCount].productCount = Number(newSaleDetailDTOList[hasCount] + .productCount) + Number(item.saleDetailDTOList[i].stockLogList1[m].productCount) + } else { + item.saleDetailDTOList[i].stockLogList1[m].name = this.sliceMsg(item.saleDetailDTOList[i] + .stockLogList1[m].attributeList) + newSaleDetailDTOList.push(item.saleDetailDTOList[i].stockLogList1[m]) + attrMap.set(item.saleDetailDTOList[i].stockLogList1[m].attributeList, num) + num++ } - - } - - if(newSaleDetailDTOList.length != 0){ - obj.saleDetailQueryDTO = newSaleDetailDTOList - obj.num = 0 - obj.id = item.saleDetailDTOList[i].productId - obj.price = item.saleDetailDTOList[i].price - obj.lsprice = item.saleDetailDTOList[i].price - obj.categoryId=item.saleDetailDTOList[i].categoryId - obj.zPrice = item.saleDetailDTOList[i].discountAmount - obj.unitPrice = item.saleDetailDTOList[i].discountAmount || item.saleDetailDTOList[i].wholesalePrice - obj.productName = item.saleDetailDTOList[i].productName - obj.productPicture = item.saleDetailDTOList[i].productPicture+'?time='+new Date().getTime() - obj.productSn = item.saleDetailDTOList[i].productSn - obj.wholesalePrice = item.saleDetailDTOList[i].wholesalePrice - obj.saleId = item.id - obj.remark = item.remark - obj.xsyId = item.createBy - obj.createByName = item.createByName - dataList.push(obj) - }else{ - obj.saleId = item.id - obj.remark = item.remark - obj.xsyId = item.createBy - obj.createByName = item.createByName - dataList.push(obj) } + obj.saleDetailQueryDTO = newSaleDetailDTOList + obj.num = 0 + obj.id = item.saleDetailDTOList[i].productId + obj.price = item.saleDetailDTOList[i].price + obj.lsprice = item.saleDetailDTOList[i].price + obj.categoryId = item.saleDetailDTOList[i].categoryId + obj.zPrice = item.saleDetailDTOList[i].discountAmount + obj.unitPrice = item.saleDetailDTOList[i].discountAmount || item.saleDetailDTOList[i] + .wholesalePrice + obj.productName = item.saleDetailDTOList[i].productName + obj.productPicture = item.saleDetailDTOList[i].productPicture + '?time=' + new Date().getTime() + obj.productSn = item.saleDetailDTOList[i].productSn + obj.wholesalePrice = item.saleDetailDTOList[i].wholesalePrice + obj.returnPrice = item.saleDetailDTOList[i].returnPrice + obj.saleId = item.id + obj.remark = item.remark + obj.xsyId = item.createBy + obj.createByName = item.createByName + dataList.push(obj) } - }else{ + } else { let obj = {} obj.num = 0 obj.price = 0 @@ -953,6 +980,7 @@ sort: "", }, false, false).then((res) => { if (res.code == 200) { + this.returnList = new Map() uni.setStorageSync('khName', JSON.stringify(res.result.records[0])) uni.setStorageSync('carList1', JSON.stringify(dataList)) uni.setStorageSync('hangOrder', true) @@ -964,8 +992,37 @@ }) }, //点击切换折叠状态 - clickCollapse(item) { + clickCollapse(item,index) { item.isCollapse = !item.isCollapse + this.getReturnOrders(item.id,index) + }, + //退款接口 + async getReturnOrders(id,index) { + let that = this; + this.regList[index].returnList = [] + await this.tui.request("/app/return/list", "post", { + remark: 3, + saleId: id + }, false, false).then((res1) => { + if (res1.code == 200 && res1.result != null && res1.result != undefined) { + if (res1.result != '') { + this.inventoryList = res1.result + this.inventoryList.forEach(item => { + this.tui.request("/app/return/get/" + item.id, "GET", null, false, + false).then((res) => { + if (res.code == 200 && res.result != null && res.result != + undefined) { + this.regList[index].returnList.push(res.result.saleDetailDTOList) + } + }).catch((res) => {}) + }) + + } + } else { + this.tui.toast(res.message) + } + }) + console.log('returnList',this.regList) }, //查看大图 largeImg(img) { @@ -1401,7 +1458,8 @@ border-radius: 10px; margin: 0 auto 20rpx; overflow: hidden; - display: block; + display: block; + position: relative; } .image-box { diff --git a/package1/AI/AIInventoryList.vue b/package1/AI/AIInventoryList.vue index 46bdde6..37f542e 100644 --- a/package1/AI/AIInventoryList.vue +++ b/package1/AI/AIInventoryList.vue @@ -118,7 +118,8 @@ this.tui.request("/app/purchase/getPurchaseList", "POST", { pageNum: this.pageNum, pageSize: 10, - isAiList: 1 + isAiList: 1, + fromWhere:0 }, false, false).then((res) => { this.status = 'nomore'; if (this.pages == 1) { diff --git a/package1/AI/AIPicture.vue b/package1/AI/AIPicture.vue index c35b781..a80b71b 100644 --- a/package1/AI/AIPicture.vue +++ b/package1/AI/AIPicture.vue @@ -78,9 +78,9 @@ - + 提示:建议使用原相机拍照并在相册内截图后上传 - 拍照 + 从相册选择 取消 diff --git a/package1/AI/AiChangeGoods.vue b/package1/AI/AiChangeGoods.vue index 6ce0ae3..dac6173 100644 --- a/package1/AI/AiChangeGoods.vue +++ b/package1/AI/AiChangeGoods.vue @@ -28,7 +28,7 @@ - {{item.productName}} + {{item.productName == null ?'':item.productName}} (已下架) {{item.productSn}} diff --git a/package1/AI/AiChat.vue b/package1/AI/AiChat.vue index 00a9a55..f204739 100644 --- a/package1/AI/AiChat.vue +++ b/package1/AI/AiChat.vue @@ -76,7 +76,7 @@ style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"> - + 确认无误 @@ -154,9 +154,9 @@ '四': 4, '五': 5, '六': 6, '七': 7, '八': 8, '九': 9,'杠':'-','刚':'-','军色':'均色','叉':'X','井':'#', '时间':'10件','事件':'10件','世间':'10件','实践':'10件','实件':'10件', - '景':'#','警':'#','颈':'#','括号':'货号' + '景':'#','警':'#','颈':'#','括号':'货号','名城':'名称','明城':'名称','名成':'名称','名程':'名称', }; - const regex = /(零|一|二|两|三|四|五|六|七|八|九|杠|刚|军色|叉|井|时间|事件|世间|实践|实件|景|警|颈|括号)/g; + const regex = /(零|一|二|两|三|四|五|六|七|八|九|杠|刚|军色|叉|井|时间|事件|世间|实践|实件|景|警|颈|括号|名城|名程|名成|明城)/g; return str.replace(regex, match => chineseNumToArabic[match]); }, inputSaveText(){ diff --git a/package1/AI/addAiList.vue b/package1/AI/addAiList.vue index cbe3016..ba50ef3 100644 --- a/package1/AI/addAiList.vue +++ b/package1/AI/addAiList.vue @@ -72,11 +72,13 @@ 图片上传 - + - + @@ -121,10 +123,12 @@ - + 语音录入 - + 确定 @@ -139,21 +143,25 @@ 示例: - + 发货人: 发货电话: - - + + 收货人: 收货电话: - + 重量: 数量: - - + + 小费: 到达站: @@ -187,25 +195,26 @@ export default { data() { return { - voiceText:'', + voiceText: '', isVoice: false, - voiceData:{}, + voiceData: {}, recordState: false, productPicture: [], + messages:['消息1', '消息2', '消息3'] } }, onShow() { uni.authorize({ - scope: 'scope.record', - success() { - - },fail(){ + scope: 'scope.record', + success() { + + }, + fail() { this.tui.toast("您未授权,语音功能可能会出现错误") } }) }, onLoad(option) { - }, methods: { //按住语音识别,开始 @@ -225,197 +234,63 @@ manager.stop() }, extractInfo(str) { - const info = {}; - const regexes = [ - { name: 'senderName', regex: /发货人:(.*?),/ }, - { name: 'senderPhone', regex: /发货电话:(.*?),/ }, - { name: 'receiverName', regex: /收货人:(.*?),/ }, - { name: 'receiverPhone', regex: /收货电话:(.*?),/ }, - { name: 'weight', regex: /重量:(.*?),/ }, - { name: 'count', regex: /数量:(.*?),/ }, - { name: 'methodOfSettlement', regex: /结算方式:(.*?),/ }, - { name: 'tips', regex: /小费:(.*?),/ }, - { name: 'arrivalStation', regex: /到达站:(.*)/ } - ]; - - regexes.forEach(({name, regex}) => { - const match = str.match(regex); - if (match && match[1]) { - // 去除可能的前后空格 - info[name] = match[1].trim(); - } - }); - - return info; + const info = {}; + const regexes = [{ + name: 'senderName', + regex: /发货人:(.*?),/ + }, + { + name: 'senderPhone', + regex: /发货电话:(.*?),/ + }, + { + name: 'receiverName', + regex: /收货人:(.*?),/ + }, + { + name: 'receiverPhone', + regex: /收货电话:(.*?),/ + }, + { + name: 'weight', + regex: /重量:(.*?),/ + }, + { + name: 'count', + regex: /数量:(.*?),/ + }, + { + name: 'methodOfSettlement', + regex: /结算方式:(.*?),/ + }, + { + name: 'tips', + regex: /小费:(.*?),/ + }, + { + name: 'arrivalStation', + regex: /到达站:(.*)/ + } + ]; + + regexes.forEach(({ + name, + regex + }) => { + const match = str.match(regex); + if (match && match[1]) { + // 去除可能的前后空格 + info[name] = match[1].trim(); + } + }); + + return info; }, - yuyinChange(){ + yuyinChange() { console.log("yuyin") this.isVoice = false }, - getVoiceData(){ - let that = this; - if (this.voiceText == '') { - this.tui.toast('识别内容不能为空') - return - } - let convertedStr = this.voiceText; - if (convertedStr.indexOf(',发货人') != -1) { - convertedStr = convertedStr.replace(/,发货人/g, '发货人') - } - if (convertedStr.indexOf('发货人,') != -1) { - convertedStr = convertedStr.replace(/发货人,/g, '发货人') - } - if (convertedStr.indexOf('发货人::') != -1) { - convertedStr = convertedStr.replace(/发货人::/g, '发货人') - } - if (convertedStr.indexOf('发货人:') != -1) { - convertedStr = convertedStr.replace(/发货人:/g, '发货人') - } - if (convertedStr.indexOf('发货人') != -1) { - convertedStr = convertedStr.replace(/发货人/g, '发货人:') - } - if (convertedStr.indexOf(',发货电话') != -1) { - convertedStr = convertedStr.replace(/,发货电话/g, '发货电话') - } - if (convertedStr.indexOf('发货电话,') != -1) { - convertedStr = convertedStr.replace(/发货电话,/g, '发货电话') - } - if (convertedStr.indexOf('发货电话::') != -1) { - convertedStr = convertedStr.replace(/发货电话::/g, '发货电话') - } - if (convertedStr.indexOf('发货电话:') != -1) { - convertedStr = convertedStr.replace(/发货电话:/g, '发货电话') - } - if (convertedStr.indexOf('发货电话') != -1) { - convertedStr = convertedStr.replace(/发货电话/g, ',发货电话:') - } - if (convertedStr.indexOf(',收货人') != -1) { - convertedStr = convertedStr.replace(/,收货人/g, '收货人') - } - if (convertedStr.indexOf('收货人,') != -1) { - convertedStr = convertedStr.replace(/收货人,/g, '收货人') - } - if (convertedStr.indexOf('收货人::') != -1) { - convertedStr = convertedStr.replace(/收货人::/g, '收货人') - } - if (convertedStr.indexOf('收货人:') != -1) { - convertedStr = convertedStr.replace(/收货人:/g, '收货人') - } - if (convertedStr.indexOf('收货人') != -1) { - convertedStr = convertedStr.replace(/收货人/g, ',收货人:') - } - - if (convertedStr.indexOf(',收货电话') != -1) { - convertedStr = convertedStr.replace(/,收货电话/g, '收货电话') - } - if (convertedStr.indexOf('收货电话,') != -1) { - convertedStr = convertedStr.replace(/收货电话,/g, '收货电话') - } - if (convertedStr.indexOf('收货电话::') != -1) { - convertedStr = convertedStr.replace(/收货电话::/g, '收货电话') - } - if (convertedStr.indexOf('收货电话:') != -1) { - convertedStr = convertedStr.replace(/收货电话:/g, '收货电话') - } - if (convertedStr.indexOf('收货电话') != -1) { - convertedStr = convertedStr.replace(/收货电话/g, ',收货电话:') - } - - if (convertedStr.indexOf(',到达站') != -1) { - convertedStr = convertedStr.replace(/,到达站/g, '到达站') - } - if (convertedStr.indexOf('到达站,') != -1) { - convertedStr = convertedStr.replace(/到达站,/g, '到达站') - } - if (convertedStr.indexOf('到达站::') != -1) { - convertedStr = convertedStr.replace(/到达站::/g, '到达站') - } - if (convertedStr.indexOf('到达站:') != -1) { - convertedStr = convertedStr.replace(/到达站:/g, '到达站') - } - if (convertedStr.indexOf('到达站') != -1) { - convertedStr = convertedStr.replace(/到达站/g, ',到达站:') - } - - if (convertedStr.indexOf(',重量') != -1) { - convertedStr = convertedStr.replace(/,重量/g, '重量') - } - if (convertedStr.indexOf('重量,') != -1) { - convertedStr = convertedStr.replace(/重量,/g, '重量') - } - if (convertedStr.indexOf('重量::') != -1) { - convertedStr = convertedStr.replace(/重量::/g, '重量') - } - if (convertedStr.indexOf('重量:') != -1) { - convertedStr = convertedStr.replace(/重量:/g, '重量') - } - if (convertedStr.indexOf('重量') != -1) { - convertedStr = convertedStr.replace(/重量/g, ',重量:') - } - - if (convertedStr.indexOf(',数量') != -1) { - convertedStr = convertedStr.replace(/,数量/g, '数量') - } - if (convertedStr.indexOf('数量,') != -1) { - convertedStr = convertedStr.replace(/数量,/g, '数量') - } - if (convertedStr.indexOf('数量::') != -1) { - convertedStr = convertedStr.replace(/数量::/g, '数量') - } - if (convertedStr.indexOf('数量:') != -1) { - convertedStr = convertedStr.replace(/数量:/g, '数量') - } - if (convertedStr.indexOf('数量') != -1) { - convertedStr = convertedStr.replace(/数量/g, ',数量:') - } - - if (convertedStr.indexOf(',结算方式') != -1) { - convertedStr = convertedStr.replace(/,结算方式/g, '结算方式') - } - if (convertedStr.indexOf('结算方式,') != -1) { - convertedStr = convertedStr.replace(/结算方式,/g, '结算方式') - } - if (convertedStr.indexOf('结算方式::') != -1) { - convertedStr = convertedStr.replace(/结算方式::/g, '结算方式') - } - if (convertedStr.indexOf('结算方式:') != -1) { - convertedStr = convertedStr.replace(/结算方式:/g, '结算方式') - } - if (convertedStr.indexOf('结算方式') != -1) { - convertedStr = convertedStr.replace(/结算方式/g, ',结算方式:') - } - - if (convertedStr.indexOf(',小费') != -1) { - convertedStr = convertedStr.replace(/,小费/g, '小费') - } - if (convertedStr.indexOf('小费,') != -1) { - convertedStr = convertedStr.replace(/小费,/g, '小费') - } - if (convertedStr.indexOf('小费::') != -1) { - convertedStr = convertedStr.replace(/小费::/g, '小费') - } - if (convertedStr.indexOf('小费:') != -1) { - convertedStr = convertedStr.replace(/小费:/g, '小费') - } - if (convertedStr.indexOf('小费') != -1) { - convertedStr = convertedStr.replace(/小费/g, ',小费:') - } - convertedStr = this.spliceMsg(convertedStr) - this.voiceData = this.extractInfo(convertedStr); - if(this.voiceData.weight){ - this.voiceData.weight = this.voiceData.weight.replace(/[^0-9]/g, ""); - } - if(this.voiceData.count){ - this.voiceData.count = this.voiceData.count.replace(/[^0-9]/g, ""); - } - - this.voiceData.freight = this.voiceData.weight * this.voiceData.count - if(this.voiceData.arrivalStation.indexOf('。') != -1){ - - this.voiceData.arrivalStation = this.voiceData.arrivalStation.replace(/\。/g, '') - - } - this.$forceUpdate() + getVoiceData() { this.$refs.popup.close() }, spliceMsg(res) { @@ -440,7 +315,7 @@ manager.onStop = (res) => { that.voiceText = res.result } - + // 识别错误事件 manager.onError = (res) => { if (res.retcode == '-30011') { @@ -472,16 +347,16 @@ success(res) { uni.showLoading({ title: '加载中...', - mask:true + mask: true }) - for(let i=0;i{ + await setTimeout(res => { uni.hideLoading(); - },1000) + }, 1000) }, } } @@ -538,9 +413,10 @@ font-size: 36rpx; color: #fff; display: flex; - z-index:99 + z-index: 99 } - .circle{ + + .circle { width: 40rpx; height: 40rpx; text-align: center; @@ -551,12 +427,14 @@ font-size: 22rpx; margin-top: 20rpx; } - .content{ + + .content { display: flex; height: 80rpx; line-height: 80rpx; } - .input-box{ + + .input-box { width: 100%; height: 60rpx; line-height: 60rpx; @@ -565,9 +443,11 @@ border-bottom: 1px solid #eee; padding-left: 10px; } - .name-box{ + + .name-box { width: 20%; } + .voice-popup-content { align-items: center; justify-content: center; @@ -577,18 +457,18 @@ height: 720rpx; background-color: #fff; } - + .voice-popup-title { font-size: 36rpx; font-weight: bold; text-align: center; position: relative; } - + .voice-popup-container { margin-top: 20rpx; } - + .voice-popup-bottom { display: flex; height: 80rpx; @@ -596,17 +476,17 @@ line-height: 80rpx; margin-top: 30rpx; } - + .voice-popup-btn { flex: 1; text-align: center; background: linear-gradient(90deg, #FF9797, #FFC1E0); } - + .voice-popup-btn:last-child { background: linear-gradient(90deg, #60F3FF, #088FEB); } - + .voice-model { width: 300rpx; height: 300rpx; @@ -623,13 +503,13 @@ margin-left: -150rpx; z-index: 999; } - + .voice-model img { width: 200rpx; height: 200rpx; margin: 0 auto; } - + .voice-btn { position: absolute; bottom: -250rpx; @@ -639,6 +519,7 @@ background: #eee; border-radius: 50%; } + .mask-model { width: 60%; height: 100rpx; @@ -655,7 +536,8 @@ border-radius: 5px; z-index: 99; } - .upload-img{ + + .upload-img { width: 160rpx; height: 160rpx; } diff --git a/package1/AI/voiceInventory.vue b/package1/AI/voiceInventory.vue index 8e5541c..30fdc13 100644 --- a/package1/AI/voiceInventory.vue +++ b/package1/AI/voiceInventory.vue @@ -5,31 +5,32 @@ 供应商 - + - - - 生成货号 - - - - - - - - 货号规则 - + + + 生成货号 + + + + + + + + 货号规则 + @@ -51,7 +52,7 @@ - + @@ -61,40 +62,61 @@ AI语音入库 - 您可以语音录入商品进行识别入库 + + 补货-根据货号模糊搜索 + + + 上传提示图 - + - + + + + - + 长按编辑 + + - - + 暂无图片 + - + 删除 - 合并 + 合并 + + + + 上传多图 + + {{value[1].productPictures.length}} - - - 上传多图 - - {{value[1].productPictures.length}} - @@ -108,16 +130,17 @@ 品名: - - 货号: - + style="height: 55rpx;border-bottom: 1px solid #eee;color:#777;width: 318rpx;padding-left: 20rpx;"> + 分类: - - - 语音录入 + + + 语音录入 @@ -166,15 +189,20 @@ - - - - - - - - + - + @change="GoodsNumChange($event,value,values[0])" /> --> + + + - + + + + + + @@ -248,10 +276,17 @@ - + 备注 - + *长按“语音”按钮录入,系统将自动识别 @@ -559,19 +601,119 @@ - - - - - - - - - - - - 更换图片 - + + + + + + + + *长按可更换图片 + + + + + + 温馨提示 + + + 如果您的入库单为电子版,或者查看入库单不方便,可以点击下方“+”号上传图片,对照进行语音入库,已经上传的图片可“长按更换” + + + + + + + 语音录入 + + 关闭 + + + + + 示例:货号0237,数量10件,单价88,名称:裙子,批发价:12 + + + + + *长按“语音”按钮录入,系统将自动识别 + + + 清空 + 确认 + 语音 + + + + + + + + + 查询到多个商品 + + + + + + 暂无图片 + + + + {{item.productSn}} + (已下架) + + {{item.productName == null ?'':item.productName}} + + + {{item.inStorageStatus==0?'待入库':item.purchasePrice == null ?'新商品':item.purchasePrice}} + 采购价 + + + {{item.wholesalePrice}} + 批发价 + + + {{item.price}} + 零售价 + + + {{item.stockCount}} + 库存 + + + + + + + + + + + + + + + + + + + 更换图片 + @@ -598,11 +740,14 @@ isVoice: false, allChangeNum: 0, voiceText: '', + voiceText1: '', khName: [], carList: new Map(), remark: '', + voiceGetOneData: false, otherPay: '', noPay: 0, + promptImg: '', alreadyPay: '', realAmount: 0, shouldPay: '', @@ -613,57 +758,61 @@ recordState: false, goodsDetail: [], temporaryList: [], - zNum: 0, - snList:[], - carList1: [], - zhuImg:'', - productNum: null, - prefixRule:'', - numRule:'', - yuedikou:0, - leijiqiankuan:0, - productId: '', - oneGoodsId:'', - goodsId:'', + zNum: 0, + snList: [], + carList1: [], + zhuImg: '', + productNum: null, + prefixRule: '', + numRule: '', + yuedikou: 0, + leijiqiankuan: 0, + productId: '', + oneGoodsId: '', + showTan: false, + currentPopupIndex: 0, + moreData: [], + goodsId: '', pageOldTemList: [], oldTemList: [], attrList: [], goodsList: [], mergeId: '', newTemList: [], - pecsList: [], - childrenId:'', - isGenerateSnRadio:1, - productPictures:[], + pecsList: [], + single: '', + childrenId: '', + isGenerateSnRadio: 1, + productPictures: [], categoryText: '', dataObj: new Map(), isPlusAndMinus: false, indexList: [], evalue: [], attributeValue: [], - specifications: '', - current:0, - swiperDotIndex:0, - zhiqianqiankuan:0, + specifications: '', + current: 0, + swiperDotIndex: 0, + zhiqianqiankuan: 0, currentAnchor: '', temporaryNum: 0, - isBottom: false, - isGenerateSn: [{ - value: '0', - name: '生成' - }, - { - value: '1', - name: '不生成' - } - ], - snName:'ty', - defaultList:[{ - name:'颜色', - value:[] - },{ - name:'尺码', - value:[] + isBottom: false, + isGenerateSn: [{ + value: '0', + name: '生成' + }, + { + value: '1', + name: '不生成' + } + ], + snName: 'ty', + defaultList: [{ + name: '颜色', + value: [] + }, { + name: '尺码', + value: [] }], temporary: [] //修改单个规格值临时存放要修改的对象 } @@ -682,13 +831,23 @@ }, onShow() { uni.authorize({ - scope: 'scope.record', - success() { - - },fail(){ + scope: 'scope.record', + success() { + + }, + fail() { this.tui.toast("您未授权,语音功能可能会出现错误") } }) + uni.authorize({ + scope: 'scope.writePhotosAlbum', + success() { + + }, + fail() { + this.tui.toast("您未授权,图片上传功能可能会出现错误") + } + }) uni.showLoading({ title: '加载中...' }) @@ -748,17 +907,17 @@ this.carList1 = this.carList1 } - if(this.carList1 != ''){ + if (this.carList1 != '') { isTrue = true } this.khName = JSON.parse(JSON.stringify(this.khName)) || '' - if(this.khName != ''){ - if(this.khName.noEarn != null && this.zhiqianqiankuan != this.khName.noEarn){ + if (this.khName != '') { + if (this.khName.noEarn != null && this.zhiqianqiankuan != this.khName.noEarn) { isTrue = true } - if(this.khName.noEarn == null){ + if (this.khName.noEarn == null) { this.zhiqianqiankuan = 0 - }else{ + } else { this.zhiqianqiankuan = this.khName.noEarn } } @@ -775,12 +934,12 @@ productName: this.carList1[i].productName, wholesalePrice: this.carList1[i].wholesalePrice || 0, categoryName: this.carList1[i].categoryName, - categoryId: this.carList1[i].categoryId, + categoryId: this.carList1[i].categoryId, attrId: this.carList1[i].attrId, lsprice: this.carList1[i].price || 0, productPicture: this.carList1[i].productPicture, - productSn: this.carList1[i].productSn, - productPictures:[], + productSn: this.carList1[i].productSn, + productPictures: [], stockLogList: new Map(), stockLogList1: [] } @@ -849,14 +1008,14 @@ productName: this.carList1[i].productName, wholesalePrice: this.carList1[i].wholesalePrice || 0, categoryName: this.carList1[i].categoryName, - categoryId: this.carList1[i].categoryId, + categoryId: this.carList1[i].categoryId, attrId: this.carList1[i].attrId, lsprice: this.carList1[i].price || 0, productPicture: this.carList1[i].productPicture, productSn: this.carList1[i].productSn, stockLogList: new Map(), - stockLogList1: [], - productPictures:[], + stockLogList1: [], + productPictures: [], name: '' } for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { @@ -885,7 +1044,7 @@ this.carList1 = [] uni.removeStorageSync('carList1') - if(isTrue){ + if (isTrue) { this.getAllPrice() } if (this.carList1 != '') { @@ -901,200 +1060,249 @@ }) }, onLoad(options) { - this.userType = uni.getStorageSync('type') - this.getSnList() - this.getShopCategory() + this.userType = uni.getStorageSync('type') + this.getSnList() + this.getShopCategory() this.getDefaultCategory() + this.getMonth() }, - methods: { - //店铺规格库 - getShopCategory(){ - this.tui.request("/app/productCategory/getCategoryOfshop", "POST", {}, false, true).then((res) => { - if (res.code == 200) { - //this.specifiList[0] this.defaultList[1] 尺码 - //this.specifiList[1] this.defaultList[0] 颜色 - this.specifiList = res.result.productAttributeOfAddVos - if(this.specifiList[0].attributeName == '尺码'){ - for(let m=0;m{ - if(isysTrue){ - this.defaultList[1].value.push(this.specifiList[0].productAttributeValueVoList[m]) - } - }) - } - }else{ - for(let m=0;m{ - if(isTrue){ - this.defaultList[0].value.push(this.specifiList[0].productAttributeValueVoList[m]) - } - }) - - } - } - if(this.specifiList[1].attributeName == '尺码'){ - for(let m=0;m{ - if(isysTrue){ - this.defaultList[1].value.push(this.specifiList[1].productAttributeValueVoList[m]) - } - }) - } - }else{ - for(let m=0;m{ - if(isTrue){ - this.defaultList[0].value.push(this.specifiList[1].productAttributeValueVoList[m]) - } - }) - - } - } - } else { - this.tui.toast(res.message) - } - }).catch((res) => {}) - }, - //店铺默认分类 - getDefaultCategory(){ - this.tui.request("/app/productCategory/getDefaultCategory", "POST", {}, false, true).then((res) => { - if (res.code == 200) { - this.categoryList = res.result - } else { - this.tui.toast(res.message) - } - }).catch((res) => {}) - }, - //进入页面,查询货号列表 - getSnList(){ - // snList - this.snList = [] - this.snName = '' - this.tui.request("/app/productSn/getProductSnByShopId", "POST", {}, false, true).then((res1) => { - if (res1.code == 200) { - if(res1.result != ''){ - for(let i=0;i {}) - }, - //根据规则生成货号 - startGetSn(){ - var that = this; - uni.showLoading({ - title:'加载中...', - mask:true - }) - that.$refs.SNDialog.close() - if(this.prefixRule == ''){ - this.tui.toast('请输入货号生成前缀规则') - return - } - if(this.numRule == ''){ - this.tui.toast('请输入货号生成位数规则') - return - } - this.tui.request("/app/productSn/addAndGetNewProductSn", "POST", { - snPre:this.prefixRule, - snSufLength:this.numRule - }, false, false).then((res1) => { - if (res1.code == 200) { - // this.snList = res1.result - if(res1.message=='货号前缀已存在!'){ //被删除,调启用方法 - uni.showModal({ - title: "提示", - content: "货号前缀已存在!", - success: function(res) { - if (res.confirm) { - that.tui.request("/app/productSn/useAgainProductSn", "POST", { - id:res1.result.id - }, false, true).then((res2) => { - if (res2.code == 200) { - that.tui.toast('成功') - that.prefixRule = '' - that.numRule = '' - setTimeout(res=>{ - that.getSnList() - },1000) - } else { - that.tui.toast(res2.message) - } - that.$forceUpdate() - }).catch((res) => {}) - } - } - }) - }else{ - this.addPageGoods(this.zhuImg,res1.result) - that.getSnList() - } - - } else { - this.tui.toast(res.message) - } - }).catch((res) => {}) - this.$nextTick(()=>{ - uni.hideLoading() - }) - }, - //生成货号弹出层 - generateSn(id){ - if(this.snList.length > 0){ - this.tui.request("/app/productSn/getNewProductSn", "POST", { - snPre: this.snName - }, false, true).then((res) => { - if (res.code == 200) { - this.carList.get(id).productSn = res.result - this.$forceUpdate() - } else { - this.tui.toast(res.message) - } - }).catch((res) => {}) - }else{ - this.zhuImg = '' - this.$refs.SNDialog.open('center') - } - - }, - addSn(){ - this.$refs.SNDialog.open('center') + methods: { + uploadFile() { + let that = this; + uni.chooseMedia({ + count: 1, + mediaType: ['image'], + sourceType: ['album'], + camera: 'back', + success(res) { + uni.uploadFile({ + url: that.tui.interfaceUrl() + '/upload/file', + filePath: res.tempFiles[0].tempFilePath, + name: 'file', + header: { + "content-type": "multipart/form-data", + 'accessToken': that.tui.getToken() + }, + formData: {}, + success: (uploadFileRes) => { + let path = JSON.parse(uploadFileRes.data) + //后端返回的地址,存入图片地址 + that.promptImg = path.result + that.$forceUpdate() + } + }); + } + }) + }, + getMonth() { + let date = new Date() + let year = date.getFullYear().toString() //'年' + let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1).toString() : (date.getMonth() + 1) + .toString() //'月' + let da = date.getDate() < 10 ? '0' + date.getDate().toString() : date.getDate().toString() //'日' + this.single = year + '-' + month + '-' + da //当天 + }, + //店铺规格库 + getShopCategory() { + this.tui.request("/app/productCategory/getCategoryOfshop", "POST", {}, false, true).then((res) => { + if (res.code == 200) { + //this.specifiList[0] this.defaultList[1] 尺码 + //this.specifiList[1] this.defaultList[0] 颜色 + this.specifiList = res.result.productAttributeOfAddVos + if (this.specifiList[0].attributeName == '尺码') { + for (let m = 0; m < this.specifiList[0].productAttributeValueVoList + .length; m++) { //尺码库 + let isysTrue = true + for (let i = 0; i < this.defaultList[1].value.length; i++) { //合并尺码 默认尺码 + if (this.defaultList[1].value[i].value == this.specifiList[0] + .productAttributeValueVoList[m].value) { + isysTrue = false + } + } + this.$nextTick(() => { + if (isysTrue) { + this.defaultList[1].value.push(this.specifiList[0] + .productAttributeValueVoList[m]) + } + }) + } + } else { + for (let m = 0; m < this.specifiList[0].productAttributeValueVoList + .length; m++) { //颜色库 + let isTrue = true + for (let i = 0; i < this.defaultList[0].value.length; i++) { //合并颜色 默认颜色 + if (this.defaultList[0].value[i].value == this.specifiList[0] + .productAttributeValueVoList[m].value) { + isTrue = false + } + } + this.$nextTick(() => { + if (isTrue) { + this.defaultList[0].value.push(this.specifiList[0] + .productAttributeValueVoList[m]) + } + }) + + } + } + if (this.specifiList[1].attributeName == '尺码') { + for (let m = 0; m < this.specifiList[1].productAttributeValueVoList + .length; m++) { //尺码库 + let isysTrue = true + for (let i = 0; i < this.defaultList[1].value.length; i++) { //合并尺码 默认尺码 + if (this.defaultList[1].value[i].value == this.specifiList[1] + .productAttributeValueVoList[m].value) { + isysTrue = false + } + } + this.$nextTick(() => { + if (isysTrue) { + this.defaultList[1].value.push(this.specifiList[1] + .productAttributeValueVoList[m]) + } + }) + } + } else { + for (let m = 0; m < this.specifiList[1].productAttributeValueVoList + .length; m++) { //颜色库 + let isTrue = true + for (let i = 0; i < this.defaultList[0].value.length; i++) { //合并颜色 默认颜色 + if (this.defaultList[0].value[i].value == this.specifiList[1] + .productAttributeValueVoList[m].value) { + isTrue = false + } + } + this.$nextTick(() => { + if (isTrue) { + this.defaultList[0].value.push(this.specifiList[1] + .productAttributeValueVoList[m]) + } + }) + + } + } + } else { + this.tui.toast(res.message) + } + }).catch((res) => {}) + }, + //店铺默认分类 + getDefaultCategory() { + this.tui.request("/app/productCategory/getDefaultCategory", "POST", {}, false, true).then((res) => { + if (res.code == 200) { + this.categoryList = res.result + } else { + this.tui.toast(res.message) + } + }).catch((res) => {}) + }, + //进入页面,查询货号列表 + getSnList() { + // snList + this.snList = [] + this.snName = '' + this.tui.request("/app/productSn/getProductSnByShopId", "POST", {}, false, true).then((res1) => { + if (res1.code == 200) { + if (res1.result != '') { + for (let i = 0; i < res1.result.length; i++) { + let data = { + text: '前缀:' + res1.result[i].snPre + ',位数:' + res1.result[i].snSufLength, + value: res1.result[i].snPre + } + this.snList.push(data) + } + this.snName = res1.result[0].snPre + } + + } else { + this.tui.toast(res.message) + } + this.$forceUpdate() + }).catch((res) => {}) + }, + //根据规则生成货号 + startGetSn() { + var that = this; + uni.showLoading({ + title: '加载中...', + mask: true + }) + that.$refs.SNDialog.close() + if (this.prefixRule == '') { + this.tui.toast('请输入货号生成前缀规则') + return + } + if (this.numRule == '') { + this.tui.toast('请输入货号生成位数规则') + return + } + this.tui.request("/app/productSn/addAndGetNewProductSn", "POST", { + snPre: this.prefixRule, + snSufLength: this.numRule + }, false, false).then((res1) => { + if (res1.code == 200) { + // this.snList = res1.result + if (res1.message == '货号前缀已存在!') { //被删除,调启用方法 + uni.showModal({ + title: "提示", + content: "货号前缀已存在!", + success: function(res) { + if (res.confirm) { + that.tui.request("/app/productSn/useAgainProductSn", "POST", { + id: res1.result.id + }, false, true).then((res2) => { + if (res2.code == 200) { + that.tui.toast('成功') + that.prefixRule = '' + that.numRule = '' + setTimeout(res => { + that.getSnList() + }, 1000) + } else { + that.tui.toast(res2.message) + } + that.$forceUpdate() + }).catch((res) => {}) + } + } + }) + } else { + this.addPageGoods(this.zhuImg, res1.result) + that.getSnList() + } + + } else { + this.tui.toast(res.message) + } + }).catch((res) => {}) + this.$nextTick(() => { + uni.hideLoading() + }) + }, + //生成货号弹出层 + generateSn(id) { + if (this.snList.length > 0) { + this.tui.request("/app/productSn/getNewProductSn", "POST", { + snPre: this.snName + }, false, true).then((res) => { + if (res.code == 200) { + this.carList.get(id).productSn = res.result + this.$forceUpdate() + } else { + this.tui.toast(res.message) + } + }).catch((res) => {}) + } else { + this.zhuImg = '' + this.$refs.SNDialog.open('center') + } + + }, + addSn() { + this.$refs.SNDialog.open('center') }, AiVoice() { + console.log('this.carList1', this.carList1) if (this.carList.size == 0) { //当前页没有数据 for (let i = 0; i < this.carList1.length; i++) { let obj = { @@ -1108,13 +1316,13 @@ productName: this.carList1[i].productName, wholesalePrice: this.carList1[i].wholesalePrice || 0, categoryName: this.carList1[i].categoryName, - categoryId: this.carList1[i].categoryId, + categoryId: this.carList1[i].categoryId, attrId: this.carList1[i].attrId, lsprice: this.carList1[i].price || 0, productPicture: this.carList1[i].productPicture, productSn: this.carList1[i].productSn, - stockLogList: new Map(), - productPictures:[], + stockLogList: new Map(), + productPictures: [], stockLogList1: [] } @@ -1159,7 +1367,10 @@ for (let i = 0; i < this.carList1.length; i++) { let id = this.carList1[i].isNew == true ? this.carList1[i].id : this.carList1[i].productId if (this.carList.has(this.carList1[i].id) == true) { //商品相同 - this.carList.get(this.carList1[i].id).purchasePrice = this.carList1[i].purchasePrice + if (this.carList.get(this.carList1[i].id).purchasePrice == '') { + this.carList.get(this.carList1[i].id).purchasePrice = this.carList1[i].purchasePrice + } + for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { if (this.carList.get(this.carList1[i].id).stockLogList.has(this.carList1[i] .saleDetailQueryDTO[m].attributeList) == true) { //规格相同 @@ -1190,20 +1401,21 @@ price1: 0, price: this.carList1[i].price, productCount: 0, - id: this.carList1[i].productId != null ? this.carList1[i].productId : this.carList1[i].id, + id: this.carList1[i].productId != null ? this.carList1[i].productId : this.carList1[i] + .id, productId: this.carList1[i].productId == null ? '' : this.carList1[i].productId, isNew: this.carList1[i].isNew, productName: this.carList1[i].productName, wholesalePrice: this.carList1[i].wholesalePrice || 0, categoryName: this.carList1[i].categoryName, - categoryId: this.carList1[i].categoryId, + categoryId: this.carList1[i].categoryId, attrId: this.carList1[i].attrId, lsprice: this.carList1[i].price || 0, productPicture: this.carList1[i].productPicture, productSn: this.carList1[i].productSn, stockLogList: new Map(), - stockLogList1: [], - productPictures:[], + stockLogList1: [], + productPictures: [], name: '' } for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { @@ -1260,16 +1472,16 @@ this.tui.toast('请先选择商品分类') return; } - this.temporary = [id, attr, type, value] - console.log('temporary',this.temporary) + this.temporary = [id, attr, type, value] + console.log('temporary', this.temporary) let num = type == '颜色' ? 0 : 1 this.getGategoryLowList() }, getScanCodeCategroyId(num) { - num = num == '颜色' ? 0 : 1 - this.isOpenId = num - this.goodsId = this.goodsDetail.id - this.$refs.inputDialog.open('bottom') + num = num == '颜色' ? 0 : 1 + this.isOpenId = num + this.goodsId = this.goodsDetail.id + this.$refs.inputDialog.open('bottom') this.isBottom = true }, //初始化获取子分类列表 @@ -1290,8 +1502,8 @@ }, false, true).then((res2) => { if (res2.code == 200) { this.attributeValue = res2.result; - this.$forceUpdate() - console.log('this.attributeValue',this.attributeValue) + this.$forceUpdate() + console.log('this.attributeValue', this.attributeValue) } else { this.tui.toast(res.message) } @@ -1305,7 +1517,7 @@ this.tui.toast(res.message) } }).catch((res) => {}) - this.$forceUpdate() + this.$forceUpdate() this.specifications = this.temporary[3] this.$refs.getaPopup.open() }, @@ -1328,78 +1540,78 @@ } let data = this.temporary let specMap = new Map() //新的临时存放值那个更改过的值的map - await this.carList.get(data[0]).stockLogList.forEach(function(value, key) { - if(data[2] == '颜色'){ - if (that.numData(key)[0] == data[3]) { - let stringKey = key.replace(data[3], item) //拿到了更改过的key - - if (specMap.has(stringKey) == true) { - console.log('相同') - data[1] = stringKey - specMap.get(stringKey).name = that.sliceMsg(stringKey) - specMap.get(stringKey).productCount += value.productCount - } else { - console.log('不同') - data[1] = stringKey - specMap.set(stringKey, value) - specMap.get(stringKey).name = that.sliceMsg(stringKey) - } - if(that.carList.get(data[0]).isNew != true){ - that.tui.request("/app/stock/productCount", "post", { - productId: that.carList.get(data[0]).productId, - attributeList: stringKey - }, false, true).then((res) => { - if (res.code == 200) { - value.productNum = res.result - that.$forceUpdate() - } else { - that.tui.toast(res.message) - } - }).catch((res) => {}) - } - - } else { - if (specMap.has(key) == true) { - specMap.get(key).productCount += value.productCount - } else { - specMap.set(key, value) - specMap.get(key).name = that.sliceMsg(key) - } - } - }else if(data[2] == '尺码'){ - if (that.numData(key)[1] == data[3]) { - let stringKey = key.replace(data[3], item) //拿到了更改过的key - if (specMap.has(stringKey) == true) { - data[1] = stringKey - specMap.get(stringKey).name = that.sliceMsg(stringKey) - specMap.get(stringKey).productCount += value.productCount - } else { - data[1] = stringKey - - specMap.set(stringKey, value) - specMap.get(stringKey).name = that.sliceMsg(stringKey) - } - if(that.carList.get(data[0]).isNew != true){ - that.tui.request("/app/stock/productCount", "post", { - productId: that.carList.get(data[0]).productId, - attributeList: stringKey - }, false, true).then((res) => { - if (res.code == 200) { - value.productNum = res.result - that.$forceUpdate() - } else { - that.tui.toast(res.message) - } - }).catch((res) => {}) - } - } else { - if (specMap.has(key) == true) { - specMap.get(key).productCount += value.productCount - } else { - specMap.set(key, value) - specMap.get(key).name = that.sliceMsg(key) - } - } + await this.carList.get(data[0]).stockLogList.forEach(function(value, key) { + if (data[2] == '颜色') { + if (that.numData(key)[0] == data[3]) { + let stringKey = key.replace(data[3], item) //拿到了更改过的key + + if (specMap.has(stringKey) == true) { + console.log('相同') + data[1] = stringKey + specMap.get(stringKey).name = that.sliceMsg(stringKey) + specMap.get(stringKey).productCount += value.productCount + } else { + console.log('不同') + data[1] = stringKey + specMap.set(stringKey, value) + specMap.get(stringKey).name = that.sliceMsg(stringKey) + } + if (that.carList.get(data[0]).isNew != true) { + that.tui.request("/app/stock/productCount", "post", { + productId: that.carList.get(data[0]).productId, + attributeList: stringKey + }, false, true).then((res) => { + if (res.code == 200) { + value.productNum = res.result + that.$forceUpdate() + } else { + that.tui.toast(res.message) + } + }).catch((res) => {}) + } + + } else { + if (specMap.has(key) == true) { + specMap.get(key).productCount += value.productCount + } else { + specMap.set(key, value) + specMap.get(key).name = that.sliceMsg(key) + } + } + } else if (data[2] == '尺码') { + if (that.numData(key)[1] == data[3]) { + let stringKey = key.replace(data[3], item) //拿到了更改过的key + if (specMap.has(stringKey) == true) { + data[1] = stringKey + specMap.get(stringKey).name = that.sliceMsg(stringKey) + specMap.get(stringKey).productCount += value.productCount + } else { + data[1] = stringKey + + specMap.set(stringKey, value) + specMap.get(stringKey).name = that.sliceMsg(stringKey) + } + if (that.carList.get(data[0]).isNew != true) { + that.tui.request("/app/stock/productCount", "post", { + productId: that.carList.get(data[0]).productId, + attributeList: stringKey + }, false, true).then((res) => { + if (res.code == 200) { + value.productNum = res.result + that.$forceUpdate() + } else { + that.tui.toast(res.message) + } + }).catch((res) => {}) + } + } else { + if (specMap.has(key) == true) { + specMap.get(key).productCount += value.productCount + } else { + specMap.set(key, value) + specMap.get(key).name = that.sliceMsg(key) + } + } } }) await that.$nextTick(() => { @@ -1408,7 +1620,7 @@ this.$refs.getaPopup.close() }) }, - delDefaultCate(index,value,index1){ + delDefaultCate(index, value, index1) { let data = this.goodsDetail.attributeList[index].value[index1] this.goodsDetail.attributeList[index].value.splice(index1, 1); this.tui.request("/app/productAttributeValue/delById", "post", { @@ -1448,14 +1660,81 @@ } } }, + showPopup(index) { + this.currentPopupIndex = index; + this.showTan = true; + }, + clickGetOne(item) { + console.log('选择了:', item); + console.log('oneData', this.oneData) + // 如果还有下一个弹出层,则显示下一个 + if (this.currentPopupIndex + 1 < this.moreData.length) { + this.showTan = false; // 先关闭当前弹出层 + this.voiceText = '' + this.voiceText1 = '' + let data = { + attributeList: '{"颜色":"均色","尺码":"均码"}', + productCount: Number(item.productCount) + } + item.productId = item.id + item.saleDetailQueryDTO = [] + item.saleDetailQueryDTO.push(data) + let purchaseDetails = item + + let id = this.oneGoodsId + console.log('purchaseDetails4827', purchaseDetails) + if (purchaseDetails) { + this.carList1.push(purchaseDetails) + this.$nextTick(() => { + this.AiVoice() + }) + + } else { + this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") + } + + setTimeout(() => { + this.showTan = true; // 再显示下一个弹出层 + this.currentPopupIndex += 1; + }, 0); + } else { + this.showTan = false; // 如果没有更多弹出层,则关闭最后一个弹出层 + this.voiceText = '' + this.voiceText1 = '' + + let data = { + attributeList: '{"颜色":"均色","尺码":"均码"}', + productCount: Number(item.productCount) + } + item.productId = item.id + item.saleDetailQueryDTO = [] + item.saleDetailQueryDTO.push(data) + + + let purchaseDetails = item + + let id = this.oneGoodsId + if (purchaseDetails) { + this.moreData = [] + this.carList1.push(purchaseDetails) + this.$nextTick(() => { + this.AiVoice() + }) + + } else { + this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") + } + } + }, //确认语音输入的内容 - async setDetail(e) { + async setDetail(e) { let that = this; if (this.voiceText == '') { this.tui.toast('识别内容不能为空') return } - let convertedStr = this.convertChineseToArabic(this.voiceText); + let convertedStr = this.trimWhitespace(this.voiceText); + convertedStr = this.convertChineseToArabic(convertedStr); if (convertedStr.indexOf('点') != -1) { convertedStr = this.replaceCharAfterNumber(convertedStr, '点', '.') } @@ -1464,12 +1743,12 @@ } if (convertedStr.indexOf('名称,') != -1) { convertedStr = convertedStr.replace(/名称,/g, '名称') - } - if (convertedStr.indexOf('名称::') != -1) { - convertedStr = convertedStr.replace(/名称::/g, '名称') - } - if (convertedStr.indexOf('名称:') != -1) { - convertedStr = convertedStr.replace(/名称:/g, '名称') + } + if (convertedStr.indexOf('名称::') != -1) { + convertedStr = convertedStr.replace(/名称::/g, '名称') + } + if (convertedStr.indexOf('名称:') != -1) { + convertedStr = convertedStr.replace(/名称:/g, '名称') } if (convertedStr.indexOf('名称') != -1) { convertedStr = convertedStr.replace(/名称/g, ',名称:') @@ -1479,12 +1758,12 @@ } if (convertedStr.indexOf('单价,') != -1) { convertedStr = convertedStr.replace(/单价,/g, '单价') - } - if (convertedStr.indexOf('单价::') != -1) { - convertedStr = convertedStr.replace(/单价::/g, '单价') - } - if (convertedStr.indexOf('单价:') != -1) { - convertedStr = convertedStr.replace(/单价:/g, '单价') + } + if (convertedStr.indexOf('单价::') != -1) { + convertedStr = convertedStr.replace(/单价::/g, '单价') + } + if (convertedStr.indexOf('单价:') != -1) { + convertedStr = convertedStr.replace(/单价:/g, '单价') } if (convertedStr.indexOf('单价') != -1) { convertedStr = convertedStr.replace(/单价/g, ',单价:') @@ -1494,18 +1773,18 @@ } if (convertedStr.indexOf('数量,') != -1) { convertedStr = convertedStr.replace(/数量,/g, '数量') - } - if (convertedStr.indexOf('数量::') != -1) { - convertedStr = convertedStr.replace(/数量::/g, '数量') - } - if (convertedStr.indexOf('数量:') != -1) { - convertedStr = convertedStr.replace(/数量:/g, '数量') + } + if (convertedStr.indexOf('数量::') != -1) { + convertedStr = convertedStr.replace(/数量::/g, '数量') + } + if (convertedStr.indexOf('数量:') != -1) { + convertedStr = convertedStr.replace(/数量:/g, '数量') } if (convertedStr.indexOf('数量') != -1) { convertedStr = convertedStr.replace(/数量/g, ',数量:') } - - + + if (convertedStr.indexOf(',批发价') != -1) { convertedStr = convertedStr.replace(/,批发价/g, '批发价') } @@ -1523,605 +1802,1222 @@ } if (convertedStr.indexOf('货号,') != -1) { convertedStr = convertedStr.replace(/货号,/g, '货号') - } - if (convertedStr.indexOf('货号::') != -1) { - convertedStr = convertedStr.replace(/货号::/g, '货号') - } - if (convertedStr.indexOf('货号:') != -1) { - convertedStr = convertedStr.replace(/货号:/g, '货号') + } + if (convertedStr.indexOf('货号::') != -1) { + convertedStr = convertedStr.replace(/货号::/g, '货号') + } + if (convertedStr.indexOf('货号:') != -1) { + convertedStr = convertedStr.replace(/货号:/g, '货号') } convertedStr = this.convertStringCorrectly(convertedStr) convertedStr = this.spliceMsg(convertedStr) if (convertedStr.indexOf(',') == 0) { convertedStr = convertedStr.substr(1) - } - if (convertedStr.startsWith("号")) { - convertedStr = "货号" + convertedStr.substr(1); + } + if (convertedStr.startsWith("号")) { + convertedStr = "货号" + convertedStr.substr(1); } this.getMsg = convertedStr - - if(this.isQuantityFollowsProductCode(convertedStr) || (convertedStr.indexOf('色') == -1 && convertedStr.indexOf('码') == -1)){ - try{ - console.log('convertedStr',convertedStr) + let regexCount = /-?\d+/g; + if (this.isQuantityFollowsProductCode(convertedStr) || (convertedStr.indexOf('色') == -1 && convertedStr + .indexOf('码') == -1)) { + try { + console.log('convertedStr', convertedStr) const regex = /货号.*?(?=货号|$)/g; convertedStr = convertedStr.match(regex); - for(let i=0;i { - if (res.code == 200) { - if(res.result != ''){ - this.voiceText = '' - this.$refs.popup.close() - - let data = { - attributeList: '{"颜色":"均色","尺码":"均码"}', - productCount: Number(voiceData.productCount), - stockCount: null - } - res.result[0].productId = res.result[0].id - res.result[0].stockLogList1 = [] - res.result[0].stockLogList1.push(data) - let purchaseDetails = res.result - if(this.oneGoodsId){ - let id = this.oneGoodsId - if(purchaseDetails.length > 0){ - if(this.carList.get(id).productSn != ''){ - for(let j=0;j { + if (this.voiceGetOneData == true) { + let voiceData = this.extractInfo(convertedStr[i] + '。') + if (voiceData.productSn) { + voiceData.productSn = voiceData.productSn.replace(/[沟勾钩]/g, 'J'); + } + if (voiceData.productCount) { + voiceData.productCount = voiceData.productCount.replace(/[^0-9]/g, ""); + } + if (voiceData.purchasePrice) { + voiceData.purchasePrice = this.replaceCharAfterNumber(voiceData + .purchasePrice, '块','.') + voiceData.purchasePrice = this.replaceCharAfterNumber(voiceData + .purchasePrice, '元','') + voiceData.purchasePrice = voiceData.purchasePrice.replace(/[^0-9.]/g, ""); + + } + if (voiceData.wholesalePrice) { + voiceData.wholesalePrice = this.replaceCharAfterNumber(voiceData + .wholesalePrice, '块','.') + voiceData.wholesalePrice = this.replaceCharAfterNumber(voiceData + .wholesalePrice, '元','') + voiceData.wholesalePrice = voiceData.wholesalePrice.replace(/[^0-9.]/g, + ''); + } + if (i == convertedStr.length - 1) { + setTimeout(res => { + this.getOneData(voiceData, true, 200 * (i + 1)) + }, 200 * (i + 1)) + } else { + setTimeout(res => { + this.getOneData(voiceData, false, 200 * (i + 1)) + }, 200 * (i + 1)) + + } + } else { + setTimeout(res => { + let voiceData = this.extractInfo(convertedStr[i] + '。') + if (voiceData.productSn) { + voiceData.productSn = voiceData.productSn.replace(/[沟勾钩]/g, 'J'); + } + if (voiceData.productCount) { + voiceData.productCount = voiceData.productCount.match(regexCount); + } + if (voiceData.wholesalePrice) { + voiceData.wholesalePrice = this.replaceCharAfterNumber(voiceData + .wholesalePrice,'块', '.') + voiceData.wholesalePrice = this.replaceCharAfterNumber(voiceData + .wholesalePrice, '元','') + voiceData.wholesalePrice = voiceData.wholesalePrice.replace(/[^0-9.]/g, + ""); + } + this.tui.request('/app/product/getByProductSn', "post", { + productSn: voiceData.productSn + }, false, true).then((res) => { + if (res.code == 200) { + if (res.result != '') { + this.voiceText = '' + this.$refs.popup.close() + + let data = { + attributeList: '{"颜色":"均色","尺码":"均码"}', + productCount: Number(voiceData.productCount), + stockCount: null + } + if (voiceData.wholesalePrice) { + voiceData.wholesalePrice = this + .replaceCharAfterNumber(voiceData.wholesalePrice, '块', '.') + voiceData.wholesalePrice = this + .replaceCharAfterNumber(voiceData.wholesalePrice, '元', '') + voiceData.wholesalePrice = voiceData.wholesalePrice + .replace( + /[^0-9.]/g, ""); + } + res.result[0].productId = res.result[0].id + res.result[0].stockLogList1 = [] + res.result[0].stockLogList1.push(data) + let purchaseDetails = res.result + if (this.oneGoodsId) { + let id = this.oneGoodsId + if (purchaseDetails.length > 0) { + if (this.carList.get(id).productSn != '') { + for (let j = 0; j < purchaseDetails + .length; j++) { + for (let i = 0; i < purchaseDetails[j] + .stockLogList1.length; i++) { + if (this.carList.get(id) + .productName == '') { + this.carList.get(id) + .productName = + purchaseDetails[0] + .productName + } + if (this.carList.get(id).attrId == + '') { + this.carList.get(id).attrId = + purchaseDetails[0].attrId + } + if (this.carList.get(id) + .purchasePrice == '' || this + .carList.get(id) + .purchasePrice == null) { + if (voiceData.purchasePrice) { + this.carList.get(id) + .purchasePrice = + voiceData.purchasePrice + } else { + this.carList.get(id) + .purchasePrice = + purchaseDetails[0] + .purchasePrice + } + + } + if (this.carList.get(id) + .productPicture == '') { + this.carList.get(id) + .productPicture = + purchaseDetails[0] + .productPicture + } + purchaseDetails[j].stockLogList1[i] + .name = this.sliceMsg( + purchaseDetails[j] + .stockLogList1[i] + .attributeList) + if (this.carList.get(id) + .stockLogList.size == 0) { + this.carList.get(id) + .stockLogList.set( + purchaseDetails[j] + .stockLogList1[i] + .attributeList, + purchaseDetails[j] + .stockLogList1[i]) + } else { + if (this.carList.get(id) + .stockLogList.has( + purchaseDetails[j] + .stockLogList1[i] + .attributeList) == true + ) { + this.carList.get(id) + .stockLogList.get( + purchaseDetails[j] + .stockLogList1[i] + .attributeList) + .productCount += + purchaseDetails[j] + .stockLogList1[i] + .productCount + } else { + this.carList.get(id) + .stockLogList.set( + purchaseDetails[j] + .stockLogList1[i] + .attributeList, + purchaseDetails[j] + .stockLogList1[i]) + } + } + this.carList.get(id) + .productCount += + purchaseDetails[j] + .stockLogList1[i].productCount + } } - this.carList.get(id).productCount += purchaseDetails[j].stockLogList1[i].productCount + if (this.carList.get(id).stockLogList.get( + '{"颜色":"均色","尺码":"均码"}') + .productCount == 0 && purchaseDetails[ + 0].stockLogList1.length > 0) { + this.carList.get(id).stockLogList + .delete('{"颜色":"均色","尺码":"均码"}') + } + this.carList.get(id).price1 = this.carList + .get(id).productCount * this.carList + .get(id).purchasePrice + } else { + + let isTrue = false + this.carList.forEach(function(value, key) { + if (value.productSn == + purchaseDetails[0] + .productSn) { + isTrue = true + that.tui.toast( + '该货号被页面其他商品占用,请重新输入!' + ) + that.carList.get(id) + .productSn = '' + setTimeout(res => { + that.$forceUpdate() + }, 1000) + throw Error('被占用') + } + }) + + this.$nextTick(() => { + if (this.carList.get(id) + .productName == '') { + this.carList.get(id) + .productName = + purchaseDetails[0] + .productName + } + if (isTrue == false && this + .carList.get(id) + .productSn == '') { + this.carList.get(id) + .productSn = + purchaseDetails[0] + .productSn + } + if (isTrue == false) { + if (purchaseDetails[0] + .productId) { + this.carList.get(id) + .id = + purchaseDetails[0] + .productId + this.carList.get(id) + .isNew = false + id = purchaseDetails[0] + .productId + } else if (purchaseDetails[ + 0].productSn == + '' || purchaseDetails[ + 0].productSn == + null) { + this.carList.get(id) + .id = + purchaseDetails[0] + .productName + id = purchaseDetails[0] + .productName + } else if (purchaseDetails[ + 0].productSn == + '货号') { + this.carList.get(id) + .productSn = + purchaseDetails[0] + .productName + this.carList.get(id) + .id = + purchaseDetails[0] + .productName + id = purchaseDetails[0] + .productName + } else if (purchaseDetails[ + 0].productSn) { + this.carList.get(id) + .id = + purchaseDetails[0] + .productSn + id = purchaseDetails[0] + .productSn + } + } + }) + if (this.carList.get(id).purchasePrice == + '' || this.carList.get(id) + .purchasePrice == null) { + if (voiceData.purchasePrice) { + this.carList.get(id) + .purchasePrice = voiceData + .purchasePrice + } else { + this.carList.get(id) + .purchasePrice = + purchaseDetails[0] + .purchasePrice + } + + } + if (this.carList.get(id).productPicture == + '') { + this.carList.get(id).productPicture = + purchaseDetails[0].productPicture + } + if (purchaseDetails[0].productId) { + this.carList.get(id).attrId = + purchaseDetails[0].attrId + this.carList.get(id).wholesalePrice = + purchaseDetails[0].wholesalePrice + this.carList.get(id).lsPrice = + purchaseDetails[0].lsPrice + } + + let specMap = + new Map() //新的临时存放值那个更改过的值的map + this.$nextTick(() => { + this.carList.forEach(function( + value, key) { + if (key != value + .id) { + specMap.set( + value + .id, + value) + } else { + specMap.set( + key, + value) + } + }) + this.carList = specMap + }) + this.$nextTick(() => { + for (let j = 0; j < + purchaseDetails.length; j++ + ) { + for (let i = 0; i < + purchaseDetails[j] + .stockLogList1 + .length; i++) { + purchaseDetails[j] + .stockLogList1[i] + .name = this + .sliceMsg( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList) + if (this.carList.get( + id) + .stockLogList + .size == 0) { + this.carList.get( + id) + .stockLogList + .set( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList, + purchaseDetails[ + j] + .stockLogList1[ + i]) + } else { + if (this.carList + .get(id) + .stockLogList + .has( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList + ) == true + ) { + this.carList + .get(id) + .stockLogList + .get( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList + ) + .productCount += + purchaseDetails[ + j] + .stockLogList1[ + i] + .productCount + } else { + this.carList + .get(id) + .stockLogList + .set( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList, + purchaseDetails[ + j] + .stockLogList1[ + i]) + } + } + this.carList.get(id) + .productCount += + purchaseDetails[j] + .stockLogList1[i] + .productCount + } + } + this.carList.get(id).price1 = + this.carList.get(id) + .productCount * this + .carList.get(id) + .purchasePrice + if (this.carList.get(id) + .stockLogList.get( + '{"颜色":"均色","尺码":"均码"}' + ).productCount == 0 && + purchaseDetails[0] + .stockLogList1.length > 0 + ) { + this.carList.get(id) + .stockLogList.delete( + '{"颜色":"均色","尺码":"均码"}' + ) + } + }) } + + this.$nextTick(() => { + this.getAllPrice() + this.oneGoodsId = '' + }) + } else { + this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") } - if(this.carList.get(id).stockLogList.get('{"颜色":"均色","尺码":"均码"}').productCount == 0 &&purchaseDetails[0].stockLogList1.length > 0){ - this.carList.get(id).stockLogList.delete('{"颜色":"均色","尺码":"均码"}') - } - this.carList.get(id).price1 = this.carList.get(id).productCount * this.carList.get(id).purchasePrice - }else{ - - let isTrue = false - this.carList.forEach(function(value, key) { - if(value.productSn == purchaseDetails[0].productSn){ - isTrue = true - that.tui.toast('该货号被页面其他商品占用,请重新输入!') - that.carList.get(id).productSn = '' - setTimeout(res=>{ - that.$forceUpdate() - },2000) - throw Error('被占用') - } - }) - - this.$nextTick(()=>{ - if(this.carList.get(id).productName == ''){ - this.carList.get(id).productName = purchaseDetails[0].productName + } else { + for (let i = 0; i < purchaseDetails.length; i++) { + let data = { + id: "", + price: purchaseDetails[i].price, + productCount: 0, + attrId: purchaseDetails[i].attrId, + categoryId: purchaseDetails[i] + .categoryId == '' ? this + .categoryList.categoryId : + purchaseDetails[i].categoryId, + categoryName: purchaseDetails[i] + .categoryName == '' ? this + .categoryList.categoryName : + purchaseDetails[i].categoryName, + wholesalePrice: voiceData + .wholesalePrice ? voiceData + .wholesalePrice : purchaseDetails[ + i].wholesalePrice, + purchasePrice: voiceData + .purchasePrice ? voiceData + .purchasePrice : purchaseDetails[i] + .purchasePrice, + isNew: purchaseDetails[i].productId == + null ? true : false, + productId: purchaseDetails[i] + .productId, + productName: purchaseDetails[i] + .productName, + productSn: purchaseDetails[i] + .productSn, + productPicture: purchaseDetails[i] + .productPicture, + supplierName: purchaseDetails[i] + .supplierName, + productPictures: [], + saleDetailQueryDTO: [] } - if(isTrue == false && this.carList.get(id).productSn == ''){ - this.carList.get(id).productSn = purchaseDetails[0].productSn + if (purchaseDetails[i].productId) { + data.id = purchaseDetails[i].productId + } else if (purchaseDetails[i].productSn == + '' || purchaseDetails[i].productSn == + null) { + data.id = purchaseDetails[i].productName + } else if (purchaseDetails[i].productSn == + '货号') { + data.productSn = purchaseDetails[i] + .productName + data.id = purchaseDetails[i].productName + } else if (purchaseDetails[i].productSn) { + data.id = purchaseDetails[i].productSn } - if(isTrue == false){ - if (purchaseDetails[0].productId) { - this.carList.get(id).id = purchaseDetails[0].productId - this.carList.get(id).isNew = false - id = purchaseDetails[0].productId - } else if (purchaseDetails[0].productSn == '' || purchaseDetails[0].productSn == - null) { - this.carList.get(id).id = purchaseDetails[0].productName - id = purchaseDetails[0].productName - } else if (purchaseDetails[0].productSn == '货号') { - this.carList.get(id).productSn = purchaseDetails[0].productName - this.carList.get(id).id = purchaseDetails[0].productName - id = purchaseDetails[0].productName - }else if (purchaseDetails[0].productSn) { - this.carList.get(id).id = purchaseDetails[0].productSn - id = purchaseDetails[0].productSn + for (let m = 0; m < purchaseDetails[i] + .stockLogList1.length; m++) { + let list = { + attributeList: this.getAttribute( + purchaseDetails[i] + .stockLogList1[m] + .attributeList), + productCount: purchaseDetails[i] + .stockLogList1[m] + .productCount || + purchaseDetails[i] + .stockLogList1[m] + .productCounts, + productNum: '', + name: this.sliceMsg(this + .getAttribute( + purchaseDetails[i] + .stockLogList1[m] + .attributeList)), + price: purchaseDetails[i] + .stockLogList1[m].purchasePrice } + data.productCount += purchaseDetails[i] + .stockLogList1[m].productCount + data.saleDetailQueryDTO.push(list) } - this.$forceUpdate() - }) - if(this.carList.get(id).purchasePrice == '' || this.carList.get(id).purchasePrice == null){ - this.carList.get(id).purchasePrice = purchaseDetails[0].purchasePrice - } - if(this.carList.get(id).productPicture == ''){ - this.carList.get(id).productPicture = purchaseDetails[0].productPicture + this.carList1.push(data) } - if(purchaseDetails[0].productId){ - this.carList.get(id).attrId = purchaseDetails[0].attrId - this.carList.get(id).wholesalePrice = purchaseDetails[0].wholesalePrice - this.carList.get(id).lsPrice = purchaseDetails[0].lsPrice - } - - let specMap = new Map() //新的临时存放值那个更改过的值的map - this.$nextTick(()=>{ - this.carList.forEach(function(value, key) { - if(key != value.id){ - specMap.set(value.id,value) - }else{ - specMap.set(key,value) - } + if (i == convertedStr.length - 1) { + this.$nextTick(() => { + setTimeout(res => { + this.AiVoice() + }, 300) }) - this.carList = specMap - }) - this.$nextTick(()=>{ - for(let j=0;j 0){ - this.carList.get(id).stockLogList.delete('{"颜色":"均色","尺码":"均码"}') - } - }) + } } - - this.$nextTick(()=>{ - this.getAllPrice() - this.oneGoodsId = '' - }) - }else{ - this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") - } - }else{ - for (let i = 0; i < purchaseDetails.length; i++) { - let data = { - id: "", - price: purchaseDetails[i].price, - productCount: 0, - attrId:purchaseDetails[i].attrId, - categoryId: purchaseDetails[i].categoryId == ''?this.categoryList.categoryId:purchaseDetails[i].categoryId, - categoryName: purchaseDetails[i].categoryName == ''?this.categoryList.categoryName:purchaseDetails[i].categoryName, - wholesalePrice: purchaseDetails[i].wholesalePrice, - purchasePrice: purchaseDetails[i].purchasePrice, - isNew: purchaseDetails[i].productId == null ? true : false, - productId: purchaseDetails[i].productId, - productName: purchaseDetails[i].productName, - productSn: purchaseDetails[i].productSn, - productPicture: purchaseDetails[i].productPicture, - supplierName: purchaseDetails[i].supplierName, - productPictures:[], - saleDetailQueryDTO: [] + } else { + this.voiceText = '' + this.voiceText1 = '' + this.$refs.popup.close() + if (voiceData.productCount) { + let regexZCount = /\d+/g; + voiceData.productCount = voiceData.productCount[0] + .match( + regexZCount); } - if (purchaseDetails[i].productId) { - data.id = purchaseDetails[i].productId - } else if (purchaseDetails[i].productSn == '' || purchaseDetails[i].productSn == - null) { - data.id = purchaseDetails[i].productName - } else if (purchaseDetails[i].productSn == '货号') { - data.productSn = purchaseDetails[i].productName - data.id = purchaseDetails[i].productName - } else if (purchaseDetails[i].productSn) { - data.id = purchaseDetails[i].productSn + if (voiceData.wholesalePrice) { + voiceData.wholesalePrice = this + .replaceCharAfterNumber( + voiceData.wholesalePrice, '块', '.') + voiceData.wholesalePrice = this + .replaceCharAfterNumber( + voiceData.wholesalePrice, '元', '') + voiceData.wholesalePrice = voiceData.wholesalePrice + .replace( + /[^0-9.]/g, ""); } - for (let m = 0; m < purchaseDetails[i].stockLogList1.length; m++) { - let list = { - attributeList: this.getAttribute(purchaseDetails[i].stockLogList1[m] - .attributeList), - productCount: purchaseDetails[i].stockLogList1[m].productCount || - purchaseDetails[i].stockLogList1[m].productCounts, - productNum: '', - name: this.sliceMsg(this.getAttribute(purchaseDetails[i].stockLogList1[m] - .attributeList)), - price: purchaseDetails[i].stockLogList1[m].purchasePrice - } - data.productCount += purchaseDetails[i].stockLogList1[m].productCount - data.saleDetailQueryDTO.push(list) + let data = { + id: voiceData.productSn, + productCount: voiceData.productCount || 0, + productName: voiceData.productName, + productSn: voiceData.productSn, + categoryId: this.categoryList.categoryId, + categoryName: this.categoryList.categoryName, + purchasePrice: voiceData.purchasePrice || 0, + wholesalePrice: voiceData.wholesalePrice || 0, + stockLogList1: [{ + attributeList: '{"颜色":"均色","尺码":"均码"}', + productCount: Number(voiceData + .productCount), + stockCount: null + }] } - this.carList1.push(data) - } - this.$nextTick(()=>{ - setTimeout(res=>{ - this.AiVoice() - },300) - }) - } - }else{ - this.voiceText = '' - this.$refs.popup.close() - if(voiceData.productCount){ - voiceData.productCount = voiceData.productCount.replace(/[^0-9]/g, ""); - } - let data = { - id: voiceData.productSn, - productCount: voiceData.productCount || 0, - productName: voiceData.productName, - productSn: voiceData.productSn, - categoryId:this.categoryList.categoryId, - categoryName:this.categoryList.categoryName, - purchasePrice: voiceData.purchasePrice || 0, - wholesalePrice: voiceData.wholesalePrice || 0, - stockLogList1:[{ - attributeList: '{"颜色":"均色","尺码":"均码"}', - productCount: Number(voiceData.productCount), - stockCount: null - }] - } - console.log(data) - let purchaseDetails = [] - purchaseDetails.push(data) - if(this.oneGoodsId){ - let id = this.oneGoodsId - if(purchaseDetails.length > 0){ - if(this.carList.get(id).productSn != ''){ - for(let j=0;j 0) { + if (this.carList.get(id).productSn != '') { + for (let j = 0; j < purchaseDetails + .length; j++) { + for (let i = 0; i < purchaseDetails[j] + .stockLogList1.length; i++) { + if (this.carList.get(id) + .productName == '') { + this.carList.get(id) + .productName = + purchaseDetails[0] + .productName + } + if (this.carList.get(id).attrId == + '') { + this.carList.get(id).attrId = + purchaseDetails[0].attrId + } + if (this.carList.get(id) + .purchasePrice == '' || this + .carList.get(id) + .purchasePrice == null) { + this.carList.get(id) + .purchasePrice = + purchaseDetails[0] + .purchasePrice + } + if (this.carList.get(id) + .productPicture == '') { + this.carList.get(id) + .productPicture = + purchaseDetails[0] + .productPicture + } + purchaseDetails[j].stockLogList1[i] + .name = this.sliceMsg( + purchaseDetails[j] + .stockLogList1[i] + .attributeList) + if (this.carList.get(id) + .stockLogList.size == 0) { + this.carList.get(id) + .stockLogList.set( + purchaseDetails[j] + .stockLogList1[i] + .attributeList, + purchaseDetails[j] + .stockLogList1[i]) + } else { + if (this.carList.get(id) + .stockLogList.has( + purchaseDetails[j] + .stockLogList1[i] + .attributeList) == true + ) { + this.carList.get(id) + .stockLogList.get( + purchaseDetails[j] + .stockLogList1[i] + .attributeList) + .productCount += + purchaseDetails[j] + .stockLogList1[i] + .productCount + } else { + this.carList.get(id) + .stockLogList.set( + purchaseDetails[j] + .stockLogList1[i] + .attributeList, + purchaseDetails[j] + .stockLogList1[i]) + } + } + this.carList.get(id) + .productCount += + purchaseDetails[j] + .stockLogList1[i].productCount + } } - if(this.carList.get(id).attrId == ''){ - this.carList.get(id).attrId = purchaseDetails[0].attrId + if (this.carList.get(id).stockLogList.get( + '{"颜色":"均色","尺码":"均码"}') + .productCount == 0 && purchaseDetails[ + 0].stockLogList1.length > 0) { + this.carList.get(id).stockLogList + .delete('{"颜色":"均色","尺码":"均码"}') + } + this.carList.get(id).price1 = this.carList + .get(id).productCount * this.carList + .get(id).purchasePrice + } else { + + let isTrue = false + this.carList.forEach(function(value, key) { + if (value.productSn == + purchaseDetails[0] + .productSn) { + isTrue = true + that.tui.toast( + '该货号被页面其他商品占用,请重新输入!' + ) + that.carList.get(id) + .productSn = '' + setTimeout(res => { + that.$forceUpdate() + }, 1000) + throw Error('被占用') + } + }) + + this.$nextTick(() => { + if (this.carList.get(id) + .productName == '') { + this.carList.get(id) + .productName = + purchaseDetails[0] + .productName + } + if (isTrue == false && this + .carList.get(id) + .productSn == '') { + this.carList.get(id) + .productSn = + purchaseDetails[0] + .productSn + } + if (isTrue == false) { + if (purchaseDetails[0] + .productId) { + this.carList.get(id) + .id = + purchaseDetails[0] + .productId + this.carList.get(id) + .isNew = false + id = purchaseDetails[0] + .productId + } else if (purchaseDetails[ + 0].productSn == + '' || purchaseDetails[ + 0].productSn == + null) { + this.carList.get(id) + .id = + purchaseDetails[0] + .productName + id = purchaseDetails[0] + .productName + } else if (purchaseDetails[ + 0].productSn == + '货号') { + this.carList.get(id) + .productSn = + purchaseDetails[0] + .productName + this.carList.get(id) + .id = + purchaseDetails[0] + .productName + id = purchaseDetails[0] + .productName + } else if (purchaseDetails[ + 0].productSn) { + this.carList.get(id) + .id = + purchaseDetails[0] + .productSn + id = purchaseDetails[0] + .productSn + } + } + }) + if (this.carList.get(id).purchasePrice == + '' || this.carList.get(id) + .purchasePrice == null) { + this.carList.get(id).purchasePrice = + purchaseDetails[0].purchasePrice } - if(this.carList.get(id).purchasePrice == '' || this.carList.get(id).purchasePrice == null){ - this.carList.get(id).purchasePrice = purchaseDetails[0].purchasePrice + if (this.carList.get(id).productPicture == + '') { + this.carList.get(id).productPicture = + purchaseDetails[0].productPicture } - if(this.carList.get(id).productPicture == ''){ - this.carList.get(id).productPicture = purchaseDetails[0].productPicture + if (purchaseDetails[0].productId) { + this.carList.get(id).attrId = + purchaseDetails[0].attrId + + this.carList.get(id).lsPrice = + purchaseDetails[0].lsPrice } - purchaseDetails[j].stockLogList1[i].name = this.sliceMsg(purchaseDetails[j].stockLogList1[i].attributeList) - if(this.carList.get(id).stockLogList.size == 0){ - this.carList.get(id).stockLogList.set(purchaseDetails[j].stockLogList1[i].attributeList,purchaseDetails[j].stockLogList1[i]) - }else{ - if(this.carList.get(id).stockLogList.has(purchaseDetails[j].stockLogList1[i].attributeList)== true){ - this.carList.get(id).stockLogList.get(purchaseDetails[j].stockLogList1[i].attributeList).productCount += - purchaseDetails[j].stockLogList1[i].productCount - }else{ - this.carList.get(id).stockLogList.set(purchaseDetails[j].stockLogList1[i].attributeList,purchaseDetails[j].stockLogList1[i]) + this.carList.get(id).wholesalePrice = + purchaseDetails[0].wholesalePrice + let specMap = + new Map() //新的临时存放值那个更改过的值的map + this.$nextTick(() => { + this.carList.forEach(function( + value, key) { + if (key != value + .id) { + specMap.set( + value + .id, + value) + } else { + specMap.set( + key, + value) + } + }) + this.carList = specMap + }) + this.$nextTick(() => { + for (let j = 0; j < + purchaseDetails.length; j++ + ) { + for (let i = 0; i < + purchaseDetails[j] + .stockLogList1 + .length; i++) { + purchaseDetails[j] + .stockLogList1[i] + .name = this + .sliceMsg( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList) + if (this.carList.get( + id) + .stockLogList + .size == 0) { + this.carList.get( + id) + .stockLogList + .set( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList, + purchaseDetails[ + j] + .stockLogList1[ + i]) + } else { + if (this.carList + .get(id) + .stockLogList + .has( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList + ) == true + ) { + this.carList + .get(id) + .stockLogList + .get( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList + ) + .productCount += + purchaseDetails[ + j] + .stockLogList1[ + i] + .productCount + } else { + this.carList + .get(id) + .stockLogList + .set( + purchaseDetails[ + j] + .stockLogList1[ + i] + .attributeList, + purchaseDetails[ + j] + .stockLogList1[ + i]) + } + } + this.carList.get(id) + .productCount += + purchaseDetails[j] + .stockLogList1[i] + .productCount + } } - } - this.carList.get(id).productCount += purchaseDetails[j].stockLogList1[i].productCount + this.carList.get(id).price1 = + this.carList.get(id) + .productCount * this + .carList.get(id) + .purchasePrice + if (this.carList.get(id) + .stockLogList.get( + '{"颜色":"均色","尺码":"均码"}' + ).productCount == 0 && + purchaseDetails[0] + .stockLogList1.length > 0 + ) { + this.carList.get(id) + .stockLogList.delete( + '{"颜色":"均色","尺码":"均码"}' + ) + } + }) } + + this.$nextTick(() => { + this.getAllPrice() + this.oneGoodsId = '' + }) + } else { + this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") } - if(this.carList.get(id).stockLogList.get('{"颜色":"均色","尺码":"均码"}').productCount == 0 &&purchaseDetails[0].stockLogList1.length > 0){ - this.carList.get(id).stockLogList.delete('{"颜色":"均色","尺码":"均码"}') + } else { + if (voiceData.wholesalePrice) { + voiceData.wholesalePrice = this + .replaceCharAfterNumber( + voiceData.wholesalePrice, '块', '.') + voiceData.wholesalePrice = this + .replaceCharAfterNumber( + voiceData.wholesalePrice, '元', '') + voiceData.wholesalePrice = voiceData + .wholesalePrice.replace( + /[^0-9.]/g, ""); } - this.carList.get(id).price1 = this.carList.get(id).productCount * this.carList.get(id).purchasePrice - }else{ - - let isTrue = false - this.carList.forEach(function(value, key) { - if(value.productSn == purchaseDetails[0].productSn){ - isTrue = true - that.tui.toast('该货号被页面其他商品占用,请重新输入!') - that.carList.get(id).productSn = '' - setTimeout(res=>{ - that.$forceUpdate() - },2000) - throw Error('被占用') - } - }) - - this.$nextTick(()=>{ - if(this.carList.get(id).productName == ''){ - this.carList.get(id).productName = purchaseDetails[0].productName + for (let i = 0; i < purchaseDetails.length; i++) { + let data = { + id: "", + price: purchaseDetails[i].price, + productCount: 0, + attrId: purchaseDetails[i].attrId, + categoryId: purchaseDetails[i] + .categoryId == '' ? this + .categoryList.categoryId : + purchaseDetails[i].categoryId, + categoryName: purchaseDetails[i] + .categoryName == '' ? this + .categoryList.categoryName : + purchaseDetails[i].categoryName, + wholesalePrice: voiceData + .wholesalePrice ? voiceData + .wholesalePrice : purchaseDetails[ + i].wholesalePrice, + purchasePrice: purchaseDetails[i] + .purchasePrice, + isNew: purchaseDetails[i].productId == + null ? true : false, + productId: purchaseDetails[i] + .productId, + productName: purchaseDetails[i] + .productName, + productSn: purchaseDetails[i] + .productSn, + productPicture: purchaseDetails[i] + .productPicture, + supplierName: purchaseDetails[i] + .supplierName, + productPictures: [], + saleDetailQueryDTO: [] } - if(isTrue == false && this.carList.get(id).productSn == ''){ - this.carList.get(id).productSn = purchaseDetails[0].productSn + if (purchaseDetails[i].productId) { + data.id = purchaseDetails[i].productId + } else if (purchaseDetails[i].productSn == + '' || purchaseDetails[i].productSn == + null) { + data.id = purchaseDetails[i].productName + } else if (purchaseDetails[i].productSn == + '货号') { + data.productSn = purchaseDetails[i] + .productName + data.id = purchaseDetails[i].productName + } else if (purchaseDetails[i].productSn) { + data.id = purchaseDetails[i].productSn } - if(isTrue == false){ - if (purchaseDetails[0].productId) { - this.carList.get(id).id = purchaseDetails[0].productId - this.carList.get(id).isNew = false - id = purchaseDetails[0].productId - } else if (purchaseDetails[0].productSn == '' || purchaseDetails[0].productSn == - null) { - this.carList.get(id).id = purchaseDetails[0].productName - id = purchaseDetails[0].productName - } else if (purchaseDetails[0].productSn == '货号') { - this.carList.get(id).productSn = purchaseDetails[0].productName - this.carList.get(id).id = purchaseDetails[0].productName - id = purchaseDetails[0].productName - }else if (purchaseDetails[0].productSn) { - this.carList.get(id).id = purchaseDetails[0].productSn - id = purchaseDetails[0].productSn + for (let m = 0; m < purchaseDetails[i] + .stockLogList1.length; m++) { + let list = { + attributeList: this.getAttribute( + purchaseDetails[i] + .stockLogList1[m] + .attributeList), + productCount: purchaseDetails[i] + .stockLogList1[m] + .productCount || + purchaseDetails[i] + .stockLogList1[m] + .productCounts, + productNum: '', + name: this.sliceMsg(this + .getAttribute( + purchaseDetails[i] + .stockLogList1[m] + .attributeList)), + price: purchaseDetails[i] + .stockLogList1[m].purchasePrice } + data.productCount += purchaseDetails[i] + .stockLogList1[m].productCount + data.saleDetailQueryDTO.push(list) } - this.$forceUpdate() - }) - if(this.carList.get(id).purchasePrice == '' || this.carList.get(id).purchasePrice == null){ - this.carList.get(id).purchasePrice = purchaseDetails[0].purchasePrice + this.carList1.push(data) } - if(this.carList.get(id).productPicture == ''){ - this.carList.get(id).productPicture = purchaseDetails[0].productPicture - } - if(purchaseDetails[0].productId){ - this.carList.get(id).attrId = purchaseDetails[0].attrId - - this.carList.get(id).lsPrice = purchaseDetails[0].lsPrice - } - this.carList.get(id).wholesalePrice = purchaseDetails[0].wholesalePrice - let specMap = new Map() //新的临时存放值那个更改过的值的map - this.$nextTick(()=>{ - this.carList.forEach(function(value, key) { - if(key != value.id){ - specMap.set(value.id,value) - }else{ - specMap.set(key,value) - } + if (i == convertedStr.length - 1) { + this.$nextTick(() => { + setTimeout(res => { + this.AiVoice() + }, 300) }) - this.carList = specMap - }) - this.$nextTick(()=>{ - for(let j=0;j 0){ - this.carList.get(id).stockLogList.delete('{"颜色":"均色","尺码":"均码"}') - } - }) - } - - this.$nextTick(()=>{ - this.getAllPrice() - this.oneGoodsId = '' - }) - }else{ - this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") - } - }else{ - for (let i = 0; i < purchaseDetails.length; i++) { - let data = { - id: "", - price: purchaseDetails[i].price, - productCount: 0, - attrId:purchaseDetails[i].attrId, - categoryId: purchaseDetails[i].categoryId == ''?this.categoryList.categoryId:purchaseDetails[i].categoryId, - categoryName: purchaseDetails[i].categoryName == ''?this.categoryList.categoryName:purchaseDetails[i].categoryName, - wholesalePrice: purchaseDetails[i].wholesalePrice, - purchasePrice: purchaseDetails[i].purchasePrice, - isNew: purchaseDetails[i].productId == null ? true : false, - productId: purchaseDetails[i].productId, - productName: purchaseDetails[i].productName, - productSn: purchaseDetails[i].productSn, - productPicture: purchaseDetails[i].productPicture, - supplierName: purchaseDetails[i].supplierName, - productPictures:[], - saleDetailQueryDTO: [] - } - if (purchaseDetails[i].productId) { - data.id = purchaseDetails[i].productId - } else if (purchaseDetails[i].productSn == '' || purchaseDetails[i].productSn == - null) { - data.id = purchaseDetails[i].productName - } else if (purchaseDetails[i].productSn == '货号') { - data.productSn = purchaseDetails[i].productName - data.id = purchaseDetails[i].productName - } else if (purchaseDetails[i].productSn) { - data.id = purchaseDetails[i].productSn - } - for (let m = 0; m < purchaseDetails[i].stockLogList1.length; m++) { - let list = { - attributeList: this.getAttribute(purchaseDetails[i].stockLogList1[m] - .attributeList), - productCount: purchaseDetails[i].stockLogList1[m].productCount || - purchaseDetails[i].stockLogList1[m].productCounts, - productNum: '', - name: this.sliceMsg(this.getAttribute(purchaseDetails[i].stockLogList1[m] - .attributeList)), - price: purchaseDetails[i].stockLogList1[m].purchasePrice } - data.productCount += purchaseDetails[i].stockLogList1[m].productCount - data.saleDetailQueryDTO.push(list) + } - this.carList1.push(data) + } - this.$nextTick(()=>{ - setTimeout(res=>{ - this.AiVoice() - },300) - }) } - - } - } - }) + }) + }, 200 * (i + 1)) + } + } - - }catch(e){ + this.$refs.popup.close() + this.$refs.voiceBottomPopup.close() + } catch (e) { await this.tui.request("/purchaseOcrPicture/callWithMessageOfPurchase", "POST", { questionMsg: this.getMsg }, false, true).then((res) => { if (res.code == 200) { this.voiceText = '' + this.voiceText1 = '' this.$refs.popup.close() + this.$refs.voiceBottomPopup.close() let purchaseDetails = res.result.data.purchaseDetails - if(this.oneGoodsId){ + if (this.oneGoodsId) { let id = this.oneGoodsId - if(purchaseDetails.length > 0){ - if(this.carList.get(id).productSn != ''){ - for(let j=0;j 0) { + if (this.carList.get(id).productSn != '') { + for (let j = 0; j < purchaseDetails.length; j++) { + for (let i = 0; i < purchaseDetails[j].stockLogList1 + .length; i++) { + if (this.carList.get(id).productName == '') { + this.carList.get(id).productName = purchaseDetails[0] + .productName } - if(this.carList.get(id).attrId == ''){ + if (this.carList.get(id).attrId == '') { this.carList.get(id).attrId = purchaseDetails[0].attrId } - if(this.carList.get(id).purchasePrice == '' || this.carList.get(id).purchasePrice == null){ - this.carList.get(id).purchasePrice = purchaseDetails[0].purchasePrice + if (this.carList.get(id).purchasePrice == '' || this + .carList.get(id).purchasePrice == null) { + this.carList.get(id).purchasePrice = purchaseDetails[0] + .purchasePrice } - if(this.carList.get(id).productPicture == ''){ - this.carList.get(id).productPicture = purchaseDetails[0].productPicture + if (this.carList.get(id).productPicture == '') { + this.carList.get(id).productPicture = purchaseDetails[ + 0].productPicture } - purchaseDetails[j].stockLogList1[i].name = this.sliceMsg(purchaseDetails[j].stockLogList1[i].attributeList) - if(this.carList.get(id).stockLogList.size == 0){ - this.carList.get(id).stockLogList.set(purchaseDetails[j].stockLogList1[i].attributeList,purchaseDetails[j].stockLogList1[i]) - }else{ - if(this.carList.get(id).stockLogList.has(purchaseDetails[j].stockLogList1[i].attributeList)== true){ - this.carList.get(id).stockLogList.get(purchaseDetails[j].stockLogList1[i].attributeList).productCount += - purchaseDetails[j].stockLogList1[i].productCount - }else{ - this.carList.get(id).stockLogList.set(purchaseDetails[j].stockLogList1[i].attributeList,purchaseDetails[j].stockLogList1[i]) + purchaseDetails[j].stockLogList1[i].name = this.sliceMsg( + purchaseDetails[j].stockLogList1[i].attributeList) + if (this.carList.get(id).stockLogList.size == 0) { + this.carList.get(id).stockLogList.set(purchaseDetails[ + j].stockLogList1[i].attributeList, + purchaseDetails[j].stockLogList1[i]) + } else { + if (this.carList.get(id).stockLogList.has( + purchaseDetails[j].stockLogList1[i] + .attributeList) == true) { + this.carList.get(id).stockLogList.get( + purchaseDetails[j].stockLogList1[i] + .attributeList).productCount += + purchaseDetails[j].stockLogList1[i] + .productCount + } else { + this.carList.get(id).stockLogList.set( + purchaseDetails[j].stockLogList1[i] + .attributeList, purchaseDetails[j] + .stockLogList1[i]) } } - this.carList.get(id).productCount += purchaseDetails[j].stockLogList1[i].productCount + this.carList.get(id).productCount += purchaseDetails[j] + .stockLogList1[i].productCount } } - if(this.carList.get(id).stockLogList.get('{"颜色":"均色","尺码":"均码"}').productCount == 0 &&purchaseDetails[0].stockLogList1.length > 0){ - this.carList.get(id).stockLogList.delete('{"颜色":"均色","尺码":"均码"}') + if (this.carList.get(id).stockLogList.get('{"颜色":"均色","尺码":"均码"}') + .productCount == 0 && purchaseDetails[0].stockLogList1.length > + 0) { + this.carList.get(id).stockLogList.delete( + '{"颜色":"均色","尺码":"均码"}') } - this.carList.get(id).price1 = this.carList.get(id).productCount * this.carList.get(id).purchasePrice - }else{ - + this.carList.get(id).price1 = this.carList.get(id).productCount * + this.carList.get(id).purchasePrice + } else { + let isTrue = false this.carList.forEach(function(value, key) { - if(value.productSn == purchaseDetails[0].productSn){ + if (value.productSn == purchaseDetails[0].productSn) { isTrue = true that.tui.toast('该货号被页面其他商品占用,请重新输入!') that.carList.get(id).productSn = '' - setTimeout(res=>{ + setTimeout(res => { that.$forceUpdate() - },2000) + }, 2000) throw Error('被占用') } }) - - this.$nextTick(()=>{ - if(this.carList.get(id).productName == ''){ - this.carList.get(id).productName = purchaseDetails[0].productName + + this.$nextTick(() => { + if (this.carList.get(id).productName == '') { + this.carList.get(id).productName = purchaseDetails[ + 0].productName } - if(isTrue == false && this.carList.get(id).productSn == ''){ - this.carList.get(id).productSn = purchaseDetails[0].productSn + if (isTrue == false && this.carList.get(id) + .productSn == '') { + this.carList.get(id).productSn = purchaseDetails[0] + .productSn } - if(isTrue == false){ + if (isTrue == false) { if (purchaseDetails[0].productId) { - this.carList.get(id).id = purchaseDetails[0].productId + this.carList.get(id).id = purchaseDetails[0] + .productId this.carList.get(id).isNew = false id = purchaseDetails[0].productId - } else if (purchaseDetails[0].productSn == '' || purchaseDetails[0].productSn == + } else if (purchaseDetails[0].productSn == '' || + purchaseDetails[0].productSn == null) { - this.carList.get(id).id = purchaseDetails[0].productName + this.carList.get(id).id = purchaseDetails[0] + .productName id = purchaseDetails[0].productName } else if (purchaseDetails[0].productSn == '货号') { - this.carList.get(id).productSn = purchaseDetails[0].productName - this.carList.get(id).id = purchaseDetails[0].productName + this.carList.get(id).productSn = + purchaseDetails[0].productName + this.carList.get(id).id = purchaseDetails[0] + .productName id = purchaseDetails[0].productName - }else if (purchaseDetails[0].productSn) { - this.carList.get(id).id = purchaseDetails[0].productSn + } else if (purchaseDetails[0].productSn) { + this.carList.get(id).id = purchaseDetails[0] + .productSn id = purchaseDetails[0].productSn } } this.$forceUpdate() }) - if(this.carList.get(id).purchasePrice == '' || this.carList.get(id).purchasePrice == null){ - this.carList.get(id).purchasePrice = purchaseDetails[0].purchasePrice + if (this.carList.get(id).purchasePrice == '' || this.carList.get( + id).purchasePrice == null) { + this.carList.get(id).purchasePrice = purchaseDetails[0] + .purchasePrice } - if(this.carList.get(id).productPicture == ''){ - this.carList.get(id).productPicture = purchaseDetails[0].productPicture + if (this.carList.get(id).productPicture == '') { + this.carList.get(id).productPicture = purchaseDetails[0] + .productPicture } - if(purchaseDetails[0].productId){ + if (purchaseDetails[0].productId) { this.carList.get(id).attrId = purchaseDetails[0].attrId - this.carList.get(id).wholesalePrice = purchaseDetails[0].wholesalePrice + this.carList.get(id).wholesalePrice = purchaseDetails[0] + .wholesalePrice this.carList.get(id).lsPrice = purchaseDetails[0].lsPrice } - + let specMap = new Map() //新的临时存放值那个更改过的值的map - this.$nextTick(()=>{ + this.$nextTick(() => { this.carList.forEach(function(value, key) { - if(key != value.id){ - specMap.set(value.id,value) - }else{ - specMap.set(key,value) + if (key != value.id) { + specMap.set(value.id, value) + } else { + specMap.set(key, value) } }) this.carList = specMap }) - this.$nextTick(()=>{ - for(let j=0;j { + for (let j = 0; j < purchaseDetails.length; j++) { + for (let i = 0; i < purchaseDetails[j] + .stockLogList1.length; i++) { + purchaseDetails[j].stockLogList1[i].name = this + .sliceMsg(purchaseDetails[j].stockLogList1[ + i].attributeList) + if (this.carList.get(id).stockLogList.size == + 0) { + this.carList.get(id).stockLogList.set( + purchaseDetails[j].stockLogList1[i] + .attributeList, purchaseDetails[j] + .stockLogList1[i]) + } else { + if (this.carList.get(id).stockLogList.has( + purchaseDetails[j].stockLogList1[i] + .attributeList) == true) { + this.carList.get(id).stockLogList.get( + purchaseDetails[j] + .stockLogList1[i].attributeList + ).productCount += + purchaseDetails[j].stockLogList1[i] + .productCount + } else { + this.carList.get(id).stockLogList.set( + purchaseDetails[j] + .stockLogList1[i] + .attributeList, + purchaseDetails[j] + .stockLogList1[i]) } } - this.carList.get(id).productCount += purchaseDetails[j].stockLogList1[i].productCount + this.carList.get(id).productCount += + purchaseDetails[j].stockLogList1[i] + .productCount } } - this.carList.get(id).price1 = this.carList.get(id).productCount * this.carList.get(id).purchasePrice - if(this.carList.get(id).stockLogList.get('{"颜色":"均色","尺码":"均码"}').productCount == 0 &&purchaseDetails[0].stockLogList1.length > 0){ - this.carList.get(id).stockLogList.delete('{"颜色":"均色","尺码":"均码"}') + this.carList.get(id).price1 = this.carList.get(id) + .productCount * this.carList.get(id).purchasePrice + if (this.carList.get(id).stockLogList.get( + '{"颜色":"均色","尺码":"均码"}').productCount == 0 && + purchaseDetails[0].stockLogList1.length > 0) { + this.carList.get(id).stockLogList.delete( + '{"颜色":"均色","尺码":"均码"}') } }) } - - this.$nextTick(()=>{ + + this.$nextTick(() => { this.getAllPrice() this.oneGoodsId = '' }) - }else{ + } else { this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") } - }else{ + } else { for (let i = 0; i < purchaseDetails.length; i++) { let data = { id: "", price: purchaseDetails[i].price, productCount: 0, - attrId:purchaseDetails[i].attrId, - categoryId: purchaseDetails[i].categoryId == ''?this.categoryList.categoryId:purchaseDetails[i].categoryId, - categoryName: purchaseDetails[i].categoryName == ''?this.categoryList.categoryName:purchaseDetails[i].categoryName, + attrId: purchaseDetails[i].attrId, + categoryId: purchaseDetails[i].categoryId == '' ? this + .categoryList.categoryId : purchaseDetails[i].categoryId, + categoryName: purchaseDetails[i].categoryName == '' ? this + .categoryList.categoryName : purchaseDetails[i] + .categoryName, wholesalePrice: purchaseDetails[i].wholesalePrice, purchasePrice: purchaseDetails[i].purchasePrice, isNew: purchaseDetails[i].productId == null ? true : false, @@ -2130,12 +3026,13 @@ productSn: purchaseDetails[i].productSn, productPicture: purchaseDetails[i].productPicture, supplierName: purchaseDetails[i].supplierName, - productPictures:[], + productPictures: [], saleDetailQueryDTO: [] } if (purchaseDetails[i].productId) { data.id = purchaseDetails[i].productId - } else if (purchaseDetails[i].productSn == '' || purchaseDetails[i].productSn == + } else if (purchaseDetails[i].productSn == '' || purchaseDetails[i] + .productSn == null) { data.id = purchaseDetails[i].productName } else if (purchaseDetails[i].productSn == '货号') { @@ -2146,27 +3043,31 @@ } for (let m = 0; m < purchaseDetails[i].stockLogList1.length; m++) { let list = { - attributeList: this.getAttribute(purchaseDetails[i].stockLogList1[m] + attributeList: this.getAttribute(purchaseDetails[i] + .stockLogList1[m] .attributeList), - productCount: purchaseDetails[i].stockLogList1[m].productCount || + productCount: purchaseDetails[i].stockLogList1[m] + .productCount || purchaseDetails[i].stockLogList1[m].productCounts, productNum: '', - name: this.sliceMsg(this.getAttribute(purchaseDetails[i].stockLogList1[m] + name: this.sliceMsg(this.getAttribute(purchaseDetails[i] + .stockLogList1[m] .attributeList)), price: purchaseDetails[i].stockLogList1[m].purchasePrice } - data.productCount += purchaseDetails[i].stockLogList1[m].productCount + data.productCount += purchaseDetails[i].stockLogList1[m] + .productCount data.saleDetailQueryDTO.push(list) } this.carList1.push(data) } - this.$nextTick(()=>{ - setTimeout(res=>{ + this.$nextTick(() => { + setTimeout(res => { this.AiVoice() - },300) + }, 300) }) } - + } else { uni.showModal({ title: "提示", @@ -2178,155 +3079,208 @@ this.tui.toast(res) }) } - }else{ + } else { await this.tui.request("/purchaseOcrPicture/callWithMessageOfPurchase", "POST", { questionMsg: this.getMsg }, false, true).then((res) => { if (res.code == 200) { this.voiceText = '' + this.voiceText1 = '' this.$refs.popup.close() + this.$refs.voiceBottomPopup.close() let purchaseDetails = res.result.data.purchaseDetails - if(this.oneGoodsId){ + if (this.oneGoodsId) { let id = this.oneGoodsId - if(purchaseDetails.length > 0){ - if(this.carList.get(id).productSn != ''){ - for(let j=0;j 0) { + if (this.carList.get(id).productSn != '') { + for (let j = 0; j < purchaseDetails.length; j++) { + for (let i = 0; i < purchaseDetails[j].stockLogList1.length; i++) { + if (this.carList.get(id).productName == '') { + this.carList.get(id).productName = purchaseDetails[0] + .productName } - if(this.carList.get(id).attrId == ''){ + if (this.carList.get(id).attrId == '') { this.carList.get(id).attrId = purchaseDetails[0].attrId } - if(this.carList.get(id).purchasePrice == '' || this.carList.get(id).purchasePrice == null){ - this.carList.get(id).purchasePrice = purchaseDetails[0].purchasePrice + if (this.carList.get(id).purchasePrice == '' || this.carList + .get(id).purchasePrice == null) { + this.carList.get(id).purchasePrice = purchaseDetails[0] + .purchasePrice } - if(this.carList.get(id).productPicture == ''){ - this.carList.get(id).productPicture = purchaseDetails[0].productPicture + if (this.carList.get(id).productPicture == '') { + this.carList.get(id).productPicture = purchaseDetails[0] + .productPicture } - purchaseDetails[j].stockLogList1[i].name = this.sliceMsg(purchaseDetails[j].stockLogList1[i].attributeList) - if(this.carList.get(id).stockLogList.size == 0){ - this.carList.get(id).stockLogList.set(purchaseDetails[j].stockLogList1[i].attributeList,purchaseDetails[j].stockLogList1[i]) - }else{ - if(this.carList.get(id).stockLogList.has(purchaseDetails[j].stockLogList1[i].attributeList)== true){ - this.carList.get(id).stockLogList.get(purchaseDetails[j].stockLogList1[i].attributeList).productCount += - purchaseDetails[j].stockLogList1[i].productCount - }else{ - this.carList.get(id).stockLogList.set(purchaseDetails[j].stockLogList1[i].attributeList,purchaseDetails[j].stockLogList1[i]) + purchaseDetails[j].stockLogList1[i].name = this.sliceMsg( + purchaseDetails[j].stockLogList1[i].attributeList) + if (this.carList.get(id).stockLogList.size == 0) { + this.carList.get(id).stockLogList.set(purchaseDetails[j] + .stockLogList1[i].attributeList, purchaseDetails[j] + .stockLogList1[i]) + } else { + if (this.carList.get(id).stockLogList.has(purchaseDetails[ + j].stockLogList1[i].attributeList) == true) { + this.carList.get(id).stockLogList.get(purchaseDetails[ + j].stockLogList1[i].attributeList) + .productCount += + purchaseDetails[j].stockLogList1[i].productCount + } else { + this.carList.get(id).stockLogList.set(purchaseDetails[ + j].stockLogList1[i].attributeList, + purchaseDetails[j].stockLogList1[i]) } } - this.carList.get(id).productCount += purchaseDetails[j].stockLogList1[i].productCount + this.carList.get(id).productCount += purchaseDetails[j] + .stockLogList1[i].productCount } } - if(this.carList.get(id).stockLogList.get('{"颜色":"均色","尺码":"均码"}').productCount == 0 &&purchaseDetails[0].stockLogList1.length > 0){ + if (this.carList.get(id).stockLogList.get('{"颜色":"均色","尺码":"均码"}') + .productCount == 0 && purchaseDetails[0].stockLogList1.length > 0 + ) { this.carList.get(id).stockLogList.delete('{"颜色":"均色","尺码":"均码"}') } - this.carList.get(id).price1 = this.carList.get(id).productCount * this.carList.get(id).purchasePrice - }else{ - + this.carList.get(id).price1 = this.carList.get(id).productCount * this + .carList.get(id).purchasePrice + } else { + let isTrue = false this.carList.forEach(function(value, key) { - if(value.productSn == purchaseDetails[0].productSn){ + if (value.productSn == purchaseDetails[0].productSn) { isTrue = true that.tui.toast('该货号被页面其他商品占用,请重新输入!') that.carList.get(id).productSn = '' - setTimeout(res=>{ + setTimeout(res => { that.$forceUpdate() - },2000) + }, 2000) throw Error('被占用') } }) - - this.$nextTick(()=>{ - if(this.carList.get(id).productName == ''){ - this.carList.get(id).productName = purchaseDetails[0].productName + + this.$nextTick(() => { + if (this.carList.get(id).productName == '') { + this.carList.get(id).productName = purchaseDetails[0] + .productName } - if(isTrue == false && this.carList.get(id).productSn == ''){ - this.carList.get(id).productSn = purchaseDetails[0].productSn + if (isTrue == false && this.carList.get(id).productSn == + '') { + this.carList.get(id).productSn = purchaseDetails[0] + .productSn } - if(isTrue == false){ + if (isTrue == false) { if (purchaseDetails[0].productId) { - this.carList.get(id).id = purchaseDetails[0].productId + this.carList.get(id).id = purchaseDetails[0] + .productId this.carList.get(id).isNew = false id = purchaseDetails[0].productId - } else if (purchaseDetails[0].productSn == '' || purchaseDetails[0].productSn == + } else if (purchaseDetails[0].productSn == '' || + purchaseDetails[0].productSn == null) { - this.carList.get(id).id = purchaseDetails[0].productName + this.carList.get(id).id = purchaseDetails[0] + .productName id = purchaseDetails[0].productName } else if (purchaseDetails[0].productSn == '货号') { - this.carList.get(id).productSn = purchaseDetails[0].productName - this.carList.get(id).id = purchaseDetails[0].productName + this.carList.get(id).productSn = purchaseDetails[0] + .productName + this.carList.get(id).id = purchaseDetails[0] + .productName id = purchaseDetails[0].productName - }else if (purchaseDetails[0].productSn) { - this.carList.get(id).id = purchaseDetails[0].productSn + } else if (purchaseDetails[0].productSn) { + this.carList.get(id).id = purchaseDetails[0] + .productSn id = purchaseDetails[0].productSn } } this.$forceUpdate() }) - if(this.carList.get(id).purchasePrice == '' || this.carList.get(id).purchasePrice == null){ - this.carList.get(id).purchasePrice = purchaseDetails[0].purchasePrice + if (this.carList.get(id).purchasePrice == '' || this.carList.get(id) + .purchasePrice == null) { + this.carList.get(id).purchasePrice = purchaseDetails[0] + .purchasePrice } - if(this.carList.get(id).productPicture == ''){ - this.carList.get(id).productPicture = purchaseDetails[0].productPicture + if (this.carList.get(id).productPicture == '') { + this.carList.get(id).productPicture = purchaseDetails[0] + .productPicture } - if(purchaseDetails[0].productId){ + if (purchaseDetails[0].productId) { this.carList.get(id).attrId = purchaseDetails[0].attrId - this.carList.get(id).wholesalePrice = purchaseDetails[0].wholesalePrice + this.carList.get(id).wholesalePrice = purchaseDetails[0] + .wholesalePrice this.carList.get(id).lsPrice = purchaseDetails[0].lsPrice } - + let specMap = new Map() //新的临时存放值那个更改过的值的map - this.$nextTick(()=>{ + this.$nextTick(() => { this.carList.forEach(function(value, key) { - if(key != value.id){ - specMap.set(value.id,value) - }else{ - specMap.set(key,value) + if (key != value.id) { + specMap.set(value.id, value) + } else { + specMap.set(key, value) } }) this.carList = specMap }) - this.$nextTick(()=>{ - for(let j=0;j { + for (let j = 0; j < purchaseDetails.length; j++) { + for (let i = 0; i < purchaseDetails[j].stockLogList1 + .length; i++) { + purchaseDetails[j].stockLogList1[i].name = this + .sliceMsg(purchaseDetails[j].stockLogList1[i] + .attributeList) + if (this.carList.get(id).stockLogList.size == 0) { + this.carList.get(id).stockLogList.set( + purchaseDetails[j].stockLogList1[i] + .attributeList, purchaseDetails[j] + .stockLogList1[i]) + } else { + if (this.carList.get(id).stockLogList.has( + purchaseDetails[j].stockLogList1[i] + .attributeList) == true) { + this.carList.get(id).stockLogList.get( + purchaseDetails[j].stockLogList1[i] + .attributeList).productCount += + purchaseDetails[j].stockLogList1[i] + .productCount + } else { + this.carList.get(id).stockLogList.set( + purchaseDetails[j].stockLogList1[i] + .attributeList, purchaseDetails[j] + .stockLogList1[i]) } } - this.carList.get(id).productCount += purchaseDetails[j].stockLogList1[i].productCount + this.carList.get(id).productCount += + purchaseDetails[j].stockLogList1[i] + .productCount } } - this.carList.get(id).price1 = this.carList.get(id).productCount * this.carList.get(id).purchasePrice - if(this.carList.get(id).stockLogList.get('{"颜色":"均色","尺码":"均码"}').productCount == 0 &&purchaseDetails[0].stockLogList1.length > 0){ - this.carList.get(id).stockLogList.delete('{"颜色":"均色","尺码":"均码"}') + this.carList.get(id).price1 = this.carList.get(id) + .productCount * this.carList.get(id).purchasePrice + if (this.carList.get(id).stockLogList.get( + '{"颜色":"均色","尺码":"均码"}').productCount == 0 && + purchaseDetails[0].stockLogList1.length > 0) { + this.carList.get(id).stockLogList.delete( + '{"颜色":"均色","尺码":"均码"}') } }) } - - this.$nextTick(()=>{ + + this.$nextTick(() => { this.getAllPrice() this.oneGoodsId = '' }) - }else{ + } else { this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") } - }else{ + } else { for (let i = 0; i < purchaseDetails.length; i++) { let data = { id: "", price: purchaseDetails[i].price, productCount: 0, - attrId:purchaseDetails[i].attrId, - categoryId: purchaseDetails[i].categoryId == ''?this.categoryList.categoryId:purchaseDetails[i].categoryId, - categoryName: purchaseDetails[i].categoryName == ''?this.categoryList.categoryName:purchaseDetails[i].categoryName, + attrId: purchaseDetails[i].attrId, + categoryId: purchaseDetails[i].categoryId == '' ? this.categoryList + .categoryId : purchaseDetails[i].categoryId, + categoryName: purchaseDetails[i].categoryName == '' ? this + .categoryList.categoryName : purchaseDetails[i].categoryName, wholesalePrice: purchaseDetails[i].wholesalePrice, purchasePrice: purchaseDetails[i].purchasePrice, isNew: purchaseDetails[i].productId == null ? true : false, @@ -2335,12 +3289,13 @@ productSn: purchaseDetails[i].productSn, productPicture: purchaseDetails[i].productPicture, supplierName: purchaseDetails[i].supplierName, - productPictures:[], + productPictures: [], saleDetailQueryDTO: [] } if (purchaseDetails[i].productId) { data.id = purchaseDetails[i].productId - } else if (purchaseDetails[i].productSn == '' || purchaseDetails[i].productSn == + } else if (purchaseDetails[i].productSn == '' || purchaseDetails[i] + .productSn == null) { data.id = purchaseDetails[i].productName } else if (purchaseDetails[i].productSn == '货号') { @@ -2351,12 +3306,15 @@ } for (let m = 0; m < purchaseDetails[i].stockLogList1.length; m++) { let list = { - attributeList: this.getAttribute(purchaseDetails[i].stockLogList1[m] + attributeList: this.getAttribute(purchaseDetails[i] + .stockLogList1[m] .attributeList), - productCount: purchaseDetails[i].stockLogList1[m].productCount || + productCount: purchaseDetails[i].stockLogList1[m] + .productCount || purchaseDetails[i].stockLogList1[m].productCounts, productNum: '', - name: this.sliceMsg(this.getAttribute(purchaseDetails[i].stockLogList1[m] + name: this.sliceMsg(this.getAttribute(purchaseDetails[i] + .stockLogList1[m] .attributeList)), price: purchaseDetails[i].stockLogList1[m].purchasePrice } @@ -2365,13 +3323,13 @@ } this.carList1.push(data) } - this.$nextTick(()=>{ - setTimeout(res=>{ + this.$nextTick(() => { + setTimeout(res => { this.AiVoice() - },300) + }, 300) }) } - + } else { uni.showModal({ title: "提示", @@ -2383,65 +3341,1110 @@ this.tui.toast(res) }) } - - }, - delItemSn(val){ - var that = this; - uni.showModal({ - title: "提示", - content: "确定删除此条货号规则吗?", - success: function(res) { - if (res.confirm) { - that.tui.request("/app/productSn/checkProductSn", "post", { - snPre:val.value - }, false, true).then((res1) => { - if (res1.code == 200) { - that.tui.request("/app/productSn/deleteProductSn", "post", { - id:res1.result.id - }, false, true).then((res2) => { - if (res2.code == 200) { - that.tui.toast('删除成功') - setTimeout(res=>{ - that.getSnList() - },1000) - } else { - uni.showToast({ - title: res2.message, - icon: 'none' - }) - } - }).catch((res) => {}) - } else { - uni.showToast({ - title: res1.message, - icon: 'none' - }) - } - }).catch((res) => {}) - } - } - }) - + + }, + async getOneData(oneData, type, num) { + console.log('oneData', oneData) + await setTimeout(resAAS => { + this.tui.request('/app/product/getShareList', "post", { + categoryId: "", + pageNum: 1, + pageSize: '10', + searchStr: oneData.productSn + }, false, false).then((res) => { + if (res.code == 200) { + if (res.result.records != '') { + if (res.result.records.length > 1) { + for (let i = 0; i < res.result.records.length; i++) { + if (oneData.wholesalePrice) { + res.result.records[i].wholesalePrice = oneData + .wholesalePrice + res.result.records[i].unitPrice = oneData.wholesalePrice + res.result.records[i].discountAmount = oneData + .wholesalePrice + } + res.result.records[i].productCount = oneData.productCount + if (oneData.purchasePrice) { + res.result.records[i].purchasePrice = oneData.purchasePrice + } + } + this.$nextTick(() => { + this.moreData.push(res.result.records) + this.oneData = oneData + }) + + } else { + this.voiceText = '' + this.voiceText1 = '' + this.$refs.popup.close() + this.$refs.voiceBottomPopup.close() + + let data = { + attributeList: '{"颜色":"均色","尺码":"均码"}', + productCount: Number(oneData.productCount), + stockCount: null + } + res.result.records[0].productId = res.result.records[0].id + res.result.records[0].saleDetailQueryDTO = [] + res.result.records[0].saleDetailQueryDTO.push(data) + let purchaseDetails = res.result.records + if (this.oneGoodsId) { + let id = this.oneGoodsId + if (purchaseDetails.length > 0) { + if (this.carList.get(id).productSn != '') { + for (let j = 0; j < purchaseDetails.length; j++) { + for (let i = 0; i < purchaseDetails[j] + .saleDetailQueryDTO + .length; i++) { + if (this.carList.get(id).productName == '') { + this.carList.get(id).productName = + purchaseDetails[0] + .productName + } + if (this.carList.get(id).attrId == '') { + this.carList.get(id).attrId = + purchaseDetails[0].attrId + } + if (this.carList.get(id).purchasePrice == '' || + this + .carList + .get(id).purchasePrice == null) { + if (oneData.purchasePrice) { + this.carList.get(id).purchasePrice = + oneData + .purchasePrice + } else { + this.carList.get(id).purchasePrice = + purchaseDetails[0] + .purchasePrice + } + + } + if (this.carList.get(id).productPicture == + '') { + this.carList.get(id).productPicture = + purchaseDetails[ + 0] + .productPicture + } + purchaseDetails[j].saleDetailQueryDTO[i].name = + this + .sliceMsg( + purchaseDetails[j].saleDetailQueryDTO[ + i] + .attributeList) + if (this.carList.get(id).stockLogList.size == + 0) { + this.carList.get(id).stockLogList.set( + purchaseDetails[ + j] + .saleDetailQueryDTO[i] + .attributeList, + purchaseDetails[j] + .saleDetailQueryDTO[i]) + } else { + if (this.carList.get(id).stockLogList.has( + purchaseDetails[ + j].saleDetailQueryDTO[i] + .attributeList) == + true) { + this.carList.get(id).stockLogList.get( + purchaseDetails[ + j].saleDetailQueryDTO[i] + .attributeList) + .productCount += + purchaseDetails[j] + .saleDetailQueryDTO[i] + .productCount + } else { + this.carList.get(id).stockLogList.set( + purchaseDetails[ + j].saleDetailQueryDTO[i] + .attributeList, + purchaseDetails[j] + .saleDetailQueryDTO[i]) + } + } + this.carList.get(id).productCount += + purchaseDetails[j] + .saleDetailQueryDTO[i].productCount + } + } + if (this.carList.get(id).stockLogList.get( + '{"颜色":"均色","尺码":"均码"}') + .productCount == 0 && purchaseDetails[0] + .saleDetailQueryDTO + .length > 0 + ) { + this.carList.get(id).stockLogList.delete( + '{"颜色":"均色","尺码":"均码"}') + } + this.carList.get(id).price1 = this.carList.get(id) + .productCount * + this + .carList.get(id).purchasePrice + } else { + + let isTrue = false + this.carList.forEach(function(value, key) { + if (value.productSn == purchaseDetails[0] + .productSn) { + isTrue = true + that.tui.toast('该货号被页面其他商品占用,请重新输入!') + that.carList.get(id).productSn = '' + setTimeout(resNM => { + that.$forceUpdate() + }, 2000) + throw Error('被占用') + } + }) + + this.$nextTick(() => { + if (this.carList.get(id).productName == + '') { + this.carList.get(id).productName = + purchaseDetails[ + 0] + .productName + } + if (isTrue == false && this.carList.get(id) + .productSn == + '') { + this.carList.get(id).productSn = + purchaseDetails[0] + .productSn + } + if (isTrue == false) { + if (purchaseDetails[0].productId) { + this.carList.get(id).id = + purchaseDetails[0] + .productId + this.carList.get(id).isNew = false + id = purchaseDetails[0].productId + } else if (purchaseDetails[0] + .productSn == '' || + purchaseDetails[0].productSn == + null) { + this.carList.get(id).id = + purchaseDetails[0] + .productName + id = purchaseDetails[0].productName + } else if (purchaseDetails[0] + .productSn == '货号') { + this.carList.get(id).productSn = + purchaseDetails[0] + .productName + this.carList.get(id).id = + purchaseDetails[0] + .productName + id = purchaseDetails[0].productName + } else if (purchaseDetails[0] + .productSn) { + this.carList.get(id).id = + purchaseDetails[0] + .productSn + id = purchaseDetails[0].productSn + } + } + this.$forceUpdate() + }) + if (this.carList.get(id).purchasePrice == '' || this + .carList.get( + id) + .purchasePrice == null) { + if (oneData.purchasePrice) { + this.carList.get(id).purchasePrice = oneData + .purchasePrice + } else { + this.carList.get(id).purchasePrice = + purchaseDetails[0] + .purchasePrice + } + + } + if (this.carList.get(id).productPicture == '') { + this.carList.get(id).productPicture = + purchaseDetails[0] + .productPicture + } + if (purchaseDetails[0].productId) { + this.carList.get(id).attrId = purchaseDetails[0] + .attrId + this.carList.get(id).wholesalePrice = + purchaseDetails[0] + .wholesalePrice + this.carList.get(id).lsPrice = purchaseDetails[0] + .lsPrice + } + + let specMap = new Map() //新的临时存放值那个更改过的值的map + this.$nextTick(() => { + this.carList.forEach(function(value, key) { + if (key != value.id) { + specMap.set(value.id, + value) + } else { + specMap.set(key, value) + } + }) + this.carList = specMap + }) + this.$nextTick(() => { + for (let j = 0; j < purchaseDetails + .length; j++) { + for (let i = 0; i < purchaseDetails[j] + .saleDetailQueryDTO + .length; i++) { + purchaseDetails[j] + .saleDetailQueryDTO[i].name = + this + .sliceMsg(purchaseDetails[j] + .saleDetailQueryDTO[i] + .attributeList) + if (this.carList.get(id) + .stockLogList.size == + 0) { + this.carList.get(id) + .stockLogList.set( + purchaseDetails[j] + .saleDetailQueryDTO[ + i] + .attributeList, + purchaseDetails[j] + .saleDetailQueryDTO[i]) + } else { + if (this.carList.get(id) + .stockLogList.has( + purchaseDetails[j] + .saleDetailQueryDTO[ + i] + .attributeList) == true + ) { + this.carList.get(id) + .stockLogList.get( + purchaseDetails[j] + .saleDetailQueryDTO[ + i] + .attributeList) + .productCount += + purchaseDetails[j] + .saleDetailQueryDTO[ + i] + .productCount + } else { + this.carList.get(id) + .stockLogList.set( + purchaseDetails[j] + .saleDetailQueryDTO[ + i] + .attributeList, + purchaseDetails[j] + .saleDetailQueryDTO[ + i]) + } + } + this.carList.get(id) + .productCount += + purchaseDetails[j] + .saleDetailQueryDTO[i] + .productCount + } + } + this.carList.get(id).price1 = this.carList + .get(id) + .productCount * this.carList.get(id) + .purchasePrice + if (this.carList.get(id).stockLogList.get( + '{"颜色":"均色","尺码":"均码"}') + .productCount == 0 && + purchaseDetails[0].saleDetailQueryDTO + .length > 0) { + this.carList.get(id).stockLogList + .delete( + '{"颜色":"均色","尺码":"均码"}') + } + }) + } + + this.$nextTick(() => { + this.getAllPrice() + this.oneGoodsId = '' + }) + } else { + this.tui.toast("抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") + } + } else { + // for (let i = 0; i < purchaseDetails.length; i++) { + let data = { + id: "", + price: purchaseDetails[0].price, + productCount: 0, + attrId: purchaseDetails[0].attrId, + categoryId: purchaseDetails[0].categoryId == '' ? + this + .categoryList + .categoryId : purchaseDetails[0].categoryId, + categoryName: purchaseDetails[0].categoryName == + '' ? this + .categoryList.categoryName : purchaseDetails[0] + .categoryName, + wholesalePrice: purchaseDetails[0].wholesalePrice, + purchasePrice: oneData.purchasePrice ? oneData + .purchasePrice : purchaseDetails[0] + .purchasePrice, + isNew: purchaseDetails[0].productId == null ? + true : false, + productId: purchaseDetails[0].productId, + productName: purchaseDetails[0].productName, + productSn: purchaseDetails[0].productSn, + productPicture: purchaseDetails[0].productPicture, + supplierName: purchaseDetails[0].supplierName, + productPictures: [], + saleDetailQueryDTO: [] + } + if (purchaseDetails[0].productId) { + data.id = purchaseDetails[0].productId + } else if (purchaseDetails[0].productSn == '' || + purchaseDetails[0] + .productSn == null) { + data.id = purchaseDetails[0].productName + } else if (purchaseDetails[0].productSn == '货号') { + data.productSn = purchaseDetails[0].productName + data.id = purchaseDetails[0].productName + } else if (purchaseDetails[0].productSn) { + data.id = purchaseDetails[0].productSn + } + // for (let m = 0; m < purchaseDetails[0].saleDetailQueryDTO.length; m++) { + let list = { + attributeList: this.getAttribute( + purchaseDetails[0] + .saleDetailQueryDTO[0] + .attributeList), + productCount: purchaseDetails[0] + .saleDetailQueryDTO[0] + .productCount || + purchaseDetails[0].saleDetailQueryDTO[0] + .productCounts, + productNum: '', + name: this.sliceMsg(this.getAttribute( + purchaseDetails[0] + .saleDetailQueryDTO[0] + .attributeList)), + price: purchaseDetails[0].saleDetailQueryDTO[0] + .purchasePrice + } + data.productCount += purchaseDetails[0] + .saleDetailQueryDTO[0] + .productCount + data.saleDetailQueryDTO.push(list) + // } + this.carList1.push(data) + console.log('-------------carList1', this.carList1) + // } + uni.showLoading({ + title: '加载中...' + }) + if (type == true) { + this.$nextTick(() => { + setTimeout(resLK => { + this.AiVoice() + uni.hideLoading(); + }, 300) + }) + } + + } + } + } else { + // this.$nextTick(() => { + // setTimeout(ressD => { + this.voiceText = '' + this.voiceText1 = '' + this.$refs.popup.close() + + this.$refs.voiceBottomPopup.close() + if (oneData.productCount) { + oneData.productCount = oneData.productCount + .replace(/[^0-9]/g, ""); + } + let data = { + id: oneData.productSn, + productCount: oneData.productCount || + 0, + productName: oneData.productName, + productSn: oneData.productSn, + categoryId: this.categoryList + .categoryId, + categoryName: this.categoryList + .categoryName, + purchasePrice: oneData.purchasePrice || + 0, + wholesalePrice: oneData + .wholesalePrice || 0, + saleDetailQueryDTO: [{ + attributeList: '{"颜色":"均色","尺码":"均码"}', + productCount: Number( + oneData + .productCount), + stockCount: null + }] + } + console.log(data) + let purchaseDetails = [] + purchaseDetails.push(data) + if (this.oneGoodsId) { + let id = this.oneGoodsId + if (purchaseDetails.length > 0) { + if (this.carList.get(id).productSn != + '') { + for (let j = 0; j < purchaseDetails + .length; j++) { + for (let i = 0; i < + purchaseDetails[j] + .saleDetailQueryDTO + .length; i++) { + if (this.carList.get(id) + .productName == '') { + this.carList.get(id) + .productName = + purchaseDetails[0] + .productName + } + if (this.carList.get(id) + .attrId == '') { + this.carList.get(id) + .attrId = + purchaseDetails[ + 0].attrId + } + if (this.carList.get(id) + .purchasePrice == '' || + this.carList.get( + id) + .purchasePrice == null + ) { + this.carList.get(id) + .purchasePrice = + purchaseDetails[0] + .purchasePrice + } + if (this.carList.get(id) + .productPicture == '' + ) { + this.carList.get(id) + .productPicture = + purchaseDetails[0] + .productPicture + } + purchaseDetails[j] + .saleDetailQueryDTO[i] + .name = + this.sliceMsg( + purchaseDetails[j] + .saleDetailQueryDTO[ + i] + .attributeList) + if (this.carList.get(id) + .stockLogList.size == 0 + ) { + this.carList.get(id) + .stockLogList.set( + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i] + .attributeList, + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i]) + } else { + if (this.carList.get( + id) + .stockLogList.has( + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i] + .attributeList + ) == true) { + this.carList.get( + id) + .stockLogList + .get( + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i] + .attributeList + ) + .productCount += + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i] + .productCount + } else { + this.carList.get( + id) + .stockLogList + .set( + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i] + .attributeList, + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i]) + } + } + this.carList.get(id) + .productCount += + purchaseDetails[j] + .saleDetailQueryDTO[i] + .productCount + } + } + if (this.carList.get(id) + .stockLogList.get( + '{"颜色":"均色","尺码":"均码"}') + .productCount == 0 && + purchaseDetails[0] + .saleDetailQueryDTO.length > 0 + ) { + this.carList.get(id) + .stockLogList.delete( + '{"颜色":"均色","尺码":"均码"}' + ) + } + this.carList.get(id).price1 = this + .carList.get(id) + .productCount * this + .carList.get(id).purchasePrice + } else { + + let isTrue = false + this.carList.forEach(function( + value, key) { + if (value.productSn == + purchaseDetails[0] + .productSn) { + isTrue = true + that.tui.toast( + '该货号被页面其他商品占用,请重新输入!' + ) + that.carList.get( + id) + .productSn = '' + setTimeout( + resSLD => { + that.$forceUpdate() + }, 2000) + throw Error('被占用') + } + }) + + this.$nextTick(() => { + if (this.carList.get( + id) + .productName == '' + ) { + this.carList.get( + id) + .productName = + purchaseDetails[ + 0] + .productName + } + if (isTrue == false && + this.carList.get( + id) + .productSn == '') { + this.carList.get( + id) + .productSn = + purchaseDetails[ + 0] + .productSn + } + if (isTrue == false) { + if (purchaseDetails[ + 0] + .productId) { + this.carList + .get(id) + .id = + purchaseDetails[ + 0] + .productId + this.carList + .get(id) + .isNew = + false + id = purchaseDetails[ + 0] + .productId + } else if ( + purchaseDetails[ + 0] + .productSn == + '' || + purchaseDetails[ + 0] + .productSn == + null) { + this.carList + .get(id) + .id = + purchaseDetails[ + 0] + .productName + id = purchaseDetails[ + 0] + .productName + } else if ( + purchaseDetails[ + 0] + .productSn == + '货号') { + this.carList + .get(id) + .productSn = + purchaseDetails[ + 0] + .productName + this.carList + .get(id) + .id = + purchaseDetails[ + 0] + .productName + id = purchaseDetails[ + 0] + .productName + } else if ( + purchaseDetails[ + 0] + .productSn) { + this.carList + .get(id) + .id = + purchaseDetails[ + 0] + .productSn + id = purchaseDetails[ + 0] + .productSn + } + } + this.$forceUpdate() + }) + if (this.carList.get(id) + .purchasePrice == '' || this + .carList.get(id) + .purchasePrice == null) { + this.carList.get(id) + .purchasePrice = + purchaseDetails[0] + .purchasePrice + } + if (this.carList.get(id) + .productPicture == '') { + this.carList.get(id) + .productPicture = + purchaseDetails[ + 0].productPicture + } + if (purchaseDetails[0].productId) { + this.carList.get(id).attrId = + purchaseDetails[0].attrId + + this.carList.get(id).lsPrice = + purchaseDetails[0] + .lsPrice + } + this.carList.get(id) + .wholesalePrice = + purchaseDetails[0] + .wholesalePrice + let specMap = + new Map() //新的临时存放值那个更改过的值的map + this.$nextTick(() => { + this.carList.forEach( + function(value, + key) { + if (key != + value + .id) { + specMap + .set( + value + .id, + value + ) + } else { + specMap + .set( + key, + value + ) + } + }) + this.carList = specMap + }) + this.$nextTick(() => { + for (let j = 0; j < + purchaseDetails + .length; j++) { + for (let i = 0; i < + purchaseDetails[ + j] + .saleDetailQueryDTO + .length; i++) { + purchaseDetails + [j] + .saleDetailQueryDTO[ + i] + .name = + this + .sliceMsg( + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i] + .attributeList + ) + if (this + .carList + .get(id) + .stockLogList + .size == 0 + ) { + this.carList + .get( + id) + .stockLogList + .set( + purchaseDetails[ + j + ] + .saleDetailQueryDTO[ + i + ] + .attributeList, + purchaseDetails[ + j + ] + .saleDetailQueryDTO[ + i + ] + ) + } else { + if (this + .carList + .get( + id) + .stockLogList + .has( + purchaseDetails[ + j + ] + .saleDetailQueryDTO[ + i + ] + .attributeList + ) == + true) { + this.carList + .get( + id + ) + .stockLogList + .get( + purchaseDetails[ + j + ] + .saleDetailQueryDTO[ + i + ] + .attributeList + ) + .productCount += + purchaseDetails[ + j + ] + .saleDetailQueryDTO[ + i + ] + .productCount + } else { + this.carList + .get( + id + ) + .stockLogList + .set( + purchaseDetails[ + j + ] + .saleDetailQueryDTO[ + i + ] + .attributeList, + purchaseDetails[ + j + ] + .saleDetailQueryDTO[ + i + ] + ) + } + } + this.carList + .get(id) + .productCount += + purchaseDetails[ + j] + .saleDetailQueryDTO[ + i] + .productCount + } + } + this.carList.get(id) + .price1 = this + .carList.get( + id) + .productCount * + this.carList.get( + id) + .purchasePrice + if (this.carList.get( + id) + .stockLogList.get( + '{"颜色":"均色","尺码":"均码"}' + ) + .productCount == + 0 && + purchaseDetails[0] + .saleDetailQueryDTO + .length > 0) { + this.carList.get( + id) + .stockLogList + .delete( + '{"颜色":"均色","尺码":"均码"}' + ) + } + }) + } + + this.$nextTick(() => { + this.getAllPrice() + this.oneGoodsId = '' + }) + } else { + this.tui.toast( + "抱歉:小助手本次未识别到商品信息,请检查识别信息是否正确") + } + } else { + for (let i = 0; i < purchaseDetails + .length; i++) { + let data = { + id: "", + price: purchaseDetails[i] + .price, + productCount: 0, + attrId: purchaseDetails[i] + .attrId, + categoryId: purchaseDetails[i] + .categoryId == '' ? this + .categoryList + .categoryId : purchaseDetails[i] + .categoryId, + categoryName: purchaseDetails[ + i].categoryName == '' ? + this.categoryList + .categoryName : purchaseDetails[i] + .categoryName, + wholesalePrice: purchaseDetails[ + i].wholesalePrice, + purchasePrice: purchaseDetails[ + i].purchasePrice, + isNew: purchaseDetails[i] + .productId == null ? true : false, + productId: purchaseDetails[i] + .productId, + productName: purchaseDetails[i] + .productName, + productSn: purchaseDetails[i] + .productSn, + productPicture: purchaseDetails[ + i].productPicture, + supplierName: purchaseDetails[ + i].supplierName, + productPictures: [], + saleDetailQueryDTO: [] + } + if (purchaseDetails[i].productId) { + data.id = purchaseDetails[i] + .productId + } else if (purchaseDetails[i] + .productSn == '' || + purchaseDetails[i] + .productSn == + null) { + data.id = purchaseDetails[i] + .productName + } else if (purchaseDetails[i] + .productSn == '货号') { + data.productSn = purchaseDetails[i] + .productName + data.id = purchaseDetails[i] + .productName + } else if (purchaseDetails[i] + .productSn) { + data.id = purchaseDetails[i] + .productSn + } + for (let m = 0; m < purchaseDetails[i] + .saleDetailQueryDTO + .length; m++) { + let list = { + attributeList: this + .getAttribute( + purchaseDetails[i] + .saleDetailQueryDTO[ + m] + .attributeList), + productCount: purchaseDetails[ + i] + .saleDetailQueryDTO[m] + .productCount || + purchaseDetails[i] + .saleDetailQueryDTO[m] + .productCounts, + productNum: '', + name: this.sliceMsg(this + .getAttribute( + purchaseDetails[ + i] + .saleDetailQueryDTO[ + m] + .attributeList) + ), + price: purchaseDetails[i] + .saleDetailQueryDTO[m] + .purchasePrice + } + data.productCount += + purchaseDetails[i] + .saleDetailQueryDTO[ + m].productCount + data.saleDetailQueryDTO.push(list) + } + this.carList1.push(data) + } + uni.showLoading({ + title: '加载中...' + }) + if (type == true) { + this.$nextTick(() => { + setTimeout(resDAAS => { + this.AiVoice() + uni.hideLoading(); + }, 500) + }) + } + + } + // }, 200 * (num +1)) + + // }) + + + } + setTimeout(res => { + if (type == true && this.moreData.length > 0) { + this.$refs.popup.close() + this.$refs.voiceBottomPopup.close() + this.$refs.oneDataPopup.open() + this.showPopup(0) + } + }, 300) + + } + }) + }, 100) + + // this.$nextTick(()=>{ + // console.log('moreData', this.moreData) + // if (type == true && this.moreData.length > 0) { + // this.$refs.popup.close() + // this.$refs.oneDataPopup.open() + // this.showPopup(0) + // } + // }) + + }, + delItemSn(val) { + var that = this; + uni.showModal({ + title: "提示", + content: "确定删除此条货号规则吗?", + success: function(res) { + if (res.confirm) { + that.tui.request("/app/productSn/checkProductSn", "post", { + snPre: val.value + }, false, true).then((res1) => { + if (res1.code == 200) { + that.tui.request("/app/productSn/deleteProductSn", "post", { + id: res1.result.id + }, false, true).then((res2) => { + if (res2.code == 200) { + that.tui.toast('删除成功') + setTimeout(res => { + that.getSnList() + }, 1000) + } else { + uni.showToast({ + title: res2.message, + icon: 'none' + }) + } + }).catch((res) => {}) + } else { + uni.showToast({ + title: res1.message, + icon: 'none' + }) + } + }).catch((res) => {}) + } + } + }) + }, dialogInputConfirm(e) { if (this.categoryText == '') { this.tui.toast("请输入规格值后提交") return - } - //this.goodsDetail[0] 颜色 - //this.goodsDetail[1] 尺码 - this.$refs.inputDialog.close() - let data = { - isChecked:false, - value:this.categoryText - } - if(this.isOpenId == '0'){ - this.goodsDetail.attributeList[0].value.push(data) - this.dataObj.set(data.value,'颜色') - }else if(this.isOpenId == '1'){ - this.goodsDetail.attributeList[1].value.push(data) - this.dataObj.set(data.value,'尺码') - } + } + //this.goodsDetail[0] 颜色 + //this.goodsDetail[1] 尺码 + this.$refs.inputDialog.close() + let data = { + isChecked: false, + value: this.categoryText + } + if (this.isOpenId == '0') { + this.goodsDetail.attributeList[0].value.push(data) + this.dataObj.set(data.value, '颜色') + } else if (this.isOpenId == '1') { + this.goodsDetail.attributeList[1].value.push(data) + this.dataObj.set(data.value, '尺码') + } this.$forceUpdate() }, dialogClose() { @@ -2449,6 +4452,10 @@ this.$refs.inputDialog.close() this.categoryText = '' }, + //去掉空格和换行 + trimWhitespace(str) { + return str.replace(/\s+/g, ''); + }, combination(arr) { let result = [ [] @@ -2532,6 +4539,14 @@ } }) }, + getZhuBigImage(path) { + console.log(path) + let paths = [] + paths.push(path) + uni.previewImage({ + urls: paths + }); + }, uploadFilePromise(value) { let that = this; uni.chooseMedia({ @@ -2541,7 +4556,7 @@ camera: 'back', success(res) { uni.uploadFile({ - url: that.tui.interfaceUrl() +'/upload/file', + url: that.tui.interfaceUrl() + '/upload/file', filePath: res.tempFiles[0].tempFilePath, name: 'file', header: { @@ -2562,15 +4577,15 @@ }, goodsAdd() { uni.navigateTo({ - url: "/pages/inventory/changeGoods1" + url: "/package1/inventory/changeGoods1" }) }, mergeGoods() { - }, - //上传子图 - uploadZi(id){ - + }, + //上传子图 + uploadZi(id) { + }, addGategory(e) { let multipleList = [{ @@ -2643,95 +4658,103 @@ } this.isPlusAndMinus == false this.temporaryChange() - }, - async mapMinusNum(index){ - this.temporaryList[index].productCount -- - this.temporaryChange() - }, - mapPlusNum(index){ - this.temporaryList[index].productCount ++ - this.temporaryChange() - }, - async oneMinusNum(index,index1){ - let that = this; - this.carList.get(index).productCount = 0 - this.carList.get(index).returnCount = 0 - this.carList.get(index).stockLogList.get(index1).productCount -- - await this.carList.get(index).stockLogList.forEach(function(value, key) { - if(value.productCount < 0){ - that.carList.get(index).returnCount = that.carList.get(index).returnCount + Math.abs(value.productCount) - }else{ - that.carList.get(index).productCount = that.carList.get(index).productCount + value.productCount - } - }) - await this.$nextTick(()=>{ - // if (that.discountType != 0) { //单品折扣 - that.carList.get(index).price1 = that.carList.get(index).productCount * that.carList - .get(index).purchasePrice - // } - }) - this.$forceUpdate() - this.getAllPrice() - }, - onePlusNum(index,index1){ - let that = this; - this.carList.get(index).stockLogList.get(index1).productCount ++ - that.carList.get(index).productCount ++ - that.carList.get(index).price1 = that.carList.get(index).productCount * that.carList - .get(index).purchasePrice - this.getAllPrice() - }, - yuyinChange(){ - console.log("yuyin") - this.isVoice = false - }, - numChange(e,index){ - if(this.linshiPrice == e.target.value){ - this.temporaryList[index].productCount = Number(e.target.value) - }else{ - if(e.detail.value == ''){ - this.temporaryList[index].productCount = Number(this.linshiPrice) - }else if(e.detail.value == 0){ - this.temporaryList[index].productCount = 0 - }else{ - this.temporaryList[index].productCount = Number(e.detail.value); - } - this.$forceUpdate() - } - this.temporaryChange() - }, - mapnumChange(e,id,id1){ - let that = this; - this.carList.get(id).productCount = 0 - this.carList.get(id).returnCount = 0 - if (this.linshiPrice == e.target.value) { - this.carList.get(id).stockLogList.get(id1).productCount = e.target.value - } else { - if (e.detail.value == '') { - this.carList.get(id).stockLogList.get(id1).productCount = this.linshiPrice - } else { - this.carList.get(id).stockLogList.get(id1).productCount = Number(e.detail.value) - } - } - - this.carList.get(id).stockLogList.forEach(function(value, key) { - if(value.productCount < 0){ - that.carList.get(id).returnCount = that.carList.get(id).returnCount + Math.abs(value.productCount) - }else{ - that.carList.get(id).productCount = that.carList.get(id).productCount + value.productCount - } - }) - this.$nextTick(()=>{ - // if (that.discountType != 0) { //单品折扣 - that.carList.get(id).price1 = that.carList.get(id).productCount * that.carList - .get(id).purchasePrice - // } - }) - this.$nextTick(()=>{ - this.getAllPrice() - }) }, - obtainPrice(e, type, num,num1) { + maskClick() { + console.log('maskClick事件:', this.single); + }, + async mapMinusNum(index) { + this.temporaryList[index].productCount-- + this.temporaryChange() + }, + mapPlusNum(index) { + this.temporaryList[index].productCount++ + this.temporaryChange() + }, + async oneMinusNum(index, index1) { + let that = this; + this.carList.get(index).productCount = 0 + this.carList.get(index).returnCount = 0 + this.carList.get(index).stockLogList.get(index1).productCount-- + await this.carList.get(index).stockLogList.forEach(function(value, key) { + if (value.productCount < 0) { + that.carList.get(index).returnCount = that.carList.get(index).returnCount + Math.abs( + value.productCount) + } else { + that.carList.get(index).productCount = that.carList.get(index).productCount + value + .productCount + } + }) + await this.$nextTick(() => { + // if (that.discountType != 0) { //单品折扣 + that.carList.get(index).price1 = that.carList.get(index).productCount * that.carList + .get(index).purchasePrice + // } + }) + this.$forceUpdate() + this.getAllPrice() + }, + onePlusNum(index, index1) { + let that = this; + this.carList.get(index).stockLogList.get(index1).productCount++ + that.carList.get(index).productCount++ + that.carList.get(index).price1 = that.carList.get(index).productCount * that.carList + .get(index).purchasePrice + this.getAllPrice() + }, + yuyinChange() { + this.isVoice = false + }, + numChange(e, index) { + if (this.linshiPrice == e.target.value) { + this.temporaryList[index].productCount = Number(e.target.value) + } else { + if (e.detail.value == '') { + this.temporaryList[index].productCount = Number(this.linshiPrice) + } else if (e.detail.value == 0) { + this.temporaryList[index].productCount = 0 + } else { + this.temporaryList[index].productCount = Number(e.detail.value); + } + this.$forceUpdate() + } + this.temporaryChange() + }, + mapnumChange(e, id, id1) { + let that = this; + this.carList.get(id).productCount = 0 + this.carList.get(id).returnCount = 0 + if (this.linshiPrice == e.target.value) { + this.carList.get(id).stockLogList.get(id1).productCount = e.target.value + } else { + if (e.detail.value == '') { + this.carList.get(id).stockLogList.get(id1).productCount = this.linshiPrice + } else { + this.carList.get(id).stockLogList.get(id1).productCount = Number(e.detail.value) + } + } + + this.carList.get(id).stockLogList.forEach(function(value, key) { + if (value.productCount < 0) { + that.carList.get(id).returnCount = that.carList.get(id).returnCount + Math.abs(value + .productCount) + } else { + that.carList.get(id).productCount = that.carList.get(id).productCount + value.productCount + } + }) + this.$nextTick(() => { + // if (that.discountType != 0) { //单品折扣 + that.carList.get(id).price1 = that.carList.get(id).productCount * that.carList + .get(id).purchasePrice + // } + }) + this.$nextTick(() => { + this.getAllPrice() + }) + }, + voiceGetOne() { + this.voiceGetOneData = !this.voiceGetOneData + }, + obtainPrice(e, type, num, num1) { this.linshiPrice = e.target.value if (type == 'danjia') { this.carList.get(num).purchasePrice = '' @@ -2740,17 +4763,17 @@ } else if (type == 'lingshou') { this.carList.get(num).lsprice = '' this.$forceUpdate() - }else if(type=='danjishu'){ - this.temporaryList[num].productCount = '' - this.$forceUpdate() + } else if (type == 'danjishu') { + this.temporaryList[num].productCount = '' + this.$forceUpdate() } else if (type == 'zongjishu') { this.allChangeNum = '' } else if (type == 'shouldPay') { this.shouldPay = '' - }else if(type=='mapdanjishu'){ - this.carList.get(num).stockLogList.get(num1).productCount = '' - this.$forceUpdate() - }else if (type == 'alreadyPay') { + } else if (type == 'mapdanjishu') { + this.carList.get(num).stockLogList.get(num1).productCount = '' + this.$forceUpdate() + } else if (type == 'alreadyPay') { this.alreadyPay = '' } this.$forceUpdate() @@ -2822,8 +4845,8 @@ url: '/package1/AI/AiChangeGoods' }) }, - longPrec(index,value,index1){ - console.log('删除',index,value,index1) + longPrec(index, value, index1) { + console.log('删除', index, value, index1) var that = this; uni.showModal({ title: "提示", @@ -2833,7 +4856,7 @@ title: '加载中...' }) if (res.confirm) { - that.delDefaultCate(index,value,index1) + that.delDefaultCate(index, value, index1) } setTimeout(res => { uni.hideLoading(); @@ -2884,7 +4907,7 @@ this.evalue.push(name) } if (jishuqi == 0) { - this.oldTemList = [] + this.oldTemList = [] this.temporaryList = this.pageOldTemList } if (this.temporaryList.length == 0) { @@ -2954,7 +4977,7 @@ for (var m = 0; m < that.pecsList.length; m++) { if (that.temporaryList[i].attributeList == that.pecsList[m].attributeList) { that.temporaryList[i].productNum = that.pecsList[m].stockCount - } + } that.$forceUpdate() } } @@ -2980,12 +5003,18 @@ this.$forceUpdate() this.$refs.typePopup.close() }, + changeMore(e) { + + if (e.show == false) { + this.moreData = [] + } + }, change() { this.allChangeNum = 0 this.oldTemList = [] - }, - lunbochange(e) { - this.current = e.detail.current + }, + lunbochange(e) { + this.current = e.detail.current }, //弹出商品规格选择 toggle(type, id) { @@ -3007,12 +5036,19 @@ } else if (type == 'center') { this.initRecord(); this.voiceText = '' + this.voiceText1 = '' this.$refs.popup.open(type) - }else if(type == 'oneGoods'){ - this.oneGoodsId = id - this.initRecord(); - this.voiceText = '' - this.$refs.popup.open('center') + } else if (type == 'voiceBottom') { + this.initRecord(); + this.voiceText = '' + this.voiceText1 = '' + this.$refs.voiceBottomPopup.open('bottom') + } else if (type == 'oneGoods') { + this.oneGoodsId = id + this.initRecord(); + this.voiceText = '' + this.voiceText1 = '' + this.$refs.popup.open('center') } }, //按住语音识别,开始 @@ -3047,49 +5083,78 @@ }, //查询货号的后面第一个中文字符是不是“数量”,是返回true isQuantityFollowsProductCode(str) { - const afterProductCode = str.split('货号')[1]; - if (!afterProductCode || afterProductCode.indexOf('数量') === -1) { - return false; - } - const beforeQuantity = afterProductCode.split('数量')[0]; - const containsChineseCharacter = /[^\u4e00-\u9fa5]/.test(beforeQuantity); - return !containsChineseCharacter; + const afterProductCode = str.split('货号')[1]; + if (!afterProductCode || afterProductCode.indexOf('数量') === -1) { + return false; + } + const beforeQuantity = afterProductCode.split('数量')[0]; + const containsChineseCharacter = /[^\u4e00-\u9fa5]/.test(beforeQuantity); + return !containsChineseCharacter; }, extractInfo(str) { - const info = {}; - const regexes = [ - { name: 'productSn', regex: /货号(.*?),/ }, - { name: 'productCount', regex: /,数量:(.*?),/ }, - { name: 'productCount', regex: /,数量:(.*?)。/ }, - { name: 'purchasePrice', regex: /,单价:(.*?),/ }, - { name: 'purchasePrice', regex: /,单价:(.*?)。/ }, - { name: 'productName', regex: /,名称:(.*?),/ }, - { name: 'productName', regex: /,名称:(.*?)。/ }, - { name: 'wholesalePrice', regex: /,批发价:(.*?),/ }, - { name: 'wholesalePrice', regex: /,批发价:(.*?)。/ } - - ]; - - regexes.forEach(({name, regex}) => { - const match = str.match(regex); - if (match && match[1]) { - // 去除可能的前后空格 - info[name] = match[1].trim(); - } - }); - if(info.productCount && info.productCount.indexOf(',') != -1){ + const info = {}; + const regexes = [{ + name: 'productSn', + regex: /货号(.*?),/ + }, + { + name: 'productCount', + regex: /,数量:(.*?),/ + }, + { + name: 'productCount', + regex: /,数量:(.*?)。/ + }, + { + name: 'purchasePrice', + regex: /,单价:(.*?),/ + }, + { + name: 'purchasePrice', + regex: /,单价:(.*?)。/ + }, + { + name: 'productName', + regex: /,名称:(.*?),/ + }, + { + name: 'productName', + regex: /,名称:(.*?)。/ + }, + { + name: 'wholesalePrice', + regex: /,批发价:(.*?),/ + }, + { + name: 'wholesalePrice', + regex: /,批发价:(.*?)。/ + } + + ]; + + regexes.forEach(({ + name, + regex + }) => { + const match = str.match(regex); + if (match && match[1]) { + // 去除可能的前后空格 + info[name] = match[1].trim(); + } + }); + if (info.productCount && info.productCount.indexOf(',') != -1) { info.productCount = info.productCount.split(',')[0] } - if(info.purchasePrice && info.purchasePrice.indexOf(',') != -1){ + if (info.purchasePrice && info.purchasePrice.indexOf(',') != -1) { info.purchasePrice = info.purchasePrice.split(',')[0] } - if(info.productName && info.productName.indexOf(',') != -1){ + if (info.productName && info.productName.indexOf(',') != -1) { info.productName = info.productName.split(',')[0] } - if(info.wholesalePrice && info.wholesalePrice.indexOf(',') != -1){ + if (info.wholesalePrice && info.wholesalePrice.indexOf(',') != -1) { info.wholesalePrice = info.wholesalePrice.split(',')[0] } - return info; + return info; }, //语音识别功能初始化 initRecord() { @@ -3100,7 +5165,7 @@ let convertedStr = this.spliceMsg(this.convertChineseToArabic(res.result)); convertedStr = this.removeSpacesAndCommas(convertedStr) convertedStr = this.removePunctuationAndSpaces(convertedStr) - console.log('说完convertedStr',convertedStr) + console.log('说完convertedStr', convertedStr) if (convertedStr.indexOf('点') != -1) { convertedStr = that.replaceCharAfterNumber(convertedStr, '点', '.') } @@ -3148,28 +5213,31 @@ } if (convertedStr.indexOf('货号,') != -1) { convertedStr = convertedStr.replace(/货号,/g, '货号') - } - if (convertedStr.indexOf('货号::') != -1) { - convertedStr = convertedStr.replace(/货号::/g, '货号') - } - if (convertedStr.indexOf('货号:') != -1) { - convertedStr = convertedStr.replace(/货号:/g, '货号') + } + if (convertedStr.indexOf('货号::') != -1) { + convertedStr = convertedStr.replace(/货号::/g, '货号') + } + if (convertedStr.indexOf('货号:') != -1) { + convertedStr = convertedStr.replace(/货号:/g, '货号') } if (convertedStr.indexOf('货号') != -1) { convertedStr = convertedStr.replace(/货号/g, '货号:') } + convertedStr = convertedStr.replace(/[沟勾钩]/g, 'J'); convertedStr = this.convertStringCorrectly(convertedStr) if (convertedStr.indexOf(',') == 0) { convertedStr = convertedStr.substr(1) } - if (convertedStr.startsWith("号")) { - convertedStr = "货号" + convertedStr.substr(1); + if (convertedStr.startsWith("号")) { + convertedStr = "货号" + convertedStr.substr(1); } if (that.voiceText == '' || that.voiceText == null) { that.voiceText = convertedStr + that.voiceText1 = convertedStr } else { that.voiceText += '\n' + convertedStr + that.voiceText1 = convertedStr + '\n' + that.voiceText1 } } @@ -3203,6 +5271,10 @@ //清空语音输入的文字 clearText() { this.voiceText = '' + this.voiceText1 = '' + }, + getText(e) { + this.voiceText = e.detail.value }, //正则匹配处理“2十9”等情况 convertStringCorrectly(str) { @@ -3242,10 +5314,25 @@ '实件': '10件', '景': '#', '警': '#', - '颈': '#', - '括号':'货号' + '颈': '#', + '括号': '货号', + '名城': '名称', + '明城': '名称', + '名成': '名称', + '名程': '名称', + '上移': '上衣', + '时1': '11', + '时2': '12', + '时3': '13', + '时4': '14', + '时5': '15', + '时6': '16', + '时7': '17', + '时8': '18', + '时9': '19', + }; - const regex = /(零|一|二|两|三|四|五|六|七|八|九|杠|刚|军色|叉|井|时间|事件|世间|实践|实件|景|警|颈|括号)/g; + const regex = /(零|一|二|两|三|四|五|六|七|八|九|杠|刚|军色|叉|井|时间|事件|世间|实践|实件|景|警|颈|括号|名城|名程|名成|明城|上移|时1|时2|时3|时4|时5|时6|时7|时8|时9)/g; return str.replace(regex, match => chineseNumToArabic[match]); }, //合并已有 @@ -3272,88 +5359,89 @@ AiAddSpec(value) { this.getById(value, 1); }, - pictureAdd(id,huan) { - let that = this - uni.showLoading({ - title: '加载中...', - mask:true - }) - if(id != ''){ //上传多图 - this.childrenId = id - if(this.carList.get(id).productPictures.length > 0 && huan !='huan'){ - this.productPictures = this.carList.get(id).productPictures - this.$refs.showImgDiaLog.open() - uni.hideLoading(); - return; - }else if(huan == 'huan'){ - this.$refs.showImgDiaLog.close() - } - }else{ - this.childrenId = '' + pictureAdd(id, huan) { + let that = this + uni.showLoading({ + title: '加载中...', + mask: true + }) + if (id != '') { //上传多图 + this.childrenId = id + if (this.carList.get(id).productPictures.length > 0 && huan != 'huan') { + this.productPictures = this.carList.get(id).productPictures + this.$refs.showImgDiaLog.open() + uni.hideLoading(); + return; + } else if (huan == 'huan') { + this.$refs.showImgDiaLog.close() + } + } else { + this.childrenId = '' } uni.chooseMedia({ count: 9, mediaType: ['image'], sourceType: ['album'], - success(res) { - if(that.childrenId !=''){ - that.carList.get(that.childrenId).productPictures = [] - } - for(let i=0;i { - let pathData = JSON.parse(uploadFileRes.data) - if(that.childrenId != ''){ - let data = { - productPicture:pathData.result - } - that.carList.get(that.childrenId).productPictures.push(data) - that.$forceUpdate() - }else{ - setTimeout(function() { - that.isSnList(pathData.result) - }, 100 * time); - - // that.addPageGoods(pathData.result) - } - }, - fail: (err) => { - uni.hideLoading(); - uni.showToast({ - title: JSON.stringify(err), - icon: 'none' - }) - } - }); - await setTimeout(res=>{ - uni.hideLoading(); - },1000) + }, + async upLoadFile(path, time) { + let that = this; + let hiver_token = uni.getStorageSync("hiver_token") + await uni.uploadFile({ + url: that.tui.interfaceUrl() + '/upload/file', + filePath: path, + name: 'file', + header: { + "content-type": "multipart/form-data", + 'accessToken': hiver_token + }, + formData: {}, + success: (uploadFileRes) => { + let pathData = JSON.parse(uploadFileRes.data) + if (that.childrenId != '') { + let data = { + productPicture: pathData.result + } + that.carList.get(that.childrenId).productPictures.push(data) + that.$forceUpdate() + } else { + setTimeout(function() { + that.isSnList(pathData.result) + }, 100 * time); + + // that.addPageGoods(pathData.result) + } + }, + fail: (err) => { + uni.hideLoading(); + uni.showToast({ + title: JSON.stringify(err), + icon: 'none' + }) + } + }); + await setTimeout(res => { + uni.hideLoading(); + }, 1000) }, removeSpacesAndCommas(str) { - // 正则表达式匹配所有空格和逗号 - const regex = /[ ,,]/g; // 注意这里的空格和全角空格(全角逗号也包括在内) - - // 使用replace()方法替换匹配到的空格和逗号为空字符串 - return str.replace(regex, ''); + // 正则表达式匹配所有空格和逗号 + const regex = /[ ,,]/g; // 注意这里的空格和全角空格(全角逗号也包括在内) + + // 使用replace()方法替换匹配到的空格和逗号为空字符串 + return str.replace(regex, ''); }, //通过商品id查询商品详细信息 getById(id, current) { @@ -3361,345 +5449,359 @@ uni.showLoading({ title: '加载中...' }) - this.isBottom = false - //判断isNew,新商品直接调店铺颜色库 - if(current == 1){ - console.log('goodsDetail',id) - that.goodsDetail = id; - that.goodsDetail.attributeList = [] - if(this.goodsDetail.isNew){ - this.goodsList = [] - that.goodsDetail.attributeList = this.defaultList - for (var i = 0; i < that.goodsDetail.attributeList.length; i++) { - for (var m = 0; m < that.goodsDetail.attributeList[i].value.length; m++) { - that.dataObj.set(that.goodsDetail.attributeList[i].value[m].value,that.goodsDetail.attributeList[i].name) - } - let specs1 = { - specs: [] - } - that.goodsList.push(specs1) - } - this.$refs.shopPopup.open('bottom') - }else{ - that.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", - "POST", { - categoryId: that.goodsDetail.attrId - }, false, true).then((res1) => { - if (res1.code == 200) { - that.goodsList = [] - if (typeof(res1.result.attributeAndValue) == 'string') { - let newObj = JSON.parse(res1.result.attributeAndValue) - let newArr = [] - let dataArr = [] - for (let val in newObj) { - let valueObj = []; - for (var i = 0; i < newObj[val].length; i++) { - valueObj.push({ - value: newObj[val][i], - isChecked: false - }) - that.dataObj.set(newObj[val][i], val) - } - newArr.push({ - name: val, - value: valueObj - }) - } - that.goodsDetail.attributeList = newArr; - for (var i = 0; i < that.goodsDetail.attributeList.length; i++) { - let specs1 = { - specs: [] - } - that.goodsList.push(specs1) - } - } else { - that.tui.toast('失败了') - } - that.getKCList(res1.result.stock); - } else { - that.tui.toast(res1.message) - } - }).catch((res) => {}) - } - this.pageOldTemList = [] - that.temporaryList = [] - if (that.carList.size > 0) { - let isArgin = false - that.carList.forEach(function(value, key) { - value.stockLogList1 = [] - if (isArgin == false) { - value.stockLogList.forEach(function(values, keys) { - if (value.stockLogList1.length == 0) { - let obj = { - productCount: values.productCount, - name: values.name, - attributeList: keys, - productNum: values.productNum - } - value.stockLogList1.push(obj) - } else { - for (var i = 0; i < value.stockLogList1.length; i++) { - if (value.stockLogList1[i].attributeList != keys) { - if (value.stockLogList1.length == (i + 1)) { - let obj = { - productCount: values.productCount, - name: values.name, - attributeList: keys, - productNum: values.productNum - } - value.stockLogList1.push(obj) - } - } - } - } - - }) - - if (value.productId == id) { - that.zNum = value.productCount - that.temporaryList = value.stockLogList1 - that.pageOldTemList = value.stockLogList1 - that.oldTemList = value.stockLogList1 - isArgin = true - } else { - if (value.isNew) { - if (value.id == id.id) { - that.zNum = value.productCount - that.temporaryList = value.stockLogList1 - that.pageOldTemList = value.stockLogList1 - that.oldTemList = value.stockLogList1 - isArgin = true - } - } else { - if (value.productId == id.productId) { - that.zNum = value.productCount - that.temporaryList = value.stockLogList1 - that.pageOldTemList = value.stockLogList1 - that.oldTemList = value.stockLogList1 - isArgin = true - } - } - - } - value.stockLogList1 = [] - - } - - }) - that.zNum = 0 - // that.$nextTick(() => { - // that.carList.forEach(function(value, key) { - - // }) - // }) - } - }else{ - this.tui.request("/app/product/getById/" + id, "POST", {}, false, true).then((res) => { - if (res.code == 200) { - if (res.result.delFlag == 0) { - that.tui.toast("请将商品上架后再操作!") - return - } - if (res.result.inStorageStatus == 0) { - that.tui.toast("请将商品入库后再操作!") - return - } - - that.goodsDetail = res.result; - that.goodsDetail.attributeList = this.defaultList - that.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", - "POST", { - categoryId: that.goodsDetail.attrId || that.categoryList.attrId - }, false, true).then((res1) => { - if (res1.code == 200) { - that.goodsList = [] - if (typeof(res1.result.attributeAndValue) == 'string') { - let newObj = JSON.parse(res1.result.attributeAndValue) - let newArr = [] - let dataArr = [] - for (let val in newObj) { - let valueObj = []; - for (var i = 0; i < newObj[val].length; i++) { - valueObj.push({ - value: newObj[val][i], - isChecked: false - }) - that.dataObj.set(newObj[val][i], val) - } - newArr.push({ - name: val, - value: valueObj - }) - } - that.goodsDetail.attributeList = newArr; - for (var i = 0; i < that.goodsDetail.attributeList.length; i++) { - // let oldCheck = false - // let oldValue = [] - // for (var m = 0; m < that.goodsDetail.attributeList[i].value - // .length; m++) { - // if (that.goodsDetail.attributeList[i].value[m] - // .isChecked == true) { - // oldCheck = true - // oldValue.push(that.goodsDetail.attributeList[i] - // .value[m].value) - // } - // } - let specs1 = { - specs: [] - } - that.goodsList.push(specs1) - // oldCheck = false - // oldValue = [] - } - } else { - that.tui.toast('失败了') - } - - this.pageOldTemList = [] - that.temporaryList = [] - if (that.carList.size > 0) { - let isArgin = false - that.carList.forEach(function(value, key) { - value.stockLogList1 = [] - if (isArgin == false) { - value.stockLogList.forEach(function(values, keys) { - if (value.stockLogList1.length == 0) { - let obj = { - productCount: values.productCount, - name: values.name, - attributeList: keys, - productNum: values.productNum - } - value.stockLogList1.push(obj) - } else { - for (var i = 0; i < value.stockLogList1.length; i++) { - if (value.stockLogList1[i].attributeList != keys) { - if (value.stockLogList1.length == (i + 1)) { - let obj = { - productCount: values.productCount, - name: values.name, - attributeList: keys, - productNum: values.productNum - } - value.stockLogList1.push(obj) - } - } - } - } - - }) - - if (value.productId == id) { - that.zNum = value.productCount - that.temporaryList = value.stockLogList1 - that.pageOldTemList = value.stockLogList1 - that.oldTemList = value.stockLogList1 - isArgin = true - } else { - if (value.isNew) { - if (value.id == id.id) { - that.zNum = value.productCount - that.temporaryList = value.stockLogList1 - that.pageOldTemList = value.stockLogList1 - that.oldTemList = value.stockLogList1 - isArgin = true - } - } else { - if (value.productId == id.productId) { - that.zNum = value.productCount - that.temporaryList = value.stockLogList1 - that.pageOldTemList = value.stockLogList1 - that.oldTemList = value.stockLogList1 - isArgin = true - } - } - - } - value.stockLogList1 = [] - - } - - }) - that.zNum = 0 - // that.$nextTick(() => { - // that.carList.forEach(function(value, key) { - - // }) - // }) - } - this.getKCList(res1.result.stock) - } else { - that.tui.toast(res1.message) - } - }).catch((res) => {}) - } else { - this.tui.toast(res.message) - } - }).catch((res) => {}) - } + this.isBottom = false + //判断isNew,新商品直接调店铺颜色库 + if (current == 1) { + console.log('goodsDetail', id) + that.goodsDetail = id; + that.goodsDetail.attributeList = [] + if (this.goodsDetail.isNew) { + this.goodsList = [] + that.goodsDetail.attributeList = this.defaultList + for (var i = 0; i < that.goodsDetail.attributeList.length; i++) { + for (var m = 0; m < that.goodsDetail.attributeList[i].value.length; m++) { + that.dataObj.set(that.goodsDetail.attributeList[i].value[m].value, that.goodsDetail + .attributeList[i].name) + } + let specs1 = { + specs: [] + } + that.goodsList.push(specs1) + } + this.$refs.shopPopup.open('bottom') + } else { + that.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", + "POST", { + categoryId: that.goodsDetail.attrId + }, false, true).then((res1) => { + if (res1.code == 200) { + that.goodsList = [] + if (typeof(res1.result.attributeAndValue) == 'string') { + let newObj = JSON.parse(res1.result.attributeAndValue) + let newArr = [] + let dataArr = [] + for (let val in newObj) { + let valueObj = []; + for (var i = 0; i < newObj[val].length; i++) { + valueObj.push({ + value: newObj[val][i], + isChecked: false + }) + that.dataObj.set(newObj[val][i], val) + } + newArr.push({ + name: val, + value: valueObj + }) + } + that.goodsDetail.attributeList = newArr; + for (var i = 0; i < that.goodsDetail.attributeList.length; i++) { + let specs1 = { + specs: [] + } + that.goodsList.push(specs1) + } + } else { + that.tui.toast('失败了') + } + that.getKCList(res1.result.stock); + } else { + that.tui.toast(res1.message) + } + }).catch((res) => {}) + } + this.pageOldTemList = [] + that.temporaryList = [] + if (that.carList.size > 0) { + let isArgin = false + that.carList.forEach(function(value, key) { + value.stockLogList1 = [] + if (isArgin == false) { + value.stockLogList.forEach(function(values, keys) { + if (value.stockLogList1.length == 0) { + let obj = { + productCount: values.productCount, + name: values.name, + attributeList: keys, + productNum: values.productNum + } + value.stockLogList1.push(obj) + } else { + for (var i = 0; i < value.stockLogList1.length; i++) { + if (value.stockLogList1[i].attributeList != keys) { + if (value.stockLogList1.length == (i + 1)) { + let obj = { + productCount: values.productCount, + name: values.name, + attributeList: keys, + productNum: values.productNum + } + value.stockLogList1.push(obj) + } + } + } + } + + }) + + if (value.productId == id) { + that.zNum = value.productCount + that.temporaryList = value.stockLogList1 + that.pageOldTemList = value.stockLogList1 + that.oldTemList = value.stockLogList1 + isArgin = true + } else { + if (value.isNew) { + if (value.id == id.id) { + that.zNum = value.productCount + that.temporaryList = value.stockLogList1 + that.pageOldTemList = value.stockLogList1 + that.oldTemList = value.stockLogList1 + isArgin = true + } + } else { + if (value.productId == id.productId) { + that.zNum = value.productCount + that.temporaryList = value.stockLogList1 + that.pageOldTemList = value.stockLogList1 + that.oldTemList = value.stockLogList1 + isArgin = true + } + } + + } + value.stockLogList1 = [] + + } + + }) + that.zNum = 0 + // that.$nextTick(() => { + // that.carList.forEach(function(value, key) { + + // }) + // }) + } + } else { + this.tui.request("/app/product/getById/" + id, "POST", {}, false, true).then((res) => { + if (res.code == 200) { + if (res.result.delFlag == 0) { + that.tui.toast("请将商品上架后再操作!") + return + } + if (res.result.inStorageStatus == 0) { + that.tui.toast("请将商品入库后再操作!") + return + } + + that.goodsDetail = res.result; + that.goodsDetail.attributeList = this.defaultList + that.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", + "POST", { + categoryId: that.goodsDetail.attrId || that.categoryList.attrId + }, false, true).then((res1) => { + if (res1.code == 200) { + that.goodsList = [] + if (typeof(res1.result.attributeAndValue) == 'string') { + let newObj = JSON.parse(res1.result.attributeAndValue) + let newArr = [] + let dataArr = [] + for (let val in newObj) { + let valueObj = []; + for (var i = 0; i < newObj[val].length; i++) { + valueObj.push({ + value: newObj[val][i], + isChecked: false + }) + that.dataObj.set(newObj[val][i], val) + } + newArr.push({ + name: val, + value: valueObj + }) + } + that.goodsDetail.attributeList = newArr; + for (var i = 0; i < that.goodsDetail.attributeList.length; i++) { + // let oldCheck = false + // let oldValue = [] + // for (var m = 0; m < that.goodsDetail.attributeList[i].value + // .length; m++) { + // if (that.goodsDetail.attributeList[i].value[m] + // .isChecked == true) { + // oldCheck = true + // oldValue.push(that.goodsDetail.attributeList[i] + // .value[m].value) + // } + // } + let specs1 = { + specs: [] + } + that.goodsList.push(specs1) + // oldCheck = false + // oldValue = [] + } + } else { + that.tui.toast('失败了') + } + + this.pageOldTemList = [] + that.temporaryList = [] + if (that.carList.size > 0) { + let isArgin = false + that.carList.forEach(function(value, key) { + value.stockLogList1 = [] + if (isArgin == false) { + value.stockLogList.forEach(function(values, keys) { + if (value.stockLogList1.length == 0) { + let obj = { + productCount: values + .productCount, + name: values.name, + attributeList: keys, + productNum: values + .productNum + } + value.stockLogList1.push(obj) + } else { + for (var i = 0; i < value + .stockLogList1.length; i++) { + if (value.stockLogList1[i] + .attributeList != keys) { + if (value.stockLogList1 + .length == (i + 1)) { + let obj = { + productCount: values + .productCount, + name: values + .name, + attributeList: keys, + productNum: values + .productNum + } + value.stockLogList1 + .push(obj) + } + } + } + } + + }) + + if (value.productId == id) { + that.zNum = value.productCount + that.temporaryList = value.stockLogList1 + that.pageOldTemList = value.stockLogList1 + that.oldTemList = value.stockLogList1 + isArgin = true + } else { + if (value.isNew) { + if (value.id == id.id) { + that.zNum = value.productCount + that.temporaryList = value + .stockLogList1 + that.pageOldTemList = value + .stockLogList1 + that.oldTemList = value.stockLogList1 + isArgin = true + } + } else { + if (value.productId == id.productId) { + that.zNum = value.productCount + that.temporaryList = value + .stockLogList1 + that.pageOldTemList = value + .stockLogList1 + that.oldTemList = value.stockLogList1 + isArgin = true + } + } + + } + value.stockLogList1 = [] + + } + + }) + that.zNum = 0 + // that.$nextTick(() => { + // that.carList.forEach(function(value, key) { + + // }) + // }) + } + this.getKCList(res1.result.stock) + } else { + that.tui.toast(res1.message) + } + }).catch((res) => {}) + } else { + this.tui.toast(res.message) + } + }).catch((res) => {}) + } uni.hideLoading() - }, - changeSn(){ - - }, - //新增商品的时候,判断有没有货号生成规则,没有则弹出货号新增弹出层 - async isSnList(img){ - if(this.isGenerateSnRadio == 1){ //不自动生成货号 - await this.addPageGoods(img,'') - }else{ - if(this.snList.length > 0){ - await this.getNewSn(img) - }else{ - this.zhuImg = img - this.$refs.SNDialog.open('center') - uni.hideLoading() - } - } - }, - //获取新货号 - getNewSn(img){ - this.tui.request("/app/productSn/getNewProductSn", "POST", { - snPre: this.snName - }, false, true).then((res) => { - if (res.code == 200) { - this.addPageGoods(img,res.result) - } else { - uni.hideLoading() - this.tui.toast(res.message) - } - }).catch((res) => { - uni.hideLoading() - }) - }, + }, + changeSn() { + + }, + //新增商品的时候,判断有没有货号生成规则,没有则弹出货号新增弹出层 + async isSnList(img) { + if (this.isGenerateSnRadio == 1) { //不自动生成货号 + await this.addPageGoods(img, '') + } else { + if (this.snList.length > 0) { + await this.getNewSn(img) + } else { + this.zhuImg = img + this.$refs.SNDialog.open('center') + uni.hideLoading() + } + } + }, + //获取新货号 + getNewSn(img) { + this.tui.request("/app/productSn/getNewProductSn", "POST", { + snPre: this.snName + }, false, true).then((res) => { + if (res.code == 200) { + this.addPageGoods(img, res.result) + } else { + uni.hideLoading() + this.tui.toast(res.message) + } + }).catch((res) => { + uni.hideLoading() + }) + }, //getNewProductSnMore count/snPre - addPageGoods(path,sn) { + addPageGoods(path, sn) { let obj = { - id: sn?sn:generateUUID(), + id: sn ? sn : generateUUID(), purchasePrice: 0, //进货价 - price: 0, - price1:0, - categoryName: this.categoryList.categoryName, + price: 0, + price1: 0, + categoryName: this.categoryList.categoryName, categoryId: this.categoryList.categoryId, productCount: 0, productId: "", productName: "", wholesalePrice: 0, lsprice: 0, - isNew: true, - productPictures:[], - productPicture: path?path:'', - productSn: sn?sn:"", + isNew: true, + productPictures: [], + productPicture: path ? path : '', + productSn: sn ? sn : "", stockLogList: new Map(), stockLogList1: [] - } - let key = '{"颜色":"均色","尺码":"均码"}' - let value = { - name: '均色/均码', - productCount: 0 - } + } + let key = '{"颜色":"均色","尺码":"均码"}' + let value = { + name: '均色/均码', + productCount: 0 + } obj.stockLogList.set(key, value) this.carList.set(obj.id, obj) - this.$forceUpdate() + this.$forceUpdate() uni.hideLoading() }, //库存商品详情 @@ -3710,9 +5812,9 @@ // }, false, true).then((res) => { // if (res.code == 200) { this.pecsList = list - // } else { - // this.tui.toast(res.message) - // } + // } else { + // this.tui.toast(res.message) + // } // }).catch((res) => {}) // setTimeout(res => { // that.$forceUpdate() @@ -3741,12 +5843,12 @@ } }, clickClose(e) { - this.evalue = [] - for (let i = 0; i < this.goodsDetail.attributeList.length; i++) { - this.goodsDetail.attributeList[i].isChecked = false; - for (let m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) { - this.goodsDetail.attributeList[i].value[m].isChecked = false - } + this.evalue = [] + for (let i = 0; i < this.goodsDetail.attributeList.length; i++) { + this.goodsDetail.attributeList[i].isChecked = false; + for (let m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) { + this.goodsDetail.attributeList[i].value[m].isChecked = false + } } this.allChangeNum = 0 }, @@ -3767,17 +5869,17 @@ wholesalePrice: this.goodsDetail.wholesalePrice, purchasePrice: this.goodsDetail.purchasePrice, categoryName: this.goodsDetail.categoryName, - categoryId: this.goodsDetail.categoryId, + categoryId: this.goodsDetail.categoryId, attrId: this.goodsDetail.attrId, lsprice: this.goodsDetail.price, productSn: this.goodsDetail.productSn, productPicture: this.goodsDetail.productPicture, - supplierName: this.goodsDetail.supplierName, - productPictures:[], + supplierName: this.goodsDetail.supplierName, + productPictures: [], saleDetailQueryDTO: this.temporaryList } carList1.push(data) - this.temporaryList = [] + this.temporaryList = [] this.oldTemList = [] this.purchasePrice = '' this.zPrice = '' @@ -3799,31 +5901,31 @@ productId: carList1[i].id, wholesalePrice: this.goodsDetail.wholesalePrice, categoryName: this.goodsDetail.categoryName, - categoryId: carList1[i].categoryId, + categoryId: carList1[i].categoryId, attrId: carList1[i].attrId, lsprice: this.goodsDetail.price, productName: carList1[i].productName, productPicture: carList1[i].productPicture, productSn: carList1[i].productSn, - stockLogList: new Map(), - productPictures:[], + stockLogList: new Map(), + productPictures: [], stockLogList1: [] } for (let m = 0; m < carList1[i].saleDetailQueryDTO.length; m++) { - + var data1 = { productCount: carList1[i].saleDetailQueryDTO[m].productCount, - name: carList1[i].saleDetailQueryDTO[m].name, - productNum:carList1[i].saleDetailQueryDTO[m].productNum - } - if(carList1[i].saleDetailQueryDTO.length > 1){ - if(data1.productCount > 0){ - obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) - } - }else{ - obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) + name: carList1[i].saleDetailQueryDTO[m].name, + productNum: carList1[i].saleDetailQueryDTO[m].productNum + } + if (carList1[i].saleDetailQueryDTO.length > 1) { + if (data1.productCount > 0) { + obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) + } + } else { + obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) } - + obj.productCount += carList1[i].saleDetailQueryDTO[m].productCount obj.price1 = obj.productCount * this.goodsDetail.purchasePrice } @@ -3851,16 +5953,17 @@ productCount: carList1[i].saleDetailQueryDTO[m].productCount, name: carList1[i].saleDetailQueryDTO[m].name } - if(carList1[i].saleDetailQueryDTO.length > 1){ - if(data1.productCount > 0){ - this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[m] - .attributeList, data1) - } - }else{ - this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[m] - .attributeList, data1) + if (carList1[i].saleDetailQueryDTO.length > 1) { + if (data1.productCount > 0) { + this.carList.get(carList1[i].id).stockLogList.set(carList1[i] + .saleDetailQueryDTO[m] + .attributeList, data1) + } + } else { + this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[m] + .attributeList, data1) } - + // this.carList.get(carList1[i].id).stockLogList.get(carList1[i] // .saleDetailQueryDTO[m].attributeList).productCount += carList1[i] // .saleDetailQueryDTO[m].productCount @@ -3870,15 +5973,16 @@ var data1 = { productCount: carList1[i].saleDetailQueryDTO[m].productCount, name: carList1[i].saleDetailQueryDTO[m].name - } - if(carList1[i].saleDetailQueryDTO.length > 1){ - if(data1.productCount > 0){ - this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[m] - .attributeList, data1) - } - }else{ - this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[m] - .attributeList, data1) + } + if (carList1[i].saleDetailQueryDTO.length > 1) { + if (data1.productCount > 0) { + this.carList.get(carList1[i].id).stockLogList.set(carList1[i] + .saleDetailQueryDTO[m] + .attributeList, data1) + } + } else { + this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[m] + .attributeList, data1) } } this.carList.get(carList1[i].id).productCount += carList1[i].saleDetailQueryDTO[ @@ -3893,7 +5997,7 @@ price1: 0, productCount: 0, productId: carList1[i].id, - categoryId: carList1[i].categoryId, + categoryId: carList1[i].categoryId, attrId: carList1[i].attrId, productName: carList1[i].productName, wholesalePrice: this.goodsDetail.wholesalePrice, @@ -3901,23 +6005,23 @@ productPicture: carList1[i].productPicture, stockLogList: new Map(), productSn: carList1[i].productSn, - stockLogList1: [], - productPictures:[], + stockLogList1: [], + productPictures: [], name: '' } for (let m = 0; m < carList1[i].saleDetailQueryDTO.length; m++) { var data1 = { productCount: carList1[i].saleDetailQueryDTO[m].productCount, - name: carList1[i].saleDetailQueryDTO[m].name, - productNum:carList1[i].saleDetailQueryDTO[m].productNum + name: carList1[i].saleDetailQueryDTO[m].name, + productNum: carList1[i].saleDetailQueryDTO[m].productNum } - if(carList1[i].saleDetailQueryDTO.length > 1){ - if(data1.productCount > 0){ - obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) - } - }else{ - obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) + if (carList1[i].saleDetailQueryDTO.length > 1) { + if (data1.productCount > 0) { + obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) + } + } else { + obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) } obj.productCount += carList1[i].saleDetailQueryDTO[m].productCount obj.price1 = obj.productCount * this.goodsDetail.purchasePrice @@ -3947,106 +6051,106 @@ } this.alreadyPay = this.shouldPay this.noPay = this.shouldPay - this.alreadyPay; - }, - sninput(e ,id){ - this.carList.get(id).productSn = e.detail.value - this.$forceUpdate() + }, + sninput(e, id) { + this.carList.get(id).productSn = e.detail.value + this.$forceUpdate() }, removePunctuationAndSpaces(str) { - const regex = /[\u3002\uff0c\uff1a\uFF0E\u3001\s,.:;]/g; - return str.replace(regex, ''); + const regex = /[\u3002\uff0c\uff1a\uFF0E\u3001\s,:;]/g; + return str.replace(regex, ''); }, //货号是否重复 - getSnIsRepeat(e, id) { - let that = this; - let isTrue = false - if(e.detail.value != ''){ - this.tui.request('/app/product/getByProductSn', "post", { - productSn: e.detail.value - }, false, true).then((res1) => { - if (res1.code == 200) { - if (res1.result != '') { - isTrue = true - that.tui.toast('当前货号已被商品:“' + res1.result[0].productName + '”占用,请重新输入') - that.carList.get(id).productSn = '' - that.carList.get(id).id = '' - setTimeout(res=>{ - that.$forceUpdate() - },2000) - throw Error('11') - }else { - this.carList.forEach(function(value, key) { - if(value.id != id){ - if(value.productSn == e.detail.value){ - isTrue = true - uni.showToast({ - title: "该货号被页面其他商品占用,请重新输入!", - icon: 'none' - }) - that.carList.get(id).productSn = '' - that.carList.get(id).id = '' - that.$forceUpdate() - throw Error('11') - } - } - }) - } - - } - }) - - this.$nextTick(()=>{ - if(isTrue == false){ - if (that.carList.get(id).productId) { - this.carList.get(id).id = that.carList.get(id).productId - this.carList.get(id).isNew = false - id = that.carList.get(id).productId - } else if (that.carList.get(id).productSn == '' || that.carList.get(id).productSn == - null) { - - this.carList.get(id).id = that.carList.get(id).productName - id = that.carList.get(id).productName - } else if (that.carList.get(id).productSn == '货号') { - this.carList.get(id).productSn = that.carList.get(id).productName - this.carList.get(id).id = that.carList.get(id).productName - id = that.carList.get(id).productName - }else if (that.carList.get(id).productSn) { - - this.carList.get(id).id = that.carList.get(id).productSn - id = that.carList.get(id).productSn - } - this.$forceUpdate() - } - }) - let specMap = new Map() //新的临时存放值那个更改过的值的map - this.$nextTick(()=>{ - // if(isTrue == false){ - this.carList.forEach(function(value, key) { - if(key != value.id){ - if(value.id == ''){ - specMap.set(generateUUID(),value) - }else{ - specMap.set(value.id,value) - } - - }else{ - specMap.set(key,value) - } - }) - this.carList = specMap - // } - }) + getSnIsRepeat(e, id) { + let that = this; + let isTrue = false + if (e.detail.value != '') { + this.tui.request('/app/product/getByProductSn', "post", { + productSn: e.detail.value + }, false, true).then((res1) => { + if (res1.code == 200) { + if (res1.result != '') { + isTrue = true + that.tui.toast('当前货号已被商品:“' + res1.result[0].productName + '”占用,请重新输入') + that.carList.get(id).productSn = '' + that.carList.get(id).id = '' + setTimeout(res => { + that.$forceUpdate() + }, 2000) + throw Error('11') + } else { + this.carList.forEach(function(value, key) { + if (value.id != id) { + if (value.productSn == e.detail.value) { + isTrue = true + uni.showToast({ + title: "该货号被页面其他商品占用,请重新输入!", + icon: 'none' + }) + that.carList.get(id).productSn = '' + that.carList.get(id).id = '' + that.$forceUpdate() + throw Error('11') + } + } + }) + } + + } + }) + + this.$nextTick(() => { + if (isTrue == false) { + if (that.carList.get(id).productId) { + this.carList.get(id).id = that.carList.get(id).productId + this.carList.get(id).isNew = false + id = that.carList.get(id).productId + } else if (that.carList.get(id).productSn == '' || that.carList.get(id).productSn == + null) { + + this.carList.get(id).id = that.carList.get(id).productName + id = that.carList.get(id).productName + } else if (that.carList.get(id).productSn == '货号') { + this.carList.get(id).productSn = that.carList.get(id).productName + this.carList.get(id).id = that.carList.get(id).productName + id = that.carList.get(id).productName + } else if (that.carList.get(id).productSn) { + + this.carList.get(id).id = that.carList.get(id).productSn + id = that.carList.get(id).productSn + } + this.$forceUpdate() + } + }) + let specMap = new Map() //新的临时存放值那个更改过的值的map + this.$nextTick(() => { + // if(isTrue == false){ + this.carList.forEach(function(value, key) { + if (key != value.id) { + if (value.id == '') { + specMap.set(generateUUID(), value) + } else { + specMap.set(value.id, value) + } + + } else { + specMap.set(key, value) + } + }) + this.carList = specMap + // } + }) } }, getName(e, id) { this.carList.get(id).productName = e.detail.value }, - noReturn(){ + noReturn() { this.yuedikou = 0 this.alreadyPay = this.shouldPay this.noPay = this.shouldPay - (this.alreadyPay == '' ? 0 : this.alreadyPay) this.noPay = this.noPay.toFixed(2) - this.leijiqiankuan = Number(this.zhiqianqiankuan) + Number(this.yuedikou) + Number(this.noPay) + this.leijiqiankuan = Number(this.zhiqianqiankuan) + Number(this.yuedikou) + Number(this.noPay) }, //计算欠款 changePay(e) { @@ -4054,25 +6158,31 @@ this.alreadyPay = e.target.value } else if (Number(e.detail.value) > Number(this.shouldPay)) { this.alreadyPay = this.shouldPay + setTimeout(res => { + this.tui.toast("已付金额不能大于应付金额") + }, 100) } else { if (e.target.value == '') { this.alreadyPay = this.linshiPrice } else { this.alreadyPay = e.target.value - if((this.shouldPay - this.alreadyPay) <= Math.abs(this.zhiqianqiankuan) && this.zhiqianqiankuan <0){ + if ((this.shouldPay - this.alreadyPay) <= Math.abs(this.zhiqianqiankuan) && this.zhiqianqiankuan < + 0) { this.yuedikou = this.shouldPay - this.alreadyPay - }else if((this.shouldPay - this.alreadyPay) > Math.abs(this.zhiqianqiankuan) && this.zhiqianqiankuan <0){ + } else if ((this.shouldPay - this.alreadyPay) > Math.abs(this.zhiqianqiankuan) && this + .zhiqianqiankuan < 0) { this.yuedikou = Math.abs(this.zhiqianqiankuan) } - + } } this.noPay = this.shouldPay - this.alreadyPay - this.yuedikou this.noPay = this.noPay.toFixed(2) - this.leijiqiankuan = Number(this.zhiqianqiankuan) + Number(this.yuedikou) + Number(this.noPay) + this.leijiqiankuan = Number(this.zhiqianqiankuan) + Number(this.yuedikou) + Number(this.noPay) }, //跳转选择供应商 goPopleList(popleType) { + uni.setStorageSync('kaidanBack', true) uni.navigateTo({ url: '/package1/index/peopleList?popleType=' + popleType }) @@ -4171,59 +6281,72 @@ }, async goRuku() { let that = this; - let purchase = { - id:uni.getStorageSync('AiInventoryId')?uni.getStorageSync('AiInventoryId'):"", + let purchase = { + id: uni.getStorageSync('AiInventoryId') ? uni.getStorageSync('AiInventoryId') : "", alreadyPay: this.alreadyPay == '' ? 0 : this.alreadyPay, //已付金额 noPay: this.noPay == '' ? 0 : this.noPay, //欠款 shouldPay: this.shouldPay, //应付金额 totalAmount: this.totalAmount, //总数量 remark: this.remark, + purchaseTime: this.single, otherPay: this.otherPay == '' ? 0 : this.otherPay, supplierId: this.khName.id, //供应商id和姓名 supplierName: this.khName.consigneeName } let purchaseDetails = []; - await this.carList.forEach(function(value, key) { - if(that.userType == 1){ - value.purchasePrice = '' + await this.carList.forEach(function(value, key) { + if (that.userType == 1) { + value.purchasePrice = '' } if (value.productSn == '') { uni.showToast({ - title: value.productName + "的货号必须维护~", + title: "货号必须维护~", icon: 'none' }) - return - } - value.price = value.lsprice - value.stockLogList1 = [] - if(value.stockLogList.size == 0){ - let obj = { - productCount: 1, - attributeList: '{"颜色":"均色","尺码":"均码"}' - } - value.productCount = 1 - value.price1 = value.productCount * value.purchasePrice - value.stockLogList1.push(obj) - }else{ - value.stockLogList.forEach(function(values, keys) { - if (values.productCount <= 0) { - that.tui.toast(value.productSn+"的入库数量不能为零~") - throw Error('error') - } - let obj = { - productCount: values.productCount, - attributeList: keys - } - value.stockLogList1.push(obj) - }) + throw Error("11") + } else { + value.price = value.lsprice + value.stockLogList1 = [] + if (value.stockLogList.size == 0) { + let obj = { + productCount: 1, + attributeList: '{"颜色":"均色","尺码":"均码"}' + } + value.productCount = 1 + value.price1 = value.productCount * value.purchasePrice + value.stockLogList1.push(obj) + } else { + value.stockLogList.forEach(function(values, keys) { + if (values.productCount <= 0) { + that.tui.toast(value.productSn + "的入库数量不能为零~") + throw Error('error') + } + let obj = { + productCount: values.productCount, + attributeList: keys + } + value.stockLogList1.push(obj) + }) + } + purchaseDetails.push(value) } - purchaseDetails.push(value) + }) await this.goInventory(purchase, purchaseDetails) }, - async inventorySubmit() { + inventorySubmit() { + let that = this if (this.khName == '') { - await this.gysList() + uni.showModal({ + title: "提示", + content: "您没有选择供应商,要使用“默认供应商”入库吗?", + success: function(res) { + if (res.confirm) { + that.gysList() + } + } + }) + } else { this.goRuku() } @@ -4232,7 +6355,9 @@ goInventory(purchase, purchaseDetails) { uni.navigateTo({ url: '/package1/inventory/inventoryConfirm?aiinventory=1&purchase=' + JSON.stringify( - purchase) + '&purchaseDetails=' + JSON.stringify(purchaseDetails) + '&zhiqianqiankuan=' + this.zhiqianqiankuan + '&yuedikou=' + this.yuedikou + '&leijiqiankuan=' + this.leijiqiankuan + purchase) + '&purchaseDetails=' + JSON.stringify(purchaseDetails) + + '&zhiqianqiankuan=' + this.zhiqianqiankuan + '&yuedikou=' + this.yuedikou + + '&leijiqiankuan=' + this.leijiqiankuan }) }, //编辑每一个的单价 @@ -4288,30 +6413,30 @@ that.shouldPay = that.shouldPay + value.price1 that.totalAmount = that.totalAmount + value.productCount }) - this.$nextTick(()=>{ - if(parseFloat(that.zhiqianqiankuan) < 0){ - if(that.shouldPay > Math.abs(that.zhiqianqiankuan)){ + this.$nextTick(() => { + if (parseFloat(that.zhiqianqiankuan) < 0) { + if (that.shouldPay > Math.abs(that.zhiqianqiankuan)) { that.yuedikou = Math.abs(that.zhiqianqiankuan) this.alreadyPay = this.shouldPay - Math.abs(that.zhiqianqiankuan) - }else if(that.shouldPay <= Math.abs(that.zhiqianqiankuan)){ + } else if (that.shouldPay <= Math.abs(that.zhiqianqiankuan)) { that.yuedikou = that.shouldPay that.alreadyPay = 0 } - }else{ + } else { this.alreadyPay = this.shouldPay } that.shouldPay = that.shouldPay.toFixed(2) - + that.noPay = this.shouldPay - (this.alreadyPay == '' ? 0 : this.alreadyPay) - that.yuedikou that.noPay = that.noPay.toFixed(2) - this.leijiqiankuan = Number(this.zhiqianqiankuan) + Number(this.yuedikou) + Number(this.noPay) + this.leijiqiankuan = Number(this.zhiqianqiankuan) + Number(this.yuedikou) + Number(this.noPay) this.$forceUpdate() }) - - }, - //选择是否需要自动生成货号 - isChange(index) { - this.isGenerateSnRadio = index + + }, + //选择是否需要自动生成货号 + isChange(index) { + this.isGenerateSnRadio = index }, //修改已选规格的数量 GoodsNumChange(e, index, index1) { @@ -4479,7 +6604,8 @@ .price-box-title text { flex: 1; } - .price-box{ + + .price-box { width: 95%; margin: 10px auto; background: #eee; @@ -4494,6 +6620,7 @@ background: linear-gradient(180deg, #fff, #FDF5E6); border: 1px solid #FAEBD7; } + .uni-list-cell { display: flex; margin-right: 20rpx; @@ -4507,7 +6634,7 @@ background: #fff; border-top: 1px solid #eee; height: 150rpx; - z-index: 99; + z-index: 98; } .bottom-left { @@ -4859,7 +6986,7 @@ height: 80rpx; color: #fff; line-height: 80rpx; - margin-top: 30rpx; + margin-top: 50rpx; } .voice-popup-btn { @@ -4920,76 +7047,85 @@ padding: 5px; border-radius: 5px; z-index: 99; - } - .one-goods{ - margin-top: 10px; - width: 100%; - height: 50rpx; - background: #088FEB; - font-size: 28rpx; - text-align: center; - line-height: 50rpx; - color: #fff; - border-radius: 5px; - position: relative; - } - .jiaobiao{ - width: 40rpx; - height: 40rpx; - border-radius: 10px; - color: #fff; - background: red; - position: absolute; - top: -5px; - right: -5px; - text-align: center; - line-height: 40rpx; - font-size: 28rpx; - } - .showImg-box{ - width: 500rpx; - height: 500rpx; - } - @media screen and (min-width: 500px) { - .uni-swiper-dot-box { - width: 400px; - margin: 0 auto; - margin-top: 8px; - } - - .image { - width: 100%; - } - } - .swiper-box { - height: 200px; - } - .swiper-item { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - height: 200px; - color: #fff; - background-color: #cee1fd; - } - .lb-btn{ - width: 100%; - height: 100rpx; - text-align: center; - line-height: 100rpx; - background: #088FEB; - color: #fff; - border-bottom-left-radius: 10px; - border-bottom-right-radius: 10px; } + + .one-goods { + margin-top: 10px; + width: 100%; + height: 50rpx; + background: #088FEB; + font-size: 28rpx; + text-align: center; + line-height: 50rpx; + color: #fff; + border-radius: 5px; + position: relative; + } + + .jiaobiao { + width: 40rpx; + height: 40rpx; + border-radius: 10px; + color: #fff; + background: red; + position: absolute; + top: -5px; + right: -5px; + text-align: center; + line-height: 40rpx; + font-size: 28rpx; + } + + .showImg-box { + width: 700rpx; + height: 1100rpx; + } + + @media screen and (min-width: 500px) { + .uni-swiper-dot-box { + width: 400px; + margin: 0 auto; + margin-top: 8px; + } + + .image { + width: 100%; + } + } + + .swiper-box { + height: 1000rpx; + } + + .swiper-item { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 1000rpx; + color: #fff; + background-color: #cee1fd; + } + + .lb-btn { + width: 100%; + height: 100rpx; + text-align: center; + line-height: 100rpx; + background: #088FEB; + color: #fff; + border-bottom-left-radius: 10px; + border-bottom-right-radius: 10px; + } + @media screen and (min-width: 470px) { - + /* 适配宽度为375px及以上的屏幕 */ .shop-popup-content { height: 900rpx; } - .voice-popup-content{ + + .voice-popup-content { align-items: center; justify-content: center; padding: 15px; @@ -4998,10 +7134,12 @@ height: 500rpx; background-color: #fff; } - .voice-popup-container textarea{ + + .voice-popup-container textarea { height: 200rpx !important; } - .voice-btn{ + + .voice-btn { position: absolute; bottom: -190rpx; left: 30%; @@ -5011,4 +7149,55 @@ border-radius: 50%; } } + + .right-box { + width: 100%; + height: 190rpx; + display: flex; + border-bottom: 1px solid #eee; + position: relative; + } + + .box-left { + width: 130rpx; + height: 131rpx; + background-size: 100%; + margin: 25rpx 30rpx 35rpx 10rpx; + border-radius: 20rpx; + } + + .box-left img { + width: 100%; + height: 100%; + + } + + .box-right { + margin-top: 17rpx; + } + + .box-right-name { + font-size: 30rpx; + font-weight: bold; + } + + .box-right-num { + padding: 5rpx 0; + color: #777; + } + + .box-right-price { + display: flex; + font-size: 25rpx; + } + + .voice-price-box { + display: flex; + flex-direction: column; + margin-right: 20rpx; + } + + .voice-price-box text:first-child { + color: #ffa200 + } \ No newline at end of file diff --git a/package1/index/order.vue b/package1/index/order.vue index 9f48fb6..44a2eba 100644 --- a/package1/index/order.vue +++ b/package1/index/order.vue @@ -1,11 +1,31 @@ @@ -348,6 +470,7 @@ import * as blesdk from '@/components/kk-printer/utils/bluetoolth.js'; import kkPrinter from '@/components/kk-printer/index.vue'; import gbk from '@/components/kk-printer/utils/printUtil-GBK.js'; + import ayQrcode from "@/components/ay-qrcode/ay-qrcode.vue" import { maskShopName, maskPhone @@ -357,6 +480,9 @@ return { defaultText: '贴包单', radio1: 0, + bigImg: [], + shopId: '', + swiperDotIndex: 0, sex: [{ text: '是', value: 0 @@ -382,7 +508,7 @@ returnList: [], editNoPrice: false, newEarn: 0, - shopRemark:[], + shopRemark: [], qrcodeData: '', isgys: true, printHeight: 0, @@ -399,16 +525,18 @@ sAmout: 0, yNum: 150, printTotal: 1040, - zReturnNum: "", deviceType: 'ios', qrArr: [], isShare: false, isDownKH: false, - addressArr:[] + addressArr: [], + modal_qr: false, + qrCodeUrl: 'https://u.wechat.com/EOzom56XQ_1MKeVPPqgwMlI', // 要生成的二维码值 } }, components: { - kkPrinter + kkPrinter, + ayQrcode }, computed: { changeAmount() { @@ -456,10 +584,10 @@ // fail () {} // }) return { - title: '查看采购单详情', + title: this.shopName + '的采购单', imageUrl: 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/b28b3d46c21d4f60a334b25f56175cf3.jpg', path: '/package1/index/orderDetail?popleType=khName&id=' + this.sales.id + '&shopId=' + uni - .getStorageSync('shopId') + .getStorageSync('shopId') + '&shopName=' + this.shopName } }, onShow() { @@ -468,12 +596,16 @@ mode: 'central' }) this.lbgName = JSON.parse(JSON.stringify(this.lbgName)) + + let that = this; }, onLoad(option) { var that = this; + if (option.shopId && option.shopId != uni.getStorageSync('shopId')) { this.isDownKH = true } + this.saleId = option.id this.isShare = option.shopId ? true : false if (option.id != null && option.id != undefined && option.id != "") { @@ -521,79 +653,156 @@ this.order = res.result.customer this.orderXd = res.result.orderXd this.shopData = res.result.shop - this.splitTextIntoChunks(res.result.shop.shopAddress,30) + this.splitTextIntoChunks(res.result.shop.shopAddress, 30) this.getReturnOrder(option.id) } else { - this.tui.toast(res.message) + if (res.code == 500 && res.message == 'java.lang.NullPointerException') { + this.tui.toast('订单已撤销,无法查看') + } else { + this.tui.toast(res.message) + } + } }).catch((res) => {}) } } + this.shopId = option.shopId || uni.getStorageSync('shopId') || "" + this.shopName = option.shopName ? option.shopName : uni.getStorageSync('shopName') uni.getSystemInfo({ success(res) { that.deviceType = res.osName } }) + uni.setNavigationBarTitle({ + title: this.shopName + }); this.analysisQrCode() - this.getRemark() + }, methods: { - getRemark(){ - let remark = "工行:6214830159975241 户名:王浩伟\n工行:6214830159975241 户名:王浩伟\n备注:货品售出如有质量问题7天内凭单调换,逾期自负。"; - if(uni.getStorageSync('shopRemark') != ''){ - this.shopRemark = remark.split('\n'); + // 展示二维码 + showQrcode() { + let _this = this; + this.modal_qr = true; + console.log('$refs', _this.$refs.qrcodePopup) + for (let i = 0; i < _this.$refs.qrcodePopup.length; i++) { + _this.$refs.qrcodePopup[i].crtQrCode() } - console.log(this.shopRemark); + }, - //打印小票二维码,分割二维码字符串 - analysisQrCode() { - let qrCode = uni.getStorageSync('shopIcon') - if (qrCode != '') { - let data = qrCode.split(',') - for (let i = 0; i < data.length; i++) { - var weixin = data[i].indexOf("微信"); - var dianpu = data[i].indexOf("店铺"); - var zifubao = data[i].indexOf("支付"); - var yinlian = data[i].indexOf("收款"); - if (dianpu != -1) { - var result = data[i].substring(dianpu + 2); - let obj = { - name: '店铺微信', - path: result, - level: "M" - } - this.qrArr.push(obj) - } - if (weixin != -1) { - var result = data[i].substring(weixin + 2); - let obj = { - name: '微信收款码', - path: result, - level: "M" - } - this.qrArr.push(obj) - } - if (zifubao != -1) { - var result = data[i].substring(zifubao + 2); - let obj = { - name: '支付宝收款码', - path: result, - level: "Q" + + //传入组件的方法 + hideQrcode() { + this.modal_qr = false; + }, + //获取子图 + getChildrenPic(img) { + let that = this; + this.tui.request("/app/productPicture/getProductPictureByProductId", "POST", { + productId: img.productId, + }, false, true).then((res) => { + if (res.code == 200) { + img.productPictures = [] + for (let i = 0; i < res.result.length; i++) { + let data = { + productPicture: res.result[i].productPicture } - this.qrArr.push(obj) + img.productPictures.push(data) } - if (yinlian != -1) { - var result = data[i].substring(yinlian + 2); - let obj = { - name: '银行收款码', - path: result, - level: "M" + setTimeout(res1 => { + console.log(img) + that.largeImg(img) + }, 400); + } else { + this.tui.toast(res.message) + } + }).catch((res) => {}) + }, + largeImg(img) { + console.log('img', img) + if (img.productPicture == null && img.productPictures == null) { + this.tui.toast("暂无可展示的图片", 1000) + return + } + this.bigImg = [] + if (img.productPicture != null) { + let data = { + productPicture: img.productPicture + } + this.bigImg.push(data) + } + if (img.productPictures != null) { + for (let i = 0; i < img.productPictures.length; i++) { + this.bigImg.push(img.productPictures[i]) + } + } + this.$refs.imgPopup.open() + }, + lunbochange(e) { + this.current = e.detail.current + }, + //打印小票二维码,分割二维码字符串 + analysisQrCode() { + let that = this; + that.tui.request("/app/shop/getShopInfoById", "post", { + id: this.shopId, + }, false, true).then((res) => { + if (res.code == 200) { + this.shopRemark = res.result.remark.split('\n'); + console.log('shopRemark', this.shopRemark) + let qrCode = res.result.shopIcon + // let qrCode = '店铺https://u.wechat.com/EOzom56XQ_1MKeVPPqgwMlI?uVsMiaUpfpOk8MxSE19t4ao0TCVrd,微信wxp://f2f0QYU_-Jjd882vOWEqu7GA8F9Vbo_ftIqsS9muVsMiaUpfpOk8MxSE19t4ao0TCVrd,收款https://life.qujie365.com/smpay/unionpay/index.html?qrcode=80000013007399283719457' + if (qrCode != '') { + let data = qrCode.split(',') + for (let i = 0; i < data.length; i++) { + var weixin = data[i].indexOf("微信"); + var dianpu = data[i].indexOf("店铺"); + var zifubao = data[i].indexOf("支付"); + var yinlian = data[i].indexOf("收款"); + if (dianpu != -1) { + var result = data[i].substring(dianpu + 2); + let obj = { + name: '店铺微信', + path: result, + level: "M" + } + this.qrArr.push(obj) + } + if (weixin != -1) { + var result = data[i].substring(weixin + 2); + let obj = { + name: '微信收款码', + path: result, + level: "M" + } + this.qrArr.push(obj) + } + if (zifubao != -1) { + var result = data[i].substring(zifubao + 2); + let obj = { + name: '支付宝收款码', + path: result, + level: "Q" + } + this.qrArr.push(obj) + } + if (yinlian != -1) { + var result = data[i].substring(yinlian + 2); + let obj = { + name: '银行收款码', + path: result, + level: "M" + } + this.qrArr.push(obj) + } } - this.qrArr.push(obj) + setTimeout(res => { + that.showQrcode(); + }, 1000) } } - } + }).catch((res) => {}) }, deleteOrder() { var that = this; @@ -627,15 +836,15 @@ getPrintHeight() { let that = this; console.log('newData', that.newData) - this.printHeight = 900 + this.printHeight = 940 for (let i = 0; i < that.newData.length; i++) { - this.printHeight += 70 + this.printHeight += 40 for (let m = 0; m < that.newData[i].stockLogList1.length; m++) { this.printHeight += 40 } } if (that.qrArr.length > 0) { - this.printHeight += 320 + this.printHeight += 360 } if (that.shopRemark.length > 0) { this.printHeight += that.shopRemark.length * 40 @@ -645,24 +854,25 @@ } }, splitTextIntoChunks(text, chunkSize) { - let result = []; - for (let i = 0; i < text.length; i += chunkSize) { - result.push(text.slice(i, i + chunkSize)); - } - this.$nextTick(()=>{ + let result = []; + for (let i = 0; i < text.length; i += chunkSize) { + result.push(text.slice(i, i + chunkSize)); + } + this.$nextTick(() => { this.addressArr = result - console.log('addressArr',this.addressArr) + console.log('addressArr', this.addressArr) }) - + }, //打印小票 onPrintSmall() { let that = this; - console.log('printHeight',this.printHeight) + console.log('printHeight', this.printHeight) let strCmd = '' let pageNum = 1 that.yNum = 390 - strCmd = blesdk.CreatCPCLPage(1080, this.printHeight>=(1990 * pageNum)?1990:this.printHeight, 1, 0,0); + strCmd = blesdk.CreatCPCLPage(1080, this.printHeight >= (1990 * pageNum) ? 1990 : this.printHeight, 1, 0, + 0); strCmd += blesdk.addCPCLSETMAG(4, 4) blesdk.addCPCLSETBOLD('bold') strCmd += blesdk.addCPCLLocation(2); @@ -679,417 +889,599 @@ strCmd += blesdk.addCPCLText('500', '350', '24', '0', 0, '日期:' + that.sales.createTime) strCmd += blesdk.addCPCLText('0', '390', '24', '0', 0, '-----------------------------------------------------------------------------------') + strCmd += blesdk.addCPCLText('10', that.yNum += 40, '24', '0', 0, '货号(名称)') + strCmd += blesdk.addCPCLText('320', that.yNum, '24', '0', 0, '规格') + strCmd += blesdk.addCPCLText('520', that.yNum, '24', '0', 0, '数量') + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, '单价') + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, '总价') for (var i = 0; i < that.newData.length; i++) { - if(that.yNum + 40 >= 1990){ - + if (that.yNum + 25 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - pageNum ++ - console.log('商品pageNum',pageNum) - if (that.newData[i].productName == that.newData[i].productSn) { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, that.newData[i].productName) - } else { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, that.newData[i].productName + - '(' + - that.newData[i].productSn + ')') - } + pageNum++ + + strCmd += blesdk.addCPCLText('0', that.yNum += 25, '24', '0', 0, + '-----------------------------------------------------------------------------------') + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 25, '24', '0', 0, + '-----------------------------------------------------------------------------------') + } + + if (that.yNum + 40 >= 1990) { + + strCmd += blesdk.addCPCLPrint(); + that.bufferData.push(strCmd); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 40), 1, 0, 162); + that.yNum = 0 + pageNum++ + console.log('商品pageNum', pageNum) + console.log('规格', that.yNum) + for (var m = 0; m < that.newData[i].stockLogList1.length; m++) { - if(that.yNum + 40 >= 1990){ + if (that.yNum + 40 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : ( + this.printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - - pageNum ++ - console.log('规格pageNum',pageNum) + + pageNum++ + console.log('规格pageNum', pageNum) if (that.newData[i].stockLogList1[m].isReturn) { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '□【退】' + that.slicePrint( - that.newData[i].stockLogList1[m].attributeList)) + if (that.newData[i].productName == that.newData[i].productSn) { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【退】' + that + .newData[i].productSn) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【退】' + that + .newData[i].productSn + + '(' + (that.newData[i] + .productName == null ? '' : that.newData[i].productName) + ')') + } } else { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '□【销】' + that.slicePrint( - that.newData[i].stockLogList1[m].attributeList)) + if (that.newData[i].productName == that.newData[i].productSn) { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【销】' + that + .newData[i].productSn) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【销】' + that + .newData[i].productSn + + '(' + (that.newData[i] + .productName == null ? '' : that.newData[i].productName) + ')') + } } - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '数量:' + that.newData[i].stockLogList1[ - m].productCount) + + + if (that.shopId == '1820269107191353344' || that.shopId == '1818888277105709056' || that + .shopId == '1811579958284390400') { + 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, '分码') + } + } + strCmd += blesdk.addCPCLText('320', that.yNum, '24', '0', 0, that + .slicePrint(that.newData[i].stockLogList1[m].attributeList)) + + strCmd += blesdk.addCPCLText('520', that.yNum, '24', '0', 0, that.newData[i] + .stockLogList1[m].productCount) if (that.newData[i].stockLogList1[m].isReturn) { - strCmd += blesdk.addCPCLText('460', that.yNum, '24', '0', 0, '单价:' + that.newData[i] + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .stockLogList1[m].discountAmount) } else { - strCmd += blesdk.addCPCLText('460', that.yNum, '24', '0', 0, '单价:' + that.newData[i] + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .discountAmount) } - - strCmd += blesdk.addCPCLText('650', that.yNum, '24', '0', 0, '总价:' + (that.newData[i] + + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] .discountAmount * that.newData[i].stockLogList1[m].productCount)) console.log('【销】', that.yNum) - }else{ - console.log('规格不等于pageNum',pageNum) + } else { + console.log('规格不等于pageNum', pageNum) if (that.newData[i].stockLogList1[m].isReturn) { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '□【退】' + that.slicePrint( - that.newData[i].stockLogList1[m].attributeList)) + if (that.newData[i].productName == that.newData[i].productSn) { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【退】' + that + .newData[i].productSn) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【退】' + that + .newData[i].productSn + + '(' + (that.newData[i] + .productName == null ? '' : that.newData[i].productName) + ')') + } } else { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '□【销】' + that.slicePrint( - that.newData[i].stockLogList1[m].attributeList)) + if (that.newData[i].productName == that.newData[i].productSn) { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【销】' + that + .newData[i].productSn) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【销】' + that + .newData[i].productSn + + '(' + (that.newData[i] + .productName == null ? '' : that.newData[i].productName) + ')') + } } - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '数量:' + that.newData[i].stockLogList1[ - m].productCount) + + + if (that.shopId == '1820269107191353344' || that.shopId == '1818888277105709056' || that + .shopId == '1811579958284390400') { + 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, '分码') + } + } + strCmd += blesdk.addCPCLText('320', that.yNum, '24', '0', 0, that + .slicePrint(that.newData[i].stockLogList1[m].attributeList)) + + strCmd += blesdk.addCPCLText('520', that.yNum, '24', '0', 0, that.newData[i] + .stockLogList1[m].productCount) if (that.newData[i].stockLogList1[m].isReturn) { - strCmd += blesdk.addCPCLText('460', that.yNum, '24', '0', 0, '单价:' + that.newData[i] + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .stockLogList1[m].discountAmount) } else { - strCmd += blesdk.addCPCLText('460', that.yNum, '24', '0', 0, '单价:' + that.newData[i] + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .discountAmount) } - - strCmd += blesdk.addCPCLText('650', that.yNum, '24', '0', 0, '总价:' + (that.newData[i] + + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] .discountAmount * that.newData[i].stockLogList1[m].productCount)) console.log('【销】', that.yNum) } - - } - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, - '-----------------------------------------------------------------------------------') - }else{ - if (that.newData[i].productName == that.newData[i].productSn) { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, that.newData[i].productName) - } else { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, that.newData[i].productName + - '(' + - that.newData[i].productSn + ')') + } + } else { + console.log('规格', that.yNum) for (var m = 0; m < that.newData[i].stockLogList1.length; m++) { - if(that.yNum + 40 >= 1990){ + if (that.yNum + 40 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : ( + this.printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - - pageNum ++ - console.log('规格pageNum',pageNum) + + pageNum++ + console.log('规格pageNum', pageNum) if (that.newData[i].stockLogList1[m].isReturn) { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '□【退】' + that.slicePrint( - that.newData[i].stockLogList1[m].attributeList)) + if (that.newData[i].productName == that.newData[i].productSn) { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【退】' + that + .newData[i].productSn) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【退】' + that + .newData[i].productSn + + '(' + (that.newData[i] + .productName == null ? '' : that.newData[i].productName) + ')') + } } else { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '□【销】' + that.slicePrint( - that.newData[i].stockLogList1[m].attributeList)) + if (that.newData[i].productName == that.newData[i].productSn) { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【销】' + that + .newData[i].productSn) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【销】' + that + .newData[i].productSn + + '(' + (that.newData[i] + .productName == null ? '' : that.newData[i].productName) + ')') + } + } + + if (that.shopId == '1820269107191353344' || that.shopId == '1818888277105709056' || that + .shopId == '1811579958284390400') { + 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, '分码') + } } - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '数量:' + that.newData[i].stockLogList1[ - m].productCount) + strCmd += blesdk.addCPCLText('320', that.yNum, '24', '0', 0, that + .slicePrint(that.newData[i].stockLogList1[m].attributeList)) + + strCmd += blesdk.addCPCLText('520', that.yNum, '24', '0', 0, that.newData[i] + .stockLogList1[m].productCount) if (that.newData[i].stockLogList1[m].isReturn) { - strCmd += blesdk.addCPCLText('460', that.yNum, '24', '0', 0, '单价:' + that.newData[i] + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .stockLogList1[m].discountAmount) } else { - strCmd += blesdk.addCPCLText('460', that.yNum, '24', '0', 0, '单价:' + that.newData[i] + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .discountAmount) } - - strCmd += blesdk.addCPCLText('650', that.yNum, '24', '0', 0, '总价:' + (that.newData[i] + + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] .discountAmount * that.newData[i].stockLogList1[m].productCount)) console.log('【销】', that.yNum) - - }else{ - console.log('规格不等于pageNum',pageNum) + + } else { + console.log('规格不等于pageNum', pageNum) if (that.newData[i].stockLogList1[m].isReturn) { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '□【退】' + that.slicePrint( - that.newData[i].stockLogList1[m].attributeList)) + if (that.newData[i].productName == that.newData[i].productSn) { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【退】' + that + .newData[i].productSn) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【退】' + that + .newData[i].productSn + + '(' + (that.newData[i] + .productName == null ? '' : that.newData[i].productName) + ')') + } } else { - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '□【销】' + that.slicePrint( - that.newData[i].stockLogList1[m].attributeList)) + if (that.newData[i].productName == that.newData[i].productSn) { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【销】' + that + .newData[i].productSn) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, '【销】' + that + .newData[i].productSn + + '(' + (that.newData[i] + .productName == null ? '' : that.newData[i].productName) + ')') + } + } + if (that.shopId == '1820269107191353344' || that.shopId == '1818888277105709056' || that + .shopId == '1811579958284390400') { + 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, '分码') + } } - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '数量:' + that.newData[i].stockLogList1[ - m].productCount) + strCmd += blesdk.addCPCLText('320', that.yNum, '24', '0', 0, that + .slicePrint(that.newData[i].stockLogList1[m].attributeList)) + + + strCmd += blesdk.addCPCLText('520', that.yNum, '24', '0', 0, that.newData[i] + .stockLogList1[m].productCount) if (that.newData[i].stockLogList1[m].isReturn) { - strCmd += blesdk.addCPCLText('460', that.yNum, '24', '0', 0, '单价:' + that.newData[i] + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .stockLogList1[m].discountAmount) } else { - strCmd += blesdk.addCPCLText('460', that.yNum, '24', '0', 0, '单价:' + that.newData[i] + strCmd += blesdk.addCPCLText('620', that.yNum, '24', '0', 0, that.newData[i] .discountAmount) } - - strCmd += blesdk.addCPCLText('650', that.yNum, '24', '0', 0, '总价:' + (that.newData[i] + + strCmd += blesdk.addCPCLText('720', that.yNum, '24', '0', 0, (that.newData[i] .discountAmount * that.newData[i].stockLogList1[m].productCount)) console.log('【销】', that.yNum) } } - strCmd += blesdk.addCPCLText('0', that.yNum += 40, '24', '0', 0, - '-----------------------------------------------------------------------------------') + } - + } // strCmd += blesdk.addCPCLPrint(); // that.bufferData.push(strCmd); // that.yNum = 0 // strCmd = blesdk.CreatCPCLPage(1080, 700, 1, 0); - + strCmd += blesdk.addCPCLText('0', that.yNum += 25, '24', '0', 0, + '-----------------------------------------------------------------------------------') strCmd += blesdk.addCPCLSETMAG(1, 1) strCmd += blesdk.addCPCLLocation(0); - if(that.yNum + 60 >= 1990){ + if (that.yNum + 60 >= 1990 * pageNum) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ?1990:(this.printHeight - that.yNum + 60), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 60), 1, 0, 162); that.yNum = 0 - pageNum ++ - strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '欠款抵退货:' + that.sales.debtDeductionAmount) - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '销售抵退货:' + that.sales.saleDeductionAmount) + pageNum++ + strCmd += + blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '销售数量:' + that.sales.productCount) + strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '销售金额:' + that.sales.totalAmount) + // strCmd += blesdk.addCPCLSETMAG(1, 2) strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '余额抵销售:' + (that.sales .balanceDeductionAmount)) - }else{ - strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '欠款抵退货:' + that.sales.debtDeductionAmount) - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '销售抵退货:' + that.sales.saleDeductionAmount) + // strCmd += blesdk.addCPCLText('600', (that.yNum - 20), '24', '0', 0, '本单实收:' + that.sales.alreadyEarn) + + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '销售数量:' + that.sales.productCount) + strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '销售金额:' + that.sales.totalAmount) + // strCmd += blesdk.addCPCLSETMAG(1, 2) strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '余额抵销售:' + (that.sales .balanceDeductionAmount)) + // strCmd += blesdk.addCPCLText('600', (that.yNum - 20), '24', '0', 0, '本单实收:' + that.sales.alreadyEarn) } - - console.log('欠款抵退货', that.yNum) - if(that.yNum + 60 >= 1990){ + + console.log('销售数量', that.yNum) + strCmd += blesdk.addCPCLSETMAG(1, 1) + if (that.yNum + 60 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ?1990:(this.printHeight - that.yNum + 60), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 60), 1, 0, 162); that.yNum = 0 - pageNum ++ + pageNum++ strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '退货数量:' + that.returnNum) strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '退货金额:' + that.returnPrice) strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '其他费用:' + (that.sales.otherExpense)) - }else{ + } else { strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '退货数量:' + that.returnNum) strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '退货金额:' + that.returnPrice) strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '其他费用:' + (that.sales.otherExpense)) } - + console.log('退货数量', that.yNum) - if(that.yNum + 60 >= 1990*pageNum){ + if (that.yNum + 60 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ?1990:(this.printHeight - that.yNum + 60), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 60), 1, 0, 162); that.yNum = 0 - pageNum ++ - strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '销售数量:' + that.sales.productCount) - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '销售金额:' + that.sales.totalAmount) + pageNum++ + strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '欠款抵退货:' + that.sales + .debtDeductionAmount) + strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '销售抵退货:' + that.sales.saleDeductionAmount) + strCmd += blesdk.addCPCLSETMAG(1, 2) if (that.dealingsRecord.lastDebtAmount >= 0) { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '之前欠款:' + that.dealingsRecord + strCmd += blesdk.addCPCLText('600', that.yNum, '24', '0', 0, '之前欠款:' + that.dealingsRecord .lastDebtAmount) } else if (that.dealingsRecord.lastDebtAmount < 0) { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '之前余额:' + Math.abs(that.dealingsRecord + strCmd += blesdk.addCPCLText('600', that.yNum, '24', '0', 0, '之前余额:' + Math.abs(that.dealingsRecord .lastDebtAmount)) } else { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '之前欠款:0') + strCmd += blesdk.addCPCLText('600', that.yNum, '24', '0', 0, '之前欠款:0') } - }else{ - strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '销售数量:' + that.sales.productCount) - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '销售金额:' + that.sales.totalAmount) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '欠款抵退货:' + that.sales + .debtDeductionAmount) + strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '销售抵退货:' + that.sales.saleDeductionAmount) + // strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '余额抵销售:' + (that.sales + // .balanceDeductionAmount)) + strCmd += blesdk.addCPCLSETMAG(1, 2) if (that.dealingsRecord.lastDebtAmount >= 0) { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '之前欠款:' + that.dealingsRecord + strCmd += blesdk.addCPCLText('610', (that.yNum - 10), '24', '0', 0, '之前欠款:' + that.dealingsRecord .lastDebtAmount) } else if (that.dealingsRecord.lastDebtAmount < 0) { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '之前余额:' + Math.abs(that.dealingsRecord + strCmd += blesdk.addCPCLText('610', (that.yNum - 10), '24', '0', 0, '之前余额:' + Math.abs(that + .dealingsRecord .lastDebtAmount)) } else { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '之前欠款:0') + strCmd += blesdk.addCPCLText('610', (that.yNum - 10), '24', '0', 0, '之前欠款:0') } } - - console.log('销售数量', that.yNum) - if(that.yNum + 60 >= 1990){ + console.log('欠款抵退货', that.yNum) + // strCmd += blesdk.addCPCLSETMAG(1,1) + // if(that.yNum + 40 >= 1990){ + // strCmd += blesdk.addCPCLPrint(); + // that.bufferData.push(strCmd); + + // strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + // that.yNum = 0 + // pageNum ++ + // strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, + // '-----------------------------------------------------------------------------------') + // }else{ + // strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, + // '-----------------------------------------------------------------------------------') + // } + strCmd += blesdk.addCPCLSETMAG(1, 2) + if (that.yNum + 60 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ?1990:(this.printHeight - that.yNum + 60), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 60), 1, 0, 162); that.yNum = 0 - pageNum ++ - strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '本单应收:' + that.sales.realAmount) - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '本单已收:' + that.sales.alreadyEarn) - if (that.sales.noEarn >= 0) { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '本单欠款:' + (that.sales.noEarn)) - } else { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '本单余额:' + Math.abs(that.sales.noEarn)) - } - }else{ - strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '本单应收:' + that.sales.realAmount) - strCmd += blesdk.addCPCLText('300', that.yNum, '24', '0', 0, '本单已收:' + that.sales.alreadyEarn) - if (that.sales.noEarn >= 0) { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '本单欠款:' + (that.sales.noEarn)) - } else { - strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '本单余额:' + Math.abs(that.sales.noEarn)) - } + pageNum++ + strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '本单实收:' + that.sales.alreadyEarn) + strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '本单应收:' + that.sales.realAmount) + + } else { + + strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '本单实收:' + that.sales.alreadyEarn) + strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '本单应收:' + that.sales.realAmount) } - + // strCmd += blesdk.addCPCLSETMAG(2, 2) // strCmd += blesdk.addCPCLLocation(0); - if(that.yNum + 60 >= 1990){ + if (that.yNum + 60 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ?1990:(this.printHeight - that.yNum + 60), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 60), 1, 0, 162); that.yNum = 0 - pageNum ++ + pageNum++ + if (that.sales.noEarn >= 0) { + strCmd += blesdk.addCPCLText('0', that.yNum += 70, '24', '0', 0, '本单欠款:' + (that.sales.noEarn)) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 70, '24', '0', 0, '本单余额:' + Math.abs(that.sales + .noEarn)) + } if (that.dealingsRecord.balanceDue >= 0) { - strCmd += blesdk.addCPCLText('610', that.yNum += 60, '24', '0', 0, '累计欠款:' + that.dealingsRecord + strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '累计欠款:' + that.dealingsRecord .balanceDue) } else if (that.dealingsRecord.balanceDue < 0) { - strCmd += blesdk.addCPCLText('610', that.yNum += 60, '24', '0', 0, '累计余额:' + Math.abs(that + strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '累计余额:' + Math.abs(that .dealingsRecord.balanceDue)) } else { - strCmd += blesdk.addCPCLText('610', that.yNum += 60, '24', '0', 0, '累计欠款:0') + strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '累计欠款:0') + } + } else { + if (that.sales.noEarn >= 0) { + strCmd += blesdk.addCPCLText('0', that.yNum += 70, '24', '0', 0, '本单欠款:' + (that.sales.noEarn)) + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 70, '24', '0', 0, '本单余额:' + Math.abs(that.sales + .noEarn)) } - }else{ if (that.dealingsRecord.balanceDue >= 0) { - strCmd += blesdk.addCPCLText('610', that.yNum += 60, '24', '0', 0, '累计欠款:' + that.dealingsRecord + strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '累计欠款:' + that.dealingsRecord .balanceDue) } else if (that.dealingsRecord.balanceDue < 0) { - strCmd += blesdk.addCPCLText('610', that.yNum += 60, '24', '0', 0, '累计余额:' + Math.abs(that + strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '累计余额:' + Math.abs(that .dealingsRecord.balanceDue)) } else { - strCmd += blesdk.addCPCLText('610', that.yNum += 60, '24', '0', 0, '累计欠款:0') + strCmd += blesdk.addCPCLText('610', that.yNum, '24', '0', 0, '累计欠款:0') } } - if(that.yNum + 40 >= 1990){ + strCmd += blesdk.addCPCLSETMAG(1, 1) + if (that.yNum + 60 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 60) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - pageNum ++ - strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, + pageNum++ + strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '-----------------------------------------------------------------------------------') - }else{ - strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, + } else { + strCmd += blesdk.addCPCLText('0', that.yNum += 60, '24', '0', 0, '-----------------------------------------------------------------------------------') } - if(that.yNum + 40 >= 1990){ + if (that.yNum + 40 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - pageNum ++ + pageNum++ if (that.sales.remark) { strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '订单备注:' + that.sales.remark) strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '-----------------------------------------------------------------------------------') } - }else{ + } else { if (that.sales.remark) { strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '订单备注:' + that.sales.remark) strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '-----------------------------------------------------------------------------------') } } - + //店铺地址 strCmd += blesdk.addCPCLSETMAG(1, 1) - if(that.yNum + 40 >= 1990){ + if (that.yNum + 40 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - pageNum ++ - for(let i=0;i= 1990){ + if (that.yNum + 40 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - pageNum ++ - strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '店铺电话:' + uni.getStorageSync( - 'username')) - }else{ - strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '店铺电话:' + uni.getStorageSync( - 'username')) + pageNum++ + strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '店铺电话:' + (uni.getStorageSync( + 'shopOwnerPhone')?uni.getStorageSync('shopOwnerPhone'): uni.getStorageSync('username'))) + } else { + strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '店铺电话:' + (uni.getStorageSync( + 'shopOwnerPhone')?uni.getStorageSync('shopOwnerPhone'): uni.getStorageSync('username'))) } - + //物流 if (this.sales.companyName != null) { strCmd += blesdk.addCPCLSETMAG(1, 1) - if(that.yNum + 40 >= 1990){ + if (that.yNum + 40 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - pageNum ++ - - strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '发货方式:' + this.sales.companyName + ' '+ this.sales.companyPhone) - }else{ - strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '发货方式:' + this.sales.companyName + ' '+ this.sales.companyPhone) + pageNum++ + + strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '发货方式:' + this.sales + .companyName + ' ' + this.sales.companyPhone) + } else { + strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, '发货方式:' + this.sales + .companyName + ' ' + this.sales.companyPhone) } } - + //店铺备注 - if(this.shopRemark.length > 0){ - for(let i=0;i= 1990){ + if (this.shopRemark.length > 0) { + for (let i = 0; i < this.shopRemark.length; i++) { + if (that.yNum + 40 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ?1990:(this.printHeight - that.yNum + 40), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 40) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 40), 1, 0, 162); that.yNum = 0 - pageNum ++ + pageNum++ strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, this.shopRemark[i]) - }else{ + } else { strCmd += blesdk.addCPCLText('0', that.countPrint(), '24', '0', 0, this.shopRemark[i]) } } } - - if(that.yNum + 260 >= 1990){ + + if (that.yNum + 260 >= 1990) { strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); - - strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 260) >= 1990 ?1990:(this.printHeight - that.yNum + 260), 1, 0,162); + + strCmd = blesdk.CreatCPCLPage(1080, (this.printHeight - that.yNum + 260) >= 1990 ? 1990 : (this + .printHeight - that.yNum + 260), 1, 0, 162); that.yNum = 0 - pageNum ++ + pageNum++ if (that.qrArr.length != 0) { //店铺微信/微信收款/支付宝收款/收款码收款(店铺,微信,支付,收款) for (let i = 0; i < that.qrArr.length; i++) { //店铺二维码 if (i == 0) { - strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += 80), + strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / 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, 900 / that.qrArr.length), (that.yNum += 180), + strCmd += blesdk.addCPCLText(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += + 220), '24', '0', 0, that.qrArr[i].name) } else { - strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / that.qrArr.length), (that.yNum -= 180), + strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / that.qrArr.length), (that.yNum -= + 220), that .qrArr[i].level, '2', 4, that.qrArr[i].path) //二维码 strCmd += blesdk.addCPCLSETMAG(1, 1) - strCmd += blesdk.addCPCLText(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += 180), + strCmd += blesdk.addCPCLText(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += + 220), '24', '0', 0, that.qrArr[i].name) } @@ -1102,24 +1494,28 @@ strCmd += blesdk.addCPCLPrint(); that.bufferData.push(strCmd); } - }else{ + } else { if (that.qrArr.length != 0) { //店铺微信/微信收款/支付宝收款/收款码收款(店铺,微信,支付,收款) for (let i = 0; i < that.qrArr.length; i++) { //店铺二维码 if (i == 0) { - strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += 80), + strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / 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, 900 / that.qrArr.length), (that.yNum += 180), + strCmd += blesdk.addCPCLText(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += + 220), '24', '0', 0, that.qrArr[i].name) } else { - strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / that.qrArr.length), (that.yNum -= 180), + strCmd += blesdk.addCPCLQRCode(that.countWidth(i, 900 / that.qrArr.length), (that.yNum -= + 220), that .qrArr[i].level, '2', 4, that.qrArr[i].path) //二维码 strCmd += blesdk.addCPCLSETMAG(1, 1) - strCmd += blesdk.addCPCLText(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += 180), + strCmd += blesdk.addCPCLText(that.countWidth(i, 900 / that.qrArr.length), (that.yNum += + 220), '24', '0', 0, that.qrArr[i].name) } @@ -1133,7 +1529,7 @@ that.bufferData.push(strCmd); } } - + console.log(that.bufferData) this.$nextTick(() => { console.log('that.yNum', that.yNum) @@ -1143,7 +1539,16 @@ }, countWidth(num, len) { - return num * len + 20 + return num * len + }, + replaceCharAfterNumber(str, charToFind, charToReplace) { + // 正则表达式匹配字符前是否有数字,并且该字符与charToFind相同 + const regex = new RegExp(`\\d${charToFind}`, 'g'); + // 使用replace方法进行替换 + return str.replace(regex, (match) => { + // 将匹配到的字符中的指定字符替换为charToReplace + return match.replace(charToFind, charToReplace); + }); }, goPrint(type) { let strCmd = '' @@ -1199,7 +1604,7 @@ let yNum = 920 strCmd += blesdk.addCPCLSETMAG(1, 1) strCmd += blesdk.addCPCLLocation(0); - for(let i=0;i { @@ -1362,11 +1766,15 @@ undefined) { that.returnList.push(res.result) that.shopList.push(...res.result.saleDetailDTOList); + for (let j = 0; j < res.result.saleDetailDTOList .length; j++) { let isTure = true + res.result.saleDetailDTOList[j].productCount = 0 for (let m = 0; m < res.result.saleDetailDTOList[j] .stockLogList1.length; m++) { + res.result.saleDetailDTOList[j].productCount += + res.result.saleDetailDTOList[j].stockLogList1[m].productCount res.result.saleDetailDTOList[j].stockLogList1[ m].isReturn = true res.result.saleDetailDTOList[j].stockLogList1[ @@ -1387,75 +1795,10 @@ j]) } } - var data = res.result.saleDetailDTOList - for (let i = 0; i < data.length; i++) { - for (let m = 0; m < data[i].stockLogList1 - .length; m++) { - if (returnDat.has(data[i].productId + '-' + - data[i] - .stockLogList1[m].attributeList) == - true) { - returnDat.set(data[i].productId + '-' + - data[i] - .stockLogList1[m].attributeList, - returnDat.get(data[i].productId + - '-' + - data[i].stockLogList1[m] - .attributeList) + data[i] - .stockLogList1[m].productCount) - } else { - returnDat.set(data[i].productId + '-' + - data[i] - .stockLogList1[m].attributeList, - data[ - i].stockLogList1[m] - .productCount) - } - } - } - this.zReturnNum = 0 - this.$nextTick(() => { - for (let i = 0; i < that.list - .length; i++) { - for (let z = 0; z < that.list[i] - .stockLogList1.length; z++) { - - that.zReturnNum += that.list[i] - .stockLogList1[z].productCount - if (returnDat.has(that.list[i] - .productId + '-' + that - .list[i] - .stockLogList1[z] - .attributeList - ) == true) { - that.list[i].stockLogList1[z] - .maxNum = that.list[i] - .stockLogList1[z] - .productCount - - returnDat.get(that.list[i] - .productId + '-' + that - .list[i].stockLogList1[ - z] - .attributeList) - } else { - that.list[i].stockLogList1[z] - .maxNum = that.list[i] - .stockLogList1[z] - .productCount - } - } - } - - }) - - returnDat.forEach(function(value, key) { - that.zReturnNum -= value - }) - } }).catch((res) => {}) }) - + } else { for (let i = 0; i < that.list.length; i++) { for (let z = 0; z < that.list[i].stockLogList1.length; z++) { @@ -1507,91 +1850,6 @@ close() { this.popupShow = false }, - //调用退货接口 - sureReturn() { - uni.showLoading({ - title: '加载中...' - }) - if (this.sales.productCount - this.zReturnNum == 0) { - this.tui.toast("已经超过最大退货数量") - return - } - if (this.$refs.returnClose.val == '' || this.$refs.returnClose.val <= 0) { - this.tui.toast("金额不能为空") - return - } - let returnNum = 0 - for (let i = 0; i < this.inventoryList.length; i++) { - returnNum += this.inventoryList[i].totalAmount - } - if (this.inventoryList == '') { - if (this.$refs.returnClose.val > this.sales.totalAmount) { - this.tui.toast('退货金额不能超出可退货金额') - return - } - } else { - if (this.$refs.returnClose.val > this.inventoryList[0].totalAmount - returnNum) { - this.tui.toast('退货金额不能超出可退货金额') - return - } - } - let dataList = [] - let returnCount = 0; - // 新增一个stockLogList参数,把有returnCount的放进去 - for (var i = 0; i < this.list.length; i++) { - this.list[i].stockLogList = [] - let isTrue = false - let returnStock = [] - for (var m = 0; m < this.list[i].stockLogList1.length; m++) { - if (this.list[i].stockLogList1[m].returnCount && this.list[i].stockLogList1[m].returnCount > 0) { - returnCount += this.list[i].stockLogList1[m].returnCount - this.list[i].stockLogList1[m].productCount = this.list[i].stockLogList1[m].returnCount - returnStock.push(this.list[i].stockLogList1[m]) - if (m == 0) { - this.list[i].productCount = this.list[i].stockLogList1[m].productCount - } else { - this.list[i].productCount += this.list[i].stockLogList1[m].productCount - } - isTrue = true - } - - } - if (isTrue) { - this.list[i].stockLogList1 = returnStock - dataList.push(this.list[i]) - } - } - if (returnCount == 0) { - this.tui.toast("退货数量不能为零") - return; - } - this.sales.saleId = this.sales.id; - this.sales.province = '' - this.sales.city = '' - this.sales.area = '' - this.sales.receiveAddress = this.changeA - this.sales.totalAmount = this.$refs.returnClose.val; - this.sales.transportType = this.radio1 - this.tui.request("/app/return/rtg", "post", { - returnSale: this.sales, - returnSaleDetailList: dataList, - transCompany: this.radio1 == 0 ? '99999999' : '', - orderByWorker: this.lbgName.workerId, - isReturnPrice: 1 - }, false, false).then((res) => { - uni.showToast({ - title: res.message - }); - if (res.code == 200) { - uni.navigateBack() - } else { - this.tui.toast(res.message) - } - }).catch((res) => {}) - setTimeout(res => { - uni.hideLoading(); - }, 200) - }, returnGoods() { if (this.isReturn) { // this.returnAmount = this.sAmout @@ -1894,7 +2152,7 @@ font-size: 26rpx; box-shadow: 0 0 1px rgba(0, 0, 0, .3); padding-bottom: env(safe-area-inset-bottom); - z-index: 996; + z-index: 99; } .tui-btn-mr { @@ -1985,4 +2243,25 @@ margin-right: 0 !important; margin-left: 50rpx !important; } + + .showImg-box { + width: 700rpx; + height: 1000rpx; + border-radius: 10px; + } + + .swiper-box { + height: 1000rpx; + } + + .swiper-item { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 1000rpx; + color: #fff; + background-color: #cee1fd; + border-radius: 10px; + } \ No newline at end of file diff --git a/package1/index/peopleList.vue b/package1/index/peopleList.vue index bffc37e..f215f64 100644 --- a/package1/index/peopleList.vue +++ b/package1/index/peopleList.vue @@ -1,8 +1,13 @@