优化
This commit is contained in:
@@ -45,15 +45,7 @@
|
||||
</a-button>
|
||||
|
||||
<!-- 删除按钮 -->
|
||||
<a-popconfirm
|
||||
v-if="canDelete"
|
||||
title="确定删除这个任务吗?删除后无法恢复。"
|
||||
@confirm="handleDelete"
|
||||
>
|
||||
<a-button size="small" danger>
|
||||
删除
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
<a-button size="small" danger @click="handleDelete">删除</a-button>
|
||||
|
||||
<!-- 插槽用于自定义操作 -->
|
||||
<slot name="extra" :task="task"></slot>
|
||||
@@ -125,11 +117,6 @@ const canRetry = computed(() => {
|
||||
return props.task.status === 'failed'
|
||||
})
|
||||
|
||||
// 计算属性:是否可删除
|
||||
const canDelete = computed(() => {
|
||||
return true // 所有任务都可以删除
|
||||
})
|
||||
|
||||
// 处理预览
|
||||
const handlePreview = async () => {
|
||||
if (getSignedUrlsApi) {
|
||||
@@ -162,8 +149,7 @@ const handleDelete = () => {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 确保按钮内的图标和文字对齐 */
|
||||
<style scoped lang="less">
|
||||
:deep(.ant-btn .anticon) {
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
@@ -48,11 +48,9 @@
|
||||
<div v-if="selectedRowKeys.length > 0" class="batch-actions">
|
||||
<a-alert :message="`已选中 ${selectedRowKeys.length} 项`" type="info" show-icon>
|
||||
<template #action>
|
||||
<a-popconfirm title="确定要删除选中的任务吗?" @confirm="handleBatchDelete">
|
||||
<a-button size="small" danger>
|
||||
<DeleteOutlined /> 批量删除
|
||||
</a-button>
|
||||
</a-popconfirm>
|
||||
<a-button size="small" danger @click="confirmBatchDelete">
|
||||
<DeleteOutlined /> 批量删除
|
||||
</a-button>
|
||||
</template>
|
||||
</a-alert>
|
||||
</div>
|
||||
@@ -83,7 +81,7 @@
|
||||
<div class="progress-cell">
|
||||
<a-progress
|
||||
:percent="record.progress"
|
||||
:status="PROGRESS_STATUS[record.status]"
|
||||
:status="PROGRESS_STATUS[record.status?.toLowerCase()] || 'normal'"
|
||||
size="small"
|
||||
:show-info="false"
|
||||
/>
|
||||
@@ -117,9 +115,7 @@
|
||||
取消
|
||||
</a-button>
|
||||
|
||||
<a-popconfirm title="确定删除?删除后无法恢复。" @confirm="handleDelete(record.id)">
|
||||
<a-button type="link" size="small" class="action-btn action-btn--danger">删除</a-button>
|
||||
</a-popconfirm>
|
||||
<a-button type="link" size="small" class="action-btn action-btn--danger" @click="handleDelete(record.id)">删除</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
@@ -131,7 +127,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { SearchOutlined, DownloadOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { getDigitalHumanTaskPage, cancelTask, deleteTask } from '@/api/digitalHuman'
|
||||
import { formatDate } from '@/utils/file'
|
||||
@@ -142,8 +138,11 @@ import TaskStatusTag from '@/views/system/task-management/components/TaskStatusT
|
||||
|
||||
// 进度状态映射
|
||||
const PROGRESS_STATUS = {
|
||||
pending: 'normal', running: 'active', success: 'success', failed: 'exception', canceled: 'normal',
|
||||
PENDING: 'normal', RUNNING: 'active', SUCCESS: 'success', FAILED: 'exception', CANCELED: 'normal'
|
||||
pending: 'normal',
|
||||
running: 'active',
|
||||
success: 'success',
|
||||
failed: 'exception',
|
||||
canceled: 'normal'
|
||||
}
|
||||
|
||||
// Composables
|
||||
@@ -185,6 +184,18 @@ const handleBatchDelete = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 确认批量删除
|
||||
const confirmBatchDelete = () => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '确定要删除选中的任务吗?',
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
okType: 'danger',
|
||||
onOk: handleBatchDelete
|
||||
})
|
||||
}
|
||||
|
||||
// 表格列定义
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id', key: 'id', width: 80, fixed: 'left' },
|
||||
|
||||
@@ -124,9 +124,7 @@
|
||||
重试
|
||||
</a-button>
|
||||
|
||||
<a-popconfirm title="确定删除?删除后无法恢复。" @confirm="handleDelete(record.id)">
|
||||
<a-button type="link" size="small" class="action-btn action-btn--danger">删除</a-button>
|
||||
</a-popconfirm>
|
||||
<a-button type="link" size="small" class="action-btn action-btn--danger" @click="handleDelete(record.id)">删除</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
@@ -191,6 +189,7 @@
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { SearchOutlined, PlayCircleOutlined, DownloadOutlined } from '@ant-design/icons-vue'
|
||||
import { Modal } from 'ant-design-vue'
|
||||
import { MixTaskService } from '@/api/mixTask'
|
||||
import { formatDate } from '@/utils/file'
|
||||
import { useTaskList } from '@/views/system/task-management/composables/useTaskList'
|
||||
@@ -214,17 +213,19 @@ const handleExpandedRowsChange = (keys) => { expandedRowKeys.value = keys }
|
||||
const preview = reactive({ visible: false, title: '', url: '' })
|
||||
|
||||
// 状态判断
|
||||
const isStatus = (status, target) => status === target || status === target.toUpperCase()
|
||||
const isStatus = (status, target) => status?.toLowerCase() === target.toLowerCase()
|
||||
|
||||
const canOperate = (record, action) => {
|
||||
const isSuccess = isStatus(record.status, 'success')
|
||||
const hasUrls = record.outputUrls?.length > 0
|
||||
const actions = {
|
||||
preview: isSuccess && hasUrls,
|
||||
download: isSuccess && hasUrls,
|
||||
cancel: isStatus(record.status, 'running'),
|
||||
retry: isStatus(record.status, 'failed')
|
||||
const hasOutput = record.outputUrls?.length > 0
|
||||
|
||||
switch (action) {
|
||||
case 'preview': return isSuccess && hasOutput
|
||||
case 'download': return isSuccess && hasOutput
|
||||
case 'cancel': return isStatus(record.status, 'running')
|
||||
case 'retry': return isStatus(record.status, 'failed')
|
||||
default: return false
|
||||
}
|
||||
return actions[action]
|
||||
}
|
||||
|
||||
// 预览视频
|
||||
@@ -261,7 +262,9 @@ const downloadVideo = async (taskId, index) => {
|
||||
}
|
||||
|
||||
const handleDownload = (record) => {
|
||||
if (record.outputUrls?.length) handleBatchDownload([], MixTaskService.getSignedUrls, record.id)
|
||||
if (record.outputUrls?.length) {
|
||||
handleBatchDownload(record.outputUrls, MixTaskService.getSignedUrls, record.id)
|
||||
}
|
||||
}
|
||||
|
||||
// 表格列定义
|
||||
@@ -416,10 +419,4 @@ onMounted(fetchList)
|
||||
:deep(.ant-btn .anticon) {
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
/* 修复 popconfirm 按钮对齐 */
|
||||
:deep(.ant-popover .ant-popover-buttons) {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -171,7 +171,6 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="user-name">{{ userStore.displayName }}</h2>
|
||||
<div class="user-id">ID: {{ userStore.userId || '未设置' }}</div>
|
||||
<div class="user-role-badge">普通用户</div>
|
||||
</div>
|
||||
|
||||
@@ -370,14 +369,8 @@ onMounted(async () => {
|
||||
.user-name {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.user-id {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 13px;
|
||||
margin-bottom: 12px;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.user-role-badge {
|
||||
|
||||
Reference in New Issue
Block a user