组件ImageUpload支持多图同时选择上传

master
RuoYi 3 years ago
parent 1d42696834
commit a7243a17da
  1. 11
      src/components/ImageUpload/index.vue

@ -1,6 +1,7 @@
<template>
<div class="component-upload-image">
<el-upload
multiple
:action="uploadImgUrl"
list-type="picture-card"
:on-success="handleUploadSuccess"
@ -73,6 +74,8 @@ const props = defineProps({
const { proxy } = getCurrentInstance();
const emit = defineEmits();
const number = ref(0);
const uploadList = ref([]);
const dialogImageUrl = ref("");
const dialogVisible = ref(false);
const baseUrl = import.meta.env.VITE_APP_BASE_API;
@ -115,9 +118,14 @@ function handleRemove(file, files) {
//
function handleUploadSuccess(res) {
fileList.value.push({ name: res.fileName, url: res.fileName });
uploadList.value.push({ name: res.fileName, url: res.fileName });
if (uploadList.value.length === number.value) {
fileList.value = fileList.value.concat(uploadList.value);
uploadList.value = [];
number.value = 0;
emit("update:modelValue", listToString(fileList.value));
proxy.$modal.closeLoading();
}
}
// loading
@ -150,6 +158,7 @@ function handleBeforeUpload(file) {
}
}
proxy.$modal.loading("上传中");
number.value++;
}
//

Loading…
Cancel
Save