From 4bbc7c0cf4154bb3bbf06b8644b0fa248135d75c Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 14 Aug 2024 12:24:15 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80=E0=B8=A1?= =?UTF-8?q?=E0=B8=B4=E0=B8=99=E0=B8=9A=E0=B8=B8=E0=B8=84=E0=B8=84=E0=B8=A5?= =?UTF-8?q?=20=3D>=20=20fix=20bug=20upload=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Detail/step/step3.vue | 13 +++---- .../components/Detail/step/step4.vue | 35 ++++++++++++------- .../components/Detail/step/step5.vue | 13 ++++--- .../components/Detail/step/step8.vue | 30 ++++++++-------- 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/src/modules/12_evaluatePersonal/components/Detail/step/step3.vue b/src/modules/12_evaluatePersonal/components/Detail/step/step3.vue index 3e9433e61..c38e6a3fe 100644 --- a/src/modules/12_evaluatePersonal/components/Detail/step/step3.vue +++ b/src/modules/12_evaluatePersonal/components/Detail/step/step3.vue @@ -37,8 +37,8 @@ function handleItemClick(itemNumber: number) { * @param volume index item */ function getFile(volume: number) { - const fileText = numToThai(volume); showLoader(); + const fileText = numToThai(volume); http .get(config.API.evaluationFilebyId("เล่ม 1", id.value, fileText)) .then((res) => { @@ -46,10 +46,8 @@ function getFile(volume: number) { const type = res.data.fileType; getPDF(link, type); }) - .catch(() => { - // messageError($q, e); - }) - .finally(() => { + .catch((e) => { + messageError($q, e); hideLoader(); }); } @@ -76,7 +74,6 @@ function getPDF(url: string, type: string) { const objectUrl = URL.createObjectURL(blob); const pdfData = await usePDF(`${objectUrl}`); - showLoader(); setTimeout(() => { store.log = 1; store.pdfSrcStore = pdfData.pdf.value; @@ -84,8 +81,8 @@ function getPDF(url: string, type: string) { hideLoader(); }, 1500); }) - .catch(async (e) => { - messageError($q, JSON.parse(await e.response.data.text())); + .catch(() => { + hideLoader(); }) .finally(() => { store.log = 0; diff --git a/src/modules/12_evaluatePersonal/components/Detail/step/step4.vue b/src/modules/12_evaluatePersonal/components/Detail/step/step4.vue index fae4b9eb2..97d6dec5a 100644 --- a/src/modules/12_evaluatePersonal/components/Detail/step/step4.vue +++ b/src/modules/12_evaluatePersonal/components/Detail/step/step4.vue @@ -265,9 +265,10 @@ async function upLoadFile(file: any) { }) .catch((e) => { messageError($q, e); + hideLoader(); }) .finally(() => { - hideLoader(); + // hideLoader(); }); } } @@ -282,12 +283,13 @@ function fileUpLoad(url: string) { headers: { "Content-Type": fileEvaluationUpload.value?.type }, onUploadProgress: (e) => console.log(e), }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { + .then(() => { checkDoc10(); success($q, "อัปโหลดไฟล์สำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + hideLoader(); }); } @@ -333,6 +335,7 @@ async function checkDoc10() { ) .then((res: any) => { download10Url.value = res.data.downloadUrl; + fetchProfile(); }) .catch(() => { // messageError($q, e); @@ -340,12 +343,11 @@ async function checkDoc10() { .finally(() => { hideLoader(); }); - fetchProfile(); } /** function เรียกข้แมูลคุณสมบัติ*/ async function fetchProfile() { - showLoader(); + // showLoader(); await http .get(config.API.evaluateGetDetail(id.value)) .then((res) => { @@ -356,7 +358,7 @@ async function fetchProfile() { messageError($q, err); }) .finally(() => { - hideLoader(); + // hideLoader(); }); } @@ -430,14 +432,14 @@ onMounted(async () => { -
+
ประกาศผลการคัดเลือกบุคคล (เอกสารหมายเลข 10)
-
+
{
-
+
{ dense hide-bottom-space lazy-rules + label="อัปโหลดไฟล์" accept=".pdf" :rules=" download10Url === '' ? [(val) => !!val || 'กรุณาเลือกไฟล์'] : [] @@ -508,7 +516,10 @@ onMounted(async () => {
-
+
{ messageError($q, e); - }) - .finally(() => { hideLoader(); }); } @@ -134,14 +132,15 @@ function fileUpLoad(url: string) { headers: { "Content-Type": fileEvaluation5.value?.type }, onUploadProgress: (e) => console.log(e), }) - .then(() => { - success($q, "อัปโหลดไฟล์สำเร็จ"); + .then(async () => { + await checkDocResult(); + await success($q, "อัปโหลดไฟล์สำเร็จ"); }) .catch((e) => { messageError($q, e); }) .finally(() => { - checkDocResult(); + hideLoader(); }); } @@ -197,7 +196,7 @@ async function getDate() { const download10Url = ref(""); /** function เช็คไฟล์อัปโหลด*/ async function checkDocResult() { - showLoader(); + // showLoader(); await http .get( config.API.evaluationPatchData( @@ -213,7 +212,7 @@ async function checkDocResult() { // messageError($q, e); }) .finally(() => { - hideLoader(); + // hideLoader(); }); } diff --git a/src/modules/12_evaluatePersonal/components/Detail/step/step8.vue b/src/modules/12_evaluatePersonal/components/Detail/step/step8.vue index 87a016704..7c745d7b9 100644 --- a/src/modules/12_evaluatePersonal/components/Detail/step/step8.vue +++ b/src/modules/12_evaluatePersonal/components/Detail/step/step8.vue @@ -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(""); * @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("");