提交 e8a457dc authored 作者: 王鹏飞's avatar 王鹏飞

chore: 上传作业文件增加上传中的状态

上级 fade4c17
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="upload"> <div class="upload">
<el-upload action :disabled="disabled" :show-file-list="false" :http-request="httpRequest" v-bind="$attrs"> <el-upload action :disabled="disabled" :show-file-list="false" :http-request="httpRequest" v-bind="$attrs">
<slot></slot> <slot></slot>
<el-button type="text" icon="el-icon-upload">{{ $t('viewerWork.clickUpload') }}</el-button> <el-button type="text" icon="el-icon-upload" :loading="loading">{{ $t('viewerWork.clickUpload') }}</el-button>
<template v-slot:tip> <template v-slot:tip>
<div class="el-upload__tips"> <div class="el-upload__tips">
<slot name="tip"></slot> <slot name="tip"></slot>
...@@ -43,6 +43,7 @@ export default { ...@@ -43,6 +43,7 @@ export default {
}, },
data() { data() {
return { return {
loading: false,
fileList: [] fileList: []
} }
}, },
...@@ -67,6 +68,7 @@ export default { ...@@ -67,6 +68,7 @@ export default {
}, },
methods: { methods: {
httpRequest(xhr) { httpRequest(xhr) {
this.loading = true
api api
.uploadFile({ file: xhr.file }) .uploadFile({ file: xhr.file })
.then(response => { .then(response => {
...@@ -84,6 +86,9 @@ export default { ...@@ -84,6 +86,9 @@ export default {
.catch(error => { .catch(error => {
this.$message.error(error.message) this.$message.error(error.message)
}) })
.finally(() => {
this.loading = false
})
}, },
handleRemove(index) { handleRemove(index) {
this.fileList.splice(index, 1) this.fileList.splice(index, 1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论