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