From a589162530e84ff0e801fbc52de939f1f2e93335 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 20 Aug 2024 11:44:42 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=20=3D>=20=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9C=E0=B8=B1?= =?UTF-8?q?=E0=B8=87=E0=B8=9A=E0=B8=B1=E0=B8=8D=E0=B8=8A=E0=B8=B5=E0=B9=80?= =?UTF-8?q?=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD?= =?UTF-8?q?=E0=B8=99,=E0=B8=9C=E0=B8=B1=E0=B8=87=E0=B8=9A=E0=B8=B1?= =?UTF-8?q?=E0=B8=8D=E0=B8=8A=E0=B8=B5=E0=B8=84=E0=B9=88=E0=B8=B2=E0=B8=88?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=88?= =?UTF-8?q?=E0=B8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/SalaryChart/DialogFormMain.vue | 10 +- .../components/SalaryChart/DialogFormRate.vue | 14 +- .../components/SalaryChart/DialogUpload.vue | 207 +++++++++--------- .../DialogEmployeeChart.vue | 2 +- .../DialogEmployeeRate.vue | 8 +- .../DialogEmployeeUpload.vue | 189 ++++++++-------- .../DialogFormCriteria.vue | 4 +- .../salaryEmployeeChart/TabCriteria.vue | 12 +- .../salaryEmployeeChart/TabStructure.vue | 58 +++-- src/modules/13_salary/views/salaryChart.vue | 44 ++-- .../13_salary/views/salaryEmployeeRate.vue | 23 +- src/modules/13_salary/views/salaryRate.vue | 74 ++++--- 12 files changed, 337 insertions(+), 308 deletions(-) diff --git a/src/modules/13_salary/components/SalaryChart/DialogFormMain.vue b/src/modules/13_salary/components/SalaryChart/DialogFormMain.vue index 437b332a8..5fa81ff11 100644 --- a/src/modules/13_salary/components/SalaryChart/DialogFormMain.vue +++ b/src/modules/13_salary/components/SalaryChart/DialogFormMain.vue @@ -133,7 +133,7 @@ function fetchSalaryDetail(id: string) { formData.endDate = data.endDate; formData.details = data.details; formData.isSpecial = data.isSpecial; - isReadonly.value = props.typeAction === 'view'? true: data.isActive; + isReadonly.value = props.typeAction === "view" ? true : data.isActive; }) .catch((err) => { messageError($q, err); @@ -192,7 +192,7 @@ function clearFormData() { } /** - * function บัยทึกข้อมูลผังบัญชีเงินเดือน + * function บันทึกข้อมูลผังบัญชีเงินเดือน */ function onSubmit() { dialogConfirm($q, async () => { @@ -203,13 +203,13 @@ function onSubmit() { ? config.API.salaryChart : config.API.salaryChartByid(salaryId.value); await http[props.typeAction === "add" ? "post" : "put"](url, formData); - success($q, "บันทีกข้อมูลสำเร็จ"); - props.fetchData?.(); + await props.fetchData?.(); + await success($q, "บันทีกข้อมูลสำเร็จ"); + closeDialog(); } catch (err) { messageError($q, err); } finally { hideLoader(); - closeDialog(); } }); } diff --git a/src/modules/13_salary/components/SalaryChart/DialogFormRate.vue b/src/modules/13_salary/components/SalaryChart/DialogFormRate.vue index eb47b489a..c7c6f4f19 100644 --- a/src/modules/13_salary/components/SalaryChart/DialogFormRate.vue +++ b/src/modules/13_salary/components/SalaryChart/DialogFormRate.vue @@ -63,13 +63,17 @@ const title = computed(() => { return name; }); -/** function ปืด Dialog*/ +/** + * function ปืด Dialog* + */ function closeDialog() { modal.value = !modal.value; clearFormData(); } -/** function เคลียข้อมูล form*/ +/** + * function เคลียข้อมูล form + */ function clearFormData() { formData.salaryId = ""; formData.salary = null; @@ -139,13 +143,13 @@ function onSubmit() { ? config.API.salaryRateList : config.API.salaryRateListByid(formData.salaryId); await http[props.typeAction === "add" ? "post" : "put"](url, body); - success($q, "บันทีกข้อมูลสำเร็จ"); - props.fetchData?.(); + await props.fetchData?.(); + await success($q, "บันทีกข้อมูลสำเร็จ"); + closeDialog(); } catch (err) { messageError($q, err); } finally { hideLoader(); - closeDialog(); } }); } diff --git a/src/modules/13_salary/components/SalaryChart/DialogUpload.vue b/src/modules/13_salary/components/SalaryChart/DialogUpload.vue index a19cf1edd..24f67985f 100644 --- a/src/modules/13_salary/components/SalaryChart/DialogUpload.vue +++ b/src/modules/13_salary/components/SalaryChart/DialogUpload.vue @@ -56,7 +56,7 @@ const itemsDocument = ref([]); /** * function fetch ข้อมูลรายการ ไฟล์ - * @param id + * @param id ไฟล์ */ function fetchDocumentFile(id: string) { showLoader(); @@ -74,13 +74,17 @@ function fetchDocumentFile(id: string) { }); } -/** function ปืด Dialog*/ +/** + * function ปืด Dialog* + */ function closeDialog() { modal.value = !modal.value; clearFormData(); } -/** function เคลียข้อมูล form*/ +/** + * function เคลียข้อมูล form* + */ function clearFormData() { formData.salaryType = ""; formData.posTypeId = ""; @@ -95,10 +99,12 @@ function clearFormData() { itemsDocument.value = []; } -/** function เรียก path อัปโหลดไฟล์*/ +/** + * function เรียก path อัปโหลดไฟล์ + */ async function uploadDocumentFile() { - const fileName = documentFile.value.name.replace(/\.(xlsx|docx|pdf)$/, ""); showLoader(); + const fileName = documentFile.value.name.replace(/\.(xlsx|docx|pdf)$/, ""); const formData = new FormData(); formData.append("file", documentFile.value); const body = { @@ -109,20 +115,17 @@ async function uploadDocumentFile() { }; await http .post(config.API.salaryChartFile(salaryId.value), body) - .then((res) => { - console.log(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); + await fileUpLoad(link); }) .catch((err) => { messageError($q, err); - }) - .finally(() => { hideLoader(); }); } @@ -136,15 +139,15 @@ function fileUpLoad(url: string) { headers: { "Content-Type": documentFile.value?.type }, onUploadProgress: (e) => console.log(e), }) - .then(() => { - success($q, "อัปโหลดไฟล์สำเร็จ"); + .then(async () => { + await fetchDocumentFile(salaryId.value); + await success($q, "อัปโหลดไฟล์สำเร็จ"); documentFile.value = null; - fetchDocumentFile(salaryId.value); }) .catch((e) => { messageError($q, e); - }) - .finally(() => {}); + hideLoader(); + }); } /** @@ -156,11 +159,11 @@ function onClickDeleteFile(fileName: string) { showLoader(); await http .delete(config.API.salaryChartDelFile(salaryId.value, fileName)) - .then(() => { - setTimeout(() => { - fetchDocumentFile(salaryId.value); - success($q, "ลบไฟล์สำเร็จ"); - }, 1000); + .then(async () => { + setTimeout(async () => { + await fetchDocumentFile(salaryId.value); + await success($q, "ลบไฟล์สำเร็จ"); + }, 1500); }) .catch((err) => { messageError($q, err); @@ -168,7 +171,7 @@ function onClickDeleteFile(fileName: string) { .finally(() => { setTimeout(() => { hideLoader(); - }, 1000); + }, 2000); }); }); } @@ -181,9 +184,9 @@ function onClickDonwload(fileName: string) { showLoader(); http .get(config.API.salaryChartDelFile(salaryId.value, fileName)) - .then((res) => { + .then(async (res) => { const data = res.data; - downloadFile(data.downloadUrl, data.fileType, fileName); + await downloadFile(data.downloadUrl, data.fileType, fileName); }) .catch((err) => { messageError($q, err); @@ -239,99 +242,93 @@ watch(