feat(admin): 为支持单删的管理列表补齐批量删除

This commit is contained in:
2026-11-20 12:08:28 +08:00
parent 132c19d51f
commit 51c41b238a
43 changed files with 2806 additions and 1948 deletions
@@ -0,0 +1,36 @@
<script setup lang="ts">
defineProps<{
batch: {
verb: string
count: number
disabled: boolean
progress: string
result: { failures: ReadonlyArray<{ id: number | string; label: string; reason: string }> } | null
submit: () => Promise<void>
clearSelection: () => void
}
}>()
</script>
<template>
<div class="batch-delete-actions">
<button class="btn btn-danger" type="button" :disabled="batch.disabled || !batch.count" @click="batch.submit">
{{ batch.progress ? `正在${batch.verb} ${batch.progress}` : `批量${batch.verb}(${batch.count})` }}
</button>
<button v-if="batch.count" class="btn btn-sm" type="button" :disabled="batch.disabled" @click="batch.clearSelection">清除勾选</button>
<details v-if="batch.result?.failures.length" class="batch-delete-failures">
<summary>查看失败原因({{ batch.result.failures.length }} 条)</summary>
<ul>
<li v-for="failure in batch.result.failures" :key="failure.id">{{ failure.label }}:{{ failure.reason }}</li>
</ul>
</details>
</div>
</template>
<style scoped>
.batch-delete-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.batch-delete-actions .btn-danger { color: #fff; background: #b35f6a; border-color: #b35f6a; }
.batch-delete-actions button:disabled { cursor: not-allowed; opacity: 0.55; }
.batch-delete-failures { max-width: 520px; color: #9f3845; overflow-wrap: anywhere; }
.batch-delete-failures ul { max-height: 180px; overflow: auto; margin: 4px 0; padding-left: 20px; }
</style>
@@ -0,0 +1,20 @@
<script setup lang="ts">
defineProps<{
label: string
checked: boolean
disabled: boolean
partial?: boolean
}>()
defineEmits<{ change: [] }>()
</script>
<template>
<input class="batch-delete-checkbox" type="checkbox" :aria-label="label" :title="label"
:checked="checked" :disabled="disabled" :indeterminate="partial ?? false" @change.stop="$emit('change')" @click.stop />
</template>
<style scoped>
.batch-delete-checkbox { width: 15px; height: 15px; vertical-align: middle; cursor: pointer; accent-color: #b33a2e; }
.batch-delete-checkbox:disabled { cursor: not-allowed; }
</style>