|
|
@ -8,12 +8,12 @@ |
|
|
|
<text class="fr" @click="closeScanPopup()">关闭</text> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="uni-flex uni-row" style="align-items: center; background-color: #fff; margin-left: 20rpx; margin-right: 20rpx; margin-top: 8rpx; border-radius: 8rpx"> |
|
|
|
<view class="uni-center" style="width: 25%"> 来源库位 </view> |
|
|
|
<view class="" style="width: 75%; padding: 8rpx"> |
|
|
|
<uni-combox :candidates="fromLocationList" v-model="fromLocationCode" placeholder="请选择库位" @confirm="fromLocationUpdate"></uni-combox> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<!-- <view class="uni-flex uni-row" style="align-items: center; background-color: #fff; margin-left: 20rpx; margin-right: 20rpx; margin-top: 8rpx; border-radius: 8rpx">--> |
|
|
|
<!-- <view class="uni-center" style="width: 25%"> 来源库位 </view>--> |
|
|
|
<!-- <view class="" style="width: 75%; padding: 8rpx">--> |
|
|
|
<!-- <uni-combox :candidates="fromLocationList" v-model="fromLocationCode" placeholder="请选择库位" @confirm="fromLocationUpdate"></uni-combox>--> |
|
|
|
<!-- </view>--> |
|
|
|
<!-- </view>--> |
|
|
|
|
|
|
|
<view class=""> |
|
|
|
<view class=""> |
|
|
@ -56,13 +56,13 @@ import balanceQtyEdit from '@/mycomponents/qty/balanceQtyEdit.vue' |
|
|
|
import balanceSelect from '@/mycomponents/balance/balanceSelect.vue' |
|
|
|
|
|
|
|
import { getDetailOption, getDetailEditRemoveOption, getDetailGiveupOption } from '@/common/array.js' |
|
|
|
import { getWorkShopLineStation, getBalanceByFilter } from '@/api/request2.js' |
|
|
|
import { getWorkShopLineStation, getBalanceByFilter, getBalanceByParams } from '@/api/request2.js' |
|
|
|
|
|
|
|
import { calc } from '@/common/calc.js' |
|
|
|
import { uniqueArray } from '@/common/basic.js' |
|
|
|
|
|
|
|
import { getBalanceByManagementPrecision } from '@/common/balance.js' |
|
|
|
import { getDirectoryItemArray } from '../../../common/directory.js' |
|
|
|
import { getDirectoryItemArray,getInventoryStatusDesc,getListLocationAreaTypeDesc } from '../../../common/directory.js' |
|
|
|
import { getLabelInfo } from '@/common/label.js' |
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
@ -137,7 +137,7 @@ const initData = () => { |
|
|
|
fromInventoryStatuses.value = jobContent.value.outInventoryStatuses |
|
|
|
toLocation.value = dataContent.value[0] |
|
|
|
toLocationCode.value = dataContent.value[0].toLocationCode |
|
|
|
fromLocationList.value = getFromLocationList() |
|
|
|
// fromLocationList.value = getFromLocationList() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -145,27 +145,27 @@ const showBalanceSelect = (items) => { |
|
|
|
balanceSelectRef.value.openPopup(items) |
|
|
|
} |
|
|
|
|
|
|
|
const getFromLocationList = () => { |
|
|
|
const list = [] |
|
|
|
const location = dataContent.value.find((r) => r.toLocationCode == toLocationCode.value) |
|
|
|
if (location != undefined) { |
|
|
|
location.Items.forEach((item) => { |
|
|
|
item.Locations.forEach((f) => { |
|
|
|
list.push(f.fromLocationCode) |
|
|
|
}) |
|
|
|
}) |
|
|
|
// 去掉重复库位 |
|
|
|
list = uniqueArray(list) |
|
|
|
fromLocationCode.value = list[0] |
|
|
|
return list |
|
|
|
} |
|
|
|
comMessageRef.value.showErrorMessages(`需求库位【${toLocationCode.value}】不存在`, (res) => { |
|
|
|
if (res) { |
|
|
|
scanMsg.value = '' |
|
|
|
getfocus() |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
// const getFromLocationList = () => { |
|
|
|
// let list = [] |
|
|
|
// const location = dataContent.value.find((r) => r.toLocationCode == toLocationCode.value) |
|
|
|
// if (location != undefined) { |
|
|
|
// location.Items.forEach((item) => { |
|
|
|
// item.Locations.forEach((f) => { |
|
|
|
// list.push(f.fromLocationCode) |
|
|
|
// }) |
|
|
|
// }) |
|
|
|
// // 去掉重复库位 |
|
|
|
// list = uniqueArray(list) |
|
|
|
// fromLocationCode.value = list[0] |
|
|
|
// return list |
|
|
|
// } |
|
|
|
// comMessageRef.value.showErrorMessages(`需求库位【${toLocationCode.value}】不存在`, (res) => { |
|
|
|
// if (res) { |
|
|
|
// scanMsg.value = '' |
|
|
|
// getfocus() |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// } |
|
|
|
|
|
|
|
const fromLocationUpdate = (fromlocation) => { |
|
|
|
const location = fromLocationList.value.find((r) => r == fromlocation) |
|
|
@ -174,15 +174,41 @@ const fromLocationUpdate = (fromlocation) => { |
|
|
|
showErrorMessage(`发料库位【${fromlocation}】不存在`) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const onScan = (result)=> { |
|
|
|
try { |
|
|
|
if (fromLocationCode.value == '') { |
|
|
|
showErrorMessage('请选择来源库位', (res) => { |
|
|
|
toLocationCombox.value.onFocus() |
|
|
|
}) |
|
|
|
if (!result.package) { |
|
|
|
this.showErrorMessage('扫描数据错误[' + result.label.code + "]", |
|
|
|
res => { |
|
|
|
getfocus(); |
|
|
|
} |
|
|
|
) |
|
|
|
return; |
|
|
|
} |
|
|
|
if (toLocation.value && result.package.packUnit) { |
|
|
|
let item = toLocation.value.Items.find(r => r.itemCode == result.package.itemCode); |
|
|
|
if (!item) { |
|
|
|
showErrorMessage('扫描物料代码不属于该任务'); |
|
|
|
return |
|
|
|
} |
|
|
|
if (result.package.packUnit !== item.packUnit) { |
|
|
|
comMessageRef.value.showQuestionMessage( |
|
|
|
`扫描物料包装【${result.package.packUnit}】与任务推荐包装规格【${item.packUnit}】不一致.是否要继续发料?`, res => { |
|
|
|
if (res) { |
|
|
|
onScanResult(result) |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
onScanResult(result) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const onScanResult = (result) => { |
|
|
|
try { |
|
|
|
// if (fromLocationCode.value == '') { |
|
|
|
// showErrorMessage('请选择来源库位', (res) => { |
|
|
|
// toLocationCombox.value.onFocus() |
|
|
|
// }) |
|
|
|
// return |
|
|
|
// } |
|
|
|
const packageInfoParams = result.package |
|
|
|
const { itemCode } = result.label |
|
|
|
const packingCode = result.label.packingNumber |
|
|
@ -194,129 +220,168 @@ const onScan = (result) => { |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var params = { |
|
|
|
itemCode: result.package.itemCode, |
|
|
|
batch: result.label.batch, |
|
|
|
packingNumber: result.label.packingNumber, |
|
|
|
parentPackingNumber: result.package.parentNumber, |
|
|
|
inventoryStatus: jobContent.value.outInventoryStatuses.split(','), |
|
|
|
areaType: jobContent.value.fromAreaTypes.split(','), |
|
|
|
bussinessCode: jobContent.value.businessType |
|
|
|
} |
|
|
|
// 查找库存信息 |
|
|
|
uni.showLoading({ |
|
|
|
title: '加载中', |
|
|
|
title: '查询中', |
|
|
|
mask: true |
|
|
|
}) |
|
|
|
|
|
|
|
getBalance(result.label, packageInfoParams, (balances) => { |
|
|
|
packageInfo.value = packageInfoParams |
|
|
|
// 扫描的是外包装 |
|
|
|
const s = '' |
|
|
|
if (!result.package.parentNumber) { |
|
|
|
if (balances.list.length == 0) { |
|
|
|
showErrorMessage('未查找到该包装的库存信息,请重新扫描') |
|
|
|
} else { |
|
|
|
const newBalances = balances.list.filter((b) => b.locationCode == that.fromLocationCode) |
|
|
|
if (newBalances.length == 0) { |
|
|
|
showErrorMessage('未查找到该包装的库存信息,请重新扫描') |
|
|
|
} else if (newBalances.length == 1) { |
|
|
|
const balance1 = newBalances[0] |
|
|
|
afterGetBalance(result.label, balance1, packageInfoParams) |
|
|
|
} else { |
|
|
|
showBalanceSelect(newBalances) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 扫描的是小包装 |
|
|
|
if (balances.list.length == 0) { |
|
|
|
showErrorMessage('未查找到该包装的库存信息,请重新扫描') |
|
|
|
} else { |
|
|
|
// 小包装库存 |
|
|
|
const subPackitems = balances.list.filter((r) => r.packingNumber == packageInfoParams.number) |
|
|
|
// 外包装库存 |
|
|
|
const subParentPackitems = balances.list.filter((r) => r.packingNumber == packageInfoParams.parentNumber && r.locationCode == fromLocationCode.value) |
|
|
|
|
|
|
|
// 小包装没有库存, |
|
|
|
if (subPackitems.length == 0) { |
|
|
|
// 外包装有库存,出库后剩余库存未转换为出库包装规格 |
|
|
|
|
|
|
|
if (subParentPackitems.length > 0) { |
|
|
|
if (subParentPackitems.length == 1) { |
|
|
|
const balance = subParentPackitems[0] |
|
|
|
balance.qty = packageInfoParams.qty |
|
|
|
afterGetBalance(result.label, balance, packageInfoParams) |
|
|
|
getBalanceByParams(params).then(res => { |
|
|
|
if (res.data.length == 0) { |
|
|
|
let status = getInventoryStatusDesc(params.inventoryStatus) |
|
|
|
let areaType = getListLocationAreaTypeDesc(params.areaType) |
|
|
|
let hint = |
|
|
|
"按物料号 [" + params.itemCode + "] <br>" + |
|
|
|
"包装号 [" + params.packingNumber + "] <br>" + |
|
|
|
"批次 [" + params.batch + "] <br>" + |
|
|
|
"状态 [" + status + "] <br>" + |
|
|
|
"库区 [" + areaType + "] <br>" + |
|
|
|
"未查找到库存余额" |
|
|
|
showErrorMessage(hint) |
|
|
|
} else if (res.data.length == 1) { |
|
|
|
result.balance = res.data[0] |
|
|
|
|
|
|
|
if (result.label.packingNumber != result.balance.packingNumber) { |
|
|
|
result.balance.handleQty = Number(result.label.qty) |
|
|
|
} else { |
|
|
|
showBalanceSelect(subParentPackitems) |
|
|
|
result.balance.handleQty = Number(result.balance.qty) |
|
|
|
} |
|
|
|
afterGetBalance(result.label, result.balance, result.package); |
|
|
|
} else { |
|
|
|
showErrorMessage(`按外包装【${packageInfoParams.parentNumber}】和子包装【${packageInfoParams.number}】都未查找到库存余额`) |
|
|
|
} |
|
|
|
} else { |
|
|
|
let locationCode = fromLocationCode.value |
|
|
|
if (balances.list == 1) { |
|
|
|
locationCode = balances.list[0].locationCode |
|
|
|
} else { |
|
|
|
const manyBlances = balances.list.filter((r) => r.locationCode != fromLocationCode.value) |
|
|
|
if (manyBlances.length > 0) { |
|
|
|
locationCode = manyBlances[0].locationCode |
|
|
|
} |
|
|
|
} |
|
|
|
showErrorMessage(`该包装【${packageInfoParams.number}】在库位【${locationCode}】已经有库存余额,请重新扫描`) |
|
|
|
} |
|
|
|
} |
|
|
|
//多条记录 |
|
|
|
balanceSelectRef.value.openPopup(res.data); |
|
|
|
} |
|
|
|
uni.hideLoading() |
|
|
|
}) |
|
|
|
}).catch(error => { |
|
|
|
uni.hideLoading() |
|
|
|
showErrorMessage(error) |
|
|
|
}) |
|
|
|
// getBalance(result.label, packageInfoParams, (balances) => { |
|
|
|
// packageInfo.value = packageInfoParams |
|
|
|
// // 扫描的是外包装 |
|
|
|
// const s = '' |
|
|
|
// if (!result.package.parentNumber) { |
|
|
|
// if (balances.list.length == 0) { |
|
|
|
// showErrorMessage('未查找到该包装的库存信息,请重新扫描') |
|
|
|
// } else { |
|
|
|
// const newBalances = balances.list.filter((b) => b.locationCode == that.fromLocationCode) |
|
|
|
// if (newBalances.length == 0) { |
|
|
|
// showErrorMessage('未查找到该包装的库存信息,请重新扫描') |
|
|
|
// } else if (newBalances.length == 1) { |
|
|
|
// const balance1 = newBalances[0] |
|
|
|
// afterGetBalance(result.label, balance1, packageInfoParams) |
|
|
|
// } else { |
|
|
|
// showBalanceSelect(newBalances) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// // 扫描的是小包装 |
|
|
|
// if (balances.list.length == 0) { |
|
|
|
// showErrorMessage('未查找到该包装的库存信息,请重新扫描') |
|
|
|
// } else { |
|
|
|
// // 小包装库存 |
|
|
|
// const subPackitems = balances.list.filter((r) => r.packingNumber == packageInfoParams.number) |
|
|
|
// // 外包装库存 |
|
|
|
// const subParentPackitems = balances.list.filter((r) => r.packingNumber == packageInfoParams.parentNumber && r.locationCode == fromLocationCode.value) |
|
|
|
// |
|
|
|
// // 小包装没有库存, |
|
|
|
// if (subPackitems.length == 0) { |
|
|
|
// // 外包装有库存,出库后剩余库存未转换为出库包装规格 |
|
|
|
// |
|
|
|
// if (subParentPackitems.length > 0) { |
|
|
|
// if (subParentPackitems.length == 1) { |
|
|
|
// const balance = subParentPackitems[0] |
|
|
|
// balance.qty = packageInfoParams.qty |
|
|
|
// afterGetBalance(result.label, balance, packageInfoParams) |
|
|
|
// } else { |
|
|
|
// showBalanceSelect(subParentPackitems) |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// showErrorMessage(`按外包装【${packageInfoParams.parentNumber}】和子包装【${packageInfoParams.number}】都未查找到库存余额`) |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// let locationCode = fromLocationCode.value |
|
|
|
// if (balances.list == 1) { |
|
|
|
// locationCode = balances.list[0].locationCode |
|
|
|
// } else { |
|
|
|
// const manyBlances = balances.list.filter((r) => r.locationCode != fromLocationCode.value) |
|
|
|
// if (manyBlances.length > 0) { |
|
|
|
// locationCode = manyBlances[0].locationCode |
|
|
|
// } |
|
|
|
// } |
|
|
|
// showErrorMessage(`该包装【${packageInfoParams.number}】在库位【${locationCode}】已经有库存余额,请重新扫描`) |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// uni.hideLoading() |
|
|
|
// }) |
|
|
|
} catch (e) { |
|
|
|
showErrorMessage(e.stack) |
|
|
|
uni.hideLoading() |
|
|
|
} |
|
|
|
} |
|
|
|
const getBalance = (labelParams, packageInfo, callback) => { |
|
|
|
const filters = [] |
|
|
|
if (packageInfo.parentNumber) { |
|
|
|
const packingNumber = `${packageInfo.parentNumber},${labelParams.packingNumber}` |
|
|
|
filters.push({ |
|
|
|
column: 'packingNumber', |
|
|
|
action: 'in', |
|
|
|
value: packingNumber |
|
|
|
}) |
|
|
|
} else { |
|
|
|
filters.push({ |
|
|
|
column: 'packingNumber', |
|
|
|
action: '==', |
|
|
|
value: labelParams.packingNumber |
|
|
|
}) |
|
|
|
} |
|
|
|
filters.push({ |
|
|
|
column: 'packingNumber', |
|
|
|
action: '==', |
|
|
|
value: labelParams.packingNumber |
|
|
|
}) |
|
|
|
filters.push({ |
|
|
|
column: 'itemCode', |
|
|
|
action: '==', |
|
|
|
value: labelParams.itemCode |
|
|
|
}) |
|
|
|
filters.push({ |
|
|
|
column: 'batch', |
|
|
|
action: '==', |
|
|
|
value: labelParams.batch |
|
|
|
}) |
|
|
|
|
|
|
|
if (fromInventoryStatuses.value != null && fromInventoryStatuses.value != '') { |
|
|
|
filters.push({ |
|
|
|
column: 'inventoryStatus', |
|
|
|
action: 'in', |
|
|
|
value: fromInventoryStatuses.value |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const params = { |
|
|
|
filters, |
|
|
|
pageNo: 1, |
|
|
|
pageSize: 100 |
|
|
|
} |
|
|
|
getBalanceByFilter(params) |
|
|
|
.then((res) => { |
|
|
|
callback(res.data) |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
showErrorMessage(err.message) |
|
|
|
}) |
|
|
|
} |
|
|
|
// const getBalance = (labelParams, packageInfo, callback) => { |
|
|
|
// const filters = [] |
|
|
|
// if (packageInfo.parentNumber) { |
|
|
|
// const packingNumber = `${packageInfo.parentNumber},${labelParams.packingNumber}` |
|
|
|
// filters.push({ |
|
|
|
// column: 'packingNumber', |
|
|
|
// action: 'in', |
|
|
|
// value: packingNumber |
|
|
|
// }) |
|
|
|
// } else { |
|
|
|
// filters.push({ |
|
|
|
// column: 'packingNumber', |
|
|
|
// action: '==', |
|
|
|
// value: labelParams.packingNumber |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// filters.push({ |
|
|
|
// column: 'packingNumber', |
|
|
|
// action: '==', |
|
|
|
// value: labelParams.packingNumber |
|
|
|
// }) |
|
|
|
// filters.push({ |
|
|
|
// column: 'itemCode', |
|
|
|
// action: '==', |
|
|
|
// value: labelParams.itemCode |
|
|
|
// }) |
|
|
|
// filters.push({ |
|
|
|
// column: 'batch', |
|
|
|
// action: '==', |
|
|
|
// value: labelParams.batch |
|
|
|
// }) |
|
|
|
// |
|
|
|
// if (fromInventoryStatuses.value != null && fromInventoryStatuses.value != '') { |
|
|
|
// filters.push({ |
|
|
|
// column: 'inventoryStatus', |
|
|
|
// action: 'in', |
|
|
|
// value: fromInventoryStatuses.value |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// |
|
|
|
// const params = { |
|
|
|
// filters, |
|
|
|
// pageNo: 1, |
|
|
|
// pageSize: 100 |
|
|
|
// } |
|
|
|
// getBalanceByFilter(params) |
|
|
|
// .then((res) => { |
|
|
|
// callback(res.data) |
|
|
|
// }) |
|
|
|
// .catch((err) => { |
|
|
|
// showErrorMessage(err.message) |
|
|
|
// }) |
|
|
|
// } |
|
|
|
|
|
|
|
const selectBalanceItem = (balanceParams) => { |
|
|
|
afterGetBalance(label.value, balanceParams, packageInfo.value) |
|
|
@ -328,7 +393,9 @@ const afterGetBalance = (labelParams, balanceParams, packageInfo) => { |
|
|
|
const packingCode = labelParams.packingNumber |
|
|
|
const lot = labelParams.batch |
|
|
|
const item = toLocation.value.Items.find((r) => r.itemCode == itemCode) |
|
|
|
fromLocationCode.value = balanceParams.locationCode; |
|
|
|
const fromLocation = item.Locations.find((l) => l.fromLocationCode == fromLocationCode.value) |
|
|
|
//如果库存余额中的库位与任务推荐的不一致 |
|
|
|
if (fromLocation != undefined) { |
|
|
|
const batch = fromLocation.Batchs.find((r) => r.batch == lot) |
|
|
|
if (batch != undefined) { |
|
|
@ -377,9 +444,11 @@ const afterGetBalance = (labelParams, balanceParams, packageInfo) => { |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
showErrorMessage(`未查找到推荐库位【${fromLocationCode.value}】的发料明细`, (res) => { |
|
|
|
getfocus() |
|
|
|
}) |
|
|
|
let locaion = createLocationInfo(labelParams, balanceParams, packageInfo); |
|
|
|
item.Locations.push(locaion); |
|
|
|
// showErrorMessage(`未查找到推荐库位【${fromLocationCode.value}】的发料明细`, (res) => { |
|
|
|
// getfocus() |
|
|
|
// }) |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
showErrorMessage(e.stack, (res) => { |
|
|
@ -387,7 +456,20 @@ const afterGetBalance = (labelParams, balanceParams, packageInfo) => { |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//增加实际扫描的明细 |
|
|
|
const createLocationInfo = (labelParams, balanceParams, packageInfo)=> { |
|
|
|
let location = { |
|
|
|
fromLocationCode: balanceParams.locationCode, |
|
|
|
qty: balanceParams.qty, |
|
|
|
uom: balanceParams.uom, |
|
|
|
handleQty: 0, |
|
|
|
Batchs: [] |
|
|
|
} |
|
|
|
let batch = createBatchInfo(labelParams, balanceParams, packageInfo); |
|
|
|
batch.detail = balanceParams; |
|
|
|
location.Batchs.push(batch); |
|
|
|
return location; |
|
|
|
} |
|
|
|
const createBatchInfo = (labelParams, balanceParams, packageInfo) => { |
|
|
|
const batch = { |
|
|
|
batch: labelParams.batch, |
|
|
@ -396,11 +478,11 @@ const createBatchInfo = (labelParams, balanceParams, packageInfo) => { |
|
|
|
Records: [] |
|
|
|
} |
|
|
|
let record = {} |
|
|
|
if (balanceParams == null) { |
|
|
|
record = creatRecordByBalance(labelParams, packageInfo) |
|
|
|
if (balanceParams != null) { |
|
|
|
record = creatRecordByBalance(balanceParams, packageInfo) |
|
|
|
batch.handleQty = Number(labelParams.qty) |
|
|
|
} else { |
|
|
|
record = creatRecordByLabel(balanceParams, packageInfo) |
|
|
|
record = creatRecordByLabel(labelParams, packageInfo) |
|
|
|
batch.handleQty = Number(balanceParams.qty) |
|
|
|
} |
|
|
|
batch.Records.push(record) |
|
|
|