Browse Source

修改文件上传

master
yangzhou-cyber 3 years ago
parent
commit
a19a5ae95a
1 changed files with 20 additions and 17 deletions
  1. +20
    -17
      src/views/second/summary/index.vue

+ 20
- 17
src/views/second/summary/index.vue View File

@@ -18,6 +18,8 @@
>
{{ file.fileName }}
</div>
<span style="padding:0 20px;"></span>
<span style="color:red">(备注:支持Word文档,execl,ppt,pdf)</span>
</div>
<el-table
height="calc(100vh - 220px)"
@@ -162,7 +164,7 @@ export default {
dataList: [],
loading: false,
file: {},
uploading:false
uploading: false,
};
},
created() {
@@ -183,7 +185,7 @@ export default {
.finally(() => {
this.loading = false;
});
this.getFile()
this.getFile();
},
methods: {
getFile() {
@@ -216,19 +218,19 @@ export default {
input.addEventListener(
"change",
(upload = (e) => {
input.removeEventListener('change',upload)
if(this.uploading){
input.removeEventListener("change", upload);
if (this.uploading) {
this.$message({
type:"warning",
message:"正在上传"
})
return
type: "warning",
message: "正在上传",
});
return;
}
this.uploading=true
this.uploading = true;
let file = e.target.files[0];
if(!file){
this.uploading=false
return
if (!file) {
this.uploading = false;
return;
}
let MAXSIZE = 5 * 1024 * 1024;
if (file.size > MAXSIZE) {
@@ -246,14 +248,15 @@ export default {
message: "上传文件成功",
});
} else {
this.$message.error(data.code);
this.$message.error(data.msg);
}
})
.catch((e) => {
this.$message.error("上传文件失败");
}).finally(e=>{
this.uploading=false
this.getFile()
this.$message.error(e);
})
.finally((e) => {
this.uploading = false;
this.getFile();
});
})
);

Loading…
Cancel
Save