| | |
| | | return { |
| | | loading:null, |
| | | uuid: null, |
| | | timer: null, |
| | | message:'开始上传', |
| | | uploadImgUrl: process.env.VUE_APP_API_PREFIX + '/public/upload', |
| | | uploadProgressUrl: process.env.VUE_APP_API_PREFIX + '/public' |
| | |
| | | } |
| | | }) |
| | | .catch(e => { |
| | | if(this.timer){ |
| | | clearInterval(this.timer) |
| | | } |
| | | this.$message.error(e) |
| | | }) |
| | | .finally(() => { |
| | | if(this.timer){ |
| | | clearInterval(this.timer) |
| | | } |
| | | that.loading.close() |
| | | this.$refs.file.value = null |
| | | }) |
| | |
| | | }, |
| | | startProgress () { |
| | | var that = this |
| | | var timer = setInterval(function () { |
| | | this.timer = setInterval(function () { |
| | | axios.get(that.uploadProgressUrl + '/' + that.uuid) |
| | | .then(res => { |
| | | if (res != null && res.data && res.data.data) { |
| | |
| | | // document.getElementById('progressBar').value = 100 |
| | | // document.getElementById('status').textContent = '已完成' + 100 + '%' |
| | | that.loading.setText( '已完成 【 ' + 100 + ' 】%') |
| | | clearInterval(timer) |
| | | clearInterval(that.timer) |
| | | } else if (res.data.data.status === 3){ |
| | | const percentCompleted = Math.round(res.data.data.rate || 0) |
| | | // document.getElementById('progressBar').value = percentCompleted |
| | | // document.getElementById('status').textContent = '上传失败' + percentCompleted + '%' |
| | | that.loading.setText('上传失败 【 ' + percentCompleted + ' 】%') |
| | | clearInterval(timer) |
| | | clearInterval(that.timer) |
| | | } |
| | | } |
| | | }) |