ประเมินบุคคล => fix bug upload file

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-14 12:24:15 +07:00
parent 537277c381
commit 4bbc7c0cf4
4 changed files with 50 additions and 41 deletions

View file

@ -113,20 +113,18 @@ function upLoadFile(name: string, file: any) {
},
},
})
.then((res) => {
.then(async (res) => {
const foundKey: any = Object.keys(res.data).find(
(key) =>
res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== ""
);
const link = res.data[foundKey]?.uploadUrl;
fileUpLoad(link, file);
await fileUpLoad(link, file);
await downloadFileList(name);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
downloadFileList(name);
hideLoader();
});
}
@ -143,11 +141,14 @@ function fileUpLoad(url: string, file: any) {
headers: { "Content-Type": file?.type },
onUploadProgress: (e) => console.log(e),
})
.then(() => {
success($q, "อัปโหลดไฟล์สำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
success($q, "อัปโหลดไฟล์สำเร็จ");
hideLoader();
});
}
@ -191,6 +192,7 @@ async function confirmApprove() {
dialogConfirm(
$q,
() => {
showLoader();
const data = {
metadata: {
additionalProp1: nameOfWork.value,
@ -198,7 +200,6 @@ async function confirmApprove() {
additionalProp3: position.value,
},
};
showLoader();
http
.patch(
config.API.evaluationPatchData(
@ -208,13 +209,14 @@ async function confirmApprove() {
),
data
)
.then(() => {})
.then(() => {
nextStep();
modalConfirm.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
nextStep();
modalConfirm.value = false;
hideLoader();
});
},
@ -294,7 +296,7 @@ const downloadFile6 = ref<string>("");
* @param fileName อไฟล
*/
async function downloadFileList(fileName: string) {
showLoader();
// showLoader();
await http
.get(config.API.evaluationFilebyId("เล่ม 2", id.value, fileName))
.then((res) => {
@ -314,10 +316,10 @@ async function downloadFileList(fileName: string) {
} else if (fileName === "แบบสรุปผลการประเมิน (เอกสารแบบ ง)") {
downloadFile6.value = res.data.downloadUrl;
}
})
.finally(() => {
hideLoader();
});
// .finally(() => {
// hideLoader();
// });
}
const author = ref<string>("");