添加考试周期

This commit is contained in:
@fawn-nine
2024-09-04 17:11:14 +08:00
parent 3aa551853d
commit ff5748b5a5
4 changed files with 281 additions and 155 deletions

View File

@@ -40,7 +40,7 @@
<el-button size="small" type="primary" @click="addOrUpdateHandle()"
>新增考题</el-button
>
<el-upload
<el-upload
class="upload-demo"
:show-file-list="false"
ref="files"
@@ -49,10 +49,18 @@
:http-request="handleRequest"
>
<!-- accept=".xlsx,.xls" -->
<el-button size="small" type="primary" plain :loading="showLoadIcon" :disabled="showLoadIcon"
<el-button
size="small"
type="primary"
plain
:loading="showLoadIcon"
:disabled="showLoadIcon"
>导入考题 {{ loadText }}</el-button
>
</el-upload>
<el-button size="small" type="danger" @click="clearQuestion()"
>清空题库</el-button
>
<!-- </el-form-item> -->
<!-- <div :loading="showLoadIcon">{{loadText}}</div> -->
</el-form>
@@ -245,7 +253,7 @@ export default {
resList: [],
resListVisible: false,
optCourse: {},
currentFile:{}
currentFile: {}
};
},
components: {
@@ -262,6 +270,38 @@ export default {
this.getTreeList(this.urlList.sociologyList, 2);
},
methods: {
clearQuestion() {
let that = this
this.$confirm("即将清空本课程下的题库, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl("/common/classExam/delSubjectByCourseId"),
method: "post",
data: this.$http.adornData({
courseId: this.course.id
})
})
.then(res => {
if (res.data.code == 0) {
that.$message.success("操作成功!");
that.getDataList()
}else{
that.$message.error(res.data.msg);
}
})
.catch(e => {
that.$message.error(e.data.msg);
_info = null;
});
})
.catch(() => {});
},
numberToABCD(num) {
let result = "";
let mod;
@@ -300,49 +340,36 @@ export default {
this.showLoadIcon = true;
this.loadText = "正在上传中";
},
handleSuccess(file, fileList) {
this.showLoadIcon = false;
this.loadText = "";
console.log("fileurl", this.course.id, file.url);
// handleSuccess(file, fileList) {
// this.showLoadIcon = false;
// this.loadText = "";
// console.log("fileurl", this.course.id, file.url);
this.getQuestList(file.url, this.course.id);
// this.form.imageList.push('file.url',file.url);
},
// this.getQuestList(file.url, this.course.id);
// // this.form.imageList.push('file.url',file.url);
// },
// 请求自动生成接口
getQuestList(url, courseId) {
// this.$http
// .request({
// url: this.$http.adornUrl('/common/classExam/importSubject'),
// method: "POST",
// data: {
// courseId: courseId,
// file:url
// },
// header: {
// //默认 无 说明:请求头
// "Content-Type": "application/json"
// }
// })
this.$http({
url: this.$http.adornUrl("/common/classExam/importSubject"),
method: "post",
data: this.$http.adornData({
courseId: courseId,
file: url
})
})
.then(res => {
console.log("reschenggong", res);
// if (res.data.code == 0) {
// this.$message.success("操作成功!");
// getQuestList(url, courseId) {
// this.$http({
// url: this.$http.adornUrl("/common/classExam/importSubject"),
// method: "post",
// data: this.$http.adornData({
// courseId: courseId,
// file: url
// })
// })
// .then(res => {
// console.log("reschenggong", res);
// // if (res.data.code == 0) {
// // this.$message.success("操作成功!");
// }
})
.catch(e => {
this.$message.error("获取课程信息失败");
_info = null;
});
},
// // }
// })
// .catch(e => {
// this.$message.error("获取课程信息失败");
// _info = null;
// });
// },
handleRemoveNovel() {
console.log("删除文件");
},
@@ -472,7 +499,7 @@ export default {
console.log("🚀 ~ handleRequest ~ formdata:", formdata);
this.showLoadIcon = true;
this.loadText = '正在上传文件'
this.loadText = "正在上传文件";
// onProgress()
axios
.post(this.baseUrl + "/common/classExam/importSubject", formdata, {
@@ -481,11 +508,11 @@ export default {
const percentCompleted = Math.round(
(progressEvent.loaded * 100) / progressEvent.total
);
if(percentCompleted == 100){
that.$message.success('文件上传成功,正在写入数据')
that.loadText = '文件上传成功,正在写入数据'
}else{
that.loadText = `${percentCompleted}%`
if (percentCompleted == 100) {
that.$message.success("文件上传成功,正在写入数据");
that.loadText = "文件上传成功,正在写入数据";
} else {
that.loadText = `${percentCompleted}%`;
}
console.log(`Upload Progress: ${percentCompleted}%`);
}
@@ -497,21 +524,21 @@ export default {
// that.fileList[that.fileList.length - 1].status = "done";
// clearInterval(that.uploadTimer);
that.showLoadIcon = false;
that.loadText = ''
that.loadText = "";
that.currentFile = {};
onSuccess();
that.getDataList()
that.getDataList();
} else {
// that.fileList[that.fileList.length - 1].ststus = "error";
that.$message.error(res.data.msg);
onError();
that.showLoadIcon = false;
that.loadText = ''
that.loadText = "";
}
})
.catch(e => {
that.$message.error(e.data.msg);
that.loadText = ''
that.loadText = "";
});
// var prom = new Promise((resolve, reject) => {});
// prom.abort = () => {};