This commit is contained in:
2025-10-03 23:41:35 +08:00
parent 8ede959fc2
commit 15d0e3cac6
2 changed files with 67 additions and 85 deletions

View File

@@ -139,7 +139,7 @@ function showStatisticsPanel() {
v-if="userStore.isSuperAdmin" v-if="userStore.isSuperAdmin"
@click="showStatisticsPanel" @click="showStatisticsPanel"
> >
数据统计 {{ isDesktop ? "统计信息" : "统计" }}
</n-button> </n-button>
<n-dropdown size="large" :options="menu" @select="select"> <n-dropdown size="large" :options="menu" @select="select">
<n-button :size="isDesktop ? 'medium' : 'small'">操作</n-button> <n-button :size="isDesktop ? 'medium' : 'small'">操作</n-button>

View File

@@ -1,87 +1,71 @@
<template> <template>
<n-flex size="large" vertical> <n-flex>
<n-form :show-feedback="false" inline label-placement="left"> <n-input
<n-form-item> placeholder="用户(可选)"
<n-input v-model:value="query.username"
placeholder="用户(可选)" style="width: 160px"
v-model:value="query.username" clearable
style="width: 200px" />
clearable <n-input
/> placeholder="题号(可选)"
</n-form-item> v-model:value="query.problem"
<n-form-item> style="width: 160px"
<n-input clearable
placeholder="题号(可选)" />
v-model:value="query.problem" <n-select
style="width: 200px" style="width: 120px"
clearable v-model:value="query.duration"
/> :options="options"
</n-form-item> />
<n-form-item> <n-button type="primary" @click="handleStatistics">统计</n-button>
<n-select <n-button v-if="route.name !== 'submissions'" @click="goSubmissions">
style="width: 120px" 前往提交列表
v-model:value="query.duration" </n-button>
:options="options"
/>
</n-form-item>
<n-form-item>
<n-button type="primary" @click="handleStatistics">统计</n-button>
</n-form-item>
<n-form-item v-if="route.name !== 'submissions'">
<n-button @click="goSubmissions">前往提交列表</n-button>
</n-form-item>
</n-form>
<n-space v-if="count.total > 0" size="large">
<n-h1 style="margin-bottom: 0">
<n-gradient-text type="primary">
正确提交数{{ count.accepted }}
</n-gradient-text>
</n-h1>
<n-h1 style="margin-bottom: 0">
<n-gradient-text type="info">
总提交数{{ count.total }}
</n-gradient-text>
</n-h1>
<n-h1 style="margin-bottom: 0">
<n-gradient-text type="warning">
正确率{{ count.rate }}
</n-gradient-text>
</n-h1>
</n-space>
<n-space v-if="count.total > 0" size="large">
<n-h1>
<n-gradient-text type="error">
回答正确的人数{{ list.length }}
</n-gradient-text>
</n-h1>
<n-h1 v-if="person.count > 0">
<n-gradient-text type="warning">
班级人数{{ person.count }}
</n-gradient-text>
</n-h1>
<n-h1 v-if="person.count > 0">
<n-gradient-text type="success">
班级完成度{{ person.rate }}
</n-gradient-text>
</n-h1>
<n-flex v-if="listUnaccepted.length > 0" style="margin-top: 8px">
<n-button type="warning" @click="toggleUnaccepted(!unaccepted)">
{{ unaccepted ? "隐藏没有完成的" : "显示没有完成的" }}
</n-button>
</n-flex>
</n-space>
<n-h1 v-if="count.total === 0">
<n-gradient-text type="primary">暂无数据统计</n-gradient-text>
</n-h1>
<n-space v-if="unaccepted" size="large">
<n-h1>{{ listUnaccepted.length }}位没有完成</n-h1>
<n-h1 v-for="name in listUnaccepted" :key="name">
{{ name }}
</n-h1>
<n-text v-if="message">{{ message }}</n-text>
</n-space>
<n-data-table v-if="list.length" striped :columns="columns" :data="list" />
</n-flex> </n-flex>
<n-flex style="margin: 20px 0" v-if="count.total > 0">
<n-gradient-text font-size="24" type="primary">
正确提交数{{ count.accepted }}
</n-gradient-text>
<n-gradient-text font-size="24" type="info">
总提交数{{ count.total }}
</n-gradient-text>
<n-gradient-text font-size="24" type="warning">
正确率{{ count.rate }}
</n-gradient-text>
</n-flex>
<n-flex style="margin: 20px 0" v-if="count.total > 0">
<n-gradient-text font-size="24" type="error">
回答正确的人数{{ list.length }}
</n-gradient-text>
<n-gradient-text font-size="24" v-if="person.count > 0" type="warning">
班级人数{{ person.count }}
</n-gradient-text>
<n-gradient-text font-size="24" v-if="person.count > 0" type="success">
班级完成度{{ person.rate }}
</n-gradient-text>
<n-flex v-if="listUnaccepted.length > 0">
<n-button type="warning" @click="toggleUnaccepted(!unaccepted)">
{{ unaccepted ? "隐藏没有完成的" : "显示没有完成的" }}
</n-button>
</n-flex>
</n-flex>
<n-gradient-text
font-size="24"
style="margin-top: 20px"
v-if="count.total === 0"
type="primary"
>
暂无数据统计
</n-gradient-text>
<n-flex style="margin-bottom: 20px" v-if="unaccepted" size="large">
<span style="font-size: 24px">
{{ listUnaccepted.length }} 位没有完成
</span>
<span style="font-size: 24px" v-for="name in listUnaccepted" :key="name">
{{ name }}
</span>
</n-flex>
<n-data-table v-if="list.length" striped :columns="columns" :data="list" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { formatISO, sub, type Duration } from "date-fns" import { formatISO, sub, type Duration } from "date-fns"
@@ -134,7 +118,6 @@ const router = useRouter()
const list = ref([]) const list = ref([])
const listUnaccepted = ref([]) const listUnaccepted = ref([])
const [unaccepted, toggleUnaccepted] = useToggle() const [unaccepted, toggleUnaccepted] = useToggle()
const message = ref("")
const subOptions = computed<Duration>(() => { const subOptions = computed<Duration>(() => {
let dur = options.find((it) => it.value === query.duration) ?? options[0] let dur = options.find((it) => it.value === query.duration) ?? options[0]
@@ -171,6 +154,5 @@ async function handleStatistics() {
person.rate = res.data.person_rate person.rate = res.data.person_rate
toggleUnaccepted(false) toggleUnaccepted(false)
message.value = ""
} }
</script> </script>