From ad53e6bd54b506811ca3e350faa49bf4fca40a2a Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 16 Aug 2024 17:58:33 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4=20=3D>=20=20=E0=B9=80=E0=B8=AD=E0=B8=81?= =?UTF-8?q?=E0=B8=AA=E0=B8=B2=E0=B8=A3=E0=B8=AB=E0=B8=A5=E0=B8=B1=E0=B8=81?= =?UTF-8?q?=E0=B8=90=E0=B8=B2=E0=B8=99=E0=B9=81=E0=B8=A5=E0=B8=B0=E0=B8=AD?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=99=E0=B9=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/Other/01_OtherInformation.vue | 62 +++++-------------- .../components/detail/Other/02_Document.vue | 21 +++---- 2 files changed, 26 insertions(+), 57 deletions(-) diff --git a/src/modules/04_registryPerson/components/detail/Other/01_OtherInformation.vue b/src/modules/04_registryPerson/components/detail/Other/01_OtherInformation.vue index 1dfd98d59..eb43b2aa0 100644 --- a/src/modules/04_registryPerson/components/detail/Other/01_OtherInformation.vue +++ b/src/modules/04_registryPerson/components/detail/Other/01_OtherInformation.vue @@ -23,7 +23,6 @@ const { hideLoader, success, messageError, - dialogRemove, dialogConfirm, pathRegistryEmp, } = mixin; @@ -43,21 +42,6 @@ const mode = ref("table"); const filterKeyword = ref(""); const rows = ref([]); -const currentPage = ref(1); -const maxPage = ref(1); -const formFilter = reactive({ - page: 1, - pageSize: 12, - keyword: "", - type: "", - posType: "", - posLevel: "", - retireYear: "", - rangeYear: { min: 0, max: 60 }, - isShowRetire: false, - isProbation: false, -}); - /** modal */ const modal = ref(false); const edit = ref(false); @@ -66,13 +50,6 @@ const modalHistory = ref(false); const date = ref(null); const detail = ref(); -const dateRef = ref(null); -const detailRef = ref(null); -const objectRef: MyObjectRef = { - date: dateRef, - detail: detailRef, -}; - const visibleColumns = ref(["date", "detail"]); const columns = ref([ { @@ -134,7 +111,7 @@ function closeDialog() { function validateForm() { dialogConfirm( $q, - async () => { + () => { if (edit.value) { editData(); } else { @@ -149,18 +126,18 @@ function validateForm() { /** * บันทึกเพิ่มข้อมูล */ -async function saveData() { +function saveData() { showLoader(); - await http + http .post(config.API.profileNewOther(empType.value), { profileId: empType.value === "" ? profileId.value : undefined, profileEmployeeId: empType.value !== "" ? profileId.value : undefined, date: date.value, detail: detail.value, }) - .then(() => { - success($q, "บันทึกข้อมูลสำเร็จ"); - getData(); + .then(async () => { + await getData(); + await success($q, "บันทึกข้อมูลสำเร็จ"); closeDialog(); }) .catch((e) => { @@ -174,16 +151,16 @@ async function saveData() { /** * บันทึกแก้ไขข้อมูล */ -async function editData() { +function editData() { showLoader(); - await http + http .patch(config.API.profileNewOtherById(id.value, empType.value), { date: date.value, detail: detail.value, }) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - getData(); + .then(async () => { + await getData(); + await success($q, "บันทึกข้อมูลสำเร็จ"); closeDialog(); }) .catch((e) => { @@ -194,9 +171,12 @@ async function editData() { }); } -async function getData() { +/** + * fetch รายการข้อมูลอื่นๆ + */ +function getData() { showLoader(); - await http + http .get(config.API.profileNewOtherByProfileId(profileId.value, empType.value)) .then((res) => { rows.value = res.data.result; @@ -467,15 +447,7 @@ onMounted(() => { - + บันทึกข้อมูล diff --git a/src/modules/04_registryPerson/components/detail/Other/02_Document.vue b/src/modules/04_registryPerson/components/detail/Other/02_Document.vue index 0184aabf8..31093dff8 100644 --- a/src/modules/04_registryPerson/components/detail/Other/02_Document.vue +++ b/src/modules/04_registryPerson/components/detail/Other/02_Document.vue @@ -57,9 +57,9 @@ async function uploadFileDoc(uploadUrl: string, file: any) { "Content-Type": file.type, }, }) - .then((res) => { + .then(async () => { + await getData(); success($q, "อัปโหลดไฟล์สำเร็จ"); - getData(); }) .catch((e) => { messageError($q, e); @@ -70,12 +70,12 @@ async function uploadFileDoc(uploadUrl: string, file: any) { }); } -async function clickUpload(file: any) { +function clickUpload(file: any) { const fileName = { fileName: file.name }; - dialogConfirm( $q, async () => { + showLoader(); const selectedFile = file; const formdata = new FormData(); formdata.append("file", selectedFile); @@ -152,17 +152,14 @@ function deleteFile(fileName: string) { fileName ) ) - .then((res) => { - success($q, `ลบไฟล์สำเร็จ`); - setTimeout(() => { - getData(); - hideLoader(); - }, 1000); + .then(async () => { + await setTimeout(async () => { + await getData(); + await success($q, `ลบไฟล์สำเร็จ`); + }, 1500); }) .catch((e) => { messageError($q, e); - }) - .finally(() => { hideLoader(); }); });