From 86943c1e5856d9766097315a40f26c8fc19713f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= <37316281+yanhao98@users.noreply.github.com> Date: Mon, 16 Dec 2024 01:09:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A6=81=E7=94=A8=E7=8A=B6=E6=80=81=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=B9=B6=E6=98=BE=E7=A4=BA=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/primevue/upload-demo.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/primevue/upload-demo.vue b/src/components/primevue/upload-demo.vue index 9675938..3f6ef9d 100644 --- a/src/components/primevue/upload-demo.vue +++ b/src/components/primevue/upload-demo.vue @@ -81,10 +81,14 @@ const showUploadButton = computed(() => { return false; }); +const fileLimit = 2; const disabled = computed(() => { if (fileUploadRef.value?.uploadedFiles?.some((f) => f.status === 'failed')) { return true; } + if ((fileUploadRef.value?.uploadedFileCount || 0) >= fileLimit) { + return true; + } return false; }); @@ -102,7 +106,7 @@ const disabled = computed(() => { accept="image/*" :maxFileSize="1000000 * 1" invalidFileSizeMessage="文件 {0} 大小超过限制 {1}" - :fileLimit="2" + :fileLimit="fileLimit" invalidFileLimitMessage="最多只能上传 {0} 个文件,请移除多余文件后点击上传" @uploader="onUploader" :chooseButtonProps="{ size: 'small' }" @@ -113,11 +117,6 @@ const disabled = computed(() => { 请上传图片 + +
files.length: {{ files.length }}
+
uploadedFiles.length: {{ uploadedFiles.length }}
+
uploadedFileCount: {{ fileUploadRef?.uploadedFileCount }}