From 0e3bf6b8e2fe8e0d9205506e0210e0522011d073 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Thu, 4 Jun 2026 16:57:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A7=E4=BD=8D=E5=BC=B9=E7=AA=97:=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=80=89=E4=B8=AD=E5=BD=93=E5=89=8D=E8=B4=A7=E4=BD=8D?= =?UTF-8?q?+=E5=A2=9E=E5=8A=A0=E6=89=AB=E7=A0=81=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E8=B4=A7=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 82 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 0b66ffe..b8899dc 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -750,6 +750,7 @@ + 📷 - {{ loc.code }} - {{ loc.name }} + {{ loc.code }} @@ -885,6 +886,8 @@ export default { popupLocLoadingMore: false, popupLocationSearch: '', popupAllLocationList: [], + _pendingPreselectWh: null, + _pendingPreselectLoc: null, // 登录 isLoggedIn: false, @@ -1315,6 +1318,9 @@ export default { openWarehousePicker(tab) { this.pickerTargetTab = tab this.showWarehousePicker = true + const savedData = tab === 'isbn' ? this.isbnWarehouseData : this.noIsbnWarehouseData + this._pendingPreselectWh = savedData ? savedData.warehouseId : null + this._pendingPreselectLoc = savedData ? savedData.locationId : null this.loadPopupWarehouses() }, @@ -1331,8 +1337,27 @@ export default { const list = res.data?.list || res.data?.records || res.list || res.records || [] if (list.length > 0) { this.popupWarehouseList = list - this.popupActiveWhIndex = 0 - this.loadPopupLocations(list[0].id) + // 默认选中第一个仓库 + let whIdx = 0 + const preselectWhId = this._pendingPreselectWh + if (preselectWhId) { + const foundIdx = list.findIndex(w => w.id === preselectWhId) + if (foundIdx !== -1) whIdx = foundIdx + } + this.popupActiveWhIndex = whIdx + this.popupSelectedWh = list[whIdx] + this.popupSelectedLoc = null + await this.loadPopupLocations(list[whIdx].id) + // 加载完货位后根据已选ID自动选中 + const preselectLocId = this._pendingPreselectLoc + if (preselectLocId && this.popupLocationList.length > 0) { + const foundLoc = this.popupLocationList.find(l => l.id === preselectLocId) + if (foundLoc) { + this.popupSelectedLoc = foundLoc + } + } + this._pendingPreselectWh = null + this._pendingPreselectLoc = null } else { console.warn('仓库列表为空, 响应code:', res.code, '响应data:', JSON.stringify(res.data)) } @@ -1486,6 +1511,39 @@ export default { this.popupLocationList = [...this.popupAllLocationList] }, + // 扫码识别货位 + scanLocationBarcode() { + uni.scanCode({ + onlyFromCamera: true, + scanType: ['barcode'], + success: (res) => { + const scanned = (res.result || '').trim().toLowerCase() + if (!scanned) return + // 在当前仓库的货位列表中查找匹配的货位 + let matched = null + for (const loc of this.popupAllLocationList) { + const code = (loc.code || '').toLowerCase() + const name = (loc.name || '').toLowerCase() + if (code === scanned || name === scanned || + code.includes(scanned) || scanned.includes(code)) { + matched = loc + break + } + } + if (matched) { + this.popupSelectedLoc = matched + // 滚动到该货位(通过设置搜索关键字并高亮) + this.popupLocationSearch = '' + this.popupLocationList = [...this.popupAllLocationList] + uni.showToast({ title: '已选中货位: ' + matched.code, icon: 'success' }) + } else { + uni.showToast({ title: '未找到匹配货位', icon: 'none' }) + } + }, + fail: () => {} + }) + }, + // 比价切换 - 切换后触发搜索 switchCompare(type) { this.compareType = type @@ -3186,7 +3244,7 @@ picker { border: none; border-radius: 8rpx; height: 56rpx; - padding: 0 60rpx 0 16rpx; + padding: 0 100rpx 0 16rpx; font-size: 26rpx; color: #303133; box-sizing: border-box; @@ -3200,7 +3258,7 @@ picker { .wh-search-clear { position: absolute; - right: 24rpx; + right: 72rpx; top: 50%; transform: translateY(-50%); width: 36rpx; @@ -3214,6 +3272,20 @@ picker { justify-content: center; } +.wh-scan-btn { + position: absolute; + right: 24rpx; + top: 50%; + transform: translateY(-50%); + width: 40rpx; + height: 40rpx; + display: flex; + align-items: center; + justify-content: center; + font-size: 30rpx; + color: #606266; +} + /* ========== 仓库货位列表 ========== */ .wh-location-list { flex: 1;