This commit is contained in:
2026-09-21 11:17:11 +08:00
parent 3e8fa3c5d7
commit e6771e8e86
3 changed files with 31 additions and 6 deletions
@@ -381,4 +381,5 @@ describe('InboundFeePanel', () => {
expect(document.body.textContent).toContain('系统已刷新最新快照')
expect(document.body.textContent).toContain('当前输入仍保留')
})
})
+29 -6
View File
@@ -47,6 +47,7 @@ const loadError = ref<ApiErrorDetails | null>(null)
const adjustmentError = ref<ApiErrorDetails | null>(null)
const conflictRefreshed = ref(false)
const snapshot = ref<InboundFeeSnapshot | null>(null)
const hasLoadedOnce = ref(false)
const adjustOpen = ref(false)
const trialOpen = ref(false)
const trialLoading = ref(false)
@@ -183,12 +184,25 @@ async function loadFee(options: { preserveAdjustment?: boolean } = {}) {
if (!options.preserveAdjustment && adjustOpen.value) fillAdjustmentForm(result)
} catch (error) {
if (sequence !== loadSequence) return
snapshot.value = null
emit('loaded', null)
if (error instanceof ApiResponseError && error.code === 'A0404') notFound.value = true
else loadError.value = getApiErrorDetails(error, '费用快照加载失败,请稍后重试')
const hadSnapshot = Boolean(snapshot.value)
if (error instanceof ApiResponseError && error.code === 'A0404') {
notFound.value = !hadSnapshot
if (!hadSnapshot) {
snapshot.value = null
emit('loaded', null)
}
} else {
loadError.value = getApiErrorDetails(error, '费用快照加载失败,请稍后重试')
if (!hadSnapshot) {
snapshot.value = null
emit('loaded', null)
}
}
} finally {
if (sequence === loadSequence) loading.value = false
if (sequence === loadSequence) {
loading.value = false
hasLoadedOnce.value = true
}
}
}
@@ -353,6 +367,7 @@ watch(
() => {
adjustOpen.value = false
snapshot.value = null
hasLoadedOnce.value = false
void loadFee()
},
{ immediate: true },
@@ -435,11 +450,18 @@ defineExpose({ reload: loadFee })
<p>需要权限:firstleg:fba-pricing:view</p>
</el-alert>
<div v-else-if="loading && !snapshot" class="fee-loading" aria-live="polite">
<div v-else-if="loading && !snapshot && !hasLoadedOnce" class="fee-loading" aria-live="polite">
<el-skeleton :rows="6" animated />
<span class="sr-only">正在加载费用快照</span>
</div>
<el-alert v-if="loadError && snapshot" class="fee-refresh-error" type="error" :closable="false" show-icon role="status">
<template #title>最新费用快照暂时无法刷新,当前仍显示上一版快照
</template>
<p>{{ loadError.message }}</p>
<ApiErrorMeta :details="loadError" />
</el-alert>
<el-alert v-else-if="loadError" type="error" :closable="false" show-icon role="alert">
<template #title>费用快照加载失败</template>
<p>{{ loadError.message }}</p>
@@ -597,6 +619,7 @@ defineExpose({ reload: loadFee })
.fee-heading-actions .el-button { margin-left: 0; }
.fee-refresh-button .is-spinning { animation: fee-refresh-spin 0.8s linear infinite; }
.fee-loading { padding: 20px 0; }
.fee-refresh-error { margin-bottom: 10px; }
.inbound-fee-panel :deep(.el-alert p) { margin: 5px 0 0; line-height: 1.55; }
.inbound-fee-panel :deep(.el-alert .el-button) { margin-top: 8px; }
.empty-note { margin: 0; color: var(--cc-muted); font-size: 12px; }