扫码货位:携带locCode请求后端过滤,直接返回匹配结果
This commit is contained in:
parent
f72aed2aee
commit
008a49e59a
@ -1379,7 +1379,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadPopupLocations(warehouseId, keepExisting = false) {
|
async loadPopupLocations(warehouseId, keepExisting = false, searchKeyword = '') {
|
||||||
if (!keepExisting) {
|
if (!keepExisting) {
|
||||||
this.popupLoadingLocation = true
|
this.popupLoadingLocation = true
|
||||||
this.popupLocPage = 1
|
this.popupLocPage = 1
|
||||||
@ -1388,10 +1388,15 @@ export default {
|
|||||||
this.popupLocTotal = 0
|
this.popupLocTotal = 0
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const res = await getLocationList({
|
const params = {
|
||||||
warehouse_id: warehouseId, type: 1, status: 1,
|
warehouse_id: warehouseId, type: 1, status: 1,
|
||||||
page: this.popupLocPage, page_size: this.popupLocPageSize
|
page: this.popupLocPage, page_size: this.popupLocPageSize
|
||||||
})
|
}
|
||||||
|
// 如果传了搜索关键词,交给后端过滤
|
||||||
|
if (searchKeyword) {
|
||||||
|
params.code = searchKeyword
|
||||||
|
}
|
||||||
|
const res = await getLocationList(params)
|
||||||
console.log('【货位列表】load响应:', JSON.stringify(res))
|
console.log('【货位列表】load响应:', JSON.stringify(res))
|
||||||
// 兼容多种响应格式:{ code:0, data:{ list:[], total:100 } } 或直接 { list:[], total:100 }
|
// 兼容多种响应格式:{ code:0, data:{ list:[], total:100 } } 或直接 { list:[], total:100 }
|
||||||
let newList = []
|
let newList = []
|
||||||
@ -1549,21 +1554,15 @@ export default {
|
|||||||
return code === search || name === search || code.includes(search)
|
return code === search || name === search || code.includes(search)
|
||||||
})
|
})
|
||||||
if (whIdx !== -1) {
|
if (whIdx !== -1) {
|
||||||
// 切换到该仓库,并等待货位接口重新请求完成
|
// 切换到该仓库,携带货位号请求后端过滤
|
||||||
await this.selectPopupWarehouse(whIdx)
|
await this.loadPopupLocations(this.popupWarehouseList[whIdx].id, false, locCode)
|
||||||
// 货位列表已重新加载,在其中搜索匹配
|
this.popupActiveWhIndex = whIdx
|
||||||
const matchedLoc = this.popupAllLocationList.find(l => {
|
this.popupSelectedWh = this.popupWarehouseList[whIdx]
|
||||||
const code = (l.code || '').toLowerCase()
|
// 如果后端返回了匹配的货位,自动选中
|
||||||
const name = (l.name || '').toLowerCase()
|
if (this.popupLocationList.length > 0) {
|
||||||
const search = locCode.toLowerCase()
|
this.popupSelectedLoc = this.popupLocationList[0]
|
||||||
return code === search || name === search ||
|
|
||||||
code.includes(search) || search.includes(code)
|
|
||||||
})
|
|
||||||
if (matchedLoc) {
|
|
||||||
this.popupSelectedLoc = matchedLoc
|
|
||||||
this.popupLocationSearch = ''
|
this.popupLocationSearch = ''
|
||||||
this.popupLocationList = [...this.popupAllLocationList]
|
uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + this.popupLocationList[0].code, icon: 'success' })
|
||||||
uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + matchedLoc.code, icon: 'success' })
|
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: '已切换仓库' + whCode + ',但未找到货位' + locCode, icon: 'none' })
|
uni.showToast({ title: '已切换仓库' + whCode + ',但未找到货位' + locCode, icon: 'none' })
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user