fix(stocktake): 探测会话失败时不再静默降级为「无盘点」
checkServerDraft 原本在请求异常时把 activeSession 置空,界面于是从绿色 「加入正在进行的盘点」退回蓝色「开始新盘点」—— 网络抖动一下,库管点下去 就会新建会话,把多人协同拆开。 现把「探测失败」独立成 probeFailed 状态:失败时保持 activeSession 不变, 界面切到「无法确认是否有进行中的盘点 + 重新检测」,不提供进入按钮。 宁可挡住操作,也不能让库管误开新会话。
This commit is contained in:
@ -31,6 +31,21 @@
|
||||
请先选择公司
|
||||
</el-button>
|
||||
|
||||
<!-- ★ 探测失败:不提供进入按钮,避免误开新会话 -->
|
||||
<template v-else-if="probeFailed">
|
||||
<div class="probe-failed">
|
||||
⚠️ 无法确认是否有进行中的盘点,请检查网络后重试
|
||||
</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="large"
|
||||
class="action-btn-full"
|
||||
@click="checkServerDraft"
|
||||
>
|
||||
重新检测
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<!-- 场景 A:该公司已有进行中的盘点 → 绿色「加入」 -->
|
||||
<template v-else-if="activeSession">
|
||||
<el-button
|
||||
@ -549,6 +564,9 @@ const companyOptions = ref<string[]>([])
|
||||
const companyLoading = ref(false)
|
||||
// 该公司的活跃会话:{ session_id, total, last_scan_time };无进行中的盘点则为 null
|
||||
const activeSession = ref<{ session_id: string; total: number; last_scan_time: string | null } | null>(null)
|
||||
// ★ 探测失败标记:网络抖动时绝不能把「没查到」当成「没有盘点」——
|
||||
// 否则界面会退回「开始新盘点」,库管一点就新建会话,把多人协同拆开
|
||||
const probeFailed = ref(false)
|
||||
|
||||
const isSuperAdmin = computed(() => userStore.role === 'SUPER_ADMIN')
|
||||
|
||||
@ -740,6 +758,7 @@ const handleCompanyChange = async (val: string) => {
|
||||
clearPersistedSession()
|
||||
activeSession.value = null
|
||||
serverDraftCount.value = 0
|
||||
probeFailed.value = false
|
||||
persistCompany(val)
|
||||
await checkServerDraft()
|
||||
}
|
||||
@ -759,9 +778,11 @@ const checkServerDraft = async () => {
|
||||
? { session_id: data.session_id, total: data.total || 0, last_scan_time: data.last_scan_time || null }
|
||||
: null
|
||||
serverDraftCount.value = data.total || 0
|
||||
probeFailed.value = false
|
||||
} catch (e) {
|
||||
activeSession.value = null
|
||||
serverDraftCount.value = 0
|
||||
// ★ 探测失败 ≠ 没有盘点。保持 activeSession 不变并把界面切到「重试」,
|
||||
// 宁可挡住也不能让库管误开新会话。
|
||||
probeFailed.value = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -1428,6 +1449,13 @@ const goToVarianceReview = () => {
|
||||
color: #909399;
|
||||
text-align: center;
|
||||
}
|
||||
/* 探测失败提示 */
|
||||
.probe-failed {
|
||||
font-size: 13px;
|
||||
color: #e6a23c;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
}
|
||||
/* 场景 A 的进度提示与次要入口 */
|
||||
.active-session-tip {
|
||||
font-size: 12px;
|
||||
|
||||
Reference in New Issue
Block a user