From 513eb66d97ae41fbdfd8c7d91c17cd5ac76625bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Tue, 17 Jul 2018 13:30:52 +0800 Subject: [PATCH] fix[UploadExcel]: add file type check (#878) --- src/components/UploadExcel/index.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/UploadExcel/index.vue b/src/components/UploadExcel/index.vue index 49658f48..f9e6a87b 100644 --- a/src/components/UploadExcel/index.vue +++ b/src/components/UploadExcel/index.vue @@ -41,6 +41,11 @@ export default { return } 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) e.stopPropagation() e.preventDefault() @@ -110,6 +115,9 @@ export default { headers.push(hdr) } return headers + }, + isExcel(file) { + return /\.(xlsx|xls|csv)$/.test(file.name) } } }