提交 f63f15b1 编写于 作者: huangwensu's avatar huangwensu

文件导入

上级 f17156d1
......@@ -63,7 +63,7 @@ export const getAddress = () => {
// qiniuUrl = "http://10.177.15.154:10203/contents/admin/qiniu/token"; //不再使用middle服务获取七牛token
qiniuUrl = "https://dev-sc.yunqueyi.com/contents/admin/qiniu/token";
// qiniuFileUrl = "http://10.177.15.154:10203/contents/admin/qiniu/token1";
qiniuFileUrl = "http://dev-sc.yunqueyi.com/contents/admin/qiniu/token1";
qiniuFileUrl = "https://dev-sc.yunqueyi.com/contents/admin/qiniu/token1";
qiniuResourceUrl = "https://test1-videos.yunqueyi.com";
} else if (isNotEmptyUtils(env)) {//测试test1 test2 uat
versionUrl = 'https://' + env + '-dev.yunqueyi.com';
......
......@@ -86,14 +86,13 @@
<el-upload
class="upload-demo"
accept=".xlsx"
:headers="uploadHeaders"
:action="returnActionUrl()"
action="#"
:before-upload="uploadImportFile"
:on-success="uploadSuccess"
>
<el-button type="default">点击上传</el-button>
</el-upload>
<span v-if="tipTextFlag" style="color:red;">请选择上传文件</span>
<span>{{importFileName.name}}</span>
<p v-if="tipTextFlag" style="color:red;">请选择上传文件</p>
<div v-if="importError" @click="downloadError">导入的Excel有问题,点击下载查看具体问题</div>
</el-form-item>
<div class="el-upload__tip" @click="download">下载导入模板</div>
......@@ -134,7 +133,8 @@ export default {
importFileName: {},
tipTextFlag: false,
importError: false,
importErrorFileUrl: ''
importErrorFileUrl: '',
filePath: ''
}
},
filters: {
......@@ -149,27 +149,25 @@ export default {
methods: {
// 封装一下请求通用的方法
getData(type, url, req, callback) {
openLoading(this);
//openLoading(this);
this.$axios[type](localStorage.getItem("lectureUrl") + url, req)
.then(res => {
closeLoading(this);
//closeLoading(this);
let data = res.data;
if (data.code == "000000") {
if (callback) callback(data);
} else {
this.$message.error(data.message);
}
})
.catch(error => {
closeLoading(this);
this.$message.error("网络出现点问题");
});
},
search(param) {
openLoading(this);
if(param) this.searchParam.pageNo = 1;
this.getData(
"get", `/riskcontrol/blacklist/list?searchName=${this.searchParam.searchName}&pageNo=${this.searchParam.pageNo}&pageSize=${this.searchParam.pageSize}`, {},
data => {
closeLoading(this);
this.tableData = data.data.blackListResps;
this.totalRows = data.data.total;
}
......@@ -180,36 +178,48 @@ export default {
this.importDialogVisible = true;
this.tipTextFlag = false;
},
returnActionUrl() {
return localStorage.getItem("lectureUrl") + "/riskcontrol/blacklist/import";
},
// returnActionUrl() {
// return localStorage.getItem("lectureUrl") + "/riskcontrol/blacklist/import";
// },
// 判断有没有导入文件
confirmImport() {
if(!this.importFileName.name) {
this.tipTextFlag = true;
}else {
this.importDialogVisible = false;
}
let req = {
file: this.filePath
};
this.getData(
"post", `/riskcontrol/blacklist/import`, req,
data => {
if(data.code == '000000') {
this.importDialogVisible = false;
}else {
this.tipTextFlag = true;
}
}
);
},
// 上传文件
uploadImportFile(file) {
this.tipTextFlag = false;
let _this = this;
_this.tipTextFlag = false;
var FileExt = file.name.replace(/.+\./, "");
if (["xls", "xlsx"].indexOf(FileExt.toLowerCase()) === -1) {
this.$message({
_this.$message({
type: "warning",
message: "请上传后缀名为xls,xlsx的原文件!",
});
return false;
}
this.importFileName = file;
},
uploadSuccess(res, file, fileList) {
if(res.data) { // 导入的Excel有问题
this.importError = true;
this.importErrorFileUrl = res.data;
}
_this.importFileName = file;
doUpload(_this, file, getFilePath(file,null), 'preview4', 'progress1', 1).then( path => {
_this.filePath = path.fullPath;
});
},
// uploadSuccess(res, file, fileList) {
// if(res.data) { // 导入的Excel有问题
// this.importError = true;
// this.importErrorFileUrl = res.data;
// }
// },
// 下载查看导入的有问题Excel
downloadError() {
//window.open(this.importErrorFileUrl);
......
......@@ -86,13 +86,12 @@
<el-upload
class="upload-demo"
accept=".xlsx"
:headers="uploadHeaders"
:action="returnActionUrl()"
:before-upload="uploadImportFile"
:on-success="uploadSuccess">
action="#"
:before-upload="uploadImportFile">
<el-button type="default">点击上传</el-button>
</el-upload>
<span v-if="tipTextFlag" style="color:red;">请选择上传文件</span>
<span>{{importFileName.name}}</span>
<p v-if="tipTextFlag" style="color:red;">请选择上传文件</p>
<div v-if="importError" @click="downloadError">导入的Excel有问题,点击下载查看具体问题</div>
</el-form-item>
<div class="el-upload__tip" @click="download">下载导入模板</div>
......@@ -128,11 +127,13 @@ export default {
removeTel: '',
importFileName: {},
uploadHeaders: {
token: window.localStorage.getItem('token')
token: window.localStorage.getItem('token'),
'Content-Type': 'multipart/form-data'
},
tipTextFlag: false,
importError: false,
importErrorFileUrl: ''
importErrorFileUrl: '',
filePath: ''
}
},
filters: {
......@@ -146,27 +147,25 @@ export default {
methods: {
// 封装一下请求通用的方法
getData(type, url, req, callback) {
openLoading(this);
// openLoading(this);
this.$axios[type](localStorage.getItem("lectureUrl") + url, req)
.then(res => {
closeLoading(this);
let data = res.data;
if (data.code == "000000") {
if (callback) callback(data);
} else {
this.$message.error(data.message);
}
// closeLoading(this);
let data = res.data;
if (data.code == "000000") {
if (callback) callback(data);
} else {
this.$message.error(data.message);
}
})
.catch(error => {
closeLoading(this);
this.$message.error("网络出现点问题");
});
},
search(param) {
openLoading(this);
if(param) this.searchParam.pageNo = 1;
this.getData(
"get", `/riskcontrol/emptyNumber/list?searchName=${this.searchParam.searchName}&pageNo=${this.searchParam.pageNo}&pageSize=${this.searchParam.pageSize}`, {},
data => {
closeLoading(this);
this.tableData = data.data.blackListResps;
this.totalRows = data.data.total;
}
......@@ -210,46 +209,47 @@ export default {
this.importDialogVisible = true;
this.tipTextFlag = false;
},
returnActionUrl() {
return localStorage.getItem("lectureUrl") + "/riskcontrol/emptyNumber/import";
},
// 判断有没有导入文件
confirmImport() {
if(!this.importFileName.name) {
this.tipTextFlag = true;
}else {
this.importDialogVisible = false;
}
let req = {
file: this.filePath
};
this.getData(
"post", `/riskcontrol/emptyNumber/import`, req,
data => {
if(data.code == '000000') {
this.importDialogVisible = false;
}else {
this.tipTextFlag = true;
}
}
);
},
// 上传文件
uploadImportFile(file) {
this.tipTextFlag = false;
let _this = this;
_this.tipTextFlag = false;
var FileExt = file.name.replace(/.+\./, "");
if (["xls", "xlsx"].indexOf(FileExt.toLowerCase()) === -1) {
this.$message({
_this.$message({
type: "warning",
message: "请上传后缀名为xls,xlsx的原文件!",
});
return false;
}
this.importFileName = file;
},
uploadSuccess(res, file, fileList) {
if(res.data) { // 导入的Excel有问题
this.importError = true;
this.importErrorFileUrl = res.data;
}
_this.importFileName = file;
doUpload(_this, file, getFilePath(file,null), 'preview4', 'progress1', 1).then( path => {
_this.filePath = path.fullPath;
});
},
// 下载查看导入的有问题Excel
downloadError() {
//window.open(this.importErrorFileUrl);
let a = document.createElement('a');
a.setAttribute('href',this.importErrorFileUrl);
a.click();
},
// 下载导入模板
download() {
//window.open('https://file.yunqueyi.com/risk/template.xlsx'); // 后台给的导入Excel地址
let a = document.createElement('a');
a.setAttribute('href', 'https://file.yunqueyi.com/risk/template.xlsx');
a.click();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册