Browse Source

断点续传input隐藏

main
jinlan.du 5 years ago
parent
commit
345cd7744c
  1. 27
      web/src/view/example/breakpoint/breakpoint.vue

27
web/src/view/example/breakpoint/breakpoint.vue

@ -2,23 +2,23 @@
<div class="hello"> <div class="hello">
<el-divider content-position="left">大文件上传</el-divider> <el-divider content-position="left">大文件上传</el-divider>
<form id="fromCont" method="post" > <form id="fromCont" method="post" >
<div class="fileUpload">
选择文件<input @change="choseFile" id="file" multiple="multiple" type="file" />
<div class="fileUpload" @click="inputChange">
选择文件
<input v-show="false" @change="choseFile" id="file" multiple="multiple" type="file" ref="Input" />
</div> </div>
</form> </form>
<el-button @click="getFile" :disabled="limitFileSize" type="primary" size="medium" class="uploadBtn">上传文件</el-button> <el-button @click="getFile" :disabled="limitFileSize" type="primary" size="medium" class="uploadBtn">上传文件</el-button>
<div class="el-upload__tip">请上传不超过5MB的文件</div> <div class="el-upload__tip">请上传不超过5MB的文件</div>
<div class="list"> <div class="list">
<transition-group name="list" tag="p">
<div class="list-item" v-for="item in uploadList" :key="item.name" >
<transition name="list" tag="p">
<div class="list-item" v-if="file" >
<i class="el-icon-document"></i> <i class="el-icon-document"></i>
<span>{{ item.name }}</span>
<span v-if="file" class="percentage" >{{percentage}}%</span>
<span>{{ file.name }}</span>
<span class="percentage" >{{percentage}}%</span>
<el-progress :show-text='false' :text-inside="false" :stroke-width="2" :percentage="percentage"></el-progress> <el-progress :show-text='false' :text-inside="false" :stroke-width="2" :percentage="percentage"></el-progress>
</div> </div>
</transition-group>
</transition>
</div> </div>
<!-- <span <!-- <span
v-if="this.file" v-if="this.file"
>{{Math.floor(((this.formDataList.length-this.waitNum)/this.formDataList.length)*100)}}%</span> --> >{{Math.floor(((this.formDataList.length-this.waitNum)/this.formDataList.length)*100)}}%</span> -->
@ -45,8 +45,7 @@ export default {
limitFileSize: false, limitFileSize: false,
percentage:0, percentage:0,
percentageFlage: true, percentageFlage: true,
customColor: '#409eff',
uploadList:[]
customColor: '#409eff'
} }
}, },
created(){ created(){
@ -59,6 +58,7 @@ export default {
const file = e.target.files[0] // const file = e.target.files[0] //
const maxSize = 5*1024*1024 const maxSize = 5*1024*1024
this.file = file // file 便 func this.file = file // file 便 func
this.percentage = 0
if(file.size<maxSize){ if(file.size<maxSize){
fileR.readAsArrayBuffer(file) // ArrayBuffer fileR.readAsArrayBuffer(file) // ArrayBuffer
fileR.onload = async e => { fileR.onload = async e => {
@ -123,9 +123,6 @@ export default {
this.percentageFlage = false this.percentageFlage = false
} }
this.sliceFile() // this.sliceFile() //
if(this.percentage == 100){
this.uploadList.push(this.file)
}
}, },
sliceFile() { sliceFile() {
this.waitUpLoad && this.waitUpLoad &&
@ -164,6 +161,9 @@ export default {
await removeChunk(params) await removeChunk(params)
} }
} }
},
inputChange(){
this.$refs.Input.dispatchEvent(new MouseEvent('click'))
} }
} }
} }
@ -206,7 +206,6 @@ a {
opacity: 0; opacity: 0;
cursor: pointer; cursor: pointer;
} }
} }
.fileName{ .fileName{
display: inline-block; display: inline-block;

Loading…
Cancel
Save