Browse Source

采购收货扫描数据逻辑验证

hella_vue3
lijuncheng 8 months ago
parent
commit
fe91a3f283
  1. 49
      src/common/detail.js
  2. 2
      src/mycomponents/item/itemCompareQty.vue
  3. 2
      src/mycomponents/package/packageList.vue
  4. 2
      src/mycomponents/scan/winScanPack.vue
  5. 61
      src/pages/purchaseReceipt/job/receiptDetail.vue
  6. 6
      src/static/config.js

49
src/common/detail.js

@ -5,7 +5,10 @@ import {
import { import {
Decimal Decimal
} from 'decimal.js'; //引入 } from 'decimal.js'; //引入
export function getDataSource(dataList) {
export function getTreeDataSource(dataList) {
let items = []; let items = [];
let parentList = dataList.filter(r => r.parentPackingNumber == null || r let parentList = dataList.filter(r => r.parentPackingNumber == null || r
@ -31,14 +34,35 @@ export function getDataSource(dataList) {
items.forEach(r => items.forEach(r =>
r.subList.forEach(s => { r.subList.forEach(s => {
s.packList = childList.filter(c => c.parentPackingNumber == s.packingNumber) s.packList = childList.filter(c => c.parentPackingNumber == s.packingNumber)
s.packList.forEach(pac=>{
pac.scaned=false;
})
}) })
) )
} }
return items; return items;
} }
export function getDataSource(subList) {
let items = [];
subList.forEach(detail => {
var item = items.find(r =>
r.itemCode == detail.itemCode)
if (item == undefined) {
item = createItemInfo(detail);
let newDetail = createDetailInfo(detail); //
item.subList.push(newDetail);
items.push(item)
} else {
item.qty = calc.add(item.qty, detail.qty)
let newDetail = createDetailInfo(detail); //
item.subList.push(newDetail);
}
})
return items;
}
export function createItemInfo(detail) { export function createItemInfo(detail) {
let item = { let item = {
itemCode: detail.itemCode, itemCode: detail.itemCode,
@ -88,6 +112,27 @@ export function calcHandleQty(detailSource) {
} }
} }
export function calcTreeHandleQty(detailSource) {
for (let item of detailSource) {
item.handleQty = new Decimal(0).toNumber();
for (let detail of item.subList) {
if (detail != undefined && detail.scaned) {
detail.handleQty = new Decimal(0).toNumber();
for (let pack of detail.packList){
if(pack!=undefined&&pack.scaned){
detail.handleQty = calc.add(detail.handleQty, pack.handleQty);
}
}
item.handleQty = calc.add(item.handleQty, detail.handleQty);
}
}
}
}
export function getScanCount(subList) { export function getScanCount(subList) {
let items = subList.filter(r => { let items = subList.filter(r => {

2
src/mycomponents/item/itemCompareQty.vue

@ -4,7 +4,7 @@
<item :dataContent="dataContent"></item> <item :dataContent="dataContent"></item>
</view> </view>
<view style="word-break: break-all;width: 50%;display: flex;justify-content:flex-end;margin-right: 10rpx;"> <view style="word-break: break-all;width: 50%;display: flex;justify-content:flex-end;margin-right: 10rpx;">
<recommend-qty v-if="handleQty==0" :dataContent="dataContent" :isShowStatus="false" :isShowStdPack ="isShowStdPack"></recommend-qty> <recommend-qty v-if="handleQty==0" :dataContent="dataContent" :isShowStatus="false" :isShowStdPack ="true"></recommend-qty>
<compare-qty v-else :dataContent="dataContent" :recommendQty="Number(dataContent.qty)" <compare-qty v-else :dataContent="dataContent" :recommendQty="Number(dataContent.qty)"
:handleQty="Number(handleQty)" :isShowStatus="false" :handleQty="Number(handleQty)" :isShowStatus="false"
:isShowPackUnit ="isShowPackUnit"> :isShowPackUnit ="isShowPackUnit">

2
src/mycomponents/package/packageList.vue

@ -20,7 +20,7 @@
import config from '@/static/config.js' import config from '@/static/config.js'
import packageCard from '@/mycomponents/package/packageCard.vue' import packageCard from '@/mycomponents/package/packageCard.vue'
export default { export default {
emits: ["refreshUI"], emits: ["collapseChange"],
components: { components: {
packageCard packageCard
}, },

2
src/mycomponents/scan/winScanPack.vue

@ -58,7 +58,7 @@
openScanPopup() { openScanPopup() {
setTimeout(res => { setTimeout(res => {
this.$refs.popup.open('bottom') this.$refs.popup.open('bottom')
}, 500) }, 200)
}, },
closeScanPopup() { closeScanPopup() {

61
src/pages/purchaseReceipt/job/receiptDetail.vue

@ -79,10 +79,11 @@
} from '@/common/balance.js'; } from '@/common/balance.js';
import { import {
getDataSource, getTreeDataSource,
createRecordInfo, createRecordInfo,
calcHandleQty, calcHandleQty,
getScanCount getScanCount,
calcTreeHandleQty
} from '@/common/detail.js'; } from '@/common/detail.js';
@ -200,10 +201,9 @@
that.toLocationTypeList = getDirectoryItemArray(that.jobContent.toLocationTypes); that.toLocationTypeList = getDirectoryItemArray(that.jobContent.toLocationTypes);
// that.jobContent.toLocationTypeList = that.toLocationTypeList; // that.jobContent.toLocationTypeList = that.toLocationTypeList;
that.subList = res.data.subList; that.subList = res.data.subList;
that.subList[0].containerNumber = "CN-00000001";
that.jobStatus = res.data.status that.jobStatus = res.data.status
that.jobToLocationCode = that.subList[0].toLocationCode that.jobToLocationCode = that.subList[0].toLocationCode
that.detailSource = getDataSource( that.subList) that.detailSource = getTreeDataSource(that.subList)
console.log(JSON.stringify(this.detailSource)) console.log(JSON.stringify(this.detailSource))
} else { } else {
that.showMessage('列表数据为0'); that.showMessage('列表数据为0');
@ -219,7 +219,6 @@
getScanResult(result) { getScanResult(result) {
try { try {
var itemCode = result.label.itemCode; var itemCode = result.label.itemCode;
var detail = this.detailSource.find(r => r.itemCode == itemCode); var detail = this.detailSource.find(r => r.itemCode == itemCode);
if (detail == undefined) { if (detail == undefined) {
@ -254,12 +253,51 @@
if (detail == undefined) { if (detail == undefined) {
this.showMessage("物料号【" + itemCode + "】不在列表中") this.showMessage("物料号【" + itemCode + "】不在列表中")
} else { } else {
//
var itemDetail = detail.subList.find(r => r.packingNumber == packingNumber && r.batch == var itemDetail = detail.subList.find(r => r.packingNumber == packingNumber && r.batch ==
batch); batch);
if (itemDetail == undefined) { if (itemDetail == undefined) {
this.showMessage("箱码【" + packingNumber + "】、批次【" + batch + "】不在列表中") var isExit;
for (let subItem of detail.subList) {
var item;
for (let pack of subItem.packList) {
if (pack.packingNumber == packingNumber &&
pack.batch == batch) {
item = pack;
isExit = pack;
break;
}
}
if (item != undefined) {
subItem.scaned = true
subItem.handleQty = 0;
item=undefined
}
}
if (isExit == undefined) {
this.showMessage("箱码【" + packingNumber + "】、批次【" + batch + "】不在列表中")
} else {
if (isExit.scaned) {
this.showMessage("箱码【" + packingNumber + "】已经扫描")
} else {
isExit.scaned = true
isExit.handleQty = Number(result.label.qty);
isExit.toLocationCode = this.toLocationCode;
isExit.labelQty = Number(result.label.qty);
}
}
calcTreeHandleQty(this.detailSource);
this.$forceUpdate()
} else { } else {
if (itemDetail.scaned) { var scanedLength =0;
itemDetail.packList.forEach(res=>{
if(res.scaned){
scanedLength++;
}
})
if (itemDetail.scaned&&scanedLength==itemDetail.packList.length) {
this.showMessage("箱码【" + packingNumber + "】已经扫描") this.showMessage("箱码【" + packingNumber + "】已经扫描")
} else { } else {
itemDetail.scaned = true; itemDetail.scaned = true;
@ -267,7 +305,13 @@
itemDetail.handleQty = Number(result.label.qty); itemDetail.handleQty = Number(result.label.qty);
itemDetail.toLocationCode = this.toLocationCode; itemDetail.toLocationCode = this.toLocationCode;
itemDetail.labelQty = Number(result.label.qty); itemDetail.labelQty = Number(result.label.qty);
calcHandleQty(this.detailSource); itemDetail.packList.forEach(pac => {
pac.scaned = true
pac.handleQty = Number(pac.qty);
pac.toLocationCode = this.toLocationCode;
})
calcTreeHandleQty(this.detailSource);
this.continueScan() this.continueScan()
this.$forceUpdate() this.$forceUpdate()
} }
@ -280,7 +324,6 @@
} }
}, },
// //
continueScan() { continueScan() {
this.scanCount = getScanCount(this.subList); this.scanCount = getScanCount(this.subList);

6
src/static/config.js

@ -1,7 +1,7 @@
// let request_url = "http://dev.ccwin-in.com:25300/api/admin-api" let request_url = "http://dev.ccwin-in.com:25300/api/admin-api"
let request_url = "http://192.168.0.211:12080/admin-api" // let request_url = "http://192.168.0.211:12080/admin-api"
let isDevelopment = false let isDevelopment = true
export default { export default {
request_url, request_url,

Loading…
Cancel
Save