From 9357474966445bf2452813bc084e3e4a727cab33 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Thu, 4 Jun 2026 17:38:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E5=BC=B9=E7=AA=97:=E6=94=B9?= =?UTF-8?q?=E7=94=A8=E8=87=AA=E5=AE=9A=E4=B9=89=E5=BC=B9=E7=AA=97(?= =?UTF-8?q?=E4=BB=BFzhizhu=E7=BC=96=E8=BE=91=E5=BC=B9=E7=AA=97=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F),=E5=8E=BB=E9=99=A4uni.showModal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 246 ++++++++++++++++++++++++++++++---------- 1 file changed, 188 insertions(+), 58 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index d0e34f5..fbbe306 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -785,6 +785,35 @@ + + + + + + 扫码结果 + + + + + 仓库编码 + {{ scanPopupWhCode }} + + + 货位号 + {{ scanPopupLocCode }} + + + 条码内容 + {{ scanPopupRaw }} + + 点击「搜索」查询匹配货位 + + + 取消 + 搜索 + + + @@ -891,6 +920,12 @@ export default { _pendingPreselectWh: null, _pendingPreselectLoc: null, + // 扫码弹窗 + showScanPopup: false, + scanPopupWhCode: '', + scanPopupLocCode: '', + scanPopupRaw: '', + // 登录 isLoggedIn: false, shopName: '', @@ -1546,73 +1581,76 @@ export default { const whCode = scanned.substring(0, sepIdx).trim() const locCode = scanned.substring(sepIdx + 2).trim() if (whCode && locCode) { - // 弹窗显示识别内容,让用户确认后搜索 - uni.showModal({ - title: '扫码结果', - content: '仓库编码:' + whCode + '\n货位号:' + locCode + '\n\n点击"搜索"查询货位', - confirmText: '搜索', - cancelText: '取消', - success: async (modalRes) => { - if (!modalRes.confirm) return - // 按仓库编码查找匹配的仓库 - const whIdx = this.popupWarehouseList.findIndex(w => { - const code = (w.code || '').toLowerCase() - const name = (w.name || '').toLowerCase() - const search = whCode.toLowerCase() - return code === search || name === search || code.includes(search) - }) - if (whIdx !== -1) { - // 切换到该仓库,携带货位号请求后端过滤 - 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 = '' - uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + this.popupLocationList[0].code, icon: 'success' }) - } else { - uni.showToast({ title: '已切换仓库' + whCode + ',但未找到货位' + locCode, icon: 'none' }) - } - } else { - uni.showToast({ title: '未找到仓库: ' + whCode, icon: 'none' }) - } - } - }) + this.scanPopupWhCode = whCode + this.scanPopupLocCode = locCode + this.scanPopupRaw = '' + this.showScanPopup = true return } } - // 无##格式,在当前仓库的货位列表中查找匹配的货位 - uni.showModal({ - title: '扫码结果', - content: '条码内容:' + scanned + '\n\n点击"搜索"在当前仓库中查询货位', - confirmText: '搜索', - cancelText: '取消', - success: async (modalRes) => { - if (!modalRes.confirm) return - const search = scanned.toLowerCase() - const matched = this.popupAllLocationList.find(l => { - const code = (l.code || '').toLowerCase() - const name = (l.name || '').toLowerCase() - return code === search || name === search || - code.includes(search) || search.includes(code) - }) - if (matched) { - this.popupSelectedLoc = matched - this.popupLocationSearch = '' - this.popupLocationList = [...this.popupAllLocationList] - uni.showToast({ title: '已选中货位: ' + matched.code, icon: 'success' }) - } else { - uni.showToast({ title: '未找到匹配货位', icon: 'none' }) - } - } - }) + // 纯条码格式 + this.scanPopupWhCode = '' + this.scanPopupLocCode = '' + this.scanPopupRaw = scanned + this.showScanPopup = true }, fail: () => {} }) }, + closeScanPopup() { + this.showScanPopup = false + }, + + async confirmScanSearch() { + this.showScanPopup = false + const whCode = this.scanPopupWhCode + const locCode = this.scanPopupLocCode + const raw = this.scanPopupRaw + + if (whCode && locCode) { + // 格式 NS##a5-4 + const whIdx = this.popupWarehouseList.findIndex(w => { + const code = (w.code || '').toLowerCase() + const name = (w.name || '').toLowerCase() + const search = whCode.toLowerCase() + return code === search || name === search || code.includes(search) + }) + if (whIdx !== -1) { + 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 = '' + uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + this.popupLocationList[0].code, icon: 'success' }) + } else { + uni.showToast({ title: '已切换仓库' + whCode + ',但未找到货位' + locCode, icon: 'none' }) + } + } else { + uni.showToast({ title: '未找到仓库: ' + whCode, icon: 'none' }) + } + } else if (raw) { + // 纯条码,在当前仓库的货位列表中查找 + const search = raw.toLowerCase() + const matched = this.popupAllLocationList.find(l => { + const code = (l.code || '').toLowerCase() + const name = (l.name || '').toLowerCase() + return code === search || name === search || + code.includes(search) || search.includes(code) + }) + if (matched) { + this.popupSelectedLoc = matched + this.popupLocationSearch = '' + this.popupLocationList = [...this.popupAllLocationList] + uni.showToast({ title: '已选中货位: ' + matched.code, icon: 'success' }) + } else { + uni.showToast({ title: '未找到匹配货位', icon: 'none' }) + } + } + }, + // 比价切换 - 切换后触发搜索 switchCompare(type) { this.compareType = type @@ -3464,6 +3502,98 @@ picker { opacity: 0.6; } +/* ========== 扫码结果弹窗 ========== */ +.scan-result-overlay { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + background-color: rgba(0,0,0,0.3); + z-index: 2000; + display: flex; + align-items: center; + justify-content: center; +} + +.scan-result-popup { + width: 560rpx; + background-color: #ffffff; + border-radius: 12rpx; + overflow: hidden; +} + +.popup-scan-header { + padding: 30rpx; + display: flex; + justify-content: space-between; + align-items: center; + border-bottom: 1rpx solid #f0f0f0; +} + +.popup-scan-title { + font-size: 32rpx; + font-weight: bold; + color: #333333; +} + +.popup-scan-close { + font-size: 36rpx; + color: #999999; + padding: 0 10rpx; +} + +.popup-scan-content { + padding: 30rpx; + min-height: 120rpx; +} + +.scan-result-row { + display: flex; + align-items: center; + margin-bottom: 16rpx; +} + +.scan-result-label { + font-size: 28rpx; + color: #666666; + margin-right: 20rpx; + min-width: 120rpx; +} + +.scan-result-value { + font-size: 30rpx; + color: #333333; + font-weight: 500; +} + +.scan-result-hint { + font-size: 26rpx; + color: #999999; + margin-top: 10rpx; + display: block; +} + +.popup-scan-footer { + display: flex; + border-top: 1rpx solid #f0f0f0; +} + +.popup-scan-btn { + flex: 1; + height: 90rpx; + line-height: 90rpx; + text-align: center; + font-size: 32rpx; +} + +.popup-scan-cancel { + background-color: #f5f5f5; + color: #333333; +} + +.popup-scan-confirm { + background-color: #007aff; + color: #ffffff; +} + /* ========== 定价策略 ========== */ .mode-tabs { display: flex;