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'
/** 日志管理页:桌面客户端 / 麦象采集机上报的日志浏览(仅超管)。
* 支持来源/用户/日期筛选,尾部内容查看(自动滚到底、可向前加载更早内容)、
* 完整下载、删除;「采集配置」可调全量/精选模式(全局默认 + 终端覆盖)。 */
@@ -191,10 +194,23 @@ function loadMore() {
loadContent(false)
}
const batch = useRowSelection({
pageRows: () => rows.value,
rowId: (row) => row.id,
rowLabel: (row) => row.fileName,
deleteOne: (id) => deleteDeviceLogFile(id),
refresh: load,
blocked: () => loading.value || !!loadFailure.value,
scope: () => companyTab.activeId,
consequence: '将删除所选云端日志,此操作不可恢复。',
})
async function remove(row: DeviceLogFileRow) {
if (batch.busy) return
if (!(await openAdminConfirm({ message: `确认删除「${row.fileName}」(${row.deviceName || row.deviceId})的云端日志?删除后不可恢复。`, danger: true }))) return
try {
await deleteDeviceLogFile(row.id)
batch.removeFromSelection(row.id)
ElMessage.success('已删除')
load()
} catch (error) {
@@ -339,10 +355,15 @@ onMounted(() => {
</div>
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
<BatchDeleteActions :batch="batch" />
<div class="logs-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: 110px">来源</th>
<th style="width: 200px">用户</th>
<th style="width: 230px">文件名</th>
@@ -355,7 +376,11 @@ onMounted(() => {
</thead>
<tbody>
<template v-if="rows.length">
<tr v-for="row in rows" :key="row.id">
<tr v-for="row in rows" :key="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="source-pill" :class="row.source === 'maixiang' ? 'is-maixiang' : 'is-client'">
{{ sourceLabel(row.source) }}
@@ -376,15 +401,15 @@ onMounted(() => {
<td class="ops-cell">
<button class="btn btn-sm" type="button" @click="openViewer(row)">查看</button>
<a class="btn btn-sm btn-ghost dl-link" :href="deviceLogDownloadUrl(row.id)" download>下载</a>
<button class="btn btn-sm btn-danger" type="button" @click="remove(row)">删除</button>
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @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">
<td colspan="9" class="empty-tip">
{{ sourceFilter || uidFilter ? '暂无匹配日志' : '暂无日志上报(客户端/采集机上报后自动出现在这里)' }}
</td>
</tr>
@@ -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>