From 87317f44d9cc20ad70b6971168667e1c843e03d8 Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Fri, 26 Aug 2022 01:16:50 +0800 Subject: [PATCH] 添加上传进度条 添加日志统计文字 --- src/components/mini/box10-add.vue | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/src/components/mini/box10-add.vue b/src/components/mini/box10-add.vue index 42572cc..e7f0ea4 100644 --- a/src/components/mini/box10-add.vue +++ b/src/components/mini/box10-add.vue @@ -380,12 +380,31 @@ myFileInfoUpload(formData).then((res) => { if (res.success) { this.$message.success('上传成功') - option.onSuccess(res, option.file) + // 在上传成功后进度条显示为99 + progress.percent = 100 } else { this.$message.error('上传失败:' + res.message) } }) + + let progress = { + percent: 1 + } + let speed = 100 / (option.file.size / 65000) //上传速度 + const intervalId = setInterval(() => { + // 控制进度条防止在未上传成功时进度条达到100 + if (progress.percent < 99 && progress.percent + speed < 100) { + progress.percent += speed //控制进度条速度 + option.onProgress(progress) //onProgress接收一个对象{ percent: 进度 }在进度条上显示 + } else if ((progress.percent < 100)) { + progress.percent++ + } else if (progress.percent >= 100) { + clearInterval(intervalId) + } + }, 500) + + }, disabledDate(current) { return current < moment().subtract(1, "day"); -- Gitblit v1.9.1