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.

78 lines
1.8 KiB

import { calc } from '@/common/calc'
1 year ago
export function getDataSource(subList) {
1 year ago
let items = [];
1 year ago
subList.forEach(detail => {
1 year ago
var item = items.find(r =>
r.itemCode == detail.itemCode)
if (item == undefined) {
item = createItemInfo(detail);
let newDetail = createDetailInfo(detail); //
1 year ago
item.subList.push(newDetail);
1 year ago
items.push(item)
} else {
item.qty = calc.add(item.qty,detail.qty)
1 year ago
let newDetail = createDetailInfo(detail); //
1 year ago
item.subList.push(newDetail);
1 year ago
}
})
return items;
}
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,
1 year ago
subList: []
1 year ago
}
return item;
}
export function createDetailInfo(data) {
data.scaned = false;
// data.record = {};
let detail = data;
return detail;
}
//根据明细创建记录
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;
}
//计算实际数量
export function calcHandleQty(detailSource) {
for (let item of detailSource) {
item.handleQty = 0;
1 year ago
for (let detail of item.subList) {
1 year ago
if (detail != undefined && detail.scaned) {
item.handleQty = calc.add(item.handleQty,detail.handleQty)
1 year ago
}
}
}
}
1 year ago
export function getScanCount(subList) {
let items = subList.filter(r => {
1 year ago
if (r.scaned) {
return r;
}
})
let scanCount = items != null ? items.length : 0;
return scanCount;
}