提交 345cd774 编写于 作者: J jinlan.du

断点续传input隐藏

上级 5acdef73
...@@ -2,24 +2,24 @@ ...@@ -2,24 +2,24 @@
<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"> <div class="fileUpload" @click="inputChange">
选择文件<input @change="choseFile" id="file" multiple="multiple" type="file" /> 选择文件
<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"> <transition name="list" tag="p">
<div class="list-item" v-for="item in uploadList" :key="item.name" > <div class="list-item" v-if="file" >
<i class="el-icon-document"></i> <i class="el-icon-document"></i>
<span>{{ item.name }}</span> <span>{{ file.name }}</span>
<span v-if="file" class="percentage" >{{percentage}}%</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> -->
<div class="tips">此版本为先行体验功能测试版,样式美化和性能优化正在进行中,上传切片文件和合成的完整文件分别再QMPlusserver目录的breakpointDir文件夹和fileDir文件夹</div> <div class="tips">此版本为先行体验功能测试版,样式美化和性能优化正在进行中,上传切片文件和合成的完整文件分别再QMPlusserver目录的breakpointDir文件夹和fileDir文件夹</div>
...@@ -45,8 +45,7 @@ export default { ...@@ -45,8 +45,7 @@ export default {
limitFileSize: false, limitFileSize: false,
percentage:0, percentage:0,
percentageFlage: true, percentageFlage: true,
customColor: '#409eff', customColor: '#409eff'
uploadList:[]
} }
}, },
created(){ created(){
...@@ -59,6 +58,7 @@ export default { ...@@ -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 { ...@@ -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 { ...@@ -164,6 +161,9 @@ export default {
await removeChunk(params) await removeChunk(params)
} }
} }
},
inputChange(){
this.$refs.Input.dispatchEvent(new MouseEvent('click'))
} }
} }
} }
...@@ -198,15 +198,14 @@ a { ...@@ -198,15 +198,14 @@ a {
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
display: inline-block; display: inline-block;
input{ input{
position: absolute; position: absolute;
font-size: 100px; font-size: 100px;
right: 0; right: 0;
top: 0; top: 0;
opacity: 0; opacity: 0;
cursor: pointer; cursor: pointer;
} }
} }
.fileName{ .fileName{
display: inline-block; display: inline-block;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册