From a670266acf1fd1d3497550b7feefc2d96c16ed69 Mon Sep 17 00:00:00 2001 From: liujun Date: Tue, 27 Feb 2024 11:03:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/util/uploadFile/index.vue | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/views/util/uploadFile/index.vue b/src/views/util/uploadFile/index.vue index ba25c46..811fc1f 100644 --- a/src/views/util/uploadFile/index.vue +++ b/src/views/util/uploadFile/index.vue @@ -46,7 +46,9 @@ export default { return { dialogImageUrl: '', dialogVisible: false, - disabled: false + disabled: false, + file: {}, + file_name: '' } }, methods: { @@ -63,15 +65,29 @@ export default { const isLt2M = file.size / 1024 / 1024 < this.fileSize if (!isLt2M) { this.$message.error('上传视频大小不能超过 ' + this.fileSize + 'MB!') - this.$refs.uploadFile.clearFiles() + this.$refs.uploadFile.handleRemove(file) return false } + + let nameNumber = 0 + for (let j = 0; j < fileList.length; j++) { + if (fileList[j].name === file.name) { + nameNumber = nameNumber + 1 + } + } + if (nameNumber > 1) { + this.$message.error('文件名重复,请重新选择!') + this.$refs.uploadFile.handleRemove(file) + return false + } + this.$emit('update:fileList', fileList) }, onRemove(file, fileList) { this.$emit('update:fileList', fileList) }, handleExceed(files, fileList) { + console.log(files, fileList) this.$message.warning(`当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`) } }