fix: 在回收站标签页全选,执行批量删除操作时 相应的删除功能没有实现
This commit is contained in:
parent
916a326183
commit
db8fd19be6
@ -489,23 +489,52 @@ async function handleDeleteSelected() {
|
||||
if (selectedKeys.value.length === 0) return
|
||||
const previewWasInSelection = previewName.value && selectedKeys.value.includes(previewName.value)
|
||||
const removedIdx = previewWasInSelection ? rows.value.findIndex(r => r.name === previewName.value) : -1
|
||||
loading.value = true
|
||||
try {
|
||||
for (const name of selectedKeys.value) {
|
||||
try {
|
||||
await api.call('jingrow.email.inbox.mark_as_trash', { email: name })
|
||||
} catch { /* skip failed */ }
|
||||
const isDeletableFilter = activeFilter.value === 'spam' || activeFilter.value === 'trash'
|
||||
|
||||
if (isDeletableFilter) {
|
||||
// In spam/trash: permanent delete with confirmation
|
||||
dialog.warning({
|
||||
title: t('Delete Permanently'),
|
||||
content: t('Are you sure you want to delete permanently? This action cannot be undone.'),
|
||||
positiveText: t('Delete Permanently'),
|
||||
negativeText: t('Cancel'),
|
||||
onPositiveClick: async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
await deleteRecords(entity.value, selectedKeys.value)
|
||||
message.success(t('Deleted permanently'))
|
||||
selectedKeys.value = []
|
||||
await loadData()
|
||||
if (previewWasInSelection) {
|
||||
previewNextOrClose(previewName.value, removedIdx)
|
||||
}
|
||||
} catch {
|
||||
message.error(t('Delete failed'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// In other tabs: move to trash
|
||||
loading.value = true
|
||||
try {
|
||||
for (const name of selectedKeys.value) {
|
||||
try {
|
||||
await api.call('jingrow.email.inbox.mark_as_trash', { email: name })
|
||||
} catch { /* skip failed */ }
|
||||
}
|
||||
message.success(t('Moved to trash'))
|
||||
selectedKeys.value = []
|
||||
await loadData()
|
||||
if (previewWasInSelection) {
|
||||
previewNextOrClose(previewName.value, removedIdx)
|
||||
}
|
||||
} catch {
|
||||
message.error(t('Operation failed'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
message.success(t('Moved to trash'))
|
||||
selectedKeys.value = []
|
||||
await loadData()
|
||||
if (previewWasInSelection) {
|
||||
previewNextOrClose(previewName.value, removedIdx)
|
||||
}
|
||||
} catch {
|
||||
message.error(t('Operation failed'))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,6 +669,15 @@ async function refreshPreview() {
|
||||
if (!currentName) return
|
||||
// Capture index before reload (in case the record gets removed from current view)
|
||||
const currentIdx = rows.value.findIndex(r => r.name === currentName)
|
||||
// Refresh the left list first
|
||||
await loadData()
|
||||
// If the current record is no longer in the list (e.g., permanently deleted, marked as spam/trash/restored),
|
||||
// auto-navigate to the next record without trying to reload the removed record
|
||||
if (!rows.value.some(r => r.name === currentName)) {
|
||||
previewNextOrClose(currentName, currentIdx)
|
||||
return
|
||||
}
|
||||
// Record still in list, reload its detail
|
||||
try {
|
||||
const [recordRes, attachmentsRes] = await Promise.all([
|
||||
getRecord(entity.value, currentName),
|
||||
@ -652,13 +690,6 @@ async function refreshPreview() {
|
||||
}
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
// Refresh the left list
|
||||
await loadData()
|
||||
// If the current record is no longer in the list (e.g., marked as spam/trash/restored),
|
||||
// auto-navigate to the next record
|
||||
if (!rows.value.some(r => r.name === currentName)) {
|
||||
previewNextOrClose(currentName, currentIdx)
|
||||
}
|
||||
}
|
||||
|
||||
async function navigatePreview(name: string) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user