扫码货位:携带locCode请求后端过滤,直接返回匹配结果

This commit is contained in:
97694732@qq.com 2026-06-04 17:23:15 +08:00
parent f72aed2aee
commit 008a49e59a

View File

@ -1379,7 +1379,7 @@ export default {
}
},
async loadPopupLocations(warehouseId, keepExisting = false) {
async loadPopupLocations(warehouseId, keepExisting = false, searchKeyword = '') {
if (!keepExisting) {
this.popupLoadingLocation = true
this.popupLocPage = 1
@ -1388,10 +1388,15 @@ export default {
this.popupLocTotal = 0
}
try {
const res = await getLocationList({
const params = {
warehouse_id: warehouseId, type: 1, status: 1,
page: this.popupLocPage, page_size: this.popupLocPageSize
})
}
// ,
if (searchKeyword) {
params.code = searchKeyword
}
const res = await getLocationList(params)
console.log('【货位列表】load响应:', JSON.stringify(res))
// { code:0, data:{ list:[], total:100 } } { list:[], total:100 }
let newList = []
@ -1549,21 +1554,15 @@ export default {
return code === search || name === search || code.includes(search)
})
if (whIdx !== -1) {
//
await this.selectPopupWarehouse(whIdx)
//
const matchedLoc = this.popupAllLocationList.find(l => {
const code = (l.code || '').toLowerCase()
const name = (l.name || '').toLowerCase()
const search = locCode.toLowerCase()
return code === search || name === search ||
code.includes(search) || search.includes(code)
})
if (matchedLoc) {
this.popupSelectedLoc = matchedLoc
// ,
await this.loadPopupLocations(this.popupWarehouseList[whIdx].id, false, locCode)
this.popupActiveWhIndex = whIdx
this.popupSelectedWh = this.popupWarehouseList[whIdx]
// ,
if (this.popupLocationList.length > 0) {
this.popupSelectedLoc = this.popupLocationList[0]
this.popupLocationSearch = ''
this.popupLocationList = [...this.popupAllLocationList]
uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + matchedLoc.code, icon: 'success' })
uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + this.popupLocationList[0].code, icon: 'success' })
} else {
uni.showToast({ title: '已切换仓库' + whCode + ',但未找到货位' + locCode, icon: 'none' })
}