|
@@ -46,9 +46,10 @@
|
|
|
:before-upload="beforeUpload"
|
|
:before-upload="beforeUpload"
|
|
|
:show-file-list="false"
|
|
:show-file-list="false"
|
|
|
:accept="accept"
|
|
:accept="accept"
|
|
|
|
|
+ :disabled="uploading"
|
|
|
multiple
|
|
multiple
|
|
|
>
|
|
>
|
|
|
- <el-button type="primary">
|
|
|
|
|
|
|
+ <el-button type="primary" :loading="uploading">
|
|
|
<Icon icon="ep:upload" />点击选择文件
|
|
<Icon icon="ep:upload" />点击选择文件
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</el-upload>
|
|
</el-upload>
|
|
@@ -101,6 +102,8 @@ const props = defineProps({
|
|
|
const emit = defineEmits(['update:modelValue', 'success'])
|
|
const emit = defineEmits(['update:modelValue', 'success'])
|
|
|
|
|
|
|
|
const uploadRef = ref()
|
|
const uploadRef = ref()
|
|
|
|
|
+const uploadingCount = ref(0)
|
|
|
|
|
+const uploading = computed(() => uploadingCount.value > 0)
|
|
|
|
|
|
|
|
const fileList: any = computed({
|
|
const fileList: any = computed({
|
|
|
get: () => props.modelValue || [],
|
|
get: () => props.modelValue || [],
|
|
@@ -113,6 +116,7 @@ const { httpRequest: uploadFn } = useUpload(
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const httpRequest = (options: any) => {
|
|
const httpRequest = (options: any) => {
|
|
|
|
|
+ uploadingCount.value++
|
|
|
const rawFile = options.file
|
|
const rawFile = options.file
|
|
|
uploadFn(options)
|
|
uploadFn(options)
|
|
|
.then((res: any) => {
|
|
.then((res: any) => {
|
|
@@ -131,6 +135,9 @@ const httpRequest = (options: any) => {
|
|
|
.catch(() => {
|
|
.catch(() => {
|
|
|
message.error('上传失败')
|
|
message.error('上传失败')
|
|
|
})
|
|
})
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ uploadingCount.value--
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const beforeUpload = (rawFile: any) => {
|
|
const beforeUpload = (rawFile: any) => {
|