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
@@ -1,4 +1,7 @@
<script setup lang="ts">
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
import { useRowSelection } from '@/utils/use-row-selection'
/** 数字人版本管理页 · 像素复刻旧版 admin.html panel-digital-human-version(自绘:面板头+上传、三态状态色、最新★、操作矩阵、数字页码分页)。
* script 逻辑沿用现有 Vue 实现(确认文案/上传进度/下载取链接);确认走原生 confirm 对齐旧版。 */
import { formatDateTime } from '@/utils/datetime'
@@ -182,13 +185,25 @@ async function download(row: DigitalHumanVersion) {
}
}
const batch = useRowSelection({
pageRows: () => pagedItems.value,
rowId: (row) => row.version,
rowLabel: (row) => row.version,
deleteOne: (id) => deleteDigitalHumanVersion(id),
refresh: load,
blocked: () => loading.value || confirming.value != null || !!loadFailure.value,
precheck: (row) => canDelete(row) ? undefined : '不能删除当前最新版本',
})
async function remove(row: DigitalHumanVersion) {
if (batch.busy) return
const text = digitalHumanDeleteConfirmText(row.version)
if (!text) return
if (!(await openAdminConfirm({ message: text, danger: true }))) return
confirming.value = row.version
try {
await deleteDigitalHumanVersion(row.version)
batch.removeFromSelection(row.version)
ElMessage.success('删除成功')
load()
} catch (error) {
@@ -221,10 +236,15 @@ onMounted(load)
</div>
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
<BatchDeleteActions :batch="batch" />
<div class="table-scroll digital-human-version-table-scroll">
<table>
<thead>
<tr>
<th class="batch-delete-cell" scope="col">
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
</th>
<th style="width: 80px">版本号</th>
<th style="width: 60px">状态</th>
<th style="width: 60px">最新</th>
@@ -237,7 +257,11 @@ onMounted(load)
</thead>
<tbody>
<template v-if="pagedItems.length">
<tr v-for="row in pagedItems" :key="row.version + row.id">
<tr v-for="row in pagedItems" :key="row.version + row.id" :class="{ 'batch-selected': batch.isSelected(row) }">
<td class="batch-delete-cell">
<BatchDeleteCheckbox :label="batch.reason(row) || `选择 ${batch.label(row)}`" :checked="batch.isSelected(row)"
:disabled="batch.disabled || !!batch.reason(row)" @change="batch.toggle(row)" />
</td>
<td><span class="mono-cell">{{ row.version }}</span></td>
<td>
<span class="st-pill" :class="`is-${statusOf(row).tag}`">{{ statusOf(row).text }}</span>
@@ -261,15 +285,15 @@ onMounted(load)
设为最新
</button>
<button v-if="canSetLatestDigitalHumanVersion(row.status)" class="btn btn-sm btn-secondary" type="button" :disabled="downloadingVersion === row.version" @click="download(row)">下载</button>
<button v-if="canDelete(row)" class="btn btn-sm btn-danger" type="button" :disabled="confirming === row.version" @click="remove(row)">删除</button>
<button v-if="canDelete(row)" class="btn btn-sm btn-danger" type="button" :disabled="batch.busy || confirming === row.version" @click="remove(row)">删除</button>
</td>
</tr>
</template>
<tr v-else-if="loading">
<td colspan="8" class="empty-tip">加载中...</td>
<td colspan="9" class="empty-tip">加载中...</td>
</tr>
<tr v-else>
<td colspan="8" class="empty-tip">{{ versionKeyword ? '暂无匹配版本' : '暂无版本记录' }}</td>
<td colspan="9" class="empty-tip">{{ versionKeyword ? '暂无匹配版本' : '暂无版本记录' }}</td>
</tr>
</tbody>
</table>