From 38859853be33335efd2a8e7983578eee95f5c789 Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@qq.com> Date: Wed, 27 May 2020 21:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E4=BC=A0=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E8=BF=9B=E5=BA=A6=E6=9D=A1=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/bizComponents/UploadFile/index.vue | 21 ++++----------------- vue/src/utils/file.js | 2 +- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/vue/src/bizComponents/UploadFile/index.vue b/vue/src/bizComponents/UploadFile/index.vue index 0ef9ae0..d753001 100644 --- a/vue/src/bizComponents/UploadFile/index.vue +++ b/vue/src/bizComponents/UploadFile/index.vue @@ -63,9 +63,7 @@ }, data() { return { - data: this.fileList, - index: 0, - show: false + data: this.fileList } }, computed: { @@ -89,11 +87,6 @@ return } this.data = [...this.fileList.map(file => ({...file, url: autoCompleteUrl(file.url)}))] - - //更新前保留预览图片的index - if (this.data[this.index]) { - this.index = this.data.findIndex(i => i === this.data[this.index]) - } } } }, @@ -169,23 +162,17 @@ elError(`${file.name}的大小超出${numberFormatter(maxSize)}`) return false } - /*return getToken() - .then(token => { - let now = new Date() - file.token = token - file.key = timeFormat('yyyy/MM/dd/', now) + now.getTime() + '/' + file.name - })*/ }, - httpRequest(option) { + httpRequest({file, onProgress}) { const CancelToken = axios.CancelToken const source = CancelToken.source() - const promise = upload(option.file, option.file.name, { + const promise = upload(file, file.name, { onUploadProgress(e) { if (e.total > 0) { e.percent = (Number)((e.loaded / e.total * 100).toFixed(2)) } - option.onProgress(e) + onProgress(e) }, cancelToken: source.token }) diff --git a/vue/src/utils/file.js b/vue/src/utils/file.js index 8924ae0..838ccc6 100644 --- a/vue/src/utils/file.js +++ b/vue/src/utils/file.js @@ -42,7 +42,7 @@ export function upload(blob, filename = '快照.png', options = defaultOptions) return getToken() .then(token => { const param = new FormData() - options = {...options, ...defaultOptions} + options = {...defaultOptions, ...options} param.append('token', token) param.append('key', options.generateKey(filename)) param.append('file', blob, filename)