288 lines
16 KiB
Vue
288 lines
16 KiB
Vue
<script setup lang="ts">
|
||
import { computed, onMounted, reactive, ref } from 'vue'
|
||
import { useRouter } from 'vue-router'
|
||
import { Check, DataAnalysis, Refresh, Search, Warning } from '@element-plus/icons-vue'
|
||
import { ElMessage } from 'element-plus'
|
||
import http, { apiErrorMessage } from '../api/http'
|
||
import { useAuthStore } from '../stores/auth'
|
||
import {
|
||
academicTermLabel,
|
||
academicTermOptionClass,
|
||
defaultAcademicTermId,
|
||
} from '../utils/academicTerms'
|
||
|
||
const router = useRouter()
|
||
const auth = useAuthStore()
|
||
const loading = ref(false)
|
||
const terms = ref<any[]>([])
|
||
const colleges = ref<any[]>([])
|
||
const items = ref<any[]>([])
|
||
const total = ref(0)
|
||
const summary = ref<any>({
|
||
totalTaskCount: 0,
|
||
grade: {},
|
||
experiment: {},
|
||
})
|
||
const filters = reactive({
|
||
academicTermId: '',
|
||
collegeId: '',
|
||
keyword: '',
|
||
attentionOnly: false,
|
||
page: 1,
|
||
pageSize: 20,
|
||
})
|
||
|
||
const canSelectCollege = computed(() =>
|
||
auth.user?.roles.some((role) => ['SuperAdmin', 'AcademicAdmin', 'Leader'].includes(role)) ?? false,
|
||
)
|
||
|
||
const gradeStatusLabels: Record<string, string> = {
|
||
Draft: '录入中',
|
||
Submitted: '待审核',
|
||
Approved: '审核通过',
|
||
Published: '已发布',
|
||
Returned: '已退回',
|
||
}
|
||
|
||
type TagType = 'success' | 'info' | 'warning' | 'primary' | 'danger'
|
||
|
||
function statusType(status?: string): TagType {
|
||
return ({ Draft: 'info', Submitted: 'warning', Approved: 'success', Published: 'primary', Returned: 'danger' } as Record<string, TagType>)[status ?? ''] ?? 'info'
|
||
}
|
||
|
||
function percent(value?: number) {
|
||
return Math.max(0, Math.min(100, Number(value ?? 0)))
|
||
}
|
||
|
||
function experimentStage(row: any): { label: string; type: TagType } {
|
||
const progress = row.experiment
|
||
if (!progress?.projectCount) return { label: '无实验项目', type: 'info' }
|
||
if (progress.returnedSheetCount) return { label: `${progress.returnedSheetCount} 项已退回`, type: 'danger' }
|
||
if (progress.publishedSheetCount === progress.projectCount) return { label: '全部发布', type: 'primary' }
|
||
if (progress.approvedSheetCount) return { label: `${progress.approvedSheetCount} 项审核通过`, type: 'success' }
|
||
if (progress.submittedSheetCount) return { label: `${progress.submittedSheetCount} 项待审核`, type: 'warning' }
|
||
if (progress.sheetCount) return { label: '评分中', type: 'info' }
|
||
return { label: '尚未建成绩单', type: 'info' }
|
||
}
|
||
|
||
function dateTime(value?: string) {
|
||
if (!value) return '暂无更新'
|
||
return new Intl.DateTimeFormat('zh-CN', {
|
||
month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit',
|
||
}).format(new Date(value))
|
||
}
|
||
|
||
async function load() {
|
||
loading.value = true
|
||
try {
|
||
const { data } = await http.get('/teaching-monitoring', {
|
||
params: {
|
||
academicTermId: filters.academicTermId || undefined,
|
||
collegeId: filters.collegeId || undefined,
|
||
keyword: filters.keyword.trim() || undefined,
|
||
attentionOnly: filters.attentionOnly || undefined,
|
||
page: filters.page,
|
||
pageSize: filters.pageSize,
|
||
},
|
||
})
|
||
items.value = data.items ?? []
|
||
total.value = data.total ?? 0
|
||
summary.value = data.summary ?? summary.value
|
||
filters.page = data.page ?? filters.page
|
||
filters.pageSize = data.pageSize ?? filters.pageSize
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
function search() {
|
||
filters.page = 1
|
||
void load()
|
||
}
|
||
|
||
function reset() {
|
||
filters.academicTermId = defaultAcademicTermId(terms.value) ?? ''
|
||
filters.collegeId = ''
|
||
filters.keyword = ''
|
||
filters.attentionOnly = false
|
||
search()
|
||
}
|
||
|
||
function openGrades(row: any) {
|
||
router.push({ path: '/grades', query: row.grade?.sheetId
|
||
? { sheetId: row.grade.sheetId }
|
||
: { keyword: row.taskNumber } })
|
||
}
|
||
|
||
function openExperimentGrades(row: any) {
|
||
router.push({ path: '/experiment-grades', query: { keyword: row.taskNumber } })
|
||
}
|
||
|
||
onMounted(async () => {
|
||
try {
|
||
const requests: Promise<any>[] = [http.get('/base-data/terms')]
|
||
if (canSelectCollege.value) requests.push(http.get('/base-data/colleges'))
|
||
const [termResponse, collegeResponse] = await Promise.all(requests)
|
||
terms.value = termResponse.data ?? []
|
||
colleges.value = collegeResponse?.data ?? []
|
||
filters.academicTermId = defaultAcademicTermId(terms.value) ?? ''
|
||
await load()
|
||
} catch (error) {
|
||
ElMessage.error(apiErrorMessage(error))
|
||
}
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<main class="monitor-page">
|
||
<header class="monitor-hero">
|
||
<div>
|
||
<span class="eyebrow">TEACHING OPERATIONS</span>
|
||
<h1>教学监测</h1>
|
||
<p>统一查看课程成绩与实验成绩的录入、审核和发布进度,及时发现已退回或结课后仍未发布的教学班。</p>
|
||
</div>
|
||
<el-button :icon="Refresh" :loading="loading" @click="load">刷新数据</el-button>
|
||
</header>
|
||
|
||
<section class="filter-panel">
|
||
<el-select v-model="filters.academicTermId" clearable filterable placeholder="全部学期" @change="search">
|
||
<el-option v-for="term in terms" :key="term.id" :label="academicTermLabel(term)" :value="term.id" :class-name="academicTermOptionClass(term)" />
|
||
</el-select>
|
||
<el-select v-if="canSelectCollege" v-model="filters.collegeId" clearable filterable placeholder="全部学院" @change="search">
|
||
<el-option v-for="college in colleges" :key="college.id" :label="college.name" :value="college.id" />
|
||
</el-select>
|
||
<el-input v-model="filters.keyword" clearable placeholder="课程、教学班、教师或行政班" @keyup.enter="search">
|
||
<template #prefix><el-icon><Search /></el-icon></template>
|
||
</el-input>
|
||
<el-checkbox v-model="filters.attentionOnly" border @change="search">仅看需跟进</el-checkbox>
|
||
<el-button type="primary" :icon="Search" @click="search">查询</el-button>
|
||
<el-button @click="reset">重置</el-button>
|
||
</section>
|
||
|
||
<section class="summary-grid">
|
||
<article class="summary-card total-card">
|
||
<el-icon><DataAnalysis /></el-icon>
|
||
<div><span>监测教学班</span><strong>{{ summary.totalTaskCount ?? 0 }}</strong><small>当前筛选范围</small></div>
|
||
</article>
|
||
<article class="summary-card">
|
||
<div class="card-heading"><span>课程成绩发布</span><b>{{ percent(summary.grade?.publicationRate) }}%</b></div>
|
||
<el-progress :percentage="percent(summary.grade?.publicationRate)" :stroke-width="9" :show-text="false" />
|
||
<p>已发布 {{ summary.grade?.publishedCount ?? 0 }} / {{ summary.totalTaskCount ?? 0 }} 个教学班</p>
|
||
<small>未建成绩单 {{ summary.grade?.missingSheetCount ?? 0 }} · 待审核 {{ (summary.grade?.submittedCount ?? 0) + (summary.grade?.approvedCount ?? 0) }} · 退回 {{ summary.grade?.returnedCount ?? 0 }}</small>
|
||
</article>
|
||
<article class="summary-card">
|
||
<div class="card-heading"><span>课程成绩录入</span><b>{{ percent(summary.grade?.completionRate) }}%</b></div>
|
||
<el-progress :percentage="percent(summary.grade?.completionRate)" :stroke-width="9" :show-text="false" />
|
||
<p>已完成 {{ summary.grade?.completedCount ?? 0 }} / {{ summary.grade?.recordCount ?? 0 }} 名学生</p>
|
||
<small>完成指已有最终成绩、评价或特殊考试状态</small>
|
||
</article>
|
||
<article class="summary-card experiment-card">
|
||
<div class="card-heading"><span>实验成绩发布</span><b>{{ percent(summary.experiment?.publicationRate) }}%</b></div>
|
||
<el-progress :percentage="percent(summary.experiment?.publicationRate)" :stroke-width="9" :show-text="false" color="#b96d2e" />
|
||
<p>已发布 {{ summary.experiment?.publishedCount ?? 0 }} / {{ summary.experiment?.projectCount ?? 0 }} 个实验项目</p>
|
||
<small>未建成绩单 {{ summary.experiment?.missingSheetCount ?? 0 }} · 待审核 {{ summary.experiment?.pendingReviewCount ?? 0 }} · 退回 {{ summary.experiment?.returnedCount ?? 0 }}</small>
|
||
</article>
|
||
</section>
|
||
|
||
<section class="monitor-list">
|
||
<div class="section-title">
|
||
<div><h2>教学班进度</h2><p>进度基于服务器端授权范围实时汇总;展开关注标记可优先处理异常项。</p></div>
|
||
<span>共 {{ total }} 个教学班</span>
|
||
</div>
|
||
<el-table :data="items" v-loading="loading" row-key="id" empty-text="当前筛选范围内没有教学班">
|
||
<el-table-column label="教学班" min-width="270" fixed>
|
||
<template #default="{ row }">
|
||
<div class="task-cell">
|
||
<div><b>{{ row.courseName }}</b><small>{{ row.courseCode }} · {{ row.taskNumber }}</small></div>
|
||
<el-tag v-if="row.needsAttention" type="danger" effect="plain" size="small"><el-icon><Warning /></el-icon>需跟进</el-tag>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="教师 / 班级" min-width="220">
|
||
<template #default="{ row }">
|
||
<div class="meta-cell"><span>{{ row.teacherNames.join('、') || '未安排教师' }}</span><small>{{ row.classNames.join('、') || '选课学生组成' }}</small></div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="课程成绩" min-width="260">
|
||
<template #default="{ row }">
|
||
<div v-if="row.grade" class="progress-cell">
|
||
<div><el-tag :type="statusType(row.grade.status)" size="small" effect="plain">{{ gradeStatusLabels[row.grade.status] ?? row.grade.status }}</el-tag><span>{{ row.grade.completedCount }} / {{ row.grade.studentCount }} 人</span></div>
|
||
<el-progress :percentage="percent(row.grade.completionRate)" :stroke-width="7" />
|
||
<small>更新于 {{ dateTime(row.grade.updatedAt) }}</small>
|
||
</div>
|
||
<div v-else class="empty-progress"><span>尚未建立成绩单</span><small>预计覆盖 {{ row.expectedStudentCount }} 名学生</small></div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="实验成绩" min-width="280">
|
||
<template #default="{ row }">
|
||
<div v-if="row.experiment.projectCount" class="progress-cell experiment-progress">
|
||
<div><el-tag :type="experimentStage(row).type" size="small" effect="plain">{{ experimentStage(row).label }}</el-tag><span>{{ row.experiment.completedCount }} / {{ row.experiment.recordCount }} 人次</span></div>
|
||
<el-progress :percentage="percent(row.experiment.completionRate)" :stroke-width="7" color="#b96d2e" />
|
||
<small>{{ row.experiment.publishedSheetCount }} / {{ row.experiment.projectCount }} 个项目已发布</small>
|
||
</div>
|
||
<div v-else class="empty-progress"><span>本教学班无实验项目</span><small>无需维护实验成绩</small></div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="150" fixed="right">
|
||
<template #default="{ row }">
|
||
<div class="row-actions"><el-button link type="primary" @click="openGrades(row)">课程成绩</el-button><el-button v-if="row.experiment.projectCount" link type="warning" @click="openExperimentGrades(row)">实验成绩</el-button></div>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<div class="pagination-row">
|
||
<el-pagination v-model:current-page="filters.page" v-model:page-size="filters.pageSize" :total="total" :page-sizes="[10, 20, 30, 50]" layout="total, sizes, prev, pager, next" @change="load" />
|
||
</div>
|
||
</section>
|
||
|
||
<aside class="definition-note">
|
||
<el-icon><Check /></el-icon>
|
||
<p><b>监测口径:</b>“需跟进”包括成绩被退回,以及教学班已结课但课程成绩或已有实验项目尚未全部发布。正在正常授课、仍处于录入阶段的教学班不会自动判为异常。</p>
|
||
</aside>
|
||
</main>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.monitor-page { display: grid; gap: 20px; }
|
||
.monitor-hero { position: relative; overflow: hidden; min-height: 150px; padding: 28px 32px; display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; color: #f8fbfb; background: linear-gradient(122deg, #173d42, #295e61 58%, #b06b34 140%); border: 1px solid #315e62; }
|
||
.monitor-hero::after { content: ''; position: absolute; width: 250px; height: 250px; right: 8%; top: -170px; border: 34px solid rgba(255,255,255,.06); border-radius: 50%; }
|
||
.monitor-hero h1 { margin: 5px 0 8px; font-size: 28px; letter-spacing: .04em; }
|
||
.monitor-hero p { max-width: 760px; margin: 0; color: #d3e4e3; line-height: 1.75; }
|
||
.eyebrow { font: 700 11px/1.2 Consolas, monospace; letter-spacing: .18em; color: #e0b88f; }
|
||
.filter-panel { padding: 16px; display: grid; grid-template-columns: minmax(190px, 1fr) minmax(170px, .8fr) minmax(260px, 1.4fr) auto auto auto; gap: 10px; align-items: center; border: 1px solid var(--line); background: #fff; }
|
||
.summary-grid { display: grid; grid-template-columns: .7fr repeat(3, 1fr); gap: 14px; }
|
||
.summary-card { min-height: 150px; padding: 20px; display: grid; align-content: center; gap: 10px; border: 1px solid #d7dfdf; background: #fff; box-shadow: 0 8px 24px rgba(31, 57, 59, .04); }
|
||
.summary-card p, .summary-card small { margin: 0; color: var(--muted); }
|
||
.summary-card p { font-size: 13px; }
|
||
.summary-card small { line-height: 1.5; }
|
||
.card-heading { display: flex; justify-content: space-between; align-items: baseline; }
|
||
.card-heading span { color: #435859; font-weight: 650; }
|
||
.card-heading b { color: #1d5658; font: 750 24px/1 Consolas, monospace; }
|
||
.experiment-card .card-heading b { color: #a75f27; }
|
||
.total-card { display: flex; align-items: center; gap: 16px; color: #f7fbfb; border-color: #244e51; background: #244e51; }
|
||
.total-card .el-icon { width: 44px; height: 44px; border-radius: 50%; font-size: 22px; color: #e4b27f; background: rgba(255,255,255,.08); }
|
||
.total-card span, .total-card small { display: block; color: #bfd2d1; }
|
||
.total-card strong { display: block; margin: 5px 0; font: 750 34px/1 Consolas, monospace; }
|
||
.monitor-list { border: 1px solid var(--line); background: #fff; }
|
||
.section-title { padding: 20px 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
|
||
.section-title h2 { margin: 0 0 5px; font-size: 18px; }
|
||
.section-title p { margin: 0; color: var(--muted); font-size: 12px; }
|
||
.section-title > span { color: var(--muted); font: 600 12px Consolas, monospace; }
|
||
.task-cell, .progress-cell > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
|
||
.task-cell b, .meta-cell span { display: block; color: #263d3e; }
|
||
.task-cell small, .meta-cell small, .progress-cell small, .empty-progress small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
|
||
.meta-cell { line-height: 1.45; }
|
||
.progress-cell { display: grid; gap: 7px; }
|
||
.progress-cell > div > span { color: #536667; font: 600 11px Consolas, monospace; }
|
||
.empty-progress { color: #718081; }
|
||
.row-actions { display: grid; justify-items: start; }
|
||
.row-actions .el-button + .el-button { margin-left: 0; }
|
||
.pagination-row { padding: 16px 20px; display: flex; justify-content: flex-end; border-top: 1px solid var(--line); }
|
||
.definition-note { padding: 14px 17px; display: flex; align-items: flex-start; gap: 10px; color: #496061; border: 1px solid #c9dada; background: #f3f8f7; }
|
||
.definition-note .el-icon { margin-top: 3px; color: #2e7774; }
|
||
.definition-note p { margin: 0; font-size: 12px; line-height: 1.7; }
|
||
@media (max-width: 1180px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } .filter-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
|
||
@media (max-width: 720px) { .monitor-hero { padding: 22px; flex-direction: column; } .summary-grid, .filter-panel { grid-template-columns: 1fr; } .section-title { align-items: flex-start; gap: 10px; flex-direction: column; } .pagination-row { overflow-x: auto; justify-content: flex-start; } }
|
||
</style>
|