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

> >
{{ file.fileName }} {{ file.fileName }}
</div> </div>
<span style="padding:0 20px;"></span>
<span style="color:red">(备注:支持Word文档,execl,ppt,pdf)</span>
</div> </div>
<el-table <el-table
height="calc(100vh - 220px)" height="calc(100vh - 220px)"
dataList: [], dataList: [],
loading: false, loading: false,
file: {}, file: {},
uploading:false
uploading: false,
}; };
}, },
created() { created() {
.finally(() => { .finally(() => {
this.loading = false; this.loading = false;
}); });
this.getFile()
this.getFile();
}, },
methods: { methods: {
getFile() { getFile() {
input.addEventListener( input.addEventListener(
"change", "change",
(upload = (e) => { (upload = (e) => {
input.removeEventListener('change',upload)
if(this.uploading){
input.removeEventListener("change", upload);
if (this.uploading) {
this.$message({ this.$message({
type:"warning",
message:"正在上传"
})
return
type: "warning",
message: "正在上传",
});
return;
} }
this.uploading=true
this.uploading = true;
let file = e.target.files[0]; let file = e.target.files[0];
if(!file){
this.uploading=false
return
if (!file) {
this.uploading = false;
return;
} }
let MAXSIZE = 5 * 1024 * 1024; let MAXSIZE = 5 * 1024 * 1024;
if (file.size > MAXSIZE) { if (file.size > MAXSIZE) {
message: "上传文件成功", message: "上传文件成功",
}); });
} else { } else {
this.$message.error(data.code);
this.$message.error(data.msg);
} }
}) })
.catch((e) => { .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