feat: add download button to Tables/Images views, add task history delete/clear-all
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
<template #prefix><el-icon><Search /></el-icon></template>
|
||||
</el-input>
|
||||
<el-button size="small" @click="loadData" :icon="Refresh">刷新</el-button>
|
||||
<el-button size="small" type="danger" @click="clearAllTasks">清除全部</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -88,10 +89,11 @@
|
||||
<span class="time-cell">{{ formatTime(row.created_at) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="140" fixed="right">
|
||||
<el-table-column label="操作" width="180" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link size="small" @click="showDetail(row)">详情</el-button>
|
||||
<el-button v-if="row.status === 'failed'" type="warning" link size="small" @click="retryTask(row)">重试</el-button>
|
||||
<el-button type="danger" link size="small" @click="deleteTask(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -137,7 +139,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, onUnmounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Timer, CircleCheck, CircleClose, Loading, Search, Refresh } from '@element-plus/icons-vue'
|
||||
import api from '../api'
|
||||
import { useDebounce } from '../composables/useDebounce'
|
||||
@@ -214,6 +216,30 @@ async function copyPath(text: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteTask(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定删除任务 #${row.id}?`, '确认删除')
|
||||
await api.delete(`/tasks/${row.id}`)
|
||||
ElMessage.success('已删除')
|
||||
loadData()
|
||||
loadStats()
|
||||
} catch (err: any) {
|
||||
if (err !== 'cancel') ElMessage.error(err.response?.data?.detail || '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function clearAllTasks() {
|
||||
try {
|
||||
await ElMessageBox.confirm('确定清除所有任务历史记录?此操作不可撤销。', '确认清除', { type: 'warning' })
|
||||
await api.delete('/tasks')
|
||||
ElMessage.success('已清除所有任务历史')
|
||||
loadData()
|
||||
loadStats()
|
||||
} catch (err: any) {
|
||||
if (err !== 'cancel') ElMessage.error(err.response?.data?.detail || '清除失败')
|
||||
}
|
||||
}
|
||||
|
||||
async function retryTask(row: any) {
|
||||
try {
|
||||
await api.post(`/tasks/${row.id}/retry`)
|
||||
|
||||
@@ -81,10 +81,11 @@
|
||||
<span class="time-text">{{ fmtTime(row.created_at) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="320" fixed="right">
|
||||
<el-table-column label="操作" width="370" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click="previewFile(row)">预览</el-button>
|
||||
<el-button link type="primary" size="small" @click="showDetail(row)">详情</el-button>
|
||||
<el-button link type="primary" size="small" @click="downloadFile(row)">下载</el-button>
|
||||
<el-button link type="primary" size="small" @click="pipelineFile(row)">生成采购单</el-button>
|
||||
<el-button link type="primary" size="small" @click="ocrFile(row)">仅OCR</el-button>
|
||||
<el-button link type="danger" size="small" @click="deleteFile(row)">删除</el-button>
|
||||
|
||||
@@ -78,10 +78,11 @@
|
||||
<span class="time-text">{{ fmtTime(row.created_at) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="280" fixed="right">
|
||||
<el-table-column label="操作" width="320" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click="previewFile(row)">预览</el-button>
|
||||
<el-button link type="primary" size="small" @click="showDetail(row)">详情</el-button>
|
||||
<el-button link type="primary" size="small" @click="downloadFile(row)">下载</el-button>
|
||||
<el-button link type="primary" size="small" @click="processFile(row)">处理</el-button>
|
||||
<el-button link type="danger" size="small" @click="deleteFile(row)">删除</el-button>
|
||||
</template>
|
||||
@@ -210,6 +211,15 @@ async function processFile(row: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadFile(row: any) {
|
||||
const token = localStorage.getItem('token')
|
||||
if (row.output_excel) {
|
||||
window.open(`/api/files/download/output/${encodeURIComponent(row.output_excel)}?token=${token}`, '_blank')
|
||||
} else if (row.result_purchase) {
|
||||
window.open(`/api/files/download/result/${encodeURIComponent(row.result_purchase)}?token=${token}`, '_blank')
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteFile(row: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(`确定删除 ${row.output_excel}?`, '确认')
|
||||
|
||||
Reference in New Issue
Block a user