update 优化多文件 多图片上传

2.X
疯狂的狮子li 3 years ago
parent 3f682fc80c
commit bc72868fc5

@ -151,12 +151,17 @@ export default {
}, },
// //
handleUploadSuccess(res) { handleUploadSuccess(res) {
this.uploadList.push({ name: res.data.fileName, url: res.data.url }); if (res.code === 200) {
if (this.uploadList.length === this.number) { this.uploadList.push({ name: res.data.fileName, url: res.data.url });
this.fileList = this.fileList.concat(this.uploadList); if (this.uploadList.length === this.number) {
this.uploadList = []; this.fileList = this.fileList.concat(this.uploadList);
this.number = 0; this.uploadList = [];
this.$emit("input", this.listToString(this.fileList)); this.number = 0;
this.$emit("input", this.listToString(this.fileList));
this.$modal.closeLoading();
}
} else {
this.$modal.msgError(res.msg);
this.$modal.closeLoading(); this.$modal.closeLoading();
} }
}, },

@ -122,12 +122,17 @@ export default {
}, },
// //
handleUploadSuccess(res) { handleUploadSuccess(res) {
this.uploadList.push({ name: res.data.fileName, url: res.data.url }); if (res.code == 200) {
if (this.uploadList.length === this.number) { this.uploadList.push({ name: res.data.fileName, url: res.data.url });
this.fileList = this.fileList.concat(this.uploadList); if (this.uploadList.length === this.number) {
this.uploadList = []; this.fileList = this.fileList.concat(this.uploadList);
this.number = 0; this.uploadList = [];
this.$emit("input", this.listToString(this.fileList)); this.number = 0;
this.$emit("input", this.listToString(this.fileList));
this.$modal.closeLoading();
}
} else {
this.$modal.msgError(res.msg);
this.$modal.closeLoading(); this.$modal.closeLoading();
} }
}, },

Loading…
Cancel
Save