<el-upload class="upload_csv" ref="upload" accept=".csv" :action="uploadAPI" :multiple="false" :limit="1" :headers="avatarHeader" :on-success="handleSuccess" :on-error="handleError" :on-progress="hanleProgressing" > <el-button class="import" size="mini" :loading="isImporting" ><i class="el-icon-download"></i> {{ $t('asset.import') }}</el-button > </el-upload>
uploadAPI: process.env.BASE_API + '/importTag', // 上传的Url地址
computed: { avatarHeader() { return { Authorization: 'bearer ' + getToken() } } }
// 上传成功的回调 handleSuccess(response, file, fileList) { if (response.success) { this.handleResetClear() this.getUploadStatus() const _this = this this.uploadTimer = setInterval(() => { _this.getUploadStatus() }, 60000) } }, // 上传失败的回调 handleError(response, file, fileList) { console.log('error-----------') console.log(response) this.isImporting = false this.$refs.upload.clearFiles() },