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(); }); });