fix(api): update-stocktake-quantity 按 session_id 隔离更新,防止跨会话误改
后端 update_stocktake_quantity 原只按 stock_id+source_table 查草稿, 不同盘点会话会相互覆盖实盘数。后端增加 session_id 过滤, 前端 handleQuantityChange 配套传入当前会话ID,API 类型同步补全。
This commit is contained in:
@ -1741,16 +1741,20 @@ def update_stocktake_quantity():
|
||||
data = request.json
|
||||
stock_id = data.get('stock_id')
|
||||
source_table = data.get('source_table')
|
||||
session_id = data.get('session_id') # ★ 修复:按会话隔离,防止跨会话误改
|
||||
quantity = float(data.get('quantity', 0))
|
||||
|
||||
|
||||
if not stock_id or not source_table:
|
||||
return jsonify({'code': 400, 'msg': '缺少必要参数'}), 400
|
||||
|
||||
# 查找对应的盘点记录
|
||||
draft = StocktakeDraft.query.filter_by(
|
||||
|
||||
# 查找对应的盘点记录(★ 修复:限定 session_id,避免不同盘点会话相互覆盖)
|
||||
query = StocktakeDraft.query.filter_by(
|
||||
stock_id=stock_id,
|
||||
source_table=source_table
|
||||
).first()
|
||||
)
|
||||
if session_id:
|
||||
query = query.filter_by(session_id=session_id)
|
||||
draft = query.first()
|
||||
|
||||
if not draft:
|
||||
return jsonify({'code': 404, 'msg': '未找到盘点记录'}), 404
|
||||
|
||||
Reference in New Issue
Block a user