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.
 
 
 
 

103 lines
2.5 KiB

export function getDataSource(list,subList) {
for (var i = 0; i < subList.length; i++) {
let detail = subList[i];
var location = list.find(r =>
r.toLocationCode == detail.toLocationCode)
if (location == undefined) {
location = {
toLocationCode: detail.toLocationCode,
Items: []
}
list.push(location);
}
createDetailInfo(location, detail);
}
return list;
}
//树形结构:需求库位 -> 零件Items -> 库位 Locations-> 批次Batchs -> 记录Records
export function createDetailInfo(location, detail) {
var item = location.Items.find(r =>
r.itemCode == detail.itemCode)
if (item == undefined) {
item = createItemInfo(detail);
location.Items.push(item)
} else {
item.qty += detail.qty
//在零件下查找库位
let location = item.Locations.find(r => r.fromLocationCode == detail.fromLocationCode);
if (location == undefined) {
location = createLocationInfo(detail);
item.Locations.push(location);
} else {
//在库位下查找批次
let batch = location.Batchs.find(r => r.batch == detail.Bacth);
if (batch == undefined) {
let batch = createBatchInfo(detail);
location.Batchs.push(batch);
} else {
batch.recommends.push(detail);
}
}
}
}
export function createItemInfo(detail) {
let item = {
itemCode: detail.itemCode,
itemName: detail.itemName,
productionLineCode:detail.productionLineCode,
workStationCode:detail.workStationCode,
stdPackQty: detail.stdPackQty,
stdPackUnit: detail.stdPackUnit,
qty: detail.qty,
uom: detail.uom,
handleQty: 0,
Locations: []
}
let location = createLocationInfo(detail);
item.Locations.push(location);
return item;
}
export function createLocationInfo(detail) {
let location = {
fromLocationCode: detail.fromLocationCode,
qty: detail.qty,
uom: detail.uom,
handleQty: 0,
Batchs: []
}
let batch = createBatchInfo(detail);
location.Batchs.push(batch);
return location;
}
export function createBatchInfo(detail) {
let batch = {
batch: detail.batch,
packingNumber: detail.packingNumber,
qty: detail.qty,
uom: detail.uom,
handleQty: 0,
// Recommends: [detail],
// Records: []
}
//推荐到了箱码和批次
if (detail.packingNumber != '') {
batch.Recommends = [detail];
}
return batch;
}
export function createRecordInfo(detail) {
var record = {}
detail.scaned = true;
// let record = JSON.parse(JSON.stringify(detail));
//克隆对象,深度克隆,防止双向绑定同一个变量
Object.assign(record, detail)
record.toLocationCode = this.toLocationCode;
return record;
}