Commit 4f5964f287fdcda31dd842f716676bb63af44798
1 parent
3cb7aba3
v3.6.0 文件上传组件添加数量限制属性
Showing
1 changed file
with
11 additions
and
0 deletions
yudao-ui-admin/src/components/FileUpload/index.vue
| ... | ... | @@ -4,7 +4,9 @@ |
| 4 | 4 | :action="uploadFileUrl" |
| 5 | 5 | :before-upload="handleBeforeUpload" |
| 6 | 6 | :file-list="fileList" |
| 7 | + :limit="limit" | |
| 7 | 8 | :on-error="handleUploadError" |
| 9 | + :on-exceed="handleExceed" | |
| 8 | 10 | :on-success="handleUploadSuccess" |
| 9 | 11 | :show-file-list="false" |
| 10 | 12 | :headers="headers" |
| ... | ... | @@ -44,6 +46,11 @@ export default { |
| 44 | 46 | props: { |
| 45 | 47 | // 值 |
| 46 | 48 | value: [String, Object, Array], |
| 49 | + // 数量限制 | |
| 50 | + limit: { | |
| 51 | + type: Number, | |
| 52 | + default: 5, | |
| 53 | + }, | |
| 47 | 54 | // 大小限制(MB) |
| 48 | 55 | fileSize: { |
| 49 | 56 | type: Number, |
| ... | ... | @@ -129,6 +136,10 @@ export default { |
| 129 | 136 | } |
| 130 | 137 | return true; |
| 131 | 138 | }, |
| 139 | + // 文件个数超出 | |
| 140 | + handleExceed() { | |
| 141 | + this.$message.error(`上传文件数量不能超过 ${this.limit} 个!`); | |
| 142 | + }, | |
| 132 | 143 | // 上传失败 |
| 133 | 144 | handleUploadError(err) { |
| 134 | 145 | this.$message.error("上传失败, 请重试"); | ... | ... |