feat(frontend): 完善数据任务数量与状态
This commit is contained in:
@@ -3,10 +3,11 @@ import { onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import DataTablePage from '@/components/DataTablePage.vue'
|
||||
import ModelStatusTag from '@/components/ModelStatusTag.vue'
|
||||
import { deleteDataProcessTask, getDataProcessTasks } from '@/api/modules/dataProcess'
|
||||
import type { DataProcessTask, DataProcessType } from '@/types/dataProcess'
|
||||
|
||||
type TaskStatusTagType = 'success' | 'warning' | 'info' | 'danger' | 'primary'
|
||||
|
||||
const processTypeMap: Record<DataProcessType, string> = {
|
||||
structured: '结构化数据',
|
||||
unstructured: '非结构化数据',
|
||||
@@ -73,12 +74,30 @@ function formatDateTime(value?: string) {
|
||||
return Number.isNaN(date.getTime()) ? value : date.toLocaleString('zh-CN', { hour12: false })
|
||||
}
|
||||
|
||||
function sourceDatasetName(task: DataProcessTask) {
|
||||
return task.source_dataset_name || task.source_dataset || '-'
|
||||
function safeCount(value: unknown) {
|
||||
const count = Number(value)
|
||||
return Number.isFinite(count) ? Math.max(0, Math.trunc(count)) : 0
|
||||
}
|
||||
|
||||
function outputDatasetName(task: DataProcessTask) {
|
||||
return task.output_dataset_name || task.output_dataset || '-'
|
||||
function documentCountLabel(task: DataProcessTask) {
|
||||
return `${safeCount(task.source_file_count)} 个`
|
||||
}
|
||||
|
||||
function generatedCountLabel(task: DataProcessTask) {
|
||||
return `${safeCount(task.output_count)} 条`
|
||||
}
|
||||
|
||||
/** 将当前轮生成状态与发布指针合并为用户可理解的列表状态。 */
|
||||
function taskDisplayStatus(task: DataProcessTask): { label: string; type: TaskStatusTagType } {
|
||||
if (task.status === 'running') return { label: '生成中', type: 'primary' }
|
||||
if (task.status === 'completed') {
|
||||
return task.output_dataset_id
|
||||
? { label: '已发布', type: 'success' }
|
||||
: { label: '已生成', type: 'warning' }
|
||||
}
|
||||
if (task.status === 'failed') return { label: '生成失败', type: 'danger' }
|
||||
if (task.status === 'stopped') return { label: '已停止', type: 'info' }
|
||||
return { label: '待生成', type: 'info' }
|
||||
}
|
||||
|
||||
onMounted(loadData)
|
||||
@@ -103,7 +122,11 @@ onMounted(loadData)
|
||||
<el-table-column label="任务名称" prop="name" align="center" show-overflow-tooltip />
|
||||
<el-table-column label="任务状态" align="center" width="110">
|
||||
<template #default="{ row }">
|
||||
<ModelStatusTag :status="row.status" />
|
||||
<el-tag
|
||||
:type="taskDisplayStatus(row as DataProcessTask).type"
|
||||
size="small"
|
||||
effect="light"
|
||||
>{{ taskDisplayStatus(row as DataProcessTask).label }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="处理类型" align="center" width="140">
|
||||
@@ -114,11 +137,11 @@ onMounted(loadData)
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="源数据集" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ sourceDatasetName(row as DataProcessTask) }}</template>
|
||||
<el-table-column label="文档数量" align="center" width="120">
|
||||
<template #default="{ row }">{{ documentCountLabel(row as DataProcessTask) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="输出数据集" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ outputDatasetName(row as DataProcessTask) }}</template>
|
||||
<el-table-column label="生成个数" align="center" width="120">
|
||||
<template #default="{ row }">{{ generatedCountLabel(row as DataProcessTask) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" width="190">
|
||||
<template #default="{ row }">{{ formatDateTime(row.create_time || row.created_at) }}</template>
|
||||
|
||||
Reference in New Issue
Block a user