添加题库导入导出功能
This commit is contained in:
parent
a0a756548c
commit
b29b69cc57
@ -86,8 +86,8 @@ if (process.env.NODE_ENV == "development") {
|
||||
// axios.defaults.baseURL = 'http://192.168.34.221:28889/' //郭圣雄本地
|
||||
// axios.defaults.baseURL = 'http://192.168.34.221:9111/' //郭圣雄本地
|
||||
// axios.defaults.baseURL = 'http://192.168.34.155:19111/' //彭洁本地
|
||||
axios.defaults.baseURL = 'http://182.90.224.237:51234' //郭圣雄远程
|
||||
// axios.defaults.baseURL = 'http://jxj.zhgdyun.com:61212/' //彭洁远程
|
||||
// axios.defaults.baseURL = 'http://182.90.224.237:51234' //郭圣雄远程
|
||||
axios.defaults.baseURL = 'http://jxj.zhgdyun.com:61212/' //彭洁远程
|
||||
// axios.defaults.baseURL ='http://101.43.164.214:45020/' //沈阳和盈
|
||||
// axios.defaults.baseURL ='http://183.249.224.118:9000/' //嘉兴王江泾公用码头
|
||||
// axios.defaults.baseURL ='http://101.43.164.214:11111/' // 百色三标段项目
|
||||
|
||||
@ -48,13 +48,13 @@ export default new Vuex.Store({
|
||||
PAGESIZRS: [10, 20, 30, 50],
|
||||
// UPLOADURL:' http://101.43.164.214:11111/upload/image/',// 百色
|
||||
// FILEURL:' http://101.43.164.214:11111/image/',// 百色
|
||||
// UPLOADURL:'http://182.90.224.237:51234/upload/image/',
|
||||
// FILEURL:'http://182.90.224.237:51234/image/',
|
||||
UPLOADURL:'http://182.90.224.237:51234/upload/image/',
|
||||
FILEURL:'http://182.90.224.237:51234/image/',
|
||||
// UPLOADURL: "http://http://192.168.34.155:19111/upload/image/", // 洁本地
|
||||
// FILEURL: "http://http://192.168.34.155:19111/image/", //洁本地
|
||||
UPLOADURL:'http://192.168.34.221:9111/upload/image/',// 郭圣雄本地
|
||||
FILEURL:'http://192.168.34.221:9111/image/',//郭圣雄本地
|
||||
WORKFLOWURL: "http://192.168.34.138:88/#/workspace/forms", //坤工作流地址(本地)
|
||||
// UPLOADURL:'http://192.168.34.221:9111/upload/image/',// 郭圣雄本地
|
||||
// FILEURL:'http://192.168.34.221:9111/image/',//郭圣雄本地
|
||||
// WORKFLOWURL: "http://192.168.34.138:88/#/workspace/forms", //坤工作流地址(本地)
|
||||
// WORKFLOWURL: "http://192.168.34.126:88/#/workspace/forms", //罗峰工作流地址(本地)
|
||||
// UPLOADURL:'http://182.90.224.237:51234/upload/image/',// 郭圣雄远程
|
||||
// FILEURL:'http://182.90.224.237:51234/image/',//郭圣雄远程
|
||||
|
||||
@ -58,9 +58,29 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" size="medium" @click="addQuestionBtn"
|
||||
v-permission="{key: 'questionManagement_add', menuPath: '/project/examSystem2/questionManagement'}"
|
||||
>添加试题</el-button
|
||||
v-permission="{key: 'questionManagement_add', menuPath: '/project/examSystem2/questionManagement'}">
|
||||
添加试题
|
||||
</el-button>
|
||||
<!-- <el-button type="primary" plain size="medium" @click="downloadFn"
|
||||
v-permission="{key: 'questionManagement_download', menuPath: '/project/examSystem2/questionManagement'}">
|
||||
下载题库导入模板
|
||||
</el-button> -->
|
||||
<el-button type="primary" plain size="medium" @click="exportFn"
|
||||
v-permission="{key: 'questionManagement_export', menuPath: '/project/examSystem2/questionManagement'}">
|
||||
导出题库
|
||||
</el-button>
|
||||
<el-upload ref="upload" :headers="headers" :before-upload="beforeAvatarUpload" :on-success="handleSuccess"
|
||||
:action="$http.defaults.baseURL + 'exam/questionBank/importExcel'"
|
||||
:limit="1" :show-file-list="false"
|
||||
:data="{ sn: $store.state.userInfo.headquartersSn }"
|
||||
name="excelFile"
|
||||
style="float: right; margin: 0 0 0 15px"
|
||||
>
|
||||
<el-button type="primary" plain size="medium" @click="importFn"
|
||||
v-permission="{key: 'questionManagement_import', menuPath: '/project/examSystem2/questionManagement'}">
|
||||
导入题库
|
||||
</el-button>
|
||||
</el-upload>
|
||||
</div>
|
||||
<vue-scroll style="height: calc(100% - 160px)">
|
||||
<el-table
|
||||
@ -482,7 +502,7 @@ import {
|
||||
exportQuestionBankApi,
|
||||
detailIdQuestionBankApi,
|
||||
moveQuestionBankApi,
|
||||
|
||||
importQuestionBankApi,
|
||||
} from '@/assets/js/api/examSystem/examSystem'
|
||||
export default {
|
||||
name: "questionManagement",
|
||||
@ -579,7 +599,7 @@ export default {
|
||||
subjectName:"",
|
||||
currentNodekey:"",
|
||||
checkList:[],
|
||||
|
||||
fullscreenLoading: false,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@ -611,6 +631,96 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSuccess(res, file) {
|
||||
console.log(res)
|
||||
this.$refs.upload.clearFiles()
|
||||
this.fullscreenLoading = false
|
||||
if (res.code == 200 || res.code == 0) {
|
||||
this.$message.success('题库导入成功')
|
||||
this.getList()
|
||||
} else {
|
||||
this.$message.error('题库导出失败')
|
||||
}
|
||||
},
|
||||
beforeAvatarUpload() {
|
||||
this.fullscreenLoading = true
|
||||
},
|
||||
importFn(){
|
||||
console.log('导入')
|
||||
},
|
||||
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,{
|
||||
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 = '题库导出文件.xls'; // 指定下载文件的文件名
|
||||
// 模拟点击下载链接
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
// 释放URL对象
|
||||
window.URL.revokeObjectURL(url);
|
||||
// 处理导出的文件
|
||||
// 这里可以使用blob对象来获取导出的文件内容或者将其保存到本地
|
||||
})
|
||||
.catch(error => {
|
||||
// 处理错误
|
||||
console.error(error);
|
||||
});
|
||||
},
|
||||
// 下载模板
|
||||
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);
|
||||
});
|
||||
},
|
||||
handleInputArea(){
|
||||
this.$forceUpdate()
|
||||
},
|
||||
@ -945,31 +1055,6 @@ export default {
|
||||
// this.$message.error(this.$t('message.laborMange.hint7'))
|
||||
// this.refreshBtn()
|
||||
},
|
||||
exportFn() {
|
||||
exportQuestionBankApi().then(result => {
|
||||
if (result.success) {
|
||||
console.log('信息编辑成功', result);
|
||||
}
|
||||
})
|
||||
// window.location.href =
|
||||
// this.$http.defaults.baseURL +
|
||||
// 'xmgl/download/exporZipWorkerInfo?idCard=' +
|
||||
// this.tableParameter.idCard +
|
||||
// '&projectSn=' +
|
||||
// this.tableParameter.projectSn +
|
||||
// '&teamId=' +
|
||||
// this.tableParameter.teamId +
|
||||
// '&workerName=' +
|
||||
// this.tableParameter.workerName +
|
||||
// '&personType=' +
|
||||
// this.tableParameter.personType +
|
||||
// '&enterDate=' +
|
||||
// this.tableParameter.enterDate +
|
||||
// '&codeState=' +
|
||||
// this.tableParameter.codeState +
|
||||
// '&enterpriseId=' +
|
||||
// this.checkedId
|
||||
},
|
||||
//刷新按钮
|
||||
refreshBtn() {
|
||||
window._paq.push(['trackEvent', '点击', '刷新', '刷新人员信息'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user