diff --git a/pages/billing/changeGoods1.vue b/pages/billing/changeGoods1.vue index a622a7a..dba1f0a 100644 --- a/pages/billing/changeGoods1.vue +++ b/pages/billing/changeGoods1.vue @@ -130,34 +130,34 @@ - + - {{item.productName}} - {{item.productSn}} + {{value[1].productName}} + {{value[1].productSn}} - ¥{{item.price}} + ¥{{value[1].price}} - + - + - + - {{items.name}} + {{values[0] | sliceMsg}} - + @@ -203,9 +203,30 @@ zNum: 0, storageType: '', carNum: 0, - carType: 0, - type:'', + carType: 0, + type: '', + oldList: [], + newList: new Map() } + }, + filters: { + sliceMsg(val) { + var name = '' + if (typeof(val) == 'string') { + let newObj = JSON.parse(val) + for (let as in newObj) { + name += newObj[as] + '/' + } + } + return name; + }, + maxNum(val) { + if (val >= 10) { + return 10 + } else if (val < 0) { + return 0 + } + } }, onLoad() { this.getGategoryList() @@ -225,7 +246,7 @@ } else { this.indexList[i].parentId = false } - } + } this.categoryId = this.indexList[0].id this.getShareList(this.indexList[0].id); } else { @@ -337,9 +358,13 @@ toggle(type, item) { // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性 if (type == 'carPopup') { + console.log(this.carList) + this.oldList = this.carList + this.newFun() + this.carNum = 0 for (let i = 0; i < this.carList.length; i++) { this.carNum += this.carList[i].num - } + } this.$refs.carPopup.open('bottom') this.carType = this.carList.length } else { @@ -348,6 +373,73 @@ } }, + newFun() { + //newList 已经是map格式了 新数组 初始为空 + //carList 旧数组 + for (let i = 0; i < this.carList.length; i++) { + if (this.newList.size == 0) { //首次放值,直接放就行 + let obj = { + purchasePrice: this.carList[i].price, //采购价 + price: 0, //总价 + discount: 10, //折扣 + unitPrice: 0, //单价 + discountAmount: 0, //折后价 + wholesalePrice: this.carList[i].wholesalePrice, //批发价 + lsprice: this.carList[i].lsprice, //零售价 + productCount: 0, //总数量 + productId: this.carList[i].id, + productName: this.carList[i].productName, + productPicture: this.carList[i].productPicture, + productSn: this.carList[i].productSn, + stockLogList: new Map(), + stockLogList1: [], + supplierName: this.carList[i].supplierName //供应商 + } + for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { + obj.stockLogList.set(this.carList[i].saleDetailQueryDTO[m].attributeList, this.carList[i] + .saleDetailQueryDTO[m].productCount) + } + this.newList.set(this.carList[i].id, obj) + } else { //不是首次,里面有值 + + if (this.newList.has(this.carList[i].id) == true) { //商品相同 ,给循环,判断规格是不是相同 + for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { + if (this.newList.get(this.carList[i].id).stockLogList.has(this.carList[i] + .saleDetailQueryDTO[m].attributeList) == true) { //规格相同 + this.newList.get(this.carList[i].id).stockLogList.set(this.carList[i].saleDetailQueryDTO[m].attributeList, this.newList.get(this.carList[i].id).stockLogList.get(this.carList[i].saleDetailQueryDTO[m].attributeList) + this.carList[i].saleDetailQueryDTO[m].productCount) + } else { //规格不同 + this.newList.get(this.carList[i].id).stockLogList.set(this.carList[i] + .saleDetailQueryDTO[m]) + } + } + } else { //商品不同,可以直接给map.set + let obj = { + purchasePrice: this.carList[i].price, //采购价 + price: 0, + discount: 10, + discountAmount: 0, + unitPrice: 0, //单价 + wholesalePrice: this.carList[i].wholesalePrice, //批发价 + lsprice: this.carList[i].lsprice, //零售价 + productCount: 0, + productId: this.carList[i].id, + productName: this.carList[i].productName, + productPicture: this.carList[i].productPicture, + stockLogList: new Map(), + stockLogList1: [], + productSn: this.carList[i].productSn, + supplierName: this.carList[i].supplierName + } + for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { + obj.stockLogList.set(this.carList[i].saleDetailQueryDTO[m].attributeList, this.carList[i] + .saleDetailQueryDTO[m].productCount) + obj.productCount += this.carList[i].saleDetailQueryDTO[m].productCount + } + this.newList.set(this.carList[i].id, obj) + } + } + } + }, //选择商品查询商品规格 checkGoods(item) { this.tui.request("/app/product/getById/" + item.id, "POST", {}, false, true).then((res) => { @@ -392,22 +484,22 @@ }, //顶部搜索框 search(res) { - this.searchName = res.value + this.searchName = res.value this.getShareList() - }, - //未入库遮罩 - clickMask(item){ - let title = '' - if(item.delFlag == 0){ - title = '请将商品上架后再操作!' - } - // else if(item.delFlag == 1){ - // title = '请将商品入库后再操作!' - // } - uni.showToast({ - title: title, - icon: 'none' - }) + }, + //未入库遮罩 + clickMask(item) { + let title = '' + if (item.delFlag == 0) { + title = '请将商品上架后再操作!' + } + // else if(item.delFlag == 1){ + // title = '请将商品入库后再操作!' + // } + uni.showToast({ + title: title, + icon: 'none' + }) }, //点击左侧菜单切换 clickLeftBtn(index) { @@ -417,7 +509,7 @@ } else { this.indexList[i].parentId = false } - } + } this.categoryId = this.indexList[index].id this.getShareList(this.indexList[index].id) }, @@ -430,12 +522,6 @@ }, //弹窗选择规格后,点击弹窗中选好了按钮 temporaryCheck() { - // if(this.storageType == 0 && this.purchasePrice == 0){ - // uni.showToast({ - // title: "请输入采购价!", - // icon: 'none' - // }) - // }else{ let data = { id: this.goodsDetail.id, price: this.zPrice, @@ -445,11 +531,19 @@ productPicture: this.goodsDetail.productPicture, supplierName: this.goodsDetail.supplierName, saleDetailQueryDTO: this.temporaryList, + saleDetailQueryDTO1: [], wholesalePrice: this.goodsDetail.wholesalePrice, lsprice: this.goodsDetail.price - } - + } + this.carList.push(data) + for (let i = 0; i < this.carList.length; i++) { + this.carList[i].num = 0 + for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { + this.carList[i].num += this.carList[i].saleDetailQueryDTO[m].productCount + } + } + console.log(this.carList) this.temporaryList = [] this.purchasePrice = '' this.zPrice = '' @@ -461,45 +555,40 @@ } } this.$refs.popup.close() - // } }, //删除整条商品 delShop(id) { var that = this; - console.log(this.carList) - for (let i = 0; i < this.carList.length; i++) { - if (this.carList[i].id == id) { - uni.showModal({ - title: "提示", - content: "确定删除此条商品吗?", - success: function(res) { - that.carList.splice(i, 1) - } - }) + uni.showModal({ + title: "提示", + content: "确定删除此条商品吗?", + success: function(res) { + if (res.confirm) { + if (that.newList.has(id) == true) { + that.newList.delete(id) + } + } + that.$forceUpdate() } - } + }) }, //删除商品下的某一个规格 delShopSpec(name) { - var that = this; - console.log(this.carList) - for (let i = 0; i < this.carList.length; i++) { - for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { - if (this.carList[i].saleDetailQueryDTO[m].name == name) { - uni.showModal({ - title: "提示", - content: "确定删除此条商品吗?", - success: function(res) { - that.carList[i].saleDetailQueryDTO.splice(m, 1) - if (that.carList[i].saleDetailQueryDTO.length == 0) { - that.carList.splice(i, 1) - } - } - }) - } - } - } + var that = this; + uni.showModal({ + title: "提示", + content: "确定删除此条商品吗?", + success: function(res) { + if (res.confirm) { + that.newList.get(id).stockLogList.delete(name) + if (that.newList.get(id).stockLogList.size == 0) { + that.newList.delete(id) + } + } + that.$forceUpdate() + } + }) }, //选择是零售价还是批发价 checkPay(price) { @@ -689,7 +778,7 @@ } .content-right { - // width: 550rpx; + // width: 550rpx; flex: 1; overflow-y: scroll; } @@ -859,9 +948,9 @@ .shop-mask { width: 100%; height: 190rpx; - position: absolute; - top: 0; - left: 0; + position: absolute; + top: 0; + left: 0; background: rgba(0, 0, 0, 0.1); } \ No newline at end of file diff --git a/pages/index/addHangOrder.vue b/pages/index/addHangOrder.vue index 5ee97a0..b56f367 100644 --- a/pages/index/addHangOrder.vue +++ b/pages/index/addHangOrder.vue @@ -539,19 +539,21 @@ uni.showModal({ title: "提示", content: "确定删除此条挂单记录吗?", - success: function(res) { - that.tui.request("/app/sale/delById", "POST", { - id: id - }, false, false).then((res) => { - if (res.code == 200) { - that.tui.toast("删除成功") - that.getRegList(); - } else { - that.tui.toast(res.message) + success: function(res) { + if (res.confirm) { + that.tui.request("/app/sale/delById", "POST", { + id: id + }, false, false).then((res) => { + if (res.code == 200) { + that.tui.toast("删除成功") + that.getRegList(); + } else { + that.tui.toast(res.message) + } + }).catch((res) => { + that.tui.toast(res) + }) } - }).catch((res) => { - that.tui.toast(res) - }) } }) }, @@ -563,14 +565,16 @@ uni.showModal({ title: "提示", content: "确定删除此条商品吗?", - success: function(res) { + success: function(res) { + if (res.confirm) { for (let i = 0; i < item.saleDetailDTOList.length; i++) { if (item.saleDetailDTOList[i].productId == productId) { item.saleDetailDTOList.splice(item.saleDetailDTOList[i], 1) } } that.carList = item.saleDetailDTOList - that.setSaleDetail(); + that.setSaleDetail(); + } } }) }, @@ -582,11 +586,13 @@ uni.showModal({ title: "提示", content: "确定删除此条规格吗?", - success: function(res) { + success: function(res) { + if (res.confirm) { item.saleDetailDTOList[index].stockLogList1.splice(item.saleDetailDTOList[index] .stockLogList1[index1], 1) that.carList = item.saleDetailDTOList - that.setSaleDetail(); + that.setSaleDetail(); + } } }) }, diff --git a/pages/index/downStearmList.vue b/pages/index/downStearmList.vue index db3166b..b990e4b 100644 --- a/pages/index/downStearmList.vue +++ b/pages/index/downStearmList.vue @@ -430,8 +430,10 @@ uni.showModal({ title: "提示", content: "确定删除此条商品吗?", - success: function(res) { - that.carList.splice(i, 1) + success: function(res) { + if (res.confirm) { + that.carList.splice(i, 1) + } } }) } @@ -447,10 +449,12 @@ uni.showModal({ title: "提示", content: "确定删除此条商品吗?", - success: function(res) { + success: function(res) { + if (res.confirm) { that.carList[i].stockLogList1.splice(m, 1) if (that.carList[i].stockLogList1.length == 0) { that.carList.splice(i, 1) + } } } }) diff --git a/pages/index/order.vue b/pages/index/order.vue index 8cf2d96..80f986c 100644 --- a/pages/index/order.vue +++ b/pages/index/order.vue @@ -1,8 +1,9 @@