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.

337 lines
6.7 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, callback) {
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, res => {
res.managementPrecision = managementPrecision;
callback(res);
});
break;
case 'BY_BATCH':
byBatch(label, locationCode, res => {
res.managementPrecision = managementPrecision;
callback(res);
});
break;
case 'BY_QUANTITY':
byQuantity(label, locationCode, res => {
res.managementPrecision = managementPrecision;
callback(res);
});
break;
case 'BY_UNIQUEID':
byUniqueId(label, res => {
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, callback) {
let result = {
success: true,
message: '',
data: {}
};
var filters = []
filters.push({
column: "packing_number",
action: "==",
value: label.packingNumber
})
filters.push({
column: "item_code",
action: "==",
value: label.itemCode
})
filters.push({
column: "batch",
action: "==",
value: label.batch
})
filters.push({
column: "location_code",
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.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, callback) {
var filters = []
filters.push({
column: "item_code",
action: "==",
value: label.itemCode
})
filters.push({
column: "batch",
action: "==",
value: label.batch
})
filters.push({
column: "location_code",
action: "==",
value: locationCode
})
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, callback) {
let result = {
success: true,
message: '',
data: {}
};
var filters = []
filters.push({
column: "item_code",
action: "==",
value: label.itemCode
})
filters.push({
column: "location_code",
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.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, callback) {
let param = {
packingNumber: label.packingNumber
};
let result = {
success: true,
message: '',
data: {}
};
var filters = []
filters.push({
column: "packing_number",
action: "==",
value: label.packingNumber
})
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: "location_code",
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)
})
}