扫码货位:携带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) { 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' })
} }