提交 ae60263c authored 作者: 陈泽健's avatar 陈泽健

feat(performance): 前端合并报告页面 ProjectReport.vue + 项目详情页查看合并报告入口

- 新增 ProjectReport.vue 合并报告页面(聚合指标卡片 4×16 + 分位数表 + 状态码分布 + 各任务明细表)
- 注册合并报告路由 /performance/project-report
- ProjectDetail.vue 批量执行完成后显示查看合并报告按钮 + 历史报告入口
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
上级 866acd45
......@@ -193,6 +193,12 @@ const routes: RouteRecordRaw[] = [
component: () => import('@/views/performance/ReportPanel.vue'),
meta: { title: '报告查看' }
},
{
path: 'project-report',
name: 'PerfProjectReport',
component: () => import('@/views/performance/ProjectReport.vue'),
meta: { title: '合并报告' }
},
{
path: 'presets',
name: 'PerfPresets',
......
......@@ -26,6 +26,12 @@
<el-button v-if="selectedIds.length > 0" type="warning" :loading="runningBatch" @click="handleBatchRun">
<el-icon><VideoPlay /></el-icon>批量执行({{ selectedIds.length }}
</el-button>
<el-button v-if="lastReportId" type="success" @click="viewMergedReport(lastReportId)">
<el-icon><Document /></el-icon>查看合并报告
</el-button>
<el-button @click="viewHistoryReports">
<el-icon><List /></el-icon>历史报告
</el-button>
<el-button @click="loadTasks">
<el-icon><Refresh /></el-icon>刷新
</el-button>
......@@ -182,7 +188,7 @@
import { ref, onMounted, onUnmounted, computed } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ArrowLeft, VideoPlay, Refresh } from '@element-plus/icons-vue'
import { ArrowLeft, VideoPlay, Refresh, Document, List } from '@element-plus/icons-vue'
import { getProject, listTasks, runTask, stopTask, deleteTask, runProjectAll, batchRunTasks } from '@/api/performance'
import type { PerformanceProject, PerformanceTaskListItem } from '@/types/performance'
......@@ -214,6 +220,7 @@ const batchTotalCount = ref(0)
const batchCurrentTaskName = ref('')
const batchSuccessCount = ref(0)
const batchFailCount = ref(0)
const lastReportId = ref<string | null>(null) // 最近一次批量执行生成的合并报告 ID
const batchProgressPercent = computed(() => {
if (batchTotalCount.value === 0) return 0
return Math.round((batchCurrentIndex.value / batchTotalCount.value) * 100)
......@@ -312,10 +319,14 @@ async function handleRunAll() {
if (confirmed === null) return
runningAll.value = true
lastReportId.value = null
showBatchProgress(tasks.value.length)
try {
const res = await runProjectAll(projectId.value)
ElMessage.success(res.message || '项目已开始执行')
if (res.reportId) {
lastReportId.value = res.reportId
}
} catch (e: any) {
ElMessage.error('执行失败: ' + (e.response?.data?.detail || e.message || ''))
} finally {
......@@ -338,10 +349,14 @@ async function handleBatchRun() {
if (confirmed === null) return
runningBatch.value = true
lastReportId.value = null
showBatchProgress(selectedIds.value.length)
try {
const res = await batchRunTasks({ taskIds: selectedIds.value, projectId: projectId.value })
ElMessage.success(res.message || '批量执行完成')
if (res.reportId) {
lastReportId.value = res.reportId
}
selectedIds.value = []
tableRef.value?.clearSelection()
await loadTasks()
......@@ -415,6 +430,16 @@ function modeLabel(mode: string) {
return map[mode] || mode
}
/** 跳转合并报告 */
function viewMergedReport(reportId: string) {
router.push(`/performance/project-report?reportId=${reportId}&projectId=${projectId.value}`)
}
/** 跳转历史报告列表 */
function viewHistoryReports() {
router.push(`/performance/project-report?projectId=${projectId.value}`)
}
/** 格式化时间 */
function formatTime(t: string) {
return t?.replace('T', ' ').substring(0, 19) || ''
......
此差异已折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论