diff --git a/src/pages/repleinsh/coms/comScanReplishPack.vue b/src/pages/repleinsh/coms/comScanReplishPack.vue index 3596d39a..faeb55ec 100644 --- a/src/pages/repleinsh/coms/comScanReplishPack.vue +++ b/src/pages/repleinsh/coms/comScanReplishPack.vue @@ -281,7 +281,7 @@ //外包装库存 let subParentPackitems = balances.list.filter(r => r.packingNumber == packageInfo - .parentNumber) + .parentNumber&&r.locationCode==this.fromLocationCode) //小包装没有库存, diff --git a/src/pages/repleinsh/record/directRepleinshRecord.vue b/src/pages/repleinsh/record/directRepleinshRecord.vue index b8593b4c..0428580d 100644 --- a/src/pages/repleinsh/record/directRepleinshRecord.vue +++ b/src/pages/repleinsh/record/directRepleinshRecord.vue @@ -40,11 +40,12 @@ - + + @@ -52,7 +53,8 @@ import { repleinshRecordSubmit, validateItemAndLocation, - getPutawayRecommendLocation + getPutawayRecommendLocation, + getBalanceByFilter } from '@/api/request2.js'; import { @@ -92,6 +94,7 @@ import winScanLocation from "@/mycomponents/scan/winScanLocation.vue" import winScanPackAndLocation from "@/mycomponents/scan/winScanPackAndLocation.vue" import recordComDetailCard from '@/mycomponents/record/recordComDetailCard.vue' + import balanceSelect from '@/mycomponents/balance/balanceSelect.vue' export default { components: { @@ -101,7 +104,8 @@ comBlankView, winScanLocation, winScanPackAndLocation, - recordComDetailCard + recordComDetailCard, + balanceSelect }, data() { return { @@ -118,7 +122,8 @@ recommendLocationList: [], //推荐库位列表 fromWarehouseCode: '', //来源仓库 businessTypeCode: "Repleinment", - toLocationCode:"" + toLocationCode:"", + resultData:{} }; }, onLoad(option) { @@ -148,7 +153,141 @@ mounted() {}, methods: { + getBalance(label, packageInfo, callback) { + var filters = [] + + if (packageInfo.parentNumber) { + var packingNumber = packageInfo.parentNumber + "," + label.packingNumber; + filters.push({ + column: "packingNumber", + action: "in", + value: packingNumber + }) + } else { + filters.push({ + column: "packingNumber", + action: "==", + value: label.packingNumber + }) + } + + filters.push({ + column: "itemCode", + action: "==", + value: label.itemCode + }) + filters.push({ + column: "batch", + action: "==", + value: label.batch + }) + + if (this.fromInventoryStatuses != null && this.fromInventoryStatuses != "") { + filters.push({ + column: "inventoryStatus", + action: "in", + value: this.fromInventoryStatuses + }) + } + + var params = { + filters: filters, + pageNo: 1, + pageSize: 100, + } + getBalanceByFilter(params).then(res => { + callback(res.data) + }).catch(err => { + this.showErrorMessage(err.message); + }) + }, getScanResult(result) { + this.resultData=result; + let packageInfo = result.package; + this.getBalance(result.label, packageInfo, balances =>{ + + //扫描的是外包装 + let s = ''; + if (!result.package.parentNumber) { + if (balances.list.length == 0) { + this.showErrorMessage('未查找到该包装的库存信息,请重新扫描') + } else { + let newBalances = balances.list.filter(b => b.locationCode == this + .fromLocationCode); + if (newBalances.length == 0) { + this.showErrorMessage('未查找到该包装的库存信息,请重新扫描') + } else if (newBalances.length == 1) { + let balance = newBalances[0]; + result.balance=balance; + this.afterGetBalance(result); + } else { + this.showBalanceSelect(newBalances); + } + } + } else { + //扫描的是小包装 + if (balances.list.length == 0) { + this.showErrorMessage('未查找到该包装的库存信息,请重新扫描') + } else { + //小包装库存 + let subPackitems = balances.list.filter(r => r.packingNumber == packageInfo + .number) + //外包装库存 + let subParentPackitems = balances.list.filter(r => r.packingNumber == + packageInfo + .parentNumber&&r.locationCode==this.fromLocationCode) + + + //小包装没有库存, + if (subPackitems.length == 0) { + //外包装有库存,出库后剩余库存未转换为出库包装规格 + + if (subParentPackitems.length > 0) { + if(subParentPackitems.length==1){ + let balance = subParentPackitems[0]; + balance.qty=packageInfo.qty; + result.balance =balance; + this.afterGetBalance(result); + }else { + this.showBalanceSelect(subParentPackitems); + } + + } else { + this.showErrorMessage('按外包装【' + packageInfo.parentNumber + '】和子包装【' + + packageInfo.number + '】都未查找到库存余额') + } + } else { + var locationCode = this.fromLocationCode + if(balances.list==1){ + locationCode=balances.list[0].locationCode + }else { + var manyBlances = balances.list.filter(r=>r.locationCode!=this.fromLocationCode) + if(manyBlances.length>0){ + locationCode = manyBlances[0].locationCode; + } + } + this.showErrorMessage('该包装【' + packageInfo.number + '】在库位【' + + locationCode + + '】已经有库存余额,请重新扫描') + } + + + } + } + + }) + + }, + + showBalanceSelect(items) { + this.$refs.balanceSelect.openPopup(items); + }, + + selectBalanceItem(balance) { + this.afterGetBalance(this.resultData, balance); + }, + + afterGetBalance(result){ let balance = result.balance; let label = result.label; let pack = result.package; @@ -197,7 +336,6 @@ } } } - }, showErrorMessage(message) {