From 64f6d28441e2036d2f21f9c22c2bc864733f588a Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期日, 25 七月 2021 20:08:55 +0800
Subject: [PATCH] 角色&菜单新增字段属性提示信息

---
 ruoyi-ui/src/components/FileUpload/index.vue |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/ruoyi-ui/src/components/FileUpload/index.vue b/ruoyi-ui/src/components/FileUpload/index.vue
index 649e077..bdbb069 100644
--- a/ruoyi-ui/src/components/FileUpload/index.vue
+++ b/ruoyi-ui/src/components/FileUpload/index.vue
@@ -4,7 +4,9 @@
       :action="uploadFileUrl"
       :before-upload="handleBeforeUpload"
       :file-list="fileList"
+      :limit="limit"
       :on-error="handleUploadError"
+      :on-exceed="handleExceed"
       :on-success="handleUploadSuccess"
       :show-file-list="false"
       :headers="headers"
@@ -44,6 +46,11 @@
   props: {
     // 值
     value: [String, Object, Array],
+    // 数量限制
+    limit: {
+      type: Number,
+      default: 5,
+    },
     // 大小限制(MB)
     fileSize: {
       type: Number,
@@ -129,6 +136,10 @@
       }
       return true;
     },
+    // 文件个数超出
+    handleExceed() {
+      this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`);
+    },
     // 上传失败
     handleUploadError(err) {
       this.$message.error("上传失败, 请重试");
@@ -152,13 +163,14 @@
         return "";
       }
     },
-    // 对象转成分隔字符串
-    listToString(list) {
-      let files = "";
-      for (let key in list) {
-        files += list[key].url + ",";
+    // 对象转成指定字符串分隔
+    listToString(list, separator) {
+      let strs = "";
+      separator = separator || ",";
+      for (let i in list) {
+        strs += list[i].url + separator;
       }
-      return files.substr(0, files.length - 1);
+      return strs != '' ? strs.substr(0, strs.length - 1) : '';
     }
   }
 };

--
Gitblit v1.9.2