diff --git a/src/pages/raw/ingoods/dnReceipt/ImportDN.vue b/src/pages/raw/ingoods/dnReceipt/ImportDN.vue index 05d79b8..04cd8cf 100644 --- a/src/pages/raw/ingoods/dnReceipt/ImportDN.vue +++ b/src/pages/raw/ingoods/dnReceipt/ImportDN.vue @@ -134,6 +134,7 @@ export default class dnReceiptDom extends BasePage { newLocation: any = []; //添加库位和数量的列表 LocationList: any = []; + DNReceivingListIndex: any = null; //所选择的库位 wl: any = { value: null, @@ -251,6 +252,20 @@ export default class dnReceiptDom extends BasePage { materialChoice(e: any) { // 待放入新增中的公共对象 this.every = { ...e.pickerName }; + if (this.DNReceivingListIndex == null) { + this.model.ImportDNReceivingList.push(this.every); + } + this.model.ImportDNReceivingList.forEach((item: any, index: any) => { + if (item.poLine == this.every.poLine || item.materialCode == this.every.materialCode || item.dnNo == this.every.dnNo) { + this.DNReceivingListIndex = index; + } + }); + this.model.ImportDNReceivingList.forEach((item: any, index: any) => { + if (item.poLine != this.every.poLine || item.materialCode != this.every.materialCode || item.dnNo != this.every.dnNo) { + this.model.ImportDNReceivingList.push(this.every); + this.DNReceivingListIndex = index + 1; + } + }); this.newLocation = []; this.newLocation = this.Location.filter((item: any) => item.sendSpot === this.every.sendSpot); console.log('newLoction', this.newLocation); @@ -303,15 +318,27 @@ export default class dnReceiptDom extends BasePage { wlCode: this.wl.label, receiptAmount: this.receiptAmount, }); + this.model.ImportDNReceivingList[this.DNReceivingListIndex].wllist.push(this.LocationList); //将本次数量蓝清空 this.receiptAmount = ''; //为什莫要将置为true???? isTrue = true; this.business(); } - deleteItem(index: any) { + deleteItem(indexItem: any) { + let Item: any = {}; + this.model.ImportDNReceivingList.forEach((item: any) => { + if (item.poLine == this.every.poLine || item.materialCode == this.every.materialCode || item.dnNo == this.every.dnNo) { + Item = item; + } + }); + Item.wllist.forEach((item: any, index: any) => { + if (item.poLine == this.LocationList[indexItem].poLine || item.materialCode == this.LocationList[indexItem].materialCode || item.dnNo == this.LocationList[indexItem].dnNo) { + Item.wllist.splice(index, 1); + } + }); //splice有删除功能,第一个参数为位置,第二个参数是数量 - this.LocationList.splice(index, 1); + this.LocationList.splice(indexItem, 1); this.business(); // guoshuang 删除成功提示 uni.showToast({ @@ -351,7 +378,7 @@ export default class dnReceiptDom extends BasePage { } //此条是什么作用 提交里的入参是和后端商量好的吗???? this.every.wllist = this.LocationList; - await this.model.submitOrderInEnter([this.every]); + await this.model.submitOrderInEnter(this.model.ImportDNReceivingList); this.resetForm(); } async bill() { diff --git a/src/pages/raw/ingoods/dnReceipt/dnReceiving.vue b/src/pages/raw/ingoods/dnReceipt/dnReceiving.vue index 634624a..444326c 100644 --- a/src/pages/raw/ingoods/dnReceipt/dnReceiving.vue +++ b/src/pages/raw/ingoods/dnReceipt/dnReceiving.vue @@ -123,6 +123,7 @@ export default class dnReceiptDom extends BasePage { every: any = {}; value = ''; type = 'text'; + DNReceivingListIndex: any = null; border = true; //本次数量 receiptAmount: any = ''; @@ -140,6 +141,8 @@ export default class dnReceiptDom extends BasePage { requestAmount: number = null; //receiptAmount = (this.receiptAmount.match(/\d+(.\d{0,2})?/) || [''])[0]; async onReady() { + this.model.DNReceivingList = []; + this.resetForm(); //this.initLocation(); } input() { @@ -180,7 +183,7 @@ export default class dnReceiptDom extends BasePage { }); return; } - await this.model.queryOrderInInfo(this.form.documentNo); + await this.model.queryOrderInInfo(this.form.documentNo.trim()); if (model.code == '1') { uni.showToast({ icon: 'none', @@ -251,6 +254,21 @@ export default class dnReceiptDom extends BasePage { async materialChoice(e: any) { // 待放入新增中的公共对象 this.every = { ...e.pickerName }; + if (this.DNReceivingListIndex == null) { + this.model.DNReceivingList.push(this.every); + } + this.model.DNReceivingList.forEach((item: any, index: any) => { + if (item.poLine == this.every.poLine || item.materialCode == this.every.materialCode || item.dnNo == this.every.dnNo) { + this.DNReceivingListIndex = index; + } + }); + this.model.DNReceivingList.forEach((item: any, index: any) => { + if (item.poLine != this.every.poLine || item.materialCode != this.every.materialCode || item.dnNo != this.every.dnNo) { + this.model.DNReceivingList.push(this.every); + this.DNReceivingListIndex = index + 1; + } + }); + console.log('this.model.DNReceivingList', this.model.DNReceivingList); //清空库位列表 避免库位重复添加 this.Location = []; // 查询时初始化仓库 @@ -292,24 +310,37 @@ export default class dnReceiptDom extends BasePage { // 判断已添加库位和新添加库位是否相同,不相同return let isTrue = this.LocationList.some((item) => item.wlCode !== this.wl.label); - if (isTrue) { - uni.showToast({ - icon: 'none', - title: this.$t('message._tips5') as any, - }); - return; - } + // if (isTrue) { + // uni.showToast({ + // icon: 'none', + // title: this.$t('message._tips5') as any, + // }); + // return; + // } this.LocationList.push({ ...this.every, wlCode: this.wl.label, receiptAmount: this.receiptAmount, }); + this.model.DNReceivingList[this.DNReceivingListIndex].wllist.push(this.LocationList); this.receiptAmount = ''; isTrue = true; + // this.addition(); this.business(); } - deleteItem(index: any) { - this.LocationList.splice(index, 1); + deleteItem(indexItem: any) { + let Item: any = {}; + this.model.DNReceivingList.forEach((item: any) => { + if (item.poLine == this.every.poLine || item.materialCode == this.every.materialCode || item.dnNo == this.every.dnNo) { + Item = item; + } + }); + Item.wllist.forEach((item: any, index: any) => { + if (item.poLine == this.LocationList[indexItem].poLine || item.materialCode == this.LocationList[indexItem].materialCode || item.dnNo == this.LocationList[indexItem].dnNo) { + Item.wllist.splice(index, 1); + } + }); + this.LocationList.splice(indexItem, 1); this.business(); // guoshuang 删除成功提示 uni.showToast({ @@ -349,11 +380,33 @@ export default class dnReceiptDom extends BasePage { }); return null; } - this.every.wllist = this.LocationList; - console.log('new this.every :::: ', this.every); - await this.model.submitOrderInEnter([this.every]); + await this.model.submitOrderInEnter(this.model.DNReceivingList); this.resetForm(); } + addition() { + if (this.model.DNReceivingList.length != 0) { + let whether: any = false; + let nnum: any; + this.model.DNReceivingList.forEach((item: any, index: any) => { + if (item.poLine == this.every.poLine || item.sendSpot == this.every.sendSpot || item.materialCode == this.every.materialCode) { + whether = true; + nnum = index; + return; + } + }); + console.log('nnum', nnum); + if (whether == true) { + this.model.DNReceivingList[nnum].wllist.push(this.LocationList[this.LocationList.length - 1]); + } else { + this.every.wllist.push(this.LocationList[this.LocationList.length - 1]); + this.model.DNReceivingList.push(this.every); + } + } + if (this.model.DNReceivingList.length == 0) { + this.model.DNReceivingList.push(this.every); + } + console.log('this.model.DNReceivingList', this.model.DNReceivingList); + } async bill() { if (this.form.documentNo == '') { uni.showToast({ diff --git a/src/pages/raw/ingoods/dnReceipt/model.ts b/src/pages/raw/ingoods/dnReceipt/model.ts index 51ba0fc..4ffcab5 100644 --- a/src/pages/raw/ingoods/dnReceipt/model.ts +++ b/src/pages/raw/ingoods/dnReceipt/model.ts @@ -35,6 +35,8 @@ export class ReceiptModule extends VuexModule { dnNo = ''; code = ''; DNdetailedList: any; + DNReceivingList: any = []; + ImportDNReceivingList: any = []; /** * 看单号查询结果 */