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.
110 lines
2.8 KiB
110 lines
2.8 KiB
import {
|
|
calc
|
|
} from '@/common/calc.js';
|
|
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,
|
|
productionLineCode: detail.productionLineCode,
|
|
workStationCode: detail.workStationCode,
|
|
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 = calc.add(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.batch);
|
|
if (batch == undefined) {
|
|
let batch = createBatchInfo(detail);
|
|
location.Batchs.push(batch);
|
|
} else {
|
|
if (detail.packingNumber != "" && detail.packingNumber != null) {
|
|
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 = {
|
|
detail: detail,
|
|
batch: detail.batch,
|
|
packingNumber: detail.packingNumber,
|
|
qty: detail.qty,
|
|
uom: detail.uom,
|
|
handleQty: 0,
|
|
Recommends: [],
|
|
Records: [],
|
|
}
|
|
|
|
//推荐到了箱码和批次
|
|
if (detail.packingNumber != "" && detail.packingNumber != null) {
|
|
batch.Recommends.push(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;
|
|
}
|
|
|