Commit 325c665c authored by FangYuePeng's avatar FangYuePeng

试题导入

parent a714e453
...@@ -78,3 +78,29 @@ export function updateStatus(data) { ...@@ -78,3 +78,29 @@ export function updateStatus(data) {
data data
}) })
} }
// 8.下载开课导入模板
export function importTemplateTrialCourse(params) {
return request({
url: '/teaexamquestions/importTemplate',
method: 'get',
responseType: 'blob',
params
})
}
// 9.导入开课信息
export function importExcel(data, courseId) {
return request({
url: '/teaexamquestions/importDictData',
method: 'post',
headers: {
'Content-Type': 'multipart/form-data'
},
transformRequest: [(data) => {
return data
}],
data,
params: { courseId }
})
}
...@@ -1222,7 +1222,7 @@ export default { ...@@ -1222,7 +1222,7 @@ export default {
this.$router.push({ this.$router.push({
path: '/courseInformation/examinationManagement/index', path: '/courseInformation/examinationManagement/index',
query: { query: {
bussinessId: data.bussinessId, bussinessId: data.businessId,
courseId: data.businessId, courseId: data.businessId,
name: data.lessonName, name: data.lessonName,
passingGrade: data.passingGrade passingGrade: data.passingGrade
......
...@@ -295,8 +295,6 @@ ...@@ -295,8 +295,6 @@
</div> </div>
</el-dialog> </el-dialog>
<!-- 导入对话框 --> <!-- 导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="500px" append-to-body> <el-dialog :title="upload.title" :visible.sync="upload.open" width="500px" append-to-body>
<el-upload <el-upload
...@@ -331,7 +329,6 @@ ...@@ -331,7 +329,6 @@
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
...@@ -341,10 +338,10 @@ import { parseTime } from '@/utils' ...@@ -341,10 +338,10 @@ import { parseTime } from '@/utils'
import { import {
addTeaExamQuestions, addTeaExamQuestions,
delTeaExamQuestions, getTeaExamQuestions, delTeaExamQuestions, getTeaExamQuestions,
listTeaExamQuestions, updateStatus, updateTeaExamQuestions listTeaExamQuestions, updateStatus, updateTeaExamQuestions, importExcel, importTemplateTrialCourse
} from '@/api/examination/teaExamQuestions' } from '@/api/examination/teaExamQuestions'
import {importExcel, importTemplateTrialCourse} from "@/api/try/teaTrialCourse";
import {getToken} from "@/utils/auth"; import { getToken } from '@/utils/auth'
export default { export default {
name: 'ExaminationPaper', name: 'ExaminationPaper',
props: { props: {
...@@ -484,6 +481,8 @@ export default { ...@@ -484,6 +481,8 @@ export default {
} }
}, },
created() { created() {
this.courseId = this.$route.query.courseId
console.log(this.courseId)
}, },
mounted: function() { mounted: function() {
this.loadData() this.loadData()
...@@ -822,7 +821,7 @@ export default { ...@@ -822,7 +821,7 @@ export default {
number: '', number: '',
questionType: 1, questionType: 1,
questionStem: '', questionStem: '',
courseId: this.bussinessId === '' ? '' : this.bussinessId, courseId: this.courseId === '' ? '' : this.courseId,
difficulty: 1, difficulty: 1,
content: '', content: '',
answer: '', answer: '',
...@@ -882,6 +881,7 @@ export default { ...@@ -882,6 +881,7 @@ export default {
}, },
// 提交上传文件 // 提交上传文件
submitFileForm() { submitFileForm() {
var courseId = this.courseId
// this.$refs.upload.submit() // this.$refs.upload.submit()
this.importLoading = true this.importLoading = true
if (this.fileList.length === 0) { if (this.fileList.length === 0) {
...@@ -892,14 +892,15 @@ export default { ...@@ -892,14 +892,15 @@ export default {
} else { // 根据后台需求数据格式 } else { // 根据后台需求数据格式
var formData = new FormData() // 当前为空 var formData = new FormData() // 当前为空
formData.append('file', this.fileList) formData.append('file', this.fileList)
importExcel(formData).then(res => {
importExcel(formData, courseId).then(res => {
if (res.code === 200) { if (res.code === 200) {
this.$message.success(res.data) this.$message.success(res.data)
this.fileList = [] this.fileList = []
// 导入成功后关闭弹出框 // 导入成功后关闭弹出框
this.upload.open = false this.upload.open = false
// 导入成功后刷新页面 // 导入成功后刷新页面
this.getList() this.loadData()
} }
this.importLoading = false this.importLoading = false
}).catch(err => { }).catch(err => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment