diff --git a/frontend/src/views/systemMonitor/diskMonitor/index.vue b/frontend/src/views/systemMonitor/diskMonitor/index.vue index 2f00bcd..98c1ae7 100644 --- a/frontend/src/views/systemMonitor/diskMonitor/index.vue +++ b/frontend/src/views/systemMonitor/diskMonitor/index.vue @@ -28,8 +28,13 @@ @confirm="confirmTarget" /> - - + + @@ -76,6 +81,7 @@ const jobList = ref([]) const jobDetailVisible = ref(false) const jobDetail = ref(null) const detailLoading = ref(false) +const jobDetailRequestSeq = ref(0) const loading = reactive({ init: false, save: false, @@ -148,7 +154,6 @@ const removeTarget = (index: number) => { const loadPolicyDetail = async () => { const response = await getDiskMonitorPolicyDetail() const detail = response.data - if (!detail) return policyForm.value = detail.policy || createDefaultPolicy() @@ -159,12 +164,16 @@ const loadPolicyDetail = async () => { const loadJobList = async () => { loading.jobs = true try { - // 统一拉取最近任务列表,并复用首条记录更新摘要卡片 + // 统一拉取最近任务列表,并按 startedAt 倒序确保摘要展示真实最新任务 const response = await getDiskMonitorJobList({ pageNum: 1, pageSize: 10 }) - const records = response.data?.records || [] + const records = [...(response.data?.records || [])].sort((a, b) => { + const first = new Date(a.startedAt).getTime() + const second = new Date(b.startedAt).getTime() + return second - first + }) jobList.value = records latestJob.value = records[0] || null } finally { @@ -172,16 +181,32 @@ const loadJobList = async () => { } } +const handleJobDetailVisibleChange = (visible: boolean) => { + jobDetailVisible.value = visible + if (!visible) { + // 抽屉关闭时让旧请求全部失效,避免回写已关闭的详情状态 + jobDetailRequestSeq.value += 1 + detailLoading.value = false + jobDetail.value = null + } +} + const openJobDetail = async (row: DiskMonitor.JobListItem) => { + const currentSeq = jobDetailRequestSeq.value + 1 + jobDetailRequestSeq.value = currentSeq jobDetailVisible.value = true jobDetail.value = null detailLoading.value = true + try { - // 点击明细时按任务 ID 拉取完整执行结果与通知日志 + // 仅允许最新一次详情请求回写,避免快速切换任务导致脏数据覆盖 const response = await getDiskMonitorJobDetail(row.id) + if (currentSeq !== jobDetailRequestSeq.value || !jobDetailVisible.value) return jobDetail.value = response.data || null } finally { - detailLoading.value = false + if (currentSeq === jobDetailRequestSeq.value) { + detailLoading.value = false + } } }