| 时间 |
2022/3/22 |
| 协作人 |
心愉、金萍、慧敏 |
//文件上传uploadOk(val) { this.getUser(); console.log(this.userId, this.userName); const type = this.isUrls ? 'bomc' : 'dt'; const userName = this.isUrls ? this.userName : 0; const userId = this.isUrls ? this.userId : 0; //上传文件调接口传参形式 let fd = new FormData(); fd.append('file', val.file); fd.append('type', type); fd.append('userName', userName); fd.append('userId', userId); setExcels(fd).then(res => { console.log(res.name); if (res.data.retCode == 500) { this.$notify({ message: '市场分类批量处理失败,失败原因:文件格式异常,请参考模板重新上传/文件处理异常,请联系平台管理员核实', type: 'error', offset: 100, }); } else if (res.data.retCode == '200') { this.$notify({ message: '市场分类批量处理成功,共导入' + res.data.data.number + '条,成功更新' + res.data.data.success + '条,请确认。', type: 'success', offset: 100, }); } else { this.$notify({ message: '市场分类批量处理失败,失败原因:文件格式异常,请参考模板重新上传/文件处理异常,请联系平台管理员核实', type: 'error', offset: 100, }); } }); },
//文件导出(下载模板)//html部分//:href="`http:${fileAddress}/static/模板.xlsx`" 为文件地址//download="excel.xlsx" 为下载模板名称<a :href="`http:${fileAddress}/static/模板.xlsx`" download="excel.xlsx" style="color:#f4f4f4"><div size="mini" type="primary" class="ll" style="cursor:pointer;" v-show="isUrlYou"><i class="el-icon-download"></i><p>下载模板</p></div></a>//script部分//导入index.jsimport config from '../../config/index';data(){ envlist: { development: 'dev', production: 'build', local: 'local', }, fileAddress: '',}//钩子函数部分 created() { this.fileAddress = config[this.envlist[process.env.NODE_ENV]].assetsPublicPath; // console.log(this.datalist); this.getUser(); }, mounted() { this.baseURL = baseURL; this.href = href; console.log(this.baseURL); },