feat(frontend): 完善数据任务数量与状态
This commit is contained in:
@@ -26,6 +26,26 @@ assert.ok(source.includes('ElMessageBox.confirm('), '删除任务前缺少二次
|
|||||||
assert.ok(source.includes('await deleteDataProcessTask(row.id)'), '删除操作没有调用真实 API')
|
assert.ok(source.includes('await deleteDataProcessTask(row.id)'), '删除操作没有调用真实 API')
|
||||||
assert.ok(!source.includes('TODO: 接入真实接口'), '列表仍包含本地 Mock 任务')
|
assert.ok(!source.includes('TODO: 接入真实接口'), '列表仍包含本地 Mock 任务')
|
||||||
assert.ok(source.includes('const dataList = ref<DataProcessTask[]>([])'), '任务列表必须以空数组初始化并等待真实 API 数据')
|
assert.ok(source.includes('const dataList = ref<DataProcessTask[]>([])'), '任务列表必须以空数组初始化并等待真实 API 数据')
|
||||||
|
assert.match(source, /label="文档数量"[\s\S]*?documentCountLabel\(row as DataProcessTask\)/, '任务列表没有展示真实文档数量')
|
||||||
|
assert.match(source, /function documentCountLabel\(task: DataProcessTask\)[\s\S]*?`\$\{safeCount\(task\.source_file_count\)\} 个`/, '文档数量没有使用 source_file_count 或缺少单位')
|
||||||
|
assert.match(source, /label="生成个数"[\s\S]*?generatedCountLabel\(row as DataProcessTask\)/, '任务列表没有展示真实生成数量')
|
||||||
|
assert.match(source, /function generatedCountLabel\(task: DataProcessTask\)[\s\S]*?`\$\{safeCount\(task\.output_count\)\} 条`/, '生成数量没有使用 output_count 或缺少单位')
|
||||||
|
assert.doesNotMatch(source, /label="源数据集"|label="输出数据集"/, '任务列表仍使用旧的数据集列标题')
|
||||||
|
for (const label of ['待生成', '生成中', '已生成', '已发布', '生成失败', '已停止']) {
|
||||||
|
assert.ok(source.includes(`label: '${label}'`), `任务状态缺少“${label}”`)
|
||||||
|
}
|
||||||
|
assert.match(source, /task\.status === 'completed'[\s\S]*?task\.output_dataset_id[\s\S]*?已发布[\s\S]*?已生成/, '完成任务没有按当前轮输出指针区分已生成与已发布')
|
||||||
|
assert.doesNotMatch(source, /task\.output_datasets\?\.length[\s\S]*?已发布/, '上一轮保留的数据集不应将当前轮标记为已发布')
|
||||||
|
for (const [label, type] of [
|
||||||
|
['待生成', 'info'],
|
||||||
|
['生成中', 'primary'],
|
||||||
|
['已生成', 'warning'],
|
||||||
|
['已发布', 'success'],
|
||||||
|
['生成失败', 'danger'],
|
||||||
|
['已停止', 'info'],
|
||||||
|
]) {
|
||||||
|
assert.ok(source.includes(`label: '${label}', type: '${type}'`), `任务状态“${label}”颜色应为 ${type}`)
|
||||||
|
}
|
||||||
|
|
||||||
assert.match(apiSource, /export (?:async )?function getDataProcessTasks/, 'API 模块缺少任务列表方法')
|
assert.match(apiSource, /export (?:async )?function getDataProcessTasks/, 'API 模块缺少任务列表方法')
|
||||||
assert.match(apiSource, /export const deleteDataProcessTask/, 'API 模块缺少任务删除方法')
|
assert.match(apiSource, /export const deleteDataProcessTask/, 'API 模块缺少任务删除方法')
|
||||||
|
|||||||
@@ -3,10 +3,11 @@ import { onMounted, ref } from 'vue'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import DataTablePage from '@/components/DataTablePage.vue'
|
import DataTablePage from '@/components/DataTablePage.vue'
|
||||||
import ModelStatusTag from '@/components/ModelStatusTag.vue'
|
|
||||||
import { deleteDataProcessTask, getDataProcessTasks } from '@/api/modules/dataProcess'
|
import { deleteDataProcessTask, getDataProcessTasks } from '@/api/modules/dataProcess'
|
||||||
import type { DataProcessTask, DataProcessType } from '@/types/dataProcess'
|
import type { DataProcessTask, DataProcessType } from '@/types/dataProcess'
|
||||||
|
|
||||||
|
type TaskStatusTagType = 'success' | 'warning' | 'info' | 'danger' | 'primary'
|
||||||
|
|
||||||
const processTypeMap: Record<DataProcessType, string> = {
|
const processTypeMap: Record<DataProcessType, string> = {
|
||||||
structured: '结构化数据',
|
structured: '结构化数据',
|
||||||
unstructured: '非结构化数据',
|
unstructured: '非结构化数据',
|
||||||
@@ -73,12 +74,30 @@ function formatDateTime(value?: string) {
|
|||||||
return Number.isNaN(date.getTime()) ? value : date.toLocaleString('zh-CN', { hour12: false })
|
return Number.isNaN(date.getTime()) ? value : date.toLocaleString('zh-CN', { hour12: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
function sourceDatasetName(task: DataProcessTask) {
|
function safeCount(value: unknown) {
|
||||||
return task.source_dataset_name || task.source_dataset || '-'
|
const count = Number(value)
|
||||||
|
return Number.isFinite(count) ? Math.max(0, Math.trunc(count)) : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputDatasetName(task: DataProcessTask) {
|
function documentCountLabel(task: DataProcessTask) {
|
||||||
return task.output_dataset_name || task.output_dataset || '-'
|
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)
|
onMounted(loadData)
|
||||||
@@ -103,7 +122,11 @@ onMounted(loadData)
|
|||||||
<el-table-column label="任务名称" prop="name" align="center" show-overflow-tooltip />
|
<el-table-column label="任务名称" prop="name" align="center" show-overflow-tooltip />
|
||||||
<el-table-column label="任务状态" align="center" width="110">
|
<el-table-column label="任务状态" align="center" width="110">
|
||||||
<template #default="{ row }">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="处理类型" align="center" width="140">
|
<el-table-column label="处理类型" align="center" width="140">
|
||||||
@@ -114,11 +137,11 @@ onMounted(loadData)
|
|||||||
<span v-else>-</span>
|
<span v-else>-</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="源数据集" align="center" show-overflow-tooltip>
|
<el-table-column label="文档数量" align="center" width="120">
|
||||||
<template #default="{ row }">{{ sourceDatasetName(row as DataProcessTask) }}</template>
|
<template #default="{ row }">{{ documentCountLabel(row as DataProcessTask) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="输出数据集" align="center" show-overflow-tooltip>
|
<el-table-column label="生成个数" align="center" width="120">
|
||||||
<template #default="{ row }">{{ outputDatasetName(row as DataProcessTask) }}</template>
|
<template #default="{ row }">{{ generatedCountLabel(row as DataProcessTask) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建时间" align="center" width="190">
|
<el-table-column label="创建时间" align="center" width="190">
|
||||||
<template #default="{ row }">{{ formatDateTime(row.create_time || row.created_at) }}</template>
|
<template #default="{ row }">{{ formatDateTime(row.create_time || row.created_at) }}</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user