fix: harden disk monitor job interactions
This commit is contained in:
@@ -28,8 +28,13 @@
|
|||||||
@confirm="confirmTarget"
|
@confirm="confirmTarget"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DiskMonitorJobTable :rows="jobList" :loading="loading.jobs" @refresh="loadPageData" @detail="openJobDetail" />
|
<DiskMonitorJobTable :rows="jobList" :loading="loading.jobs" @refresh="loadJobList" @detail="openJobDetail" />
|
||||||
<DiskMonitorJobDetailDrawer v-model:visible="jobDetailVisible" :detail="jobDetail" :loading="detailLoading" />
|
<DiskMonitorJobDetailDrawer
|
||||||
|
:visible="jobDetailVisible"
|
||||||
|
:detail="jobDetail"
|
||||||
|
:loading="detailLoading"
|
||||||
|
@update:visible="handleJobDetailVisibleChange"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -76,6 +81,7 @@ const jobList = ref<DiskMonitor.JobListItem[]>([])
|
|||||||
const jobDetailVisible = ref(false)
|
const jobDetailVisible = ref(false)
|
||||||
const jobDetail = ref<DiskMonitor.JobDetailData | null>(null)
|
const jobDetail = ref<DiskMonitor.JobDetailData | null>(null)
|
||||||
const detailLoading = ref(false)
|
const detailLoading = ref(false)
|
||||||
|
const jobDetailRequestSeq = ref(0)
|
||||||
const loading = reactive({
|
const loading = reactive({
|
||||||
init: false,
|
init: false,
|
||||||
save: false,
|
save: false,
|
||||||
@@ -148,7 +154,6 @@ const removeTarget = (index: number) => {
|
|||||||
const loadPolicyDetail = async () => {
|
const loadPolicyDetail = async () => {
|
||||||
const response = await getDiskMonitorPolicyDetail()
|
const response = await getDiskMonitorPolicyDetail()
|
||||||
const detail = response.data
|
const detail = response.data
|
||||||
|
|
||||||
if (!detail) return
|
if (!detail) return
|
||||||
|
|
||||||
policyForm.value = detail.policy || createDefaultPolicy()
|
policyForm.value = detail.policy || createDefaultPolicy()
|
||||||
@@ -159,12 +164,16 @@ const loadPolicyDetail = async () => {
|
|||||||
const loadJobList = async () => {
|
const loadJobList = async () => {
|
||||||
loading.jobs = true
|
loading.jobs = true
|
||||||
try {
|
try {
|
||||||
// 统一拉取最近任务列表,并复用首条记录更新摘要卡片
|
// 统一拉取最近任务列表,并按 startedAt 倒序确保摘要展示真实最新任务
|
||||||
const response = await getDiskMonitorJobList({
|
const response = await getDiskMonitorJobList({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10
|
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
|
jobList.value = records
|
||||||
latestJob.value = records[0] || null
|
latestJob.value = records[0] || null
|
||||||
} finally {
|
} 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 openJobDetail = async (row: DiskMonitor.JobListItem) => {
|
||||||
|
const currentSeq = jobDetailRequestSeq.value + 1
|
||||||
|
jobDetailRequestSeq.value = currentSeq
|
||||||
jobDetailVisible.value = true
|
jobDetailVisible.value = true
|
||||||
jobDetail.value = null
|
jobDetail.value = null
|
||||||
detailLoading.value = true
|
detailLoading.value = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 点击明细时按任务 ID 拉取完整执行结果与通知日志
|
// 仅允许最新一次详情请求回写,避免快速切换任务导致脏数据覆盖
|
||||||
const response = await getDiskMonitorJobDetail(row.id)
|
const response = await getDiskMonitorJobDetail(row.id)
|
||||||
|
if (currentSeq !== jobDetailRequestSeq.value || !jobDetailVisible.value) return
|
||||||
jobDetail.value = response.data || null
|
jobDetail.value = response.data || null
|
||||||
} finally {
|
} finally {
|
||||||
detailLoading.value = false
|
if (currentSeq === jobDetailRequestSeq.value) {
|
||||||
|
detailLoading.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user