Pārlūkot izejas kodu

修改文件上传

master
yangzhou-cyber pirms 3 gadiem
vecāks
revīzija
a19a5ae95a
1 mainītis faili ar 20 papildinājumiem un 17 dzēšanām
  1. +20
    -17
      src/views/second/summary/index.vue

+ 20
- 17
src/views/second/summary/index.vue Parādīt failu

@@ -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();
});
})
);

Notiek ielāde…
Atcelt
Saglabāt