fix(frontend): 批量删除不再逐条弹框/逐条刷新,删完统一报一次总数
This commit is contained in:
@@ -1699,8 +1699,8 @@ async function downloadResult(item: PriceTrackHistoryItem) {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteTaskRecord(item: PriceTrackHistoryItem) {
|
||||
if (!(await confirmTaskDeletion(item))) return
|
||||
async function deleteTaskRecord(item: PriceTrackHistoryItem, opts: { skipConfirm?: boolean; silent?: boolean } = {}) {
|
||||
if (!opts.skipConfirm && !(await confirmTaskDeletion(item))) return
|
||||
try {
|
||||
if (item.resultId != null) {
|
||||
await deletePriceTrackHistory(item.resultId)
|
||||
@@ -1712,6 +1712,7 @@ async function deleteTaskRecord(item: PriceTrackHistoryItem) {
|
||||
}
|
||||
if (item.taskId != null) removePollingTask(item.taskId)
|
||||
removeMatchedRowsLocally([item])
|
||||
if (opts.silent) return
|
||||
await loadHistory()
|
||||
await loadDashboard()
|
||||
syncPollingIdsWithHistory()
|
||||
@@ -1721,11 +1722,13 @@ async function deleteTaskRecord(item: PriceTrackHistoryItem) {
|
||||
if (item.taskId != null) removePollingTask(item.taskId)
|
||||
removeMatchedRowsLocally([item])
|
||||
removeHistoryItemLocally(item)
|
||||
if (opts.silent) return
|
||||
await loadDashboard()
|
||||
syncPollingIdsWithHistory()
|
||||
ElMessage.success('记录已不存在,已同步移除本地记录')
|
||||
return
|
||||
}
|
||||
if (opts.silent) throw e
|
||||
ElMessage.error(e instanceof Error ? e.message : '删除失败')
|
||||
}
|
||||
}
|
||||
@@ -1773,13 +1776,16 @@ onUnmounted(() => {
|
||||
})
|
||||
|
||||
/**
|
||||
* 历史记录批量删除:复用单条删除逻辑(删除后原函数各自刷新列表)
|
||||
* 历史记录批量删除:复用单条删除逻辑(silent 模式逐条不弹框、不逐条刷新)。
|
||||
* 批量入口已确认过一次,全部删完统一刷新一次、只报一次总数。
|
||||
*/
|
||||
async function batchDeleteHistory(views: TaskItemView[]) {
|
||||
const { total, failed } = await runBatchDelete(views, (view) => deleteTaskRecord(itemSource(view)))
|
||||
const { total, failed } = await runBatchDelete(views, (view) => deleteTaskRecord(itemSource(view), { skipConfirm: true, silent: true }))
|
||||
if (!total) return
|
||||
await Promise.allSettled([loadHistory(), loadDashboard()])
|
||||
syncPollingIdsWithHistory()
|
||||
if (failed > 0) {
|
||||
ElMessage.warning(`删除完成,${failed} 条失败`)
|
||||
ElMessage.warning(`删除完成:成功 ${total - failed} 条,失败 ${failed} 条`)
|
||||
} else {
|
||||
ElMessage.success(`已删除 ${total} 条历史记录`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user