diff --git a/frontend/src/api/studentRecords/studentRecords.js b/frontend/src/api/studentRecords/studentRecords.js index 1a19ecea..57a5d04e 100644 --- a/frontend/src/api/studentRecords/studentRecords.js +++ b/frontend/src/api/studentRecords/studentRecords.js @@ -45,7 +45,7 @@ export function delStudentRecord(bh) { }) } -// 分页查询学员课程成绩(xybh 学员编号必传;nd 年度可选) +// 分页查询学员课程成绩(kcbh/xydbh/xh/nd 查询) export function listStudentGrades(query) { return request({ url: '/student-records/grades', @@ -54,7 +54,7 @@ export function listStudentGrades(query) { }) } -// 分页查询学员课程过程成绩(xybh 学员编号必传;nd 年度可选) +// 分页查询学员课程过程成绩(kcbh/xydbh/xh/nd 查询) export function listStudentProcessGrades(query) { return request({ url: '/student-records/process-grades', @@ -63,22 +63,22 @@ export function listStudentProcessGrades(query) { }) } -// 导出学员课程成绩 Excel(xybh 学员编号必传) -export function exportStudentGrades(xybh) { +// 导出学员课程成绩 Excel(kcbh/xydbh/xh/nd 查询) +export function exportStudentGrades(query) { return request({ url: '/student-records/export-grades', method: 'get', - params: { xybh: xybh }, + params: query, responseType: 'blob' }) } -// 导出学员课程过程成绩 Excel(xybh 学员编号必传) -export function exportStudentProcessGrades(xybh) { +// 导出学员课程过程成绩 Excel(kcbh/xydbh/xh/nd 查询) +export function exportStudentProcessGrades(query) { return request({ url: '/student-records/export-process-grades', method: 'get', - params: { xybh: xybh }, + params: query, responseType: 'blob' }) } \ No newline at end of file diff --git a/frontend/src/views/student/score/index.vue b/frontend/src/views/student/score/index.vue index 35d3cef2..fd37ff32 100644 --- a/frontend/src/views/student/score/index.vue +++ b/frontend/src/views/student/score/index.vue @@ -3,12 +3,22 @@ - - + + + + + + + + + + + + 查询 @@ -27,7 +37,6 @@ - @@ -37,7 +46,7 @@ - + @@ -47,7 +56,6 @@ - @@ -78,6 +86,8 @@ import { exportStudentGrades, exportStudentProcessGrades } from "@/api/studentRecords/studentRecords" +import { listKb } from "@/api/teachOffice/kb" +import { listTeam } from "@/api/studentRecords/team" export default { name: 'ScoreIndex', @@ -85,10 +95,16 @@ export default { return { // ==================== 查询条件 ==================== queryForm: { - xybh: '', - nd: '' + xh: '', + nd: '', + kcbh: '', + xydbh: '' }, + // ==================== 下拉选项 ==================== + kbOptions: [], + teamOptions: [], + // ==================== 数据表格 ==================== // 数据来源:grades 课程成绩 / process 课程过程成绩 activeTab: 'grades', @@ -107,15 +123,48 @@ export default { } }, mounted() { + this.loadKbOptions() + this.loadTeamOptions() this.loadData() }, methods: { + /** 格式化考试结果:1 已通过,0 不通过 */ + formatExamResult(row, column, cellValue) { + if (cellValue === 1 || cellValue === '1') return '已通过' + if (cellValue === 0 || cellValue === '0') return '不通过' + return '' + }, + + /** 加载课程名称下拉选项 */ + loadKbOptions() { + listKb({ pageNum: 1, pageSize: 1000 }).then(res => { + const data = res.data || {} + this.kbOptions = data.records || [] + }).catch(() => { + this.kbOptions = [] + }) + }, + + /** 加载班次下拉选项 */ + loadTeamOptions() { + listTeam({ pageNum: 1, pageSize: 1000 }).then(res => { + const data = res.data || {} + this.teamOptions = data.records || [] + }).catch(() => { + this.teamOptions = [] + }) + }, + /** 组装查询参数,仅传非空值 */ buildQueryParams(params) { - const xybh = this.queryForm.xybh && this.queryForm.xybh.trim() + const xh = this.queryForm.xh && this.queryForm.xh.trim() const nd = this.queryForm.nd && this.queryForm.nd.trim() - if (xybh) params.xybh = xybh + const kcbh = this.queryForm.kcbh && this.queryForm.kcbh.trim() + const xydbh = this.queryForm.xydbh && this.queryForm.xydbh.trim() + if (xh) params.xh = xh if (nd) params.nd = nd + if (kcbh) params.kcbh = kcbh + if (xydbh) params.xydbh = xydbh }, loadData() { @@ -170,23 +219,19 @@ export default { URL.revokeObjectURL(link.href) }, - /** 校验导出所需学员编号 */ - requireXybh(exportName) { - const xybh = this.queryForm.xybh && this.queryForm.xybh.trim() - if (!xybh) { - this.$message.warning('导出' + exportName + '前请先输入学员编号') - return null - } - return xybh + /** 构建导出查询参数 */ + buildExportQuery() { + const query = {} + this.buildQueryParams(query) + return query }, /** 导出课程成绩 Excel */ handleExportGrades() { - const xybh = this.requireXybh('课程成绩') - if (!xybh) return + const query = this.buildExportQuery() this.exportLoading = true - exportStudentGrades(xybh).then(res => { - this.downloadBlob(res, `课程成绩_${xybh}.xls`) + exportStudentGrades(query).then(res => { + this.downloadBlob(res, `课程成绩_${Date.now()}.xls`) this.$message.success('课程成绩导出成功') }).catch(() => { }).finally(() => { this.exportLoading = false @@ -195,11 +240,10 @@ export default { /** 导出课程过程成绩 Excel */ handleExportProcessGrades() { - const xybh = this.requireXybh('课程过程成绩') - if (!xybh) return + const query = this.buildExportQuery() this.exportLoading = true - exportStudentProcessGrades(xybh).then(res => { - this.downloadBlob(res, `课程过程成绩_${xybh}.xls`) + exportStudentProcessGrades(query).then(res => { + this.downloadBlob(res, `课程过程成绩_${Date.now()}.xls`) this.$message.success('课程过程成绩导出成功') }).catch(() => { }).finally(() => { this.exportLoading = false