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.

108 lines
2.7 KiB

export function getDataSource(list, subList) {
1 year ago
for (var i = 0; i < subList.length; i++) {
let detail = subList[i];
1 year ago
var location = list.find(r =>
r.toLocationCode == detail.toLocationCode)
if (location == undefined) {
location = {
toLocationCode: detail.toLocationCode,
productionLineCode: detail.productionLineCode,
workStationCode: detail.workStationCode,
1 year ago
Items: []
}
list.push(location);
}
createDetailInfo(location, detail);
}
return list;
}
1 year ago
//树形结构:需求库位 -> 零件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);
1 year ago
if (location == undefined) {
location = createLocationInfo(detail);
item.Locations.push(location);
} else {
//在库位下查找批次
let batch = location.Batchs.find(r => r.batch == detail.batch);
1 year ago
if (batch == undefined) {
let batch = createBatchInfo(detail);
location.Batchs.push(batch);
} else {
if (detail.packingNumber != "" && detail.packingNumber != null) {
batch.Recommends.push(detail);
}
1 year ago
}
}
}
}
export function createItemInfo(detail) {
let item = {
itemCode: detail.itemCode,
itemName: detail.itemName,
productionLineCode: detail.productionLineCode,
workStationCode: detail.workStationCode,
1 year ago
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,
1 year ago
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 = {
detail: detail,
1 year ago
batch: detail.batch,
packingNumber: detail.packingNumber,
qty: detail.qty,
uom: detail.uom,
handleQty: 0,
Recommends: [],
Records: [],
1 year ago
}
//推荐到了箱码和批次
if (detail.packingNumber != "" && detail.packingNumber != null) {
batch.Recommends.push(detail);
1 year ago
}
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;
}