From 008a49e59a4cc2584d5108fe8bf64cf4dd20e9cf Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Thu, 4 Jun 2026 17:23:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E8=B4=A7=E4=BD=8D:=E6=90=BA?= =?UTF-8?q?=E5=B8=A6locCode=E8=AF=B7=E6=B1=82=E5=90=8E=E7=AB=AF=E8=BF=87?= =?UTF-8?q?=E6=BB=A4,=E7=9B=B4=E6=8E=A5=E8=BF=94=E5=9B=9E=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 95b46e0..f651962 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -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' }) }