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

批量导入

上级 cf403b5a
......@@ -86,11 +86,15 @@
<el-upload
class="upload-demo"
accept=".xlsx"
action="#"
v-model="importFileName"
:before-upload="uploadImportFile">
<el-input class="upload-input" v-model="importFileName" autocomplete="off"></el-input>
:headers="uploadHeaders"
:action="returnActionUrl()"
:before-upload="uploadImportFile"
:on-success="uploadSuccess"
>
<el-button type="default">点击上传</el-button>
</el-upload>
<span v-if="tipTextFlag" style="color:red;">请选择上传文件</span>
<div v-if="importError" @click="downloadError">导入的Excel有问题,点击下载查看具体问题</div>
</el-form-item>
<div class="el-upload__tip" @click="download">下载导入模板</div>
</el-form>
......@@ -123,9 +127,14 @@ export default {
},
removeId: '',
removeTel: '',
acceptValue: '*/*',
importFileName: '',
base64Str: ''
importFile: {},
uploadHeaders: {
token: window.localStorage.getItem('token')
},
importFileName: {},
tipTextFlag: false,
importError: false,
importErrorFileUrl: ''
}
},
filters: {
......@@ -169,40 +178,45 @@ export default {
// 批量导入
importBatch() {
this.importDialogVisible = true;
this.tipTextFlag = false;
},
returnActionUrl() {
return localStorage.getItem("lectureUrl") + "/riskcontrol/blacklist/import";
},
// 判断有没有导入文件
confirmImport() {
this.getData(
"post", `/riskcontrol/blacklist/import`, {base64Str: this.base64.file},
data => {
if(data.code == '000000') {
}
if(!this.importFileName.name) {
this.tipTextFlag = true;
}else {
this.importDialogVisible = false;
}
);
},
// 上传文件
uploadImportFile(file) {
let self = this;
this.importFileName = file.name;
let arr = file.type.split('/');
let ext = "." + arr[1];
let reader = new FileReader();
reader.onload = function (e) {
let fileJson = {
fileName: file.name,
file: e.target.result.substr(e.target.result.indexOf("base64,") + 7),
ext: ext
};
self.base64 = fileJson;
};
reader.readAsDataURL(file);
this.tipTextFlag = false;
var FileExt = file.name.replace(/.+\./, "");
if (["xls", "xlsx"].indexOf(FileExt.toLowerCase()) === -1) {
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;
}
},
// 下载查看导入的有问题Excel
downloadError() {
window.open(this.importErrorFileUrl);
},
// 下载导入模板
download() {
console.log('下载模板');
setTimeout(() => {
window.open(''); // 后台给的导入Excel地址
}, 500);
window.open('https://file.yunqueyi.com/risk/template.xlsx'); // 后台给的导入Excel地址
},
// 新增黑名单
addBlackList() {
......
......@@ -86,11 +86,14 @@
<el-upload
class="upload-demo"
accept=".xlsx"
action="#"
v-model="importFileName"
:before-upload="uploadImportFile">
<el-input class="upload-input" v-model="importFileName" autocomplete="off"></el-input>
:headers="uploadHeaders"
:action="returnActionUrl()"
:before-upload="uploadImportFile"
:on-success="uploadSuccess">
<el-button type="default">点击上传</el-button>
</el-upload>
<span v-if="tipTextFlag" style="color:red;">请选择上传文件</span>
<div v-if="importError" @click="downloadError">导入的Excel有问题,点击下载查看具体问题</div>
</el-form-item>
<div class="el-upload__tip" @click="download">下载导入模板</div>
</el-form>
......@@ -123,8 +126,13 @@ export default {
},
removeId: '',
removeTel: '',
acceptValue: '*/*',
importFileName: ''
importFileName: {},
uploadHeaders: {
token: window.localStorage.getItem('token')
},
tipTextFlag: false,
importError: false,
importErrorFileUrl: ''
}
},
filters: {
......@@ -200,43 +208,45 @@ export default {
// 批量导入
importBatch() {
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;
}
},
// 上传文件
uploadImportFile(file) {
console.log(file)
let self = this;
this.importFileName = file.name;
let arr = file.type.split('/');
let ext = "." + arr[1];
let reader = new FileReader();
reader.onload = function (e) {
let fileJson = {
fileName: file.name,
file: e.target.result.substr(e.target.result.indexOf("base64,") + 7),
ext: ext
};
self.base64 = fileJson;
console.log('fileJson',self.base64);
};
reader.readAsDataURL(file);
this.getData(
"post", `/riskcontrol/blacklist/import`, {base64Str: self.base64.file},
data => {
if(data.code == '000000') {
this.tipTextFlag = false;
var FileExt = file.name.replace(/.+\./, "");
if (["xls", "xlsx"].indexOf(FileExt.toLowerCase()) === -1) {
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;
}
);
},
// 下载查看导入的有问题Excel
downloadError() {
window.open(this.importErrorFileUrl);
},
// 下载导入模板
download() {
console.log('下载模板');
setTimeout(() => {
window.open(''); // 后台给的导入Excel地址
}, 500);
window.open('https://file.yunqueyi.com/risk/template.xlsx'); // 后台给的导入Excel地址
},
handleSizeChange(value) {
this.searchParam.pageSize = value;
......
......@@ -134,6 +134,7 @@ export default {
this.searchParam = data.data;
this.changeStrategy(this.searchParam.bizTypeId);
this.versionArray = this.searchParam.versionParamList;
this.paramsStyleText = this.searchParam.paramsStyle;
for(let i = 0; i < this.versionArray.length; i++) {
let arr = [], parr = [];
arr = this.versionArray[i].params.split(",")
......@@ -144,6 +145,7 @@ export default {
})
this.$set(this.versionArray[i], 'paramArray', parr)
}
}
);
},
......@@ -165,6 +167,7 @@ export default {
this.strategySelect.forEach(element => {
if(val == element.libraryId) {
this.searchParam.paramsStyle = element.paramsStyle;
this.paramsStyleText = this.searchParam.paramsStyle;
if(element.params) {
for(let i = 0; i < element.params; i++) {
arr.push({
......@@ -178,15 +181,15 @@ export default {
},
// 修改参数
changeParams(item, index, v) {
// let str1 = '';
// if(v == 0) {
// if(index == 0) {
// str1 = this.searchParam.paramsStyle.replace("{param1}", item.params);
// }else {
// str1 = str1.replace("{param2}", item.params);
// }
// this.paramsStyleText = str1
// }
let str1 = '';
if(v == 0) {
if(index == 0) {
str1 = this.searchParam.paramsStyle.replace("{param1}", item.params);
}else {
str1 = str1.replace("{param2}", item.params);
}
this.paramsStyleText = str1
}
},
// 保存
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册