|
|
|
@ -7,7 +7,7 @@ |
|
|
|
|
<div class="container"> |
|
|
|
|
<div class="upload-dragger"> |
|
|
|
|
<a-upload-dragger |
|
|
|
|
accept=".xls, .xlsx" |
|
|
|
|
accept=".csv" |
|
|
|
|
:multiple="false" |
|
|
|
|
:fileList="fileList" |
|
|
|
|
:showUploadList="false" |
|
|
|
@ -19,7 +19,7 @@ |
|
|
|
|
</p> |
|
|
|
|
<div v-if="!fileList.length"> |
|
|
|
|
<p class="ant-upload-text">点击选择文件,或者将文件拖拽至此区域</p> |
|
|
|
|
<p class="ant-upload-hint">仅支持 .xls, .xlsx 格式的excel文件,限2M以内</p> |
|
|
|
|
<p class="ant-upload-hint">仅支持.csv 格式的excel文件,限2M以内</p> |
|
|
|
|
</div> |
|
|
|
|
<div v-else> |
|
|
|
|
<p class="ant-upload-text"> |
|
|
|
@ -81,14 +81,6 @@ export default { |
|
|
|
|
|
|
|
|
|
// 上传文件之前的钩子 |
|
|
|
|
beforeUpload(file) { |
|
|
|
|
let testmsg = file.name.substring(file.name.lastIndexOf('.') + 1) |
|
|
|
|
const extension = testmsg === 'xlsx' |
|
|
|
|
const extension2 = testmsg === 'xls' |
|
|
|
|
// 验证文件大小 |
|
|
|
|
if (!extension && !extension2) { |
|
|
|
|
this.$message.error('只能上传 xlsx 或者 xls 文件') |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
const fileSizeMb = file.size / 1024 / 1024 |
|
|
|
|
if (fileSizeMb > this.uploadSizeLimit) { |
|
|
|
|
this.$message.error(`上传的文件大小不能超出${this.uploadSizeLimit}MB`) |
|
|
|
|