From 920ff58ccdb20fd4d69c477aa03542ceae24c5a8 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Thu, 4 Apr 2024 11:06:48 +0800 Subject: [PATCH] 11 --- .../index/customAndSupplierProductDetail.vue | 6 +- pages/inventory/AIInventory.vue | 389 +++++++++--------- pages/inventory/addinventory.vue | 2 +- pages/inventory/goodsList1.vue | 219 +++++++++- 4 files changed, 403 insertions(+), 213 deletions(-) diff --git a/pages/index/customAndSupplierProductDetail.vue b/pages/index/customAndSupplierProductDetail.vue index 846dced..f32c34b 100644 --- a/pages/index/customAndSupplierProductDetail.vue +++ b/pages/index/customAndSupplierProductDetail.vue @@ -5,7 +5,7 @@ - {{data.createTime}} + {{data.createTime}} 实际售价:{{data.customerBuyProductDetailLogVos[0].realPrice}} @@ -27,8 +27,8 @@ - {{data.createTime}} - 采购价:{{data.supplierBuyProductDetailLogVos[0].purchasePrice}} + {{data.createTime}} + 采购价:{{data.supplierBuyProductDetailLogVos[0].purchasePrice}} diff --git a/pages/inventory/AIInventory.vue b/pages/inventory/AIInventory.vue index a509c30..d96d438 100644 --- a/pages/inventory/AIInventory.vue +++ b/pages/inventory/AIInventory.vue @@ -67,7 +67,7 @@ - {{numData(values[0])[0]}}{{numData(values[0])[1]}} + {{numData(values[0])[0]}}{{numData(values[0])[1]}} - + - 选择规格 + 修改当前规格 + *如果当前规格中没有您想要的,可以手动输入
  • @@ -259,11 +260,18 @@ {{item.value}} + @tap="changeSpec(item.value)">{{item.value}}
+ + + + + + 确认修改 +
@@ -312,7 +320,9 @@ dataObj: new Map(), isPlusAndMinus:false, indexList:[], - attributeValue:[] + attributeValue:[], + specifications:'', + temporary:[] //修改单个规格值临时存放要修改的对象 } }, filters: { @@ -352,8 +362,7 @@ this.carList1 = uni.getStorageSync('carList1') }else{ this.carList1 = this.carList1 - } - console.log('过来吧露露',this.carList1) + } this.khName = JSON.parse(JSON.stringify(this.khName)) || '' if (this.carList.size == 0) { //当前页没有数据 for (let i = 0; i < this.carList1.length; i++) { @@ -464,8 +473,7 @@ setTimeout(res => { uni.hideLoading(); }, 300) - } - console.log('列表',this.carList) + } }, onLoad(options) { @@ -481,12 +489,12 @@ } return name; }, - checkSpec(type,id){ + checkSpec(type,id,attr,value){ if(this.carList.get(id).categoryId == ''){ this.tui.toast('请先选择商品分类') return; } - //this.attrList + this.temporary = [id,attr,type,value] let num = type == '颜色' ? 0 : 1 this.getGategoryLowList(num,this.carList.get(id).categoryId) }, @@ -523,8 +531,31 @@ }).catch((res) => {}) this.$forceUpdate() this.$refs.getaPopup.open() - - console.log('规格',this.attrList) + }, + //点击某一个规格,可修改 + changeSpec(item){ + let that = this; + if(item == ''){ + this.tui.toast('请输入要修改的规格值') + return; + } + let data = this.temporary + let specMap = new Map() //新的临时存放值那个更改过的值的数组 + this.carList.get(data[0]).stockLogList.forEach(function(value, key) { + if(key == data[1]){ + let stringKey = key.replace(data[3],item) //拿到了更改过的key + specMap.set(stringKey,value) //name的值没有改,所有的数组都放在这个下面 + that.carList.get(data[0]).stockLogList.delete(data[1]) + } + }) + if(this.carList.get(data[0]).stockLogList.size > 0){ + this.carList.get(data[0]).stockLogList.forEach(function(value, key) { + specMap.set(key,value) + }) + } + this.carList.get(data[0]).stockLogList = specMap + this.$forceUpdate() + this.$refs.getaPopup.close() }, inputDialogToggle(item) { this.inputVal = ''; @@ -880,7 +911,6 @@ clickGategroy(item){ this.carList.get(this.productId).categoryName = item.categoryName this.carList.get(this.productId).categoryId = item.id - console.log(this.carList) this.$forceUpdate() this.$refs.typePopup.close() }, @@ -899,7 +929,6 @@ }else if(type== 'addGateDialog'){ this.$refs.addGateDialog.open() }else if(type== "mergePopup"){ - console.log(id) this.mergeId = id this.$refs.mergePopup.open() } @@ -907,16 +936,10 @@ //合并已有 clickMerge(value,key){ let that = this; - console.log('key',this.mergeId) - console.log('11',this.carList.get(this.mergeId)) // 旧的 - console.log('订单',this.carList.get(value)) // 新的 this.carList.get(this.mergeId).stockLogList.forEach(function(values, keys) { if(that.carList.get(value).stockLogList.has(keys)){ - console.log('找到了') that.carList.get(value).stockLogList.get(keys).productCount += that.carList.get(that.mergeId).stockLogList.get(keys).productCount }else{ - console.log('没找到',that.carList.get(that.mergeId).stockLogList.get(keys)) - console.log('没找到',keys) that.carList.get(value).stockLogList.set(keys,that.carList.get(that.mergeId).stockLogList.get(keys)) } that.carList.get(value).productCount += that.carList.get(that.mergeId).stockLogList.get(keys).productCount @@ -924,160 +947,137 @@ }) this.carList.delete(this.mergeId) this.$forceUpdate() - console.log(this.carList) this.getAllPrice() this.$refs.mergePopup.close() }, AiAddSpec(value){ - console.log(value) - this.toggle('bottom', value.id); + if(value.categoryId == ''){ + this.tui.toast('请先选择商品分类') + return; + } + this.getById(value,1); }, //通过商品id查询商品详细信息 - getById(id) { - let that = this; - 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 - } - that.goodsDetail = res.result; - that.temporaryList = [] - - - if (that.carList.size > 0) { - // let isTrue = false - that.carList.forEach(function(value, key) { - value.stockLogList.forEach(function(values, keys) { - if(value.stockLogList1.length == 0){ - let obj = { - productCount: values.productCount, - name: values.name, - attributeList: keys, - productNum: that.productNum - } - value.stockLogList1.push(obj) - }else{ - for(var i=0;i { + if (res.code == 200) { + if (res.result.delFlag == 0) { + that.tui.toast("请将商品上架后再操作!") + return + } + that.goodsDetail = res.result; + + } else { + this.tui.toast(res.message) + } + }).catch((res) => {}) + } + + + that.temporaryList = [] + if (that.carList.size > 0) { + // let isTrue = false + that.carList.forEach(function(value, key) { + value.stockLogList.forEach(function(values, keys) { + if(value.stockLogList1.length == 0){ + let obj = { + productCount: values.productCount, + name: values.name, + attributeList: keys, + productNum: that.productNum + } + value.stockLogList1.push(obj) + }else{ + for(var i=0;i { - that.carList.forEach(function(value, key) { - if (value.productId == id) { - that.zNum = value.productCount - that.temporaryList = value.stockLogList1 - that.pageOldTemList = value.stockLogList1 - that.oldTemList = value.stockLogList1 + } + } + + + }) + }) + that.zNum = 0 + that.$nextTick(() => { + that.carList.forEach(function(value, key) { + if (value.productId == id) { + that.zNum = value.productCount + that.temporaryList = value.stockLogList1 + that.pageOldTemList = value.stockLogList1 + that.oldTemList = value.stockLogList1 + } + value.stockLogList1 = [] + }) + }) + + } + + this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", { + categoryId: this.goodsDetail.categoryId + }, false, true).then((res1) => { + if (res1.code == 200) { + this.goodsList = [] + this.$refs.shopPopup.open('bottom') + if (typeof(res1.result) == 'string') { + let newObj = JSON.parse(res1.result) + 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 + }) + this.dataObj.set(newObj[val][i], val) + // isTrue = false + } + newArr.push({ + name: val, + value: valueObj + }) + } + this.goodsDetail.attributeList = newArr; + for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { + let oldCheck = false + let oldValue = [] + for (var m = 0; m < this.goodsDetail.attributeList[i].value + .length; m++) { + if (this.goodsDetail.attributeList[i].value[m].isChecked == true) { + oldCheck = true + oldValue.push(this.goodsDetail.attributeList[i].value[m].value) } - value.stockLogList1 = [] - }) - }) - - } - that.$nextTick(() => { - console.log('oldTemList', that.oldTemList) - console.log('temporaryList', that.temporaryList) - console.log('pageOldTemList', that.pageOldTemList) - }) - - this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", { - categoryId: this.goodsDetail.categoryId - }, false, true).then((res1) => { - if (res1.code == 200) { - this.goodsList = [] - this.$refs.shopPopup.open('bottom') - if (typeof(res1.result) == 'string') { - let newObj = JSON.parse(res1.result) - let newArr = [] - let dataArr = [] - for (let val in newObj) { - let valueObj = []; - // let isTrue = false - for (var i = 0; i < newObj[val].length; i++) { - // for (var m = 0; m < this.oldTemList.length; m++) { - // var data = this.oldTemList[m].name.split('/') - // for (var j = 0; j < data.length; j++) { - // if (data[j] == newObj[val][i]) { - // isTrue = true - // } - // } - // } - // for (var m = 0; m < this.pageOldTemList.length; m++) { - // var data = this.pageOldTemList[m].name.split('/') - // for (var j = 0; j < data.length; j++) { - // if (data[j] == newObj[val][i]) { - // isTrue = true - // } - // } - // } - valueObj.push({ - value: newObj[val][i], - isChecked: false - }) - this.dataObj.set(newObj[val][i], val) - // isTrue = false - } - newArr.push({ - name: val, - value: valueObj - }) - } - this.goodsDetail.attributeList = newArr; - for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { - let oldCheck = false - let oldValue = [] - for (var m = 0; m < this.goodsDetail.attributeList[i].value - .length; m++) { - if (this.goodsDetail.attributeList[i].value[m].isChecked == true) { - oldCheck = true - oldValue.push(this.goodsDetail.attributeList[i].value[m].value) - } - } - // if (oldCheck) { - // let specs1 = { - // specs: [] - // } - - // specs1.specs = oldValue - // this.goodsList.push(specs1) - // } else { - let specs1 = { - specs: [] - } - this.goodsList.push(specs1) - // } - oldCheck = false - oldValue = [] - } - } else { - this.tui.toast('失败了') - } - - } else { - this.tui.toast(res1.message) - } - }).catch((res) => {}) - } else { - this.tui.toast(res.message) - } + } + let specs1 = { + specs: [] + } + this.goodsList.push(specs1) + oldCheck = false + oldValue = [] + } + } else { + this.tui.toast('失败了') + } + + } else { + this.tui.toast(res1.message) + } }).catch((res) => {}) - this.getKCList(id); + this.getKCList(current == 1?id.id:id); }, //库存商品详情 getKCList(id) { @@ -1275,39 +1275,34 @@ delCarData(index) { this.temporaryList.splice(index, 1); this.temporaryChange() - // uni.showModal({ - // title: "提示", - // content: "确定删除此条商品吗?", - // success: function(res) { - // if(res.confirm){ - // that.carList.get(id).productCount -= that.carList.get(id).stockLogList.get(name); - // that.carList.get(id).stockLogList.delete(name) - // that.carList.get(id).price = that.carList.get(id).productCount * that.carList.get(id).purchasePrice - // if(that.carList.get(id).stockLogList.size == 0){ - // that.carList.delete(id) - // } - - // that.getAllPrice() - // } - // that.$forceUpdate() - // } - // }) - }, //删除商品下的某一个规格 delShopSpec(id, name) { - var that = this; + var that = this; + console.log(that.carList) uni.showModal({ title: "提示", content: "确定删除此条商品吗?", success: function(res) { - if (res.confirm) { - that.carList.get(id).productCount -= that.carList.get(id).stockLogList.get(name).productCount; - that.carList.get(id).stockLogList.delete(name) + if (res.confirm) { + if(that.carList.get(id).stockLogList.size == 1){ + that.carList.get(id).productCount = that.carList.get(id).stockLogList.get(name).productCount; + }else{ + that.carList.get(id).productCount -= that.carList.get(id).stockLogList.get(name).productCount; + } + + let count = that.carList.get(id).stockLogList.get(name).productCount + that.carList.get(id).stockLogList.delete(name) + that.carList.get(id).price = that.carList.get(id).productCount * that.carList.get( id).purchasePrice if (that.carList.get(id).stockLogList.size == 0) { - that.carList.delete(id) + let key = '{"颜色":"均色","尺码":"均码"}' + let value = { + name:'均色/均码/', + productCount: count + } + that.carList.get(id).stockLogList.set(key,value) } that.getAllPrice() @@ -1320,13 +1315,14 @@ async inventorySubmit() { if (this.khName == '' || this.carList == '') { uni.showToast({ - title: "商品信息填写完成后入库!", + title: "请选择供应商后入库!", icon: 'none' }) return } let that = this; - let purchase = { + let purchase = { + id:uni.getStorageSync('AiInventoryId'), alreadyPay: this.alreadyPay == '' ? 0 : this.alreadyPay, //已付金额 noPay: this.noPay == '' ? 0 : this.noPay, //欠款 shouldPay: this.shouldPay, //应付金额 @@ -1337,7 +1333,7 @@ supplierName: this.khName.consigneeName } let purchaseDetails = []; - console.log(this.carList) + let jishuqi = 0 this.carList.forEach(function(value, key) { value.stockLogList1 = [] if (value.purchasePrice == '' || value.purchasePrice == 0) { @@ -1363,11 +1359,13 @@ value.stockLogList1.push(obj) }) delete value.id; - purchaseDetails.push(value) + purchaseDetails.push(value) + jishuqi ++ }) - console.log(purchaseDetails) - console.log(purchase) - await this.goInventory(purchase,purchaseDetails) + if(jishuqi == this.carList.size){ + await this.goInventory(purchase,purchaseDetails) + } + }, goInventory(purchase,purchaseDetails){ uni.navigateTo({ @@ -1391,8 +1389,7 @@ }) this.alreadyPay = this.shouldPay that.noPay = this.shouldPay - this.alreadyPay - this.$forceUpdate() - console.log('计算',this.carList) + this.$forceUpdate() }, //修改已选规格的数量 GoodsNumChange(e, index, index1) { diff --git a/pages/inventory/addinventory.vue b/pages/inventory/addinventory.vue index 6e53f0a..b9bcdef 100644 --- a/pages/inventory/addinventory.vue +++ b/pages/inventory/addinventory.vue @@ -977,7 +977,7 @@ inventorySubmit() { if (this.khName == '' || this.carList == '') { uni.showToast({ - title: "商品信息填写完成后入库!", + title: "请选择供应商后入库!", icon: 'none' }) return diff --git a/pages/inventory/goodsList1.vue b/pages/inventory/goodsList1.vue index 1d4386f..72cac65 100644 --- a/pages/inventory/goodsList1.vue +++ b/pages/inventory/goodsList1.vue @@ -21,20 +21,29 @@ placeholder="请选择销售员" @change="categoryChange">
- - - + + + 扫一扫 - - - + + + 添加商品 - - + +
+ + + + + + AI开单 + 使用AI助手语音识别,一键返回商品详情 + +
- + @@ -367,6 +376,39 @@ + + + + + + 语音录入 + + + + 语音示例:货号02-37,白色M码,10件 + + + + + *长按“语音”按钮录入,系统将自动识别 + + + 清空 + 确认 + + + + + + + + + + + 语音识别中... + @@ -407,7 +449,9 @@