思考题
This commit is contained in:
@@ -41,19 +41,17 @@
|
||||
>新增考题</el-button
|
||||
>
|
||||
<el-upload
|
||||
style="display: inline-block;margin-left: 10px;"
|
||||
:limit="1"
|
||||
class="upload-demo"
|
||||
:action="baseUrl + '/oss/fileoss'"
|
||||
:show-file-list="false"
|
||||
multiple
|
||||
:on-exceed="handleExceed"
|
||||
:on-success="handleSuccess"
|
||||
:before-upload="beforeUploadHandle"
|
||||
ref="files"
|
||||
action="#"
|
||||
accept=".xlsx,.xls"
|
||||
:on-remove="handleRemoveNovel"
|
||||
:http-request="handleRequest"
|
||||
>
|
||||
<!-- accept=".xlsx,.xls" -->
|
||||
<el-button size="small" type="primary" plain :loading="showLoadIcon" :disabled="showLoadIcon"
|
||||
>导入考题 {{ loadText }}</el-button
|
||||
>
|
||||
<el-button size="small" type="primary" plain :loading="showLoadIcon">导入考题 {{loadText}}</el-button>
|
||||
</el-upload>
|
||||
<!-- </el-form-item> -->
|
||||
<!-- <div :loading="showLoadIcon">{{loadText}}</div> -->
|
||||
@@ -188,13 +186,13 @@
|
||||
import global from "@/views/common/common.vue"; //引入共用组间
|
||||
import commonShopTable from "./questionBank/shopproductTable.vue";
|
||||
import Add from "./questionBank/add.vue";
|
||||
|
||||
import axios from "axios";
|
||||
export default {
|
||||
props: ["course"],
|
||||
data() {
|
||||
return {
|
||||
showLoadIcon: false,
|
||||
loadText:'',
|
||||
loadText: "",
|
||||
baseUrl: global.baseUrl,
|
||||
selectType: [],
|
||||
shopTableVisible: false,
|
||||
@@ -246,7 +244,8 @@ export default {
|
||||
},
|
||||
resList: [],
|
||||
resListVisible: false,
|
||||
optCourse: {}
|
||||
optCourse: {},
|
||||
currentFile:{}
|
||||
};
|
||||
},
|
||||
components: {
|
||||
@@ -298,17 +297,54 @@ export default {
|
||||
},
|
||||
beforeUploadHandle() {
|
||||
// this.$message.info('正在上传中')
|
||||
this.showLoadIcon = true
|
||||
this.loadText = '正在上传中'
|
||||
this.showLoadIcon = true;
|
||||
this.loadText = "正在上传中";
|
||||
},
|
||||
handleSuccess(file, fileList) {
|
||||
this.showLoadIcon = false
|
||||
this.loadText = ''
|
||||
console.log('fileurl', file.url)
|
||||
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);
|
||||
},
|
||||
// 请求自动生成接口
|
||||
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("操作成功!");
|
||||
|
||||
// }
|
||||
})
|
||||
.catch(e => {
|
||||
this.$message.error("获取课程信息失败");
|
||||
_info = null;
|
||||
});
|
||||
},
|
||||
handleRemoveNovel() {
|
||||
console.log('删除文件')
|
||||
console.log("删除文件");
|
||||
},
|
||||
handleExceed(files, fileList) {
|
||||
this.$message.warning(`当前限制选择 3 个文件`);
|
||||
@@ -422,6 +458,63 @@ export default {
|
||||
}
|
||||
this.directorShow = true;
|
||||
},
|
||||
handleRequest(option) {
|
||||
console.log("jinlailema");
|
||||
var that = this;
|
||||
const { onProgress, onSuccess, onError } = option;
|
||||
// this.progressPercent = 0;
|
||||
|
||||
this.currentFile = option.file;
|
||||
let formdata = new FormData();
|
||||
formdata.append("file", option.file);
|
||||
// formdata.append("fileName", option.file.fileNamee);
|
||||
formdata.append("courseId", this.course.id);
|
||||
console.log("🚀 ~ handleRequest ~ formdata:", formdata);
|
||||
|
||||
this.showLoadIcon = true;
|
||||
this.loadText = '正在上传文件'
|
||||
// onProgress()
|
||||
axios
|
||||
.post(this.baseUrl + "/common/classExam/importSubject", formdata, {
|
||||
headers: { token: this.$cookie.get("token") },
|
||||
onUploadProgress: function(progressEvent) {
|
||||
const percentCompleted = Math.round(
|
||||
(progressEvent.loaded * 100) / progressEvent.total
|
||||
);
|
||||
if(percentCompleted == 100){
|
||||
that.$message.success('文件上传成功,正在写入数据')
|
||||
that.loadText = '文件上传成功,正在写入数据'
|
||||
}
|
||||
console.log(`Upload Progress: ${percentCompleted}%`);
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
// console.log("上传成功", res);
|
||||
if (res.data.code == 0) {
|
||||
this.$message.success("导入成功!");
|
||||
// that.fileList[that.fileList.length - 1].status = "done";
|
||||
// clearInterval(that.uploadTimer);
|
||||
that.showLoadIcon = false;
|
||||
that.loadText = ''
|
||||
that.currentFile = {};
|
||||
onSuccess();
|
||||
that.getDataList()
|
||||
} else {
|
||||
// that.fileList[that.fileList.length - 1].ststus = "error";
|
||||
that.$message.error(res.data.msg);
|
||||
onError();
|
||||
that.showLoadIcon = false;
|
||||
that.loadText = ''
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
that.$message.error(e.data.msg);
|
||||
that.loadText = ''
|
||||
});
|
||||
// var prom = new Promise((resolve, reject) => {});
|
||||
// prom.abort = () => {};
|
||||
// return prom;
|
||||
},
|
||||
// 检索教务信息
|
||||
getDirectorInfo(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -730,6 +823,9 @@ export default {
|
||||
color: #149f97;
|
||||
}
|
||||
}
|
||||
.upload-demo {
|
||||
display: contents;
|
||||
}
|
||||
.flexbox {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
@@ -586,6 +586,7 @@ export default {
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false;
|
||||
this.tableData = []
|
||||
this.relationProductIds = [];
|
||||
this.relationProducts = [];
|
||||
this.$emit("refreshDataList");
|
||||
@@ -627,9 +628,11 @@ export default {
|
||||
handlereset() {
|
||||
// (this.fileList = []), (this.fileListNovel = []), (this.visible = false);
|
||||
this.$emit("pclose");
|
||||
|
||||
// this.relationProducts = [];
|
||||
// this.courseId = undefined;
|
||||
this.visible = false;
|
||||
this.tableData = []
|
||||
},
|
||||
handlePreview(file) {
|
||||
console.log(file);
|
||||
|
||||
Reference in New Issue
Block a user