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

文件导入

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