Commit 582fead405ffa49053bf414c618ffeb60035a0e3

Authored by YunaiV
1 parent 20bf581a

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

yudao-ui-admin/src/components/ImageUpload/index.vue
1 1 <template>
2 2 <div class="component-upload-image">
3 3 <el-upload
  4 + multiple
4 5 :action="uploadImgUrl"
5 6 list-type="picture-card"
6 7 :on-success="handleUploadSuccess"
... ... @@ -70,6 +71,8 @@ export default {
70 71 },
71 72 data() {
72 73 return {
  74 + number: 0,
  75 + uploadList: [],
73 76 dialogImageUrl: "",
74 77 dialogVisible: false,
75 78 hideUpload: false,
... ... @@ -124,9 +127,14 @@ export default {
124 127 },
125 128 // 上传成功回调
126 129 handleUploadSuccess(res) {
127   - this.fileList.push({ name: res.fileName, url: res.fileName });
128   - this.$emit("input", this.listToString(this.fileList));
129   - this.loading.close();
  130 + this.uploadList.push({ name: res.fileName, url: res.fileName });
  131 + if (this.uploadList.length === this.number) {
  132 + this.fileList = this.fileList.concat(this.uploadList);
  133 + this.uploadList = [];
  134 + this.number = 0;
  135 + this.$emit("input", this.listToString(this.fileList));
  136 + this.loading.close();
  137 + }
130 138 },
131 139 // 上传前loading加载
132 140 handleBeforeUpload(file) {
... ... @@ -163,6 +171,7 @@ export default {
163 171 text: "上传中",
164 172 background: "rgba(0, 0, 0, 0.7)",
165 173 });
  174 + this.number++;
166 175 },
167 176 // 文件个数超出
168 177 handleExceed() {
... ...