扫码货位:先弹窗显示识别内容,点击搜索后请求后端查询

This commit is contained in:
97694732@qq.com 2026-06-04 17:31:53 +08:00
parent 008a49e59a
commit 48839d8fc5

View File

@ -1546,51 +1546,68 @@ export default {
const whCode = scanned.substring(0, sepIdx).trim() const whCode = scanned.substring(0, sepIdx).trim()
const locCode = scanned.substring(sepIdx + 2).trim() const locCode = scanned.substring(sepIdx + 2).trim()
if (whCode && locCode) { if (whCode && locCode) {
// //
const whIdx = this.popupWarehouseList.findIndex(w => { uni.showModal({
const code = (w.code || '').toLowerCase() title: '扫码结果',
const name = (w.name || '').toLowerCase() content: '仓库编码:' + whCode + '\n货位号' + locCode + '\n\n点击"搜索"查询货位',
const search = whCode.toLowerCase() confirmText: '搜索',
return code === search || name === search || code.includes(search) cancelText: '取消',
}) success: async (modalRes) => {
if (whIdx !== -1) { if (!modalRes.confirm) return
// , //
await this.loadPopupLocations(this.popupWarehouseList[whIdx].id, false, locCode) const whIdx = this.popupWarehouseList.findIndex(w => {
this.popupActiveWhIndex = whIdx const code = (w.code || '').toLowerCase()
this.popupSelectedWh = this.popupWarehouseList[whIdx] const name = (w.name || '').toLowerCase()
// , const search = whCode.toLowerCase()
if (this.popupLocationList.length > 0) { return code === search || name === search || code.includes(search)
this.popupSelectedLoc = this.popupLocationList[0] })
this.popupLocationSearch = '' if (whIdx !== -1) {
uni.showToast({ title: '已匹配仓库' + whCode + ' 货位:' + this.popupLocationList[0].code, icon: 'success' }) // ,
} else { await this.loadPopupLocations(this.popupWarehouseList[whIdx].id, false, locCode)
uni.showToast({ title: '已切换仓库' + whCode + ',但未找到货位' + locCode, icon: 'none' }) 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' })
}
} }
return })
} return
} }
} }
// // ##
let matched = null uni.showModal({
for (const loc of this.popupAllLocationList) { title: '扫码结果',
const code = (loc.code || '').toLowerCase() content: '条码内容:' + scanned + '\n\n点击"搜索"在当前仓库中查询货位',
const name = (loc.name || '').toLowerCase() confirmText: '搜索',
const search = scanned.toLowerCase() cancelText: '取消',
if (code === search || name === search || success: async (modalRes) => {
code.includes(search) || search.includes(code)) { if (!modalRes.confirm) return
matched = loc const search = scanned.toLowerCase()
break 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' })
}
} }
} })
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: () => {} fail: () => {}
}) })