feat(stocktake): 重复扫码提示并确认是否修改
问题: 同一个码扫两遍输入两个数,后端 draft/add 直接覆盖,无任何提示 可能误改已盘数量 改进: - 后端 draft/list 支持 uuid 过滤,可精确查某物料是否已盘 - 扫码弹输入框前,先精确查询该物料是否已盘 - 已盘过 → 弹窗提示『当前实盘为 X,是否修改?』 确认后预填旧值供修改,取消则不改变
This commit is contained in:
@ -477,12 +477,17 @@ def get_drafts():
|
|||||||
limit = request.args.get('limit', 20, type=int)
|
limit = request.args.get('limit', 20, type=int)
|
||||||
keyword = request.args.get('keyword', '', type=str)
|
keyword = request.args.get('keyword', '', type=str)
|
||||||
session_id = request.args.get('session_id')
|
session_id = request.args.get('session_id')
|
||||||
|
uuid = request.args.get('uuid', '', type=str)
|
||||||
|
|
||||||
query = StocktakeDraft.query
|
query = StocktakeDraft.query
|
||||||
|
|
||||||
if session_id:
|
if session_id:
|
||||||
query = query.filter_by(session_id=session_id)
|
query = query.filter_by(session_id=session_id)
|
||||||
|
|
||||||
|
# ★ 按 uuid 精确过滤(扫码时检测该物料是否已盘)
|
||||||
|
if uuid:
|
||||||
|
query = query.filter_by(uuid=uuid)
|
||||||
|
|
||||||
# 先执行查询获取所有记录
|
# 先执行查询获取所有记录
|
||||||
drafts = query.all()
|
drafts = query.all()
|
||||||
|
|
||||||
|
|||||||
@ -861,15 +861,58 @@ const handleManualInput = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const openQtyDialog = (item: StockItem) => {
|
const openQtyDialog = async (item: StockItem) => {
|
||||||
currentItem.value = item
|
// ★ 重复扫码检测:精确查该物料是否已在本 session 盘过
|
||||||
inputQty.value = item.scanned ? item.qty_actual : 1
|
let existingQty: number | null = null
|
||||||
showQtyDialog.value = true
|
try {
|
||||||
|
const uuidForQuery = item.uuid || item.sku || ''
|
||||||
|
const dupRes: any = await request({
|
||||||
|
url: '/v1/inbound/stock/draft/list',
|
||||||
|
method: 'get',
|
||||||
|
params: { session_id: currentSessionId.value, uuid: uuidForQuery, limit: 1 }
|
||||||
|
})
|
||||||
|
const dupItems = dupRes?.items || dupRes?.data?.items || []
|
||||||
|
if (dupItems.length > 0 && dupItems[0].quantity !== undefined) {
|
||||||
|
existingQty = Number(dupItems[0].quantity)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// 查询失败不阻断,视为未盘过
|
||||||
|
}
|
||||||
|
|
||||||
nextTick(() => {
|
if (existingQty !== null) {
|
||||||
const inputEl = document.querySelector('.qty-dialog input') as HTMLInputElement
|
// 已盘过 → 提示当前值,询问是否修改
|
||||||
if(inputEl) inputEl.focus()
|
try {
|
||||||
})
|
await ElMessageBox.confirm(
|
||||||
|
`⚠️ 【${item.name} × ${item.standard}】已盘过,当前实盘为 ${existingQty}。\n\n是否修改本次盘点的数量?`,
|
||||||
|
'重复扫码提示',
|
||||||
|
{
|
||||||
|
confirmButtonText: '修改数量',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
// 用户确认修改 → 预填当前值,弹输入框
|
||||||
|
currentItem.value = item
|
||||||
|
inputQty.value = existingQty || 1
|
||||||
|
showQtyDialog.value = true
|
||||||
|
nextTick(() => {
|
||||||
|
const inputEl = document.querySelector('.qty-dialog input') as HTMLInputElement
|
||||||
|
if(inputEl) inputEl.focus()
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
// 用户取消,不修改
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 未盘过 → 正常弹输入框
|
||||||
|
currentItem.value = item
|
||||||
|
inputQty.value = item.scanned ? item.qty_actual : 1
|
||||||
|
showQtyDialog.value = true
|
||||||
|
nextTick(() => {
|
||||||
|
const inputEl = document.querySelector('.qty-dialog input') as HTMLInputElement
|
||||||
|
if(inputEl) inputEl.focus()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleManualConfirm = () => {
|
const handleManualConfirm = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user