Parcourir la source

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

RuoYi il y a 4 ans
Parent
commit
c43565ef43

+ 1 - 4
ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/util/ScheduleUtils.java

@@ -125,10 +125,7 @@ public class ScheduleUtils
125 125
         int count = StringUtils.countMatches(packageName, ".");
126 126
         if (count > 1)
127 127
         {
128
-            if (!StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR))
129
-            {
130
-                return false;
131
-            }
128
+            return StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR);
132 129
         }
133 130
         return true;
134 131
     }

+ 12 - 3
ruoyi-ui/src/components/ImageUpload/index.vue

@@ -1,6 +1,7 @@
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,
@@ -119,9 +122,14 @@ export default {
119 122
     },
120 123
     // 上传成功回调
121 124
     handleUploadSuccess(res) {
122
-      this.fileList.push({ name: res.data.url, url: res.data.url });
123
-      this.$emit("input", this.listToString(this.fileList));
124
-      this.loading.close();
125
+      this.uploadList.push({ name: res.data.url, url: res.data.url });
126
+      if (this.uploadList.length === this.number) {
127
+        this.fileList = this.fileList.concat(this.uploadList);
128
+        this.uploadList = [];
129
+        this.number = 0;
130
+        this.$emit("input", this.listToString(this.fileList));
131
+        this.loading.close();
132
+      }
125 133
     },
126 134
     // 上传前loading加载
127 135
     handleBeforeUpload(file) {
@@ -158,6 +166,7 @@ export default {
158 166
         text: "上传中",
159 167
         background: "rgba(0, 0, 0, 0.7)",
160 168
       });
169
+      this.number++;
161 170
     },
162 171
     // 文件个数超出
163 172
     handleExceed() {