mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-04-06 03:57:53 +08:00
fix[UploadExcel]: add file type check (#878)
This commit is contained in:
parent
62e1c851c8
commit
513eb66d97
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user