diff --git a/web/src/views/DashboardView.vue b/web/src/views/DashboardView.vue index aa61024..f2477bd 100644 --- a/web/src/views/DashboardView.vue +++ b/web/src/views/DashboardView.vue @@ -83,24 +83,42 @@ interface DashboardLink { icon: Component } +interface WarningRecord { + id: string + studentName: string + studentNumber: string + className: string + status: number + detail: string +} + const router = useRouter() const auth = useAuthStore() const roles = computed(() => auth.user?.roles ?? []) const isStudentOverview = computed(() => roles.value.includes('Student') && !roles.value.some((role) => - ['SuperAdmin', 'AcademicAdmin', 'CollegeAdmin'].includes(role), + ['SuperAdmin', 'AcademicAdmin', 'CollegeAdmin', 'Counselor'].includes(role), ), ) const loading = ref(true) const loadError = ref('') const data = ref(null) +const counselorWarnings = ref([]) const now = ref(new Date()) function hasRole(...allowedRoles: string[]) { return roles.value.some((role) => allowedRoles.includes(role)) } +const isCounselorDashboard = computed(() => + hasRole('Counselor') && !hasRole('SuperAdmin', 'AcademicAdmin', 'CollegeAdmin'), +) + +const activeCounselorWarnings = computed(() => + counselorWarnings.value.filter((warning) => warning.status === 1), +) + function parseDateOnly(value?: string) { if (!value) return null const [year, month, day] = value.slice(0, 10).split('-').map(Number) @@ -366,6 +384,11 @@ async function loadDashboard() { loadError.value = '' try { data.value = (await http.get('/dashboard')).data + if (isCounselorDashboard.value) { + counselorWarnings.value = (await http.get('/warnings/records', { + params: { academicTermId: data.value.currentTerm?.id }, + })).data + } } catch { loadError.value = '教务总览暂时无法加载,请检查服务连接后重试。' } finally { @@ -483,6 +506,29 @@ onMounted(async () => {
+
+
+
+ RADAR / COUNSELOR +

需重点关注的学生

+

{{ activeCounselorWarnings.length ? `当前有 ${activeCounselorWarnings.length} 条生效预警,按最新记录展示。` : '当前没有生效中的学业预警。' }}

+
+ +
+
+ +
+
+ +
当前没有重点关注学生新的学业预警会自动出现在这里。
+
+
+
@@ -943,6 +989,28 @@ onMounted(async () => { background: var(--dashboard-paper); } +.counselor-radar { border-top: 3px solid var(--dashboard-amber); } +.radar-link { padding: 5px 0; border: 0; color: #806136; background: transparent; font-size: 12px; white-space: nowrap; } +.radar-link:hover { color: var(--dashboard-blue); } +.counselor-risk-list { display: grid; } +.counselor-risk-list button { + padding: 13px 0; + display: grid; + grid-template-columns: 76px 68px minmax(0, 1fr) auto; + gap: 10px; + align-items: center; + text-align: left; + border: 0; + border-bottom: 1px solid #eee8dc; + background: transparent; +} +.counselor-risk-list button:last-child { border-bottom: 0; } +.counselor-risk-list button:hover b { color: var(--dashboard-blue); } +.counselor-risk-list span { color: #987337; font: 700 9px/1.3 Consolas, monospace; letter-spacing: .04em; } +.counselor-risk-list b { color: #3a4758; font-size: 13px; } +.counselor-risk-list small { overflow: hidden; color: #6c7788; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; } +.counselor-risk-list i { color: #8d7042; font-size: 11px; font-style: normal; white-space: nowrap; } + .todo-panel, .quick-panel, .readiness-panel { @@ -1250,6 +1318,9 @@ button:focus-visible { @media (max-width: 760px) { .greeting-insights { padding: 15px; } .greeting-insights > div { grid-template-columns: 1fr; } + .counselor-risk-list button { grid-template-columns: 1fr auto; } + .counselor-risk-list span { grid-column: 1 / -1; } + .counselor-risk-list small { white-space: normal; } .admin-dashboard { gap: 10px; } .overview-hero { diff --git a/web/src/views/StudentDashboardView.vue b/web/src/views/StudentDashboardView.vue index 3e3e209..96a3ac0 100644 --- a/web/src/views/StudentDashboardView.vue +++ b/web/src/views/StudentDashboardView.vue @@ -83,6 +83,14 @@ interface DashboardGreeting { }> } +interface WarningItem { + id: string + type: number + status: number + detail: string + createdAt: string +} + const router = useRouter() const auth = useAuthStore() const loading = ref(true) @@ -93,6 +101,7 @@ const unreadCount = ref(0) const exams = ref([]) const grades = ref([]) const dashboardGreeting = ref(null) +const warnings = ref([]) const now = ref(new Date()) const categoryLabels: Record = { @@ -173,6 +182,11 @@ const recentGrades = computed(() => .slice(0, 4), ) +const activeWarnings = computed(() => warnings.value.filter((warning) => warning.status === 1)) +const radarSummary = computed(() => activeWarnings.value.length + ? `发现 ${activeWarnings.value.length} 项需要你关注的学习风险,建议优先处理下方提示。` + : '系统暂未发现需要你处理的学业风险,继续保持当前学习节奏。') + function parseDateOnly(value?: string) { if (!value) return null const [year, month, day] = value.slice(0, 10).split('-').map(Number) @@ -296,6 +310,7 @@ async function loadOverview() { http.get('/exams/my-schedule'), http.get('/grades/student/transcript'), http.get('/dashboard/greeting'), + http.get('/warnings/my-warnings'), ]) if (results[0].status === 'fulfilled') { @@ -322,6 +337,11 @@ async function loadOverview() { if (results[4].status === 'fulfilled') { dashboardGreeting.value = results[4].value.data } + if (results[5].status === 'fulfilled') { + warnings.value = results[5].value.data + } else { + failedSections.value.push('学业风险雷达') + } loading.value = false } @@ -353,6 +373,24 @@ onMounted(loadOverview)

{{ dashboardGreeting.narrative }}

+
+
+
+ ACADEMIC RADAR +

学业风险雷达

+
+ +
+

{{ radarSummary }}

+
+ +
+
+ p { margin: 13px 0 0; color: #59677a; font-size: 12px; line-height: 1.7; } +.risk-list { margin-top: 13px; display: grid; } +.risk-list button { padding: 12px 0; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 10px; text-align: left; border: 0; border-top: 1px solid #eee6d8; background: transparent; } +.risk-list span { align-self: center; color: #a16b1c; font: 700 9px/1.4 Consolas, monospace; letter-spacing: .06em; } +.risk-list strong { color: #38475a; font-size: 12px; font-weight: 600; line-height: 1.55; } +.risk-list i { align-self: center; color: #9a743d; font-size: 11px; font-style: normal; white-space: nowrap; } + .today-status { min-width: 180px; margin-left: auto; @@ -945,6 +1001,9 @@ onMounted(loadOverview) @media (max-width: 600px) { .student-greeting-insights { padding: 15px 18px; grid-template-columns: 1fr; } + .student-risk-radar { padding: 18px; } + .risk-list button { grid-template-columns: 1fr auto; } + .risk-list span { grid-column: 1 / -1; } .student-overview { gap: 12px; }