This commit is contained in:
@@ -363,7 +363,7 @@ export function getProblemSetBadges(problemSetId: number) {
|
|||||||
// 获取题单用户进度列表
|
// 获取题单用户进度列表
|
||||||
export function getProblemSetUserProgress(
|
export function getProblemSetUserProgress(
|
||||||
problemSetId: number,
|
problemSetId: number,
|
||||||
params?: { limit?: number; offset?: number },
|
params?: { limit?: number; offset?: number; class_name?: string },
|
||||||
) {
|
) {
|
||||||
return http.get(`problemset/${problemSetId}/users_progress`, { params })
|
return http.get(`problemset/${problemSetId}/users_progress`, { params })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { h, computed, ref, onMounted, watch } from "vue"
|
import { h, computed, ref, onMounted, watch } from "vue"
|
||||||
|
import { watchDebounced } from "@vueuse/core"
|
||||||
import { parseTime } from "utils/functions"
|
import { parseTime } from "utils/functions"
|
||||||
import { ProblemSetProgress } from "utils/types"
|
import { ProblemSetProgress } from "utils/types"
|
||||||
import { getProblemSetUserProgress } from "../../api"
|
import { getProblemSetUserProgress } from "../../api"
|
||||||
@@ -17,6 +18,7 @@ const statistics = ref<{
|
|||||||
completed: number
|
completed: number
|
||||||
avg_progress: number
|
avg_progress: number
|
||||||
} | null>(null)
|
} | null>(null)
|
||||||
|
const classFilter = ref<string>("")
|
||||||
|
|
||||||
// 使用分页 composable
|
// 使用分页 composable
|
||||||
const { query } = usePagination({}, { defaultLimit: 10 })
|
const { query } = usePagination({}, { defaultLimit: 10 })
|
||||||
@@ -25,10 +27,14 @@ const { query } = usePagination({}, { defaultLimit: 10 })
|
|||||||
async function loadUserProgress() {
|
async function loadUserProgress() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const offset = (query.page - 1) * query.limit
|
const offset = (query.page - 1) * query.limit
|
||||||
const res = await getProblemSetUserProgress(problemSetId.value, {
|
const params: { limit?: number; offset?: number; class_name?: string } = {
|
||||||
limit: query.limit,
|
limit: query.limit,
|
||||||
offset,
|
offset,
|
||||||
})
|
}
|
||||||
|
if (classFilter.value.trim()) {
|
||||||
|
params.class_name = classFilter.value.trim()
|
||||||
|
}
|
||||||
|
const res = await getProblemSetUserProgress(problemSetId.value, params)
|
||||||
|
|
||||||
progress.value = res.data.results
|
progress.value = res.data.results
|
||||||
total.value = res.data.total
|
total.value = res.data.total
|
||||||
@@ -41,6 +47,11 @@ async function loadUserProgress() {
|
|||||||
|
|
||||||
// 监听分页参数变化
|
// 监听分页参数变化
|
||||||
watch([() => query.page, () => query.limit], loadUserProgress)
|
watch([() => query.page, () => query.limit], loadUserProgress)
|
||||||
|
// 监听班级过滤变化(防抖)
|
||||||
|
watchDebounced(classFilter, () => {
|
||||||
|
query.page = 1 // 重置到第一页
|
||||||
|
loadUserProgress()
|
||||||
|
}, { debounce: 500 })
|
||||||
|
|
||||||
// 使用后端返回的统计数据
|
// 使用后端返回的统计数据
|
||||||
const stats = computed(() => {
|
const stats = computed(() => {
|
||||||
@@ -140,6 +151,17 @@ const progressColumns = [
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<!-- 过滤条件 -->
|
||||||
|
<n-space style="margin-bottom: 16px" align="center">
|
||||||
|
<n-text>班级筛选:</n-text>
|
||||||
|
<n-input
|
||||||
|
v-model:value="classFilter"
|
||||||
|
placeholder="输入班级名称"
|
||||||
|
style="width: 200px"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
<!-- 统计信息卡片 -->
|
<!-- 统计信息卡片 -->
|
||||||
<n-grid :cols="3" :x-gap="16" style="margin-bottom: 16px">
|
<n-grid :cols="3" :x-gap="16" style="margin-bottom: 16px">
|
||||||
<n-grid-item>
|
<n-grid-item>
|
||||||
|
|||||||
@@ -204,11 +204,7 @@ watch(
|
|||||||
</n-flex>
|
</n-flex>
|
||||||
|
|
||||||
<!-- 奖章显示 -->
|
<!-- 奖章显示 -->
|
||||||
<n-flex
|
<n-flex align="center" justify="space-between">
|
||||||
v-if="problemSet.badges && problemSet.badges.length > 0"
|
|
||||||
align="center"
|
|
||||||
justify="space-between"
|
|
||||||
>
|
|
||||||
<n-text depth="3">
|
<n-text depth="3">
|
||||||
创建于
|
创建于
|
||||||
{{ parseTime(problemSet.create_time, "YYYY-MM-DD") }}
|
{{ parseTime(problemSet.create_time, "YYYY-MM-DD") }}
|
||||||
|
|||||||
Reference in New Issue
Block a user