feat: 复习总览展示任务统计

This commit is contained in:
2026-06-18 00:09:00 +08:00
parent 0be2b1c26e
commit 000b1aa9f4
+19 -6
View File
@@ -19,16 +19,25 @@ const summary = computed(() => ({
totalFragments: tasks.value.reduce((acc, item) => acc + Number(item.fragmentCount || 0), 0),
}));
const formatEffectiveTime = (seconds: number | string): string => {
const s = Number(seconds);
if (!s || s <= 0) return "0分钟";
const hours = Math.floor(s / 3600);
const minutes = Math.floor((s % 3600) / 60);
if (hours > 0) return `${hours}小时${minutes}分钟`;
return `${minutes}分钟`;
};
const loadTasks = async () => {
loading.value = true;
try {
const res = await request.get("/tasks", { pageSize: 100, pageNum: 1 });
tasks.value = (res?.data?.records || []).map((item: any) => ({
const res = await request.get("/review/tasks");
tasks.value = (res?.data || []).map((item: any) => ({
taskNum: item.taskNum,
taskName: item.taskName,
reportCount: item.reportCount ?? "-",
fragmentCount: item.fragmentCount ?? "-",
effectiveTime: item.effectiveTime ?? "-",
reportCount: item.reportCount ?? 0,
fragmentCount: item.fragmentCount ?? 0,
effectiveTime: item.effectiveTime ?? 0,
}));
} finally {
loading.value = false;
@@ -65,7 +74,11 @@ onMounted(() => {
<article class="surface-card table-card">
<el-table v-loading="loading" :data="tasks" stripe>
<el-table-column prop="taskName" label="任务名" min-width="180" />
<el-table-column prop="effectiveTime" label="累计有效学习时长" min-width="150" />
<el-table-column prop="effectiveTime" label="累计有效学习时长" min-width="150">
<template #default="{ row }">
{{ formatEffectiveTime(row.effectiveTime) }}
</template>
</el-table-column>
<el-table-column prop="reportCount" label="学习报告数" min-width="120" />
<el-table-column prop="fragmentCount" label="学习残片数" min-width="120" />
</el-table>