|
@@ -107,11 +107,18 @@ export default {
|
|
|
const _file_format = fileType.split(".").pop().toLocaleLowerCase();
|
|
|
return this.format.length
|
|
|
? this.format.some((item) => item.toLocaleLowerCase() === _file_format)
|
|
|
- : true;
|
|
|
+ : false;
|
|
|
},
|
|
|
- fileChange(fileObj) {
|
|
|
+ async fileChange(fileObj, fileList) {
|
|
|
if (fileObj.status === "ready") {
|
|
|
- this.handleBeforeUpload(fileObj.raw).catch(() => {});
|
|
|
+ if (fileList.length > 1) {
|
|
|
+ fileList[0] = fileList[1];
|
|
|
+ fileList.splice(1, 1);
|
|
|
+ }
|
|
|
+ let res = await this.handleBeforeUpload(fileObj.raw).catch(() => {});
|
|
|
+ if (res) {
|
|
|
+ this.submit();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
async handleBeforeUpload(file) {
|
|
@@ -125,15 +132,16 @@ export default {
|
|
|
if (!this.checkFileFormat(file.name)) {
|
|
|
this.handleFormatError();
|
|
|
this.fileValid = false;
|
|
|
- return Promise.reject();
|
|
|
+ // return Promise.reject();
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
if (file.size > this.maxSize) {
|
|
|
this.handleExceededSize();
|
|
|
this.fileValid = false;
|
|
|
- return Promise.reject();
|
|
|
+ // return Promise.reject();
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
const md5 = await fileMD5(file);
|
|
|
this.headers["md5"] = md5;
|
|
|
this.fileValid = true;
|
|
@@ -143,7 +151,7 @@ export default {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
},
|
|
|
submit() {
|
|
|
if (!this.fileValid) {
|