BUG:教学管理成绩查询功能错误携带之前的班级

This commit is contained in:
fan 2023-01-03 15:38:52 +08:00
parent 845ffc335e
commit fe080d704f
2 changed files with 51 additions and 49 deletions

View File

@ -303,7 +303,9 @@ export default {
methods: { methods: {
// //
initQueryModel() { initQueryModel() {
this.formModel = localStore.get(this.$route.path) || this.formModel; if (!this.queryForm.notRecord) {
this.formModel = localStore.get(this.$route.path) || this.formModel;
}
this.buildForm(); this.buildForm();
if (typeof this.queryForm.initLoadCallback === 'function') { if (typeof this.queryForm.initLoadCallback === 'function') {
this.queryForm.initLoadCallback(this.formModel); this.queryForm.initLoadCallback(this.formModel);
@ -350,7 +352,6 @@ export default {
// //
const queryObject = {}; const queryObject = {};
const model = {}; const model = {};
// debugger;
for (const item in this.queryForm.queryObject) { for (const item in this.queryForm.queryObject) {
if (this.queryForm.queryObject.show === false) { if (this.queryForm.queryObject.show === false) {
continue; continue;

View File

@ -1,22 +1,22 @@
<template> <template>
<div> <div>
<div class="title_content">{{ $route.query.name + '成绩查询' }}</div> <div class="title_content">{{ $route.query.name + '成绩查询' }}</div>
<el-button type="text" style="position: fixed;right: 20px;top: 70px;" @click="back">返回</el-button> <el-button type="text" style="position: fixed;right: 20px;top: 70px;" @click="back">返回</el-button>
<QueryListPage <QueryListPage
ref="queryListPage" ref="queryListPage"
:query-form="queryForm" :query-form="queryForm"
:pager-config="pagerConfig" :pager-config="pagerConfig"
:query-list="queryList" :query-list="queryList"
style="width:90%;margin: 0 auto;" style="width:90%;margin: 0 auto;"
/> />
</div> </div>
</template> </template>
<script> <script>
import { getClassGradeList } from '@/api/management/userexam' import { getClassGradeList } from '@/api/management/userexam';
import { getClassListUnPage } from '@/api/company' import { getClassListUnPage } from '@/api/company';
import XLSX from 'xlsx' import XLSX from 'xlsx';
import localStore from 'storejs' import localStore from 'storejs';
export default { export default {
name: 'GradeList', name: 'GradeList',
data() { data() {
@ -26,20 +26,21 @@ export default {
labelWidth: '90px', labelWidth: '90px',
textAlign: 'right', textAlign: 'right',
reset: false, reset: false,
notRecord: true,
queryObject: { queryObject: {
orgId: { orgId: {
type: 'select', type: 'select',
noClearable: true, noClearable: true,
label: '班级:', label: '班级:',
config: { config: {
data: [], data: []
}, }
}, }
}, }
}, },
pagerConfig: { pagerConfig: {
pageSize: 'pageSize', pageSize: 'pageSize',
pageIndex: 'pageNum', pageIndex: 'pageNum'
}, },
queryList: { queryList: {
query: this.queryFunction, query: this.queryFunction,
@ -49,60 +50,60 @@ export default {
columns: [ columns: [
{ {
title: '姓名', title: '姓名',
prop: 'nickname', prop: 'nickname'
}, },
{ {
title: '学号', title: '学号',
prop: 'account', prop: 'account'
}, },
{ {
title: '状态', title: '状态',
prop: 'result', prop: 'result',
type: 'tag', type: 'tag',
columnValue: row => ['未知', '通过', '不通过', '未参加', '未提交'][row.result], columnValue: row => ['未知', '通过', '不通过', '未参加', '未提交'][row.result],
tagType: row => ['', 'success', 'danger', 'info', 'warning'][row.result], tagType: row => ['', 'success', 'danger', 'info', 'warning'][row.result]
}, },
{ {
title: '得分', title: '得分',
prop: 'score', prop: 'score'
}, }
], ],
actions: [{ text: '导出成绩', handler: this.exportGrade }], actions: [{ text: '导出成绩', handler: this.exportGrade }]
}, }
} };
}, },
async created() { async created() {
const resp = await getClassListUnPage() const resp = await getClassListUnPage();
const classList = [] const classList = [];
resp.data && resp.data &&
resp.data.forEach(item => { resp.data.forEach(item => {
classList.push({ value: item.id, label: item.name }) classList.push({ value: item.id, label: item.name });
localStore.set(this.$route.path, { orgId: classList[0].value + '' }) localStore.set(this.$route.path, { orgId: classList[0].value + '' });
}) });
this.queryForm.queryObject.orgId.config.data = classList this.queryForm.queryObject.orgId.config.data = classList;
}, },
methods: { methods: {
exportGrade() { exportGrade() {
// ; // ;
const wb = XLSX.utils.book_new() const wb = XLSX.utils.book_new();
const data = [{ A: '学号', B: '姓名', C: '得分' }] const data = [{ A: '学号', B: '姓名', C: '得分' }];
this.queryList.data && this.queryList.data &&
this.queryList.data.forEach(item => { this.queryList.data.forEach(item => {
data.push({ A: item.account, B: item.username, C: item.score }) data.push({ A: item.account, B: item.username, C: item.score });
}) });
const ws = XLSX.utils.json_to_sheet(data, { skipHeader: true }) const ws = XLSX.utils.json_to_sheet(data, { skipHeader: true });
ws['!cols'] = [{ width: 20 }, { width: 20 }, { width: 20 }] ws['!cols'] = [{ width: 20 }, { width: 20 }, { width: 20 }];
XLSX.utils.book_append_sheet(wb, ws, 'file') XLSX.utils.book_append_sheet(wb, ws, 'file');
XLSX.writeFile(wb, `${this.$route.query.name}成绩.xlsx`) XLSX.writeFile(wb, `${this.$route.query.name}成绩.xlsx`);
}, },
queryFunction(params) { queryFunction(params) {
return getClassGradeList({ pcId: this.$route.query.examId, ...params }) return getClassGradeList({ pcId: this.$route.query.examId, ...params });
}, },
back() { back() {
this.$router.go(-1) this.$router.go(-1);
}, }
}, }
} };
</script> </script>
<style scoped> <style scoped>