fix[UploadExcel]: fix can't select the same excel

This commit is contained in:
Pan 2018-03-30 17:08:01 +08:00
parent d0eebf83c4
commit afe975b3c2
1 changed files with 3 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<input id="excel-upload-input" type="file" accept=".xlsx, .xls" class="c-hide" @change="handkeFileChange"> <input id="excel-upload-input" ref="excel-upload-input" type="file" accept=".xlsx, .xls" class="c-hide" @change="handkeFileChange">
<div id="drop" @drop="handleDrop" @dragover="handleDragover" @dragenter="handleDragover"> <div id="drop" @drop="handleDrop" @dragover="handleDragover" @dragenter="handleDragover">
Drop excel file here or Drop excel file here or
<el-button style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">browse</el-button> <el-button style="margin-left:16px;" size="mini" type="primary" @click="handleUpload">browse</el-button>
@ -51,7 +51,9 @@ export default {
handkeFileChange(e) { handkeFileChange(e) {
const files = e.target.files const files = e.target.files
const itemFile = files[0] // only use files[0] const itemFile = files[0] // only use files[0]
if (!itemFile) return
this.readerData(itemFile) this.readerData(itemFile)
this.$refs['excel-upload-input'].value = null // fix can't select the same excel
}, },
readerData(itemFile) { readerData(itemFile) {
const reader = new FileReader() const reader = new FileReader()