fix(web): 继续上次盘点不再拉取全量草稿,直接复用首条草稿的 session_id
resumeSession 原在 limit=1 探测后,又发起 limit=500 请求只为取出 session_id, 会触发后端 /draft/list 的全量 N+1 查询导致启动卡顿。 改为直接从第一条草稿提取 session_id,恢复会话零冗余请求。
This commit is contained in:
@ -666,24 +666,16 @@ const resumeSession = async () => {
|
||||
})
|
||||
|
||||
const total = res?.total || 0
|
||||
const firstDraft = res?.items?.[0]
|
||||
|
||||
if (total === 0) {
|
||||
if (total === 0 || !firstDraft) {
|
||||
ElMessage.warning('没有找到未完成的盘点记录')
|
||||
return
|
||||
}
|
||||
|
||||
// ★ 获取实际草稿数据用于恢复(分页加载,单次最多500条)
|
||||
const fullRes = await request({
|
||||
url: '/v1/inbound/stock/draft/list',
|
||||
method: 'get',
|
||||
params: { page: 1, limit: 500 }
|
||||
})
|
||||
const drafts = fullRes?.items || []
|
||||
|
||||
// 恢复已扫描的数据 - 简化为直接激活会话
|
||||
// 从草稿中获取 session_id
|
||||
const sessionIds = [...new Set(drafts.map((d: any) => d.session_id))]
|
||||
currentSessionId.value = sessionIds[0]
|
||||
// ★ 直接从第一条草稿恢复 session_id,不再拉取全量草稿
|
||||
// 避免 limit=500 请求触发后端 query.all() + N+1 性能瓶颈
|
||||
currentSessionId.value = firstDraft.session_id || ''
|
||||
|
||||
// 直接恢复会话状态
|
||||
isSessionActive.value = true
|
||||
|
||||
Reference in New Issue
Block a user