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.

368 lines
7.5 KiB

1 year ago
import {
getManagementPrecision,
getBalanceByFilter
} from '@/api/request2.js';
/**
* "itemCode": [],
"locationCode":"INSPECT"
管理精度策略
* @param {*}
*
*/
export function getManagementPrecisions(itemCodes, locationCode, callback) {
// let jsonParem = JSON.stringify(param)
let result = {
list: [],
success: true,
message: ''
};
var params = {
itemCodes: itemCodes,
locationCode: locationCode
}
getManagementPrecision(params).then(res => {
if (res.data == null) {
result.success = false
result.message = '未查询到管理精度信息'
} else {
result.list = res.data;
}
callback(result);
}).catch(error => {
result.success = false;
result.message = error;
callback(result);
})
}
export function getBalanceByManagementPrecision(label, locationCode, fromInventoryStatuses, callback) {
1 year ago
let result = {
list: [],
success: true,
message: ''
};
let params = {
itemCodes: [label.itemCode],
locationCode: locationCode
};
// let jsonParem = JSON.stringify(param)
getManagementPrecision(params).then(res => {
let managementPrecision = res.data[0].ManagementPrecision;
switch (managementPrecision) {
case 'BY_PACKAGING':
byPacking(label, locationCode, fromInventoryStatuses, res => {
1 year ago
res.managementPrecision = managementPrecision;
callback(res);
});
break;
case 'BY_BATCH':
byBatch(label, locationCode, fromInventoryStatuses, res => {
1 year ago
res.managementPrecision = managementPrecision;
callback(res);
});
break;
case 'BY_QUANTITY':
byQuantity(label, locationCode, fromInventoryStatuses, res => {
1 year ago
res.managementPrecision = managementPrecision;
callback(res);
});
break;
case 'BY_UNIQUEID':
byUniqueId(label, fromInventoryStatuses, res => {
1 year ago
res.managementPrecision = managementPrecision;
callback(res);
});
break;
}
}).catch(error => {
let result = {
success: false,
message: error
};
callback(result);
})
}
/**
* @param {Object} label
* @param {Object} locationCode
* @param {Object} callback
*/
export function byPacking(label, locationCode, fromInventoryStatuses, callback) {
1 year ago
let result = {
success: true,
message: '',
data: {}
};
var filters = []
filters.push({
column: "packingNumber",
1 year ago
action: "==",
value: label.packingNumber
})
filters.push({
column: "itemCode",
1 year ago
action: "==",
value: label.itemCode
})
filters.push({
column: "batch",
action: "==",
value: label.batch
})
filters.push({
column: "locationCode",
1 year ago
action: "==",
value: locationCode
})
if (fromInventoryStatuses != null && fromInventoryStatuses != "") {
filters.push({
column: "inventoryStatus",
action: "in",
value: fromInventoryStatuses
})
}
1 year ago
var params = {
filters: filters,
pageNo: 1,
pageSize: 100,
}
getBalanceByFilter(params).then(res => {
if (res.data == null) {
result.success = false;
result.message =
"按包装管理查询、未查询到物料号[" + label.itemCode + "]" +
"到箱码[" + label.packingNumber + "]" +
"批次[" + label.batch + "]" +
"库位[" + label.locationCode + "]的信息"
} else {
result.success = true;
result.data = res.data;
}
callback(result)
}).catch(err => {
result.success = false;
result.data = null;
result.message = err;
callback(result)
})
}
/**
* @param {Object} label
* @param {Object} locationCode
* @param {Object} callback
*/
export function byBatch(label, locationCode, fromInventoryStatuses, callback) {
1 year ago
var filters = []
filters.push({
column: "itemCode",
1 year ago
action: "==",
value: label.itemCode
})
filters.push({
column: "batch",
action: "==",
value: label.batch
})
filters.push({
column: "locationCode",
1 year ago
action: "==",
value: locationCode
})
if (fromInventoryStatuses != null && fromInventoryStatuses != "") {
filters.push({
column: "inventoryStatus",
action: "in",
value: fromInventoryStatuses
})
}
1 year ago
var params = {
filters: filters,
pageNo: 1,
pageSize: 100,
}
let result = {
success: true,
message: '',
data: {}
};
getBalanceByFilter(params).then(res => {
if (res.data == null) {
result.success = false;
result.message =
"按批次管理查询、未查询到物料号[" + label.itemCode + "]" +
"批次[" + label.batch + "]" +
"库位[" + label.locationCode + "]的信息"
} else {
result.success = true;
result.data = res.data;
}
callback(result)
}).catch(err => {
result.success = false;
result.data = null;
result.message = err.message;
callback(result)
})
}
/**
* @param {Object} label
* @param {Object} locationCode
* @param {Object} callback
*/
export function byQuantity(label, locationCode, fromInventoryStatuses, callback) {
1 year ago
let result = {
success: true,
message: '',
data: {}
};
var filters = []
filters.push({
column: "itemCode",
1 year ago
action: "==",
value: label.itemCode
})
filters.push({
column: "locationCode",
1 year ago
action: "==",
value: locationCode
})
if (fromInventoryStatuses != null && fromInventoryStatuses != "") {
filters.push({
column: "inventoryStatus",
action: "in",
value: fromInventoryStatuses
})
}
1 year ago
var params = {
filters: filters,
pageNo: 1,
pageSize: 100,
}
getBalanceByFilter(params).then(res => {
if (res.data == null) {
result.success = false;
result.message =
"按数量管理查询、未查询到物料号[" + label.itemCode + "]" +
"库位[" + label.locationCode + "]的信息"
} else {
result.success = true;
result.data = res.data;
}
callback(result)
}).catch(err => {
result.success = false;
result.data = null;
result.message = err.message;
callback(result)
})
}
/**
* @param {Object} label
* @param {Object} locationCode
* @param {Object} callback
*/
export function byUniqueId(label, locationCode, fromInventoryStatuses, callback) {
1 year ago
let param = {
packingNumber: label.packingNumber
};
let result = {
success: true,
message: '',
data: {}
};
var filters = []
filters.push({
column: "packingNumber",
1 year ago
action: "==",
value: label.packingNumber
})
if (fromInventoryStatuses != null && fromInventoryStatuses != "") {
filters.push({
column: "inventoryStatus",
action: "in",
value: fromInventoryStatuses
})
}
1 year ago
var params = {
filters: filters,
pageNo: 1,
pageSize: 100,
}
getBalanceByFilter(params).then(res => {
if (res.data == null) {
result.success = false;
result.message =
"按唯一码管理查询、未查询到箱码[" + label.packingNumber + "]" +
"的信息"
} else {
result.success = true;
result.data = res.data;
}
callback(result)
}).catch(err => {
result.success = false;
result.data = null;
result.message = err.message;
callback(result)
})
}
/**
* 查询指定库位下的库存
* @param {*} param
* @param {*} callback
*/
export function balanceByLocation(locationCode, callback) {
let result = {
success: true,
message: '',
data: {}
};
var filters = []
filters.push({
column: "locationCode",
1 year ago
action: "==",
value: locationCode
})
var params = {
filters: filters,
pageNo: 1,
pageSize: 100,
}
getBalanceByFilter(params).then(res => {
if (res.data == null) {
result.success = false;
result.message =
"按唯一码管理查询、未查询到库位[" + label.locationCode + "]" +
"的信息"
} else {
result.success = true;
result.data = res.data;
}
callback(result)
}).catch(err => {
result.success = false;
result.data = null;
result.message = err.message;
callback(result)
})
}