fix(stocktake): 扫码未找到物料时显示友好提示而非原始 404 错误
- 识别 HTTP 404 状态码 → 显示『条码 [xxx] 未在库存系统中找到,请确认条码是否正确』 - 其他错误 → 显示『查询失败: xxx』 - 扫码失败时振动反馈
This commit is contained in:
@ -779,12 +779,15 @@ const onScanSuccess = async (code: string) => {
|
||||
|
||||
openQtyDialog(item)
|
||||
} catch (e: any) {
|
||||
const msg = e?.msg || e?.message || '查询库存失败'
|
||||
if (msg.includes('未找到')) {
|
||||
ElMessage.error(`未找到该物料库存: ${trimCode}`)
|
||||
// ★ 友好错误提示:404=条码不在系统中,其他=网络/服务器错误
|
||||
const status = e?.response?.status || e?.status
|
||||
if (status === 404) {
|
||||
ElMessage.warning(`条码 [${trimCode}] 未在库存系统中找到,请确认条码是否正确`)
|
||||
} else {
|
||||
ElMessage.error(msg)
|
||||
const msg = e?.msg || e?.message || '查询库存失败'
|
||||
ElMessage.error(`查询失败: ${msg}`)
|
||||
}
|
||||
if (navigator.vibrate) navigator.vibrate([200, 100, 200])
|
||||
console.error(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
@ -849,12 +852,15 @@ const handleManualInput = async () => {
|
||||
|
||||
openQtyDialog(item)
|
||||
} catch (e: any) {
|
||||
const msg = e?.msg || e?.message || '查询库存失败'
|
||||
if (msg.includes('未找到')) {
|
||||
ElMessage.error(`未找到该物料库存: ${code}`)
|
||||
// ★ 友好错误提示:404=条码不在系统中,其他=网络/服务器错误
|
||||
const status = e?.response?.status || e?.status
|
||||
if (status === 404) {
|
||||
ElMessage.warning(`条码 [${code}] 未在库存系统中找到,请确认条码是否正确`)
|
||||
} else {
|
||||
ElMessage.error(msg)
|
||||
const msg = e?.msg || e?.message || '查询库存失败'
|
||||
ElMessage.error(`查询失败: ${msg}`)
|
||||
}
|
||||
if (navigator.vibrate) navigator.vibrate([200, 100, 200])
|
||||
console.error(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
||||
Reference in New Issue
Block a user