From c02d3afc58de0ffc8b9f0d3f843b1a25631b50e7 Mon Sep 17 00:00:00 2001 From: zjl Date: Mon, 23 Dec 2024 13:42:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=85=81=E8=AE=B8=E6=9C=80?= =?UTF-8?q?=E5=A4=A7=E4=B8=8A=E4=BC=A0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Upload/Images.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Upload/Images.vue b/src/components/Upload/Images.vue index 023de3b..e54fb1f 100644 --- a/src/components/Upload/Images.vue +++ b/src/components/Upload/Images.vue @@ -113,6 +113,9 @@ return props.disabled; }); + /** + * 文件列表 + */ const fileList = computed({ get: () => { console.log(props.fileLists); @@ -138,6 +141,9 @@ const handleHttpUpload = async (options) => { loading.value = true; try { + // 设置允许做大上传张数验证 + onExceed(); + // 上传文件 const formData = new FormData(); formData.append('file', options.file.file); formData.append('name', props.name); @@ -208,6 +214,9 @@ let filePath = props.name + '/' + year + '/' + month + '/' + day + '/' + fileName; loading.value = true; try { + // 设置允许做大上传张数验证 + onExceed(); + // 文件请求头 const headers = { 'Access-Control-Allow-Origin': '*', }; @@ -325,12 +334,13 @@ * 最大上传张数限制 */ const onExceed = () => { - if (props.limit) { + if (props.limit && fileList.value.length >= props.limit) { notification.warning({ message: '温馨提示', duration: 2000, description: `最多支持上传${props.limit}张`, }); + return false; } };