import { getManagementPrecision, getPrecisionStrategy, getBalanceByFilter } from '@/api/request2.js'; /** * 获取管理精度查询策略参数 * @param {*} * */ export function getPrecisionStrategyParams(dataSource) { } /** * 获取管理精度查询策略参数 * @param {*} * */ export function getPrecisionStrategyParamsByLocation(detailSource,toLocationCode) { var itemList = [] detailSource.forEach(item => { item.subList.forEach(detail => { if (detail.scaned) { detail.toLocationCode = toLocationCode; var filterResult = itemList.filter(res => { if (res.itemCode == item.itemCode && res.locationCode == detail.toLocationCode) { return res } }) //去掉重复元素 if (filterResult.length == 0) { var result = { itemCode: item.itemCode, locationCode: detail.toLocationCode } itemList.push(result) } } }) }) return itemList; } /** * "itemCode": [], "locationCode":"INSPECT" 管理精度策略 * @param {*} * */ export function getPrecisionStrategyList(itemList, callback) { // let jsonParem = JSON.stringify(param) let result = { list: [], success: true, message: '' }; getPrecisionStrategy(itemList).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); }) } /** * "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) { 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 => { res.managementPrecision = managementPrecision; callback(res); }); break; case 'BY_BATCH': byBatch(label, locationCode, fromInventoryStatuses, res => { res.managementPrecision = managementPrecision; callback(res); }); break; case 'BY_QUANTITY': byQuantity(label, locationCode, fromInventoryStatuses, res => { res.managementPrecision = managementPrecision; callback(res); }); break; case 'BY_UNIQUEID': byUniqueId(label, fromInventoryStatuses, 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, fromInventoryStatuses, callback) { let result = { success: true, message: '', data: {} }; var filters = [] filters.push({ column: "packingNumber", action: "==", value: label.packingNumber }) filters.push({ column: "itemCode", action: "==", value: label.itemCode }) filters.push({ column: "batch", action: "==", value: label.batch }) filters.push({ column: "locationCode", action: "==", value: locationCode }) if (fromInventoryStatuses != null && fromInventoryStatuses != "") { filters.push({ column: "inventoryStatus", action: "in", value: fromInventoryStatuses }) } 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) { var filters = [] filters.push({ column: "itemCode", action: "==", value: label.itemCode }) filters.push({ column: "batch", action: "==", value: label.batch }) filters.push({ column: "locationCode", action: "==", value: locationCode }) if (fromInventoryStatuses != null && fromInventoryStatuses != "") { filters.push({ column: "inventoryStatus", action: "in", value: fromInventoryStatuses }) } 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) { let result = { success: true, message: '', data: {} }; var filters = [] filters.push({ column: "itemCode", action: "==", value: label.itemCode }) filters.push({ column: "locationCode", action: "==", value: locationCode }) if (fromInventoryStatuses != null && fromInventoryStatuses != "") { filters.push({ column: "inventoryStatus", action: "in", value: fromInventoryStatuses }) } 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) { let param = { packingNumber: label.packingNumber }; let result = { success: true, message: '', data: {} }; var filters = [] filters.push({ column: "packingNumber", action: "==", value: label.packingNumber }) if (fromInventoryStatuses != null && fromInventoryStatuses != "") { filters.push({ column: "inventoryStatus", action: "in", value: fromInventoryStatuses }) } 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", 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) }) }