From 23d30d532c64f16401ad3b407a63d0c0ba800412 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 24 Oct 2024 17:52:42 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=A5?= =?UTF-8?q?=E0=B8=B0=E0=B9=80=E0=B8=AD=E0=B8=B5=E0=B8=A2=E0=B8=94=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=B2=E0=B8=AD=E0=B8=AD=E0=B8=81?= =?UTF-8?q?=E0=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/resign/ResignByid.vue | 52 +++++++------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/src/modules/06_retirement/components/resign/ResignByid.vue b/src/modules/06_retirement/components/resign/ResignByid.vue index 0b8866dc7..d027a768e 100644 --- a/src/modules/06_retirement/components/resign/ResignByid.vue +++ b/src/modules/06_retirement/components/resign/ResignByid.vue @@ -94,8 +94,6 @@ const reasonReign = ref(""); const dateBreak = ref(null); const isCheckData = computed(() => { - console.log(workflowRef.value?.permission.isOperate); - if ( organizationPositionOld.value !== "" && positionTypeOld.value !== "" && @@ -183,7 +181,6 @@ function diffDate() { /** นำข้อมูลมาจาก API*/ async function fetchData(id: string) { - showLoader(); await http .get(config.API.resingByid(id)) .then(async (res) => { @@ -219,8 +216,6 @@ async function fetchData(id: string) { }) .catch((e) => { messageError($q, e); - }) - .finally(() => { hideLoader(); }); } @@ -241,14 +236,6 @@ function onSubmit() { } else { rejectpopUp(); } - - // if (myFormConfirm.value !== null) { - // myFormConfirm.value.validate().then(async (check) => { - // if (check) { - - // } - // }); - // } } //pop up ยืนยันการอนุญาต @@ -411,13 +398,13 @@ async function fileDownload(type: string, fileName: string) { .then(async (res) => { const data = res.data.result; await genReport(data, `${fileName}`, type); - hideLoader(); }) .catch(async (e) => { messageError($q, JSON.parse(await e.response.data.text())); - hideLoader(); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); } function updatemodalPersonal(modal: boolean) { @@ -428,13 +415,11 @@ async function fetchFile() { showLoader(); await http .get(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value)) - .then((res) => { - fileList.value = res.data; + .then(async (res) => { + fileList.value = await res.data; }) .catch((e) => { messageError($q, e); - }) - .finally(() => { hideLoader(); }); } @@ -456,7 +441,7 @@ function uploadFiles() { res.data[key]?.fileName !== undefined && res.data[key]?.fileName !== "" ); - foundKey && uploadFileURL(res.data[foundKey]?.uploadUrl); + foundKey && (await uploadFileURL(res.data[foundKey]?.uploadUrl)); }) .catch((err) => { messageError($q, err); @@ -476,9 +461,9 @@ async function uploadFileURL(uploadUrl: string) { "Content-Type": file.value.type, }, }) - .then(() => { + .then(async () => { + await fetchFile(); success($q, "อัปโหลดไฟล์สำเร็จ"); - fetchFile(); }) .catch((e) => { messageError($q, e); @@ -489,14 +474,14 @@ async function uploadFileURL(uploadUrl: string) { }); } -function downloadFiles(fileName: string) { +async function downloadFiles(fileName: string) { showLoader(); - http + await http .get( config.API.fileByFile("พ้นจากราชการ", "หลักฐานลาออก", id.value, fileName) ) - .then((res) => { - const data = res.data.downloadUrl; + .then(async (res) => { + const data = await res.data.downloadUrl; window.open(data, "_blank"); }) .catch((e) => { @@ -524,9 +509,9 @@ function removeFile(fileName: string) { ) ) .then(() => { - success($q, `ลบไฟล์สำเร็จ`); - setTimeout(() => { - fetchFile(); + setTimeout(async () => { + await fetchFile(); + success($q, `ลบไฟล์สำเร็จ`); hideLoader(); }, 1000); }) @@ -539,8 +524,11 @@ function removeFile(fileName: string) { /** Hook */ onMounted(async () => { - fetchData(id.value); - fetchFile(); + showLoader(); + await Promise.all([fetchData(id.value), fetchFile()]).finally(() => { + hideLoader(); + }); + // const user = await tokenParsed(); // if (user) { // const commander = await user.role.includes("commander");