🐛(component): url上传失效修复

This commit is contained in:
liangziming 2022-04-28 23:59:17 +08:00
parent 1010a4bbed
commit 063ecd7da0

View File

@ -184,6 +184,7 @@ const localUploadTransaction = (option: localUploadTransaction) => {
let _file = files[i];
formData.append("file[" + i + "]", _file);
}
}
// Uploaddata,
if (props.data && props.data instanceof Object) {
let _requestDate = props.data;
@ -196,7 +197,6 @@ const localUploadTransaction = (option: localUploadTransaction) => {
clearTimeout(utimer);
});
}, 200);
}
};
//
@ -237,19 +237,24 @@ const localUpload = (option: localUploadOption, callback: Function) => {
//
// event callbacks
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if ((xhr.status >= 200 && xhr.status <= 300) || xhr.status === 304) {
//
let currentTimeStamp = new Date().valueOf();
let successText = xhr.responseText ? xhr.responseText : uploadSuccess;
if (xhr.readyState === 1) {
if ((xhr.status >= 200 && xhr.status <= 300) || xhr.status === 304||xhr.status == 0) {
let successText = "上传开始";
emit(
"before",
Object.assign({ currentTimeStamp, msg: successText, ...option })
);
} else {
errorF(xhr.responseText);
}
} else {
errorF(defaultErrorMsg);
}else if(xhr.readyState === 4){
//
let successText = xhr.responseText ? xhr.responseText : uploadSuccess;
console.log(xhr);
if((xhr.status >= 200 && xhr.status <= 300) || xhr.status === 304||xhr.status == 0){
let data = xhr.responseText;
emit("done", {currentTimeStamp,msg:successText,data:data});
}
}
};
xhr.open("post", url, true); //GET, getURL
@ -333,13 +338,15 @@ const getUploadChange = (e: any) => {
}
};
const commonUploadTransaction = (_files: any[]) => {
let currentTimeStamp = new Date().valueOf();
let successText = uploadSuccess;
if (props.url) {
localUploadTransaction({
url: props.url,
files: _files,
});
} else {
emit("done", _files);
emit("done", {currentTimeStamp,msg:successText,data:_files});
}
};
const chooseFile = () => {