提交 8776bf95 编写于 作者: chengxiang.li's avatar chengxiang.li

update

上级 7b9f1037
...@@ -25,4 +25,21 @@ ...@@ -25,4 +25,21 @@
text-align: right; text-align: right;
} }
} }
.batch-import-wrap{
.el-upload-list{
display: none;
}
.upload-success-modal{
.el-dialog__body{
padding: 5px 25px 20px;
}
.tips{
text-align: center;
line-height: 25px;
i{
color: #449284;
}
}
}
}
} }
\ No newline at end of file
<template> <template>
<div> <div class="batch-import-wrap">
<div class="step-guide"> <div class="step-guide">
<ul class="guide-list"> <ul class="guide-list">
<li class="first"> <li class="first">
...@@ -59,18 +59,10 @@ ...@@ -59,18 +59,10 @@
class="upload-file" class="upload-file"
drag drag
action="#" action="#"
accept=".xlsx"
:headers="uploadHeaders"
:file-list="files"
:before-upload="getPostData" :before-upload="getPostData"
:on-change="changeFile" :http-request="notUseDefaultUpload">
:on-error="uploadError"
:on-success="uploadSuccess"
:show-file-list="false"
:multiple="false">
<i class="el-icon-upload"></i> <i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<!-- <div class="el-upload__tip" slot="tip">只能上传jpg/png文件,且不超过500kb</div> -->
</el-upload> </el-upload>
</div> </div>
</li> </li>
...@@ -127,6 +119,20 @@ ...@@ -127,6 +119,20 @@
layout="total, sizes, prev, pager, next, jumper"> layout="total, sizes, prev, pager, next, jumper">
</el-pagination> </el-pagination>
</div> </div>
<!-- 上传成功弹窗 -->
<el-dialog
class="upload-success-modal"
title="上传成功"
:visible.sync="showUploadSuccess"
width="400px"
:show-close="false"
:close-on-click-modal="false"
center>
<p class="tips">我们会在<i>3-5个工作日</i>内进行处理,届时您可以在上传历史记录列表查看处理结果</p>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleCloseUploadSuccess">我知道了</el-button>
</span>
</el-dialog>
</div> </div>
</template> </template>
...@@ -151,17 +157,30 @@ ...@@ -151,17 +157,30 @@
token: localStorage.getItem('token') token: localStorage.getItem('token')
}, },
files: [], files: [],
postData: {axx: 1}, postData: {},
showUploadSuccess: false,
} }
}, },
created() { created() {
this.goToGetUploadHistory(); this.goToGetUploadHistory();
}, },
methods: { methods: {
notUseDefaultUpload(){
// console.log('just console>>>>>>>>')
},
getPostData(file) { getPostData(file) {
let self = this; let self = this;
let arr = file.type.split('/'); let arr = file.type.split('/');
let ext = "." + arr[1]; let ext = "." + arr[1];
let name = file.name;
let type = name.substring(name.lastIndexOf('.') + 1);
if (type !== 'xls' && type !== 'xlsx') {
self.$message({
message: '上传文件只能是 xls、xlsx格式!',
type: 'warning'
});
return;
}
let reader = new FileReader(); let reader = new FileReader();
reader.onload = function (e) { reader.onload = function (e) {
self.$message('开始导入'); self.$message('开始导入');
...@@ -176,46 +195,28 @@ ...@@ -176,46 +195,28 @@
base64: fileJson base64: fileJson
}]; }];
// openLoading(self);
let req = { let req = {
// token: localStorage.getItem("token"), // token: localStorage.getItem("token"),
token: 'F868A5F84DD9433E93E00E3952A16364', token: 'F868A5F84DD9433E93E00E3952A16364',
fileArray: fileArray, fileArray: fileArray,
import_type: 2, import_type: 2,
}; };
//
// console.log('req ', req);
console.log('string req ', JSON.stringify(req))
// self.postData = req;
self.postData = JSON.stringify(req); self.postData = JSON.stringify(req);
uploadExcel(self.postData).then(res => { uploadExcel(self.postData).then(res => {
console.log('%c res >> ','color: red;', res) console.log('%c res >> ','color: red;', res)
if(typeof res.import_type != 'undefined' && res.importFlag == true){
self.$message({
message: '上传成功!',
type: 'success'
});
}else{
self.$message({
message: '上传失败,请重新上传!',
type: 'success'
});
}
}) })
// self.$axios.post(localStorage.getItem("Url") + 'importServiceImpl/importToQuestionPool'
// , JSON.stringify(req)
// ).then(function (res) {
// closeLoading(self);
// let data = JSON.parse(JSON.stringify(res.data));//通过这个实现深拷贝
// if (data.flag) {
// self.$message('导入成功' + data.successNum + '条(重复的题目不会导入!)');
// self.getLabelList();
// self.search();
// } else {
// self.$message.error('导入题目失败');
// let errorList = data.errorList;
// let message = "";
// if (isNotEmptyUtils(errorList)) {
// for (let i = 0; i < errorList.length; i++) {
// message += "第" + errorList[i].index + "行:" + errorList[i].name + '<br>';
// }
// }
// htmlMessageBox(self, "警告", message, "确定", function () {
// }, "", null, "warning");
// }
// }).catch(function (error) {
// self.$message.error('导入题目失败');
// errorResponseCheck(error, self);
// });
}; };
reader.readAsDataURL(file); reader.readAsDataURL(file);
}, },
...@@ -294,9 +295,14 @@ ...@@ -294,9 +295,14 @@
this.searchData.pageSize = val; this.searchData.pageSize = val;
this.goToGetUploadHistory(); this.goToGetUploadHistory();
}, },
handleCloseUploadSuccess() {
this.showUploadSuccess = false;
},
}, },
} }
</script> </script>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册