diff --git a/pages/.DS_Store b/pages/.DS_Store index 3d95444..5191d65 100644 Binary files a/pages/.DS_Store and b/pages/.DS_Store differ diff --git a/pages/billing/changeGoods1.vue b/pages/billing/changeGoods1.vue index 502b1e4..0c03424 100644 --- a/pages/billing/changeGoods1.vue +++ b/pages/billing/changeGoods1.vue @@ -73,7 +73,8 @@ {{goodsDetail.productSn}} - + + 保存已选 + + + + + + + {{item.name}} 库存:{{item.productNum}} + + + - - - - - 数量:{{zNum}} 件 - - - 选好了 - + + + + + 数量:{{zNum}} 件 + + + 选好了 + @@ -193,10 +201,16 @@ columns: [], keyList: [], temporaryList: [], - zNum: 0, - storageType:'', - productNum:0, - productId:'' + zNum: 0, + storageType: '', + productNum: 0, + productId: '', + pageOldTemList: [], + oldTemList: [], + goodsList: [], + newTemList: [], + pecsList: [], + dataObj: new Map() } }, filters: { @@ -228,8 +242,11 @@ stockLogList1: [] } for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { - obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, this.carList1[i] - .saleDetailQueryDTO[m].productCount) + var data1 = { + productCount: this.carList1[i].saleDetailQueryDTO[m].productCount, + name: this.carList1[i].saleDetailQueryDTO[m].name + } + obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, data1) obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount } this.carList.set(this.carList1[i].id, obj) @@ -240,18 +257,25 @@ if (this.carList.has(this.carList1[i].id) == true) { //商品相同 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) { //规格相同 - this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[ - m].attributeList, this.carList.get(this.carList1[i].id).stockLogList.get(this - .carList1[i].saleDetailQueryDTO[m].attributeList) + this.carList1[i] - .saleDetailQueryDTO[m].productCount) - + m].attributeList) == true) { //规格相同 + + var data1 = { + productCount: this.carList.get(this.carList1[i].id).stockLogList.get(this.carList1[i].saleDetailQueryDTO[m].attributeList).productCount + this.carList1[i].saleDetailQueryDTO[m].productCount, + name: this.carList1[i].saleDetailQueryDTO[m].name + } + + this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, data1) + } else { //规格不同 + var data1 = { + productCount: this.carList1[i].saleDetailQueryDTO[m].productCount, + name: this.carList1[i].saleDetailQueryDTO[m].name + } this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[ - m].attributeList, this.carList1[i].saleDetailQueryDTO[m].productCount) - - } - this.carList.get(this.carList1[i].id).productCount += this.carList1[i].saleDetailQueryDTO[ + m].attributeList, data1) + + } + this.carList.get(this.carList1[i].id).productCount += this.carList1[i].saleDetailQueryDTO[ m].productCount } } else { //商品不同 @@ -261,22 +285,27 @@ productCount: 0, productId: this.carList1[i].id, productName: this.carList1[i].productName, - productPicture: this.carList1[i].productPicture, + productPicture: this.carList1[i].productPicture, productSn: this.carList1[i].productSn, stockLogList: new Map(), stockLogList1: [], name: '' } for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { - obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, this.carList1[i] - .saleDetailQueryDTO[m].productCount) - obj.name = this.carList1[i].saleDetailQueryDTO[m].name + var data1 = { + productCount: this.carList1[i].saleDetailQueryDTO[m].productCount, + name: this.carList1[i].saleDetailQueryDTO[m].name + } + obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, data1) + + obj.name = this.carList1[i].saleDetailQueryDTO[m].name obj.productCount += this.carList1[i].saleDetailQueryDTO[m].productCount } this.carList.set(this.carList1[i].id, obj) - } - - this.carList.get(this.carList1[i].id).price = this.carList.get(this.carList1[i].id).purchasePrice * this.carList.get(this.carList1[i].id).productCount; + } + + this.carList.get(this.carList1[i].id).price = this.carList.get(this.carList1[i].id).purchasePrice * + this.carList.get(this.carList1[i].id).productCount; } this.carList1 = [] } @@ -285,136 +314,215 @@ onLoad() { this.storageType = uni.getStorageSync('type') }, - methods: { - //扫一扫功能 - scanCodeAdd() { - uni.scanCode({ - success: (res) => { - if(res.scanType == "QR_CODE"){ //二维码 - - let shopId = res.result.split(',')[1] - if(shopId == uni.getStorageSync('shopId')){ - this.productId = res.result.split(',')[0] - this.toggle('bottom', res.result.split(',')[0]); - if (item.saleDetailDTOList) { - for (let i = 0; i < item.saleDetailDTOList.length; i++) { - this.carList.push(item.saleDetailDTOList[i]) - } - } - }else{ - this.tui.toast('您的店铺中暂无该商品!') - } - }else{ - - this.tui.request("/app/product/getByBarcode", "POST", { - barcode:res.result - }, false, true).then((res1) => { - if (res1.code == 200) { - this.productId = res1.result[0].id - if(res1.result == ''){ - this.tui.toast('您的店铺中暂无该商品!') - }else{ - this.toggle('bottom', res1.result[0].id); - if (item.saleDetailDTOList) { - for (let i = 0; i < item.saleDetailDTOList.length; i++) { - this.carList.push(item.saleDetailDTOList[i]) - } - } - } - - } else { - this.tui.toast(res.message) - } - }).catch((res) => { - this.tui.toast(res) - }) - } - - }, - fail: (res) => { - uni.showToast({ - title: '扫描失败', - icon: 'none' - }) - } - }) + methods: { + //保存已选 + saveCheck() { + this.pageOldTemList = this.temporaryList + for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { + this.goodsList[i].specs = [] + for (var m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) { + this.goodsDetail.attributeList[i].value[m].isChecked = false + } + } + }, + combination(arr) { + let result = [ + [] + ] + + arr.map(x => { + var res = [] + result.map(y => { + x.specs.map(z => { + res.push([...y, z]) + }) + }) + result = res + }) + return result; + }, + //扫一扫功能 + scanCodeAdd() { + uni.scanCode({ + success: (res) => { + if (res.scanType == "QR_CODE") { //二维码 + + let shopId = res.result.split(',')[1] + if (shopId == uni.getStorageSync('shopId')) { + this.productId = res.result.split(',')[0] + this.toggle('bottom', res.result.split(',')[0]); + // if (item.saleDetailDTOList) { + // for (let i = 0; i < item.saleDetailDTOList.length; i++) { + // this.carList.push(item.saleDetailDTOList[i]) + // } + // } + } else { + this.tui.toast('您的店铺中暂无该商品!') + } + } else { + + this.tui.request("/app/product/getByBarcode", "POST", { + barcode: res.result + }, false, true).then((res1) => { + if (res1.code == 200) { + this.productId = res1.result[0].id + if (res1.result == '') { + this.tui.toast('您的店铺中暂无该商品!') + } else { + this.toggle('bottom', res1.result[0].id); + // if (item.saleDetailDTOList) { + // for (let i = 0; i < item.saleDetailDTOList.length; i++) { + // this.carList.push(item.saleDetailDTOList[i]) + // } + // } + } + + } else { + this.tui.toast(res.message) + } + }).catch((res) => { + this.tui.toast(res) + }) + } + + }, + fail: (res) => { + uni.showToast({ + title: '扫描失败', + icon: 'none' + }) + } + }) }, goodsAdd() { uni.navigateTo({ url: "/pages/inventory/changeGoods1" }) }, - attrNameChange(index, index1) { - this.goodsDetail.attributeList[index].value.forEach(item => { - item.isChecked = false; - }) - this.goodsDetail.attributeList[index].isChecked = true; - this.goodsDetail.attributeList[index].value[index1].isChecked = true; - var name = '', - evalue = [], - obj = {} - for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { - for (var m = 0, Ien = this.goodsDetail.attributeList[i].value; m < Ien.length; m++) { - if (Ien[m].isChecked == true) { - evalue.push(Ien[m].value) - name += Ien[m].value + '/' - } - } + attrNameChange(index, data1, index1) { + this.goodsDetail.attributeList[index].isChecked = !this.goodsDetail.attributeList[index].isChecked; + this.goodsDetail.attributeList[index].value[index1].isChecked = !this.goodsDetail.attributeList[index] + .value[index1].isChecked; + if (this.goodsList[index].specs.indexOf(data1) != -1) { + this.goodsList[index].specs.splice(this.goodsList[index].specs.indexOf(data1), 1) + } else { + this.goodsList[index].specs.push(data1) } - this.keyList.map((item, index) => { - obj[item] = evalue[index] - }) - let jishuqi = 0; - for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { - if (this.goodsDetail.attributeList[i].isChecked == true) { + let jishuqi = 0 + for (var i = 0; i < this.goodsList.length; i++) { + if (this.goodsList[i].specs.length > 0) { jishuqi++ } } - if (this.goodsDetail.attributeList.length == jishuqi) { - this.tui.request("/app/stock/productCount", "post", { - productId: this.productId, - attributeList: JSON.stringify(obj) - }, false, true).then((res) => { - if (res.code == 200) { - this.productNum = res.result - this.attributeList = { - attributeList: JSON.stringify(obj), - productCount: this.temporaryNum, - productNum:this.productNum, - name: name, - price: this.purchasePrice - } - - 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 - } - } - if (this.temporaryList.length == 0) { - this.temporaryList.push(this.attributeList); - } else { - for (var i = 0; i < this.temporaryList.length; i++) { - if (this.temporaryList[i].name.indexOf(this.attributeList.name) == -1 || this.temporaryList[i].name.indexOf(this.attributeList.name) == 1) { - if (this.temporaryList.length == (i + 1)) { - this.temporaryList.push(this.attributeList); - return - } - } else { - this.temporaryList[i] = this.attributeList - return - - } - } - - } - } else { - this.tui.toast(res.message) - } - }).catch((res) => {}) + var resultList = [] + if (jishuqi == this.goodsList.length) { + resultList = this.combination(this.goodsList); + } + var evalue = [] + var value = [] + for (var m = 0; m < resultList.length; m++) { + var name = '' + let value1 = "{" + for (var j = 0; j < resultList[m].length; j++) { + if (j != resultList[m].length - 1) { + name += resultList[m][j] + '/' + value1 += '"' + this.dataObj.get(resultList[m][j]) + '":"' + resultList[m][j] + '",' + } else { + name += resultList[m][j] + value1 += '"' + this.dataObj.get(resultList[m][j]) + '":"' + resultList[m][j] + '"' + } + } + value1 += "}" + value.push(value1) + evalue.push(name) } + if (jishuqi == 0) { + this.oldTemList = [] + } + if (this.temporaryList.length == 0) { + if (jishuqi == this.goodsList.length) { + for (var i = 0; i < value.length; i++) { + this.attributeList = { + attributeList: value[i], + productCount: this.temporaryNum, + productNum: this.productNum, + name: evalue[i], + price: this.purchasePrice + } + this.temporaryList.push(this.attributeList); + } + } + } else { + let newProductCount = 0; + for (var i = 0; i < value.length; i++) { + for (var m = 0; m < this.temporaryList.length; m++) { + if (this.temporaryList[m].attributeList == value[i]) { + newProductCount = this.temporaryList[m].productCount + } + } + this.attributeList = { + attributeList: value[i], + productCount: newProductCount, + productNum: this.productNum, + name: evalue[i], + price: this.purchasePrice + } + + this.newTemList.push(this.attributeList); + newProductCount = 0; + } + for (var i = 0; i < this.oldTemList.length; i++) { + let oldAttributeList = ''; + let oldProductCount = ''; + let notChcek = true; + for (var m = 0; m < this.newTemList.length; m++) { + if (this.oldTemList[i].attributeList == this.newTemList[m].attributeList) { + this.newTemList[m].productCount = this.oldTemList[i].productCount + notChcek = false; + } + } + if (this.newTemList.length > 0 && notChcek) { + this.newTemList.push(this.oldTemList[i]); + } + } + + for (var i = 0; i < this.pageOldTemList.length; i++) { + let oldAttributeList = ''; + let oldProductCount = ''; + let notChcek = true; + for (var m = 0; m < this.newTemList.length; m++) { + if (this.pageOldTemList[i].attributeList == this.newTemList[m].attributeList) { + this.newTemList[m].productCount = this.pageOldTemList[i].productCount + notChcek = false; + } + } + if (this.newTemList.length > 0 && notChcek) { + this.newTemList.push(this.pageOldTemList[i]); + } + } + } + this.$nextTick(() => { + for (var i = 0; i < this.temporaryList.length; i++) { + for (var m = 0; m < this.pecsList.length; m++) { + if (this.temporaryList[i].attributeList == this.pecsList[m].attributeList) { + this.temporaryList[i].productNum = this.pecsList[m].stockCount + } + } + } + }) + if (jishuqi != this.goodsList.length) { + if (this.oldTemList.length == 0 && this.pageOldTemList.length == 0) { + this.newTemList = [] + this.temporaryList = [] + } + } + if (this.newTemList.length != 0 && jishuqi == this.goodsList.length) { + this.temporaryList = this.newTemList; + this.oldTemList = [] + this.newTemList = [] + } }, //弹出商品规格选择 toggle(type, id) { @@ -424,28 +532,104 @@ }, //通过商品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){ - this.tui.toast("请将商品上架后再操作!") - return + 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 { + that.carList.forEach(function(value, key) { + if (that.carList.has(id) == true) { + that.zNum = value.productCount + that.temporaryList = value.stockLogList1 + that.pageOldTemList = value.stockLogList1 + that.oldTemList = value.stockLogList1 + } + value.stockLogList1 = [] + }) + }) + } - this.goodsDetail = res.result; + 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) { + 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, @@ -453,20 +637,58 @@ }) } this.goodsDetail.attributeList = newArr; - this.goodsDetail.attributeList.forEach((item, index) => { - this.columns[index] = item.value; - this.keyList[index] = item.name; - }) + 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(res.message) + this.tui.toast(res1.message) } }).catch((res) => {}) } else { this.tui.toast(res.message) } }).catch((res) => {}) + this.getKCList(id); + }, + //库存商品详情 + getKCList(id) { + this.tui.request("/app/stock/productCount", "GET", { + productId: id + }, false, true).then((res) => { + if (res.code == 200) { + this.pecsList = res.result + } else { + this.tui.toast(res.message) + } + }).catch((res) => {}) + }, temporaryChange(val) { this.zNum = 0 @@ -477,9 +699,8 @@ //弹窗选择规格后,点击弹窗中选好了按钮 temporaryCheck() { - let that = this, - carList1 = [] - + let that = this, + carList1 = [] let data = { id: this.goodsDetail.id, price: 0, @@ -501,6 +722,7 @@ this.goodsDetail.attributeList[i].value[m].isChecked = false } } + if (this.carList.size == 0) { //当前页没有数据 for (let i = 0; i < carList1.length; i++) { let obj = { @@ -515,34 +737,52 @@ stockLogList1: [] } for (let m = 0; m < carList1[i].saleDetailQueryDTO.length; m++) { - obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, carList1[i] - .saleDetailQueryDTO[m].productCount) + + var data1 = { + productCount: carList1[i].saleDetailQueryDTO[m].productCount, + name: carList1[i].saleDetailQueryDTO[m].name + } + obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) obj.productCount += carList1[i].saleDetailQueryDTO[m].productCount } this.carList.set(carList1[i].id, obj) } carList1 = [] - } else { //当前页有数据 - for (let i = 0; i < carList1.length; i++) { + + } else { //当前页有数据 + + for (let i = 0; i < carList1.length; i++) { + this.carList.get(carList1[i].id).productCount = 0 if (this.carList.has(carList1[i].id) == true) { //商品相同 for (let m = 0; m < carList1[i].saleDetailQueryDTO.length; m++) { if (this.carList.get(carList1[i].id).stockLogList.has(carList1[i] .saleDetailQueryDTO[ - m].attributeList) == true) { //规格相同 - this.carList.get(carList1[i].id).stockLogList.set(carList1[i] - .saleDetailQueryDTO[ - m].attributeList, this.carList.get(carList1[i].id).stockLogList.get( - carList1[i].saleDetailQueryDTO[m].attributeList) + carList1[i] - .saleDetailQueryDTO[m].productCount) - + m].attributeList) == true) { //规格相同 + + // var data1 = { + // productCount: carList1[i].saleDetailQueryDTO[m].productCount, + // name: carList1[i].saleDetailQueryDTO[m].name + // } + // this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[ + // m].attributeList, data1) + // this.carList.get(carList1[i].id).stockLogList.set(carList1[i] + // .saleDetailQueryDTO[ + // m].attributeList, this.carList.get(carList1[i].id).stockLogList.get( + // carList1[i].saleDetailQueryDTO[m].attributeList) + carList1[i] + // .saleDetailQueryDTO[m].productCount) + } else { //规格不同 - this.carList.get(carList1[i].id).stockLogList.set(carList1[i] - .saleDetailQueryDTO[ - m].attributeList, carList1[i].saleDetailQueryDTO[m].productCount) - } - this.carList.get(carList1[i].id).productCount += carList1[i].saleDetailQueryDTO[ - m].productCount - that.carList.get(carList1[i].id).price = that.carList.get(carList1[i].id).productCount * that.carList.get(carList1[i].id).purchasePrice + var data1 = { + productCount: carList1[i].saleDetailQueryDTO[m].productCount, + name: carList1[i].saleDetailQueryDTO[m].name + } + this.carList.get(carList1[i].id).stockLogList.set(carList1[i].saleDetailQueryDTO[ + m].attributeList, data1) + } + this.carList.get(carList1[i].id).productCount += carList1[i].saleDetailQueryDTO[ + m].productCount + that.carList.get(carList1[i].id).price = that.carList.get(carList1[i].id).productCount * + that.carList.get(carList1[i].id).purchasePrice } } else { //商品不同 let obj = { @@ -552,15 +792,18 @@ productId: carList1[i].id, productName: carList1[i].productName, productPicture: carList1[i].productPicture, - stockLogList: new Map(), + stockLogList: new Map(), productSn: carList1[i].productSn, stockLogList1: [], name: '' } + for (let m = 0; m < carList1[i].saleDetailQueryDTO.length; m++) { - obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, carList1[i] - .saleDetailQueryDTO[m].productCount) - obj.name = carList1[i].saleDetailQueryDTO[m].name + var data1 = { + productCount: carList1[i].saleDetailQueryDTO[m].productCount, + name: carList1[i].saleDetailQueryDTO[m].name + } + obj.stockLogList.set(carList1[i].saleDetailQueryDTO[m].attributeList, data1) obj.productCount += carList1[i].saleDetailQueryDTO[m].productCount } this.carList.set(carList1[i].id, obj) @@ -571,13 +814,13 @@ this.getAllPrice() this.$refs.shopPopup.close() - }, - changessPrice(){ - this.noPay = this.shouldPay - this.alreadyPay; + }, + changessPrice() { + this.noPay = this.shouldPay - this.alreadyPay; }, //计算欠款 - changePay(e) { - this.alreadyPay = e.target.value >this.shouldPay ?this.shouldPay :e.target.value + changePay(e) { + this.alreadyPay = e.target.value > this.shouldPay ? this.shouldPay : e.target.value this.noPay = this.shouldPay - this.alreadyPay }, //跳转选择供应商 @@ -585,107 +828,108 @@ uni.navigateTo({ url: '/pages/index/peopleList?popleType=' + popleType }) - }, - //删除整条商品 - delShop(id) { - var that = this; - uni.showModal({ - title: "提示", - content: "确定删除此条商品吗?", - success: function(res) { - if(res.confirm){ - if(that.carList.has(id) == true){ - that.carList.delete(id) - } - that.getAllPrice() - that.$forceUpdate() - } - } - }) - - }, - //选商品的时候能删除规格 - 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; - 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() - } - }) - + }, + //删除整条商品 + delShop(id) { + var that = this; + uni.showModal({ + title: "提示", + content: "确定删除此条商品吗?", + success: function(res) { + if (res.confirm) { + if (that.carList.has(id) == true) { + that.carList.delete(id) + } + that.getAllPrice() + that.$forceUpdate() + } + } + }) + + }, + //选商品的时候能删除规格 + 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; + 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() + } + }) + }, inventorySubmit() { - if (this.khName == '' || this.carList == '') { - uni.showToast({ - title: "商品信息填写完成后入库!", - icon: 'none' - }) + if (this.khName == '' || this.carList == '') { + uni.showToast({ + title: "商品信息填写完成后入库!", + icon: 'none' + }) return - }else{ - if(this.storageType==0){ - this.carList.forEach(function(value, key) { - if(value.purchasePrice == '' || value.purchasePrice == 0){ - uni.showToast({ - title: value.productName + "的价格必须维护!", - icon: 'none' - }) - throw new Error("End"); - } - }) - } + } else { + if (this.storageType == 0) { + this.carList.forEach(function(value, key) { + if (value.purchasePrice == '' || value.purchasePrice == 0) { + uni.showToast({ + title: value.productName + "的价格必须维护!", + icon: 'none' + }) + throw new Error("End"); + } + }) + } } let that = this; let purchase = { - alreadyPay: this.alreadyPay == ''?0:this.alreadyPay, //已付金额 - noPay: this.noPay == ''?0:this.noPay, //欠款 + alreadyPay: this.alreadyPay == '' ? 0 : this.alreadyPay, //已付金额 + noPay: this.noPay == '' ? 0 : this.noPay, //欠款 shouldPay: this.shouldPay, //应付金额 totalAmount: this.totalAmount, //总数量 - remark: this.remark, - otherPay:this.otherPay == ''?0:this.otherPay, + remark: this.remark, + otherPay: this.otherPay == '' ? 0 : this.otherPay, supplierId: this.khName.id, //供应商id和姓名 supplierName: this.khName.consigneeName } let purchaseDetails = []; this.carList.forEach(function(value, key) { - value.stockLogList.forEach(function(values, keys) { - if(values <= 0){ - that.tui.toast("入库数量不能为零!") - return; + value.stockLogList.forEach(function(values, keys) { + if (values <= 0) { + that.tui.toast("入库数量不能为零!") + return; } let obj = { productCount: values, @@ -694,34 +938,34 @@ value.stockLogList1.push(obj) }) purchaseDetails.push(value) - }) - uni.showModal({ - title: "提示", - content: "请再次确认供应商、商品库存、规格是否正确,入库后不可修改。确认入库吗?", - success: function(res) { - if(res.confirm){ - that.tui.request("/app/stock/putInOfProduct", "post", { - purchase: purchase, - purchaseDetails: purchaseDetails - }, false, false).then((res) => { - if (res.code == 200) { - uni.showToast({ - title: "入库成功", - icon: 'none' - }) - uni.navigateBack({ - delta: 2 - }) - } else { - uni.showToast({ - title: "入库失败", - icon: 'none' - }) - } - }) - } - that.$forceUpdate() - } + }) + uni.showModal({ + title: "提示", + content: "请再次确认供应商、商品库存、规格是否正确,入库后不可修改。确认入库吗?", + success: function(res) { + if (res.confirm) { + that.tui.request("/app/stock/putInOfProduct", "post", { + purchase: purchase, + purchaseDetails: purchaseDetails + }, false, false).then((res) => { + if (res.code == 200) { + uni.showToast({ + title: "入库成功", + icon: 'none' + }) + uni.navigateBack({ + delta: 2 + }) + } else { + uni.showToast({ + title: "入库失败", + icon: 'none' + }) + } + }) + } + that.$forceUpdate() + } }) }, //编辑每一个的单价 @@ -735,31 +979,36 @@ let that = this; that.carList.get(that.index).purchasePrice = val that.carList.get(that.index).price = val * that.carList.get(that.index).productCount; - this.getAllPrice() - - }, - //计算总金额和总数量 - getAllPrice(){ - let that = this; - this.shouldPay = 0 - this.totalAmount = 0 - this.carList.forEach(function(value, key) { - that.shouldPay = that.shouldPay + value.price - that.totalAmount = that.totalAmount + value.productCount - }) - this.alreadyPay = this.shouldPay - that.noPay = this.shouldPay - this.alreadyPay - }, - //修改已选规格的数量 - GoodsNumChange(e,index,index1){ + this.getAllPrice() + + }, + //计算总金额和总数量 + getAllPrice() { + let that = this; + this.shouldPay = 0 + this.totalAmount = 0 + this.carList.forEach(function(value, key) { + that.shouldPay = that.shouldPay + value.price + that.totalAmount = that.totalAmount + value.productCount + }) + this.alreadyPay = this.shouldPay + that.noPay = this.shouldPay - this.alreadyPay + }, + //修改已选规格的数量 + GoodsNumChange(e, index, index1) { let that = this; - this.carList.get(index).stockLogList.set(index1,e) - this.carList.get(index).productCount = 0 - this.carList.get(index).stockLogList.forEach(function(value, key) { - that.carList.get(index).productCount = that.carList.get(index).productCount + value - that.carList.get(index).price = that.carList.get(index).productCount * that.carList.get(index).purchasePrice - }) - this.getAllPrice(); + console.log('开始了') + console.log(this.carList) + console.log(e) + console.log(this.index) + console.log(this.index1) + this.carList.get(index).stockLogList.set(index1, e) + this.carList.get(index).productCount = 0 + this.carList.get(index).stockLogList.forEach(function(value, key) { + that.carList.get(index).productCount = that.carList.get(index).productCount + value + that.carList.get(index).price = that.carList.get(index).productCount * that.carList.get(index).purchasePrice + }) + this.getAllPrice(); } } } @@ -960,8 +1209,8 @@ justify-content: center; padding: 15px; height: 1200rpx; - background-color: #fff; - margin-bottom: 30rpx; + background-color: #fff; + margin-bottom: 30rpx; overflow: scroll; } @@ -1020,15 +1269,18 @@ margin: 20rpx; background-color: #fff; color: #5fd9ee; - width: 100rpx; - line-height: 70rpx; + padding: 0 10px; + min-width: 100rpx; + line-height: 35px; height: 70rpx; text-align: center; + border-radius: 20rpx; } .checkedText { - background-color: $u-primary; + background-color: #5fd9ee; color: #fff; + border-radius: 20rpx; } } @@ -1046,13 +1298,13 @@ } .shop-popup-bottom { - width: 95%; - height: 100rpx; - position: fixed; - bottom: 0; - left: 2.5%; - display: flex; - z-index: 99; + width: 95%; + height: 100rpx; + position: fixed; + bottom: 0; + left: 2.5%; + display: flex; + z-index: 99; background: #fff; } @@ -1076,15 +1328,16 @@ background: linear-gradient(90deg, #60F3FF, #088FEB); border-radius: 70rpx; } - } - .noPic{ - border-radius: 10px; - width: 150rpx; - height: 150rpx; - // margin: 30rpx 0 0 30rpx; - text-align: center; - line-height: 140rpx; - color: #777; - background: #eee; + } + + .noPic { + border-radius: 10px; + width: 150rpx; + height: 150rpx; + // margin: 30rpx 0 0 30rpx; + text-align: center; + line-height: 140rpx; + color: #777; + background: #eee; } \ No newline at end of file diff --git a/pages/inventory/changeGoods1.vue b/pages/inventory/changeGoods1.vue index 8211748..a78e232 100644 --- a/pages/inventory/changeGoods1.vue +++ b/pages/inventory/changeGoods1.vue @@ -1,28 +1,30 @@