You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.9 KiB

import {
calc
} from '@/common/calc'
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;
}
1 year ago
export function createItemInfo(detail) {
let item = {
itemCode: detail.itemCode,
itemName: detail.itemName,
stdPackQty: Number(detail.stdPackQty) || undefined,
stdPackUnit: detail.stdPackUnit,
qty: Number(detail.qty),
handleQty: 0,
uom: detail.uom,
subList: []
}
return item;
1 year ago
}
export function createDetailInfo(data) {
data.scaned = false;
// data.record = {};
let detail = data;
return detail;
}
1 year ago
//根据明细创建记录
export function createRecordInfo(detail, balance) {
var record = {}
// let record = JSON.parse(JSON.stringify(detail));
//克隆对象,深度克隆,防止双向绑定同一个变量
Object.assign(record, detail)
detail.scaned = true;
detail.balance = balance;
detail.recommendInventoryStatus = detail.inventoryStatus;
detail.inventoryStatus = balance.inventoryStatus;
record.qty = Number(balance.qty);
return record;
}
1 year ago
//计算实际数量
export function calcHandleQty(detailSource) {
for (let item of detailSource) {
item.handleQty = 0;
for (let detail of item.subList) {
if (detail != undefined && detail.scaned) {
item.handleQty = calc.add(item.handleQty, detail.handleQty)
}
1 year ago
}
}
}
export function getScanCount(subList) {
let items = subList.filter(r => {
if (r.scaned) {
return r;
}
})
let scanCount = items != null ? items.length : 0;
return scanCount;
}