文件名重复问题修复

pet_li_6.6
liujun 2024-02-27 11:03:56 +08:00
parent ae4b1d504b
commit a670266acf
1 changed files with 18 additions and 2 deletions

View File

@ -46,7 +46,9 @@ export default {
return { return {
dialogImageUrl: '', dialogImageUrl: '',
dialogVisible: false, dialogVisible: false,
disabled: false disabled: false,
file: {},
file_name: ''
} }
}, },
methods: { methods: {
@ -63,15 +65,29 @@ export default {
const isLt2M = file.size / 1024 / 1024 < this.fileSize const isLt2M = file.size / 1024 / 1024 < this.fileSize
if (!isLt2M) { if (!isLt2M) {
this.$message.error('上传视频大小不能超过 ' + this.fileSize + 'MB!') this.$message.error('上传视频大小不能超过 ' + this.fileSize + 'MB!')
this.$refs.uploadFile.clearFiles() this.$refs.uploadFile.handleRemove(file)
return false 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) this.$emit('update:fileList', fileList)
}, },
onRemove(file, fileList) { onRemove(file, fileList) {
this.$emit('update:fileList', fileList) this.$emit('update:fileList', fileList)
}, },
handleExceed(files, fileList) { handleExceed(files, fileList) {
console.log(files, fileList)
this.$message.warning(`当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`) this.$message.warning(`当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`)
} }
} }