Merge branch 'bjxz-cjw' into bjxz-dev

This commit is contained in:
Vce 2024-06-04 20:52:54 +08:00
commit e2e3ca95d4
2 changed files with 59 additions and 41 deletions

View File

@ -2,6 +2,7 @@
* 考试系统api接口统一管理
*/
import { post, get } from '../../http'
import axios from 'axios'
//杂项Api
export const getWorkerInfoListApi = data => post('xmgl/workerInfo/selectWorkerInfoList', data); // 查询临时人员
@ -72,6 +73,10 @@ export const importQuestionBankApi = data => post('exam/questionBank/importExcel
export const detailIdQuestionBankApi = data => post('exam/questionBank/queryById', data) //查询题目详情
export const moveQuestionBankApi = data => post('exam/questionBank/move', data) //移动科目类别
export const getRandomQuestionApi = data => post('exam/questionBank/random', data) //随机获取题目
// 题库模板下载
export function downloadTheTemplate(projectSn) {
window.location.href = axios.defaults.baseURL + `xmgl/download/exporExcelExamQuestionTemplate?projectSn=${projectSn}`;
}
// 考试管理

View File

@ -61,10 +61,10 @@
v-permission="{key: 'questionManagement_add', menuPath: '/project/examSystem2/questionManagement'}">
添加试题
</el-button>
<!-- <el-button type="primary" plain size="medium" @click="downloadFn"
<el-button type="primary" plain size="medium" @click="downloadFn"
v-permission="{key: 'questionManagement_download', menuPath: '/project/examSystem2/questionManagement'}">
下载题库导入模板
</el-button> -->
</el-button>
<el-button type="primary" plain size="medium" @click="exportFn"
v-permission="{key: 'questionManagement_export', menuPath: '/project/examSystem2/questionManagement'}">
导出题库
@ -116,7 +116,8 @@
</el-table-column>
<el-table-column prop="options" width="100px" label="试题答案">
<template slot-scope="scope">
{{sortedOptions(scope.row.options)}}
<!-- {{sortedOptions(scope.row.options)}} -->
{{scope.row.options}}
</template>
</el-table-column>
<el-table-column prop="createTime" width="180px" label="创建时间"></el-table-column>
@ -503,6 +504,7 @@ import {
detailIdQuestionBankApi,
moveQuestionBankApi,
importQuestionBankApi,
downloadTheTemplate,
} from '@/assets/js/api/examSystem/examSystem'
export default {
name: "questionManagement",
@ -636,10 +638,11 @@ export default {
this.$refs.upload.clearFiles()
this.fullscreenLoading = false
if (res.code == 200 || res.code == 0) {
this.$message.success('题库导入成功')
this.$message.success(res.message)
this.getList()
} else {
this.$message.error('题库导入失败')
//
this.$message.error(res.message)
}
},
beforeAvatarUpload() {
@ -651,10 +654,18 @@ export default {
exportFn() {
// fetch(this.$http.defaults.baseURL + 'exam/questionBank/exportXls?&projectSn=' + this.projectSn + '&endReceiveTime=' + this.time[1] + '&startReceiveTime=' + this.time[0] + '&devName=' + this.devName, {
// + '&endReceiveTime=' + this.time[1] + '&startReceiveTime=' + this.time[0] + '&devName=' + this.devName, {
fetch(this.$http.defaults.baseURL + 'exam/questionBank/exportXls?&projectSn=' + this.projectSn + "&subjectId=" + this.subjectId,{
// fetch(this.$http.defaults.baseURL + 'exam/questionBank/exportXls?&projectSn=' + this.projectSn + "&subjectId=" + this.subjectId,{
let data = {
projectSn:this.projectSn,
subjectId:this.subjectId
}
fetch(this.$http.defaults.baseURL + 'exam/questionBank/exportXls',{
method: "POST",
headers: {
'Authorization': this.$store.state.userInfo.token
}
'Authorization': this.$store.state.userInfo.token,
'Content-Type': 'application/json' // JSON
},
body: JSON.stringify(data)
})
.then(response => {
//
@ -679,6 +690,7 @@ export default {
window.URL.revokeObjectURL(url);
//
// 使blob
})
.catch(error => {
//
@ -687,39 +699,40 @@ export default {
},
//
downloadFn() {
fetch(this.$http.defaults.baseURL + 'exam/questionBank/exportXls?&projectSn=' + this.projectSn, {
headers: {
'Authorization': this.$store.state.userInfo.token
}
})
.then(response => {
//
if (!response.ok) {
throw new Error('导出失败');
}
return response.blob();
})
.then(blob => {
console.log('导出成功');
//
const url = window.URL.createObjectURL(blob);
// <a>
const link = document.createElement('a');
link.href = url;
link.download = '题库导入模板.xlsx'; //
//
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// URL
window.URL.revokeObjectURL(url);
//
// 使blob
})
.catch(error => {
//
console.error(error);
});
downloadTheTemplate(this.projectSn)
// fetch(this.$http.defaults.baseURL + 'exam/questionBank/exportXls?&projectSn=' + this.projectSn, {
// headers: {
// 'Authorization': this.$store.state.userInfo.token
// }
// })
// .then(response => {
// //
// if (!response.ok) {
// throw new Error('');
// }
// return response.blob();
// })
// .then(blob => {
// console.log('');
// //
// const url = window.URL.createObjectURL(blob);
// // <a>
// const link = document.createElement('a');
// link.href = url;
// link.download = '.xlsx'; //
// //
// document.body.appendChild(link);
// link.click();
// document.body.removeChild(link);
// // URL
// window.URL.revokeObjectURL(url);
// //
// // 使blob
// })
// .catch(error => {
// //
// console.error(error);
// });
},
handleInputArea(){
this.$forceUpdate()