From f72aed2aeeb6a058b20f02bc5fc4e5feca777510 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Thu, 4 Jun 2026 17:20:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E8=B4=A7=E4=BD=8D:await?= =?UTF-8?q?=E8=B4=A7=E4=BD=8D=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E5=90=8E?= =?UTF-8?q?=E5=86=8D=E5=8C=B9=E9=85=8D,=E7=A7=BB=E9=99=A4setTimeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 16451be..95b46e0 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -1447,7 +1447,7 @@ export default { this.popupSelectedWh = wh this.popupSelectedLoc = null this.popupLocationSearch = '' - this.loadPopupLocations(wh.id) + return this.loadPopupLocations(wh.id) } }, @@ -1549,26 +1549,24 @@ export default { return code === search || name === search || code.includes(search) }) if (whIdx !== -1) { - // 切换到该仓库 - this.selectPopupWarehouse(whIdx) - // 等待货位加载完成后再搜索匹配 - setTimeout(() => { - 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 - this.popupLocationSearch = '' - this.popupLocationList = [...this.popupAllLocationList] - uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + matchedLoc.code, icon: 'success' }) - } else { - uni.showToast({ title: '已切换仓库' + whCode + ',但未找到货位' + locCode, icon: 'none' }) - } - }, 500) + // 切换到该仓库,并等待货位接口重新请求完成 + 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 + this.popupLocationSearch = '' + this.popupLocationList = [...this.popupAllLocationList] + uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + matchedLoc.code, icon: 'success' }) + } else { + uni.showToast({ title: '已切换仓库' + whCode + ',但未找到货位' + locCode, icon: 'none' }) + } return } }