From 42e692fc8c85c36587fcf0daa166a1adc7709541 Mon Sep 17 00:00:00 2001 From: yangbin <1796443586@qq.com> Date: Wed, 26 Aug 2026 18:08:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E5=91=98=E4=BF=A1=E6=81=AF=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E6=88=90=E7=BB=A9=E8=A1=A8=E5=8D=95=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/studentRecords/studentRecords.js | 10 +- .../src/views/student/studentInfo/index.vue | 132 ++++++++++++++---- 2 files changed, 113 insertions(+), 29 deletions(-) diff --git a/frontend/src/api/studentRecords/studentRecords.js b/frontend/src/api/studentRecords/studentRecords.js index 57a5d04ea..cc25fb6d2 100644 --- a/frontend/src/api/studentRecords/studentRecords.js +++ b/frontend/src/api/studentRecords/studentRecords.js @@ -45,7 +45,7 @@ export function delStudentRecord(bh) { }) } -// 分页查询学员课程成绩(kcbh/xydbh/xh/nd 查询) +// 分页查询学员课程成绩(xybh/nd 查询) export function listStudentGrades(query) { return request({ url: '/student-records/grades', @@ -54,7 +54,7 @@ export function listStudentGrades(query) { }) } -// 分页查询学员课程过程成绩(kcbh/xydbh/xh/nd 查询) +// 分页查询学员课程过程成绩(xybh/nd 查询) export function listStudentProcessGrades(query) { return request({ url: '/student-records/process-grades', @@ -63,7 +63,7 @@ export function listStudentProcessGrades(query) { }) } -// 导出学员课程成绩 Excel(kcbh/xydbh/xh/nd 查询) +// 导出指定学员的课程成绩 Excel(xybh 必传) export function exportStudentGrades(query) { return request({ url: '/student-records/export-grades', @@ -73,7 +73,7 @@ export function exportStudentGrades(query) { }) } -// 导出学员课程过程成绩 Excel(kcbh/xydbh/xh/nd 查询) +// 导出指定学员的课程过程成绩 Excel(xybh 必传) export function exportStudentProcessGrades(query) { return request({ url: '/student-records/export-process-grades', @@ -81,4 +81,4 @@ export function exportStudentProcessGrades(query) { params: query, responseType: 'blob' }) -} \ No newline at end of file +} diff --git a/frontend/src/views/student/studentInfo/index.vue b/frontend/src/views/student/studentInfo/index.vue index ff3ebeb11..b932ed9d0 100644 --- a/frontend/src/views/student/studentInfo/index.vue +++ b/frontend/src/views/student/studentInfo/index.vue @@ -210,25 +210,55 @@ -

学员:{{ gradesStudent }}

+
+ 学员:{{ gradesStudent || '-' }} + 学号:{{ gradesStudentNo || '-' }} +
-
-
{{ gradesData }}
-
+ + + + + + + + + + + + + + + + +
-
-
{{ processGradesData }}
-
+ + + + + + + + + + + + + +
- 导出成绩 + + {{ gradesTab === 'grades' ? '导出成绩' : '导出进程成绩' }} +
@@ -240,7 +270,11 @@ import { getStudentRecord, addStudentRecord, updateStudentRecord, - delStudentRecord + delStudentRecord, + listStudentGrades, + listStudentProcessGrades, + exportStudentGrades, + exportStudentProcessGrades } from "@/api/studentRecords/studentRecords" import { getDicts } from '@/api/system/dict/data' @@ -301,11 +335,13 @@ export default { // ==================== 成绩弹窗 ==================== gradesVisible: false, gradesTab: 'grades', - gradesData: null, - processGradesData: null, + gradesData: [], + processGradesData: [], gradesStudent: '', + gradesStudentNo: '', currentBh: '', - gradesLoading: false + gradesLoading: false, + gradesExporting: false } }, created() { @@ -479,25 +515,65 @@ export default { }, // ==================== 成绩弹窗 ==================== - // TODO: 后端接口未提供,成绩数据为前端模拟;接口就绪后替换为 getStudentGrades / getStudentProcessGrades - handleGrades(row) { + async handleGrades(row) { this.gradesStudent = row.xm || '' + this.gradesStudentNo = row.xh || '' this.currentBh = row.bh || '' - this.gradesData = null - this.processGradesData = null + this.gradesData = [] + this.processGradesData = [] this.gradesTab = 'grades' this.gradesVisible = true this.gradesLoading = true - setTimeout(() => { - this.gradesData = { 学员: row.xm, 学号: row.xh, 课程: '通信原理', 成绩: 92, 学分: 3.0 } - this.processGradesData = { 进程成绩: [{ 名称: '平时成绩', 得分: 95 }, { 名称: '期末成绩', 得分: 88 }] } + + const emptyResponse = { data: { records: [] } } + const query = { pageNum: 1, pageSize: 1000, xybh: this.currentBh } + try { + const [gradesResponse, processGradesResponse] = await Promise.all([ + listStudentGrades(query).catch(() => emptyResponse), + listStudentProcessGrades(query).catch(() => emptyResponse) + ]) + this.gradesData = gradesResponse.data.records || [] + this.processGradesData = processGradesResponse.data.records || [] + } finally { this.gradesLoading = false - }, 300) + } }, - // TODO: 后端接口未提供,导出为前端模拟;接口就绪后替换为 exportStudentGrades - handleExportGrades() { - this.$message.success(`已导出学员${this.gradesStudent}成绩(前端模拟)`) + formatPassStatus(value) { + if (value === 1 || value === '1') { + return '已通过' + } + if (value === 0 || value === '0') { + return '未通过' + } + return '-' + }, + + downloadGradesFile(blob, fileName) { + const link = document.createElement('a') + link.href = URL.createObjectURL(blob) + link.download = fileName + link.click() + URL.revokeObjectURL(link.href) + }, + + async handleExportGrades() { + if (!this.currentBh) { + this.$message.warning('缺少学员编号,无法导出成绩') + return + } + + this.gradesExporting = true + try { + const isProcessGrades = this.gradesTab === 'process' + const request = isProcessGrades ? exportStudentProcessGrades : exportStudentGrades + const blob = await request({ xybh: this.currentBh }) + const suffix = isProcessGrades ? '课程过程成绩' : '课程成绩' + this.downloadGradesFile(blob, `${this.gradesStudent || '学员'}_${suffix}.xlsx`) + this.$message.success(`${suffix}导出成功`) + } finally { + this.gradesExporting = false + } } } } @@ -578,5 +654,13 @@ export default { width: 100%; } + .student-summary { + display: flex; + gap: 32px; + margin-bottom: 8px; + color: #303133; + line-height: 24px; + } + }