|
|
@@ -381,6 +381,7 @@ const matchingBarcodeItem = (data, barcode) => {
|
|
|
const switchTask = () => {
|
|
|
inputBarcodeType.value = 'switchTask'
|
|
|
back.value = false
|
|
|
+ excludedLocations.value = {}
|
|
|
inputBarcodeRef.value?.show('', `请扫描容器号`, '')
|
|
|
}
|
|
|
|
|
|
@@ -388,8 +389,8 @@ const switchTask = () => {
|
|
|
const lotBarcodeList = ref([])
|
|
|
const lotBarcodeTrueFalseBy = ref(false)
|
|
|
const barcodeActiveList = ref([])
|
|
|
-// 已推荐过的库位,用于换一换时排除
|
|
|
-const excludedLocations = ref([])
|
|
|
+// 已推荐过的库位,按 lotNum 批次维度存储,用于换一换时排除
|
|
|
+const excludedLocations = ref({}) // { [lotNumber]: [locationId, ...] }
|
|
|
// 换一换按钮 loading
|
|
|
const changeLocationLoading = ref(false)
|
|
|
const reset = () => {
|
|
|
@@ -399,7 +400,6 @@ const reset = () => {
|
|
|
oldSearchBarcode.value = ''
|
|
|
locationList.value = []
|
|
|
barcodeActiveList.value = []
|
|
|
- excludedLocations.value = []
|
|
|
}
|
|
|
// 选择单据
|
|
|
const onDetailActive = (item) => {
|
|
|
@@ -459,8 +459,13 @@ const _handlerScan = (code) => {
|
|
|
}
|
|
|
}
|
|
|
// 获取推荐库位
|
|
|
-const _getRecommendedLocation = async (item, excludeList = []) => {
|
|
|
- const { lotNumber, owner, sku, quantity } = item
|
|
|
+const _getRecommendedLocation = async (item, excludeList) => {
|
|
|
+ const { lotNumber, owner, sku, quantity, lotAtt08 } = item
|
|
|
+ // 扫描商品时先看有没有推荐过
|
|
|
+ const listByLot = excludeList ?? (excludedLocations.value[lotNumber] || [])
|
|
|
+ const uniqueLocationIds = listByLot.length > 0
|
|
|
+ ? [...new Set(listByLot.map(loc => loc.locationId))]
|
|
|
+ : undefined
|
|
|
try {
|
|
|
const params = {
|
|
|
warehouse,
|
|
|
@@ -468,12 +473,18 @@ const _getRecommendedLocation = async (item, excludeList = []) => {
|
|
|
owner,
|
|
|
sku,
|
|
|
qty: quantity,
|
|
|
- excludedLocations: excludeList.length > 0 ? [...new Set(excludeList)] : undefined
|
|
|
+ lotAtt08,
|
|
|
+ ...(uniqueLocationIds && { excludedLocations: uniqueLocationIds })
|
|
|
}
|
|
|
const res = await getRecommendedLocationNew(params)
|
|
|
if (res.data) {
|
|
|
const loc = res.data.location ?? res.data
|
|
|
- excludedLocations.value = [...excludedLocations.value, loc]
|
|
|
+ // 按批次维度存储已推荐库位
|
|
|
+ const lotExcluded = excludedLocations.value[lotNumber] || []
|
|
|
+ excludedLocations.value = {
|
|
|
+ ...excludedLocations.value,
|
|
|
+ [lotNumber]: [...lotExcluded, loc]
|
|
|
+ }
|
|
|
locationList.value = [res.data]
|
|
|
searchCount.value = 1
|
|
|
}
|
|
|
@@ -482,12 +493,14 @@ const _getRecommendedLocation = async (item, excludeList = []) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 换一换:请求新的推荐库位,排除已推荐过的
|
|
|
+// 换一换:请求新的推荐库位,排除当前批次已推荐过的
|
|
|
const onChangeLocation = async () => {
|
|
|
if (barcodeActiveList.value.length > 0) {
|
|
|
changeLocationLoading.value = true
|
|
|
try {
|
|
|
- await _getRecommendedLocation(barcodeActiveList.value[0], excludedLocations.value)
|
|
|
+ const item = barcodeActiveList.value[0]
|
|
|
+ const lotExcluded = excludedLocations.value[item.lotNumber] || []
|
|
|
+ await _getRecommendedLocation(item, lotExcluded)
|
|
|
} finally {
|
|
|
changeLocationLoading.value = false
|
|
|
}
|