fix[UploadExcel]: add file type check (#878)

This commit is contained in:
花裤衩 2018-07-17 13:30:52 +08:00 committed by GitHub
parent 62e1c851c8
commit 513eb66d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -41,6 +41,11 @@ export default {
return return
} }
const rawFile = files[0] // only use files[0] const rawFile = files[0] // only use files[0]
if (!this.isExcel(rawFile)) {
this.$message.error('Only supports upload .xlsx, .xls, .csv suffix files')
return false
}
this.upload(rawFile) this.upload(rawFile)
e.stopPropagation() e.stopPropagation()
e.preventDefault() e.preventDefault()
@ -110,6 +115,9 @@ export default {
headers.push(hdr) headers.push(hdr)
} }
return headers return headers
},
isExcel(file) {
return /\.(xlsx|xls|csv)$/.test(file.name)
} }
} }
} }