diff --git a/src/main.ts b/src/main.ts index 0595dce2e..df8024dbe 100644 --- a/src/main.ts +++ b/src/main.ts @@ -104,9 +104,4 @@ if (auth.token && auth.refresh_token) { // }); } -app.config.globalProperties.$checkPermission = function () { - console.log("This is a checkPermission"); - return true; -}; - app.mount("#app"); diff --git a/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue b/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue index 934824ba7..3deba9a3d 100644 --- a/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue +++ b/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue @@ -216,28 +216,40 @@ const historyVisibleColumns = ref([ "lastUpdatedAt", ]); -async function onSubmit() { +/** + * ยืนยันการบันทึกข้อมูล + */ +function onSubmit() { dialogConfirm( $q, - async () => { + () => { dialogStatus.value === "create" ? addData() : editData(editId.value); - closeDialog(); }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +/** + * ปิด form ข้อมูลใบอนุญาตประกอบวิชาชีพ + */ function closeDialog() { dialog.value = false; } + +/** + * ปิด popup ประวัติการแก้ไขข้อมูลใบอนุญาตประกอบวิชาชีพ + */ function closeHistoryDialog() { historyDialog.value = false; } -async function fetchData(id: string) { +/** + * fetch ข้อมูลรายการใบอนุญาตประกอบวิชาชีพ + */ +function fetchData(id: string) { showLoader(); - await http + http .get(config.API.profileNewCertificateByProfileId(id, empType.value)) .then(async (res) => { rows.value = res.data.result; @@ -250,6 +262,9 @@ async function fetchData(id: string) { }); } +/** + * เคลียร์ form ข้อมูลใบอนุญาตประกอบวิชาชีพ + */ function clearForm() { profesLicenseData.expireDate = null; profesLicenseData.issueDate = new Date(); @@ -258,6 +273,10 @@ function clearForm() { profesLicenseData.issuer = ""; } +/** + * เปิด form แก้ไขข้อมูลใบอนุญาตประกอบวิชาชีพ + * @param row ข้อมูลใบอนุญาตประกอบวิชาชีพ + */ function editForm(row: any) { dialogStatus.value = "edit"; editId.value = row.id; @@ -269,16 +288,21 @@ function editForm(row: any) { dialog.value = true; } -async function addData() { - await http +/** + * เพิ่มรายการข้อมูลใบอนุญาตประกอบวิชาชีพ + */ +function addData() { + showLoader(); + http .post(config.API.profileNewCertificate(empType.value), { ...profesLicenseData, profileId: empType.value === "" ? id.value : undefined, profileEmployeeId: empType.value !== "" ? id.value : undefined, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -288,8 +312,13 @@ async function addData() { }); } -async function editData(idData: string) { - await http +/** + * แก้ไขข้อมูลใบอนุญาตประกอบวิชาชีพ + * @param idData รายการข้อมูลใบอนุญาตประกอบวิชาชีพ + */ +function editData(idData: string) { + showLoader(); + http .patch( config.API.profileNewCertificateByCertificateId(idData, empType.value), { @@ -297,9 +326,10 @@ async function editData(idData: string) { profileId: undefined, } ) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -309,25 +339,12 @@ async function editData(idData: string) { }); } -// function deleteData(idData: string) { -// dialogRemove($q, () => -// http -// .delete(config.API.profileNewCertificateByCertificateId(idData)) -// .then(() => { -// fetchData(id.value); -// }) -// .catch((err) => { -// messageError($q, err); -// }) -// .finally(() => { -// hideLoader(); -// }) -// ); -// } - -async function fetchHistoryData(id: string) { +/** + * fetch ข้อมูลประวัติการแก้ไขข้อมูลใบอนุญาตประกอบวิชาชีพ + */ +function fetchHistoryData(id: string) { showLoader(); - await http + http .get(config.API.profileNewCertificateHisByCertificateId(id, empType.value)) .then(async (res) => { historyRows.value = res.data.result; @@ -340,8 +357,8 @@ async function fetchHistoryData(id: string) { }); } -onMounted(async () => { - await fetchData(id.value); +onMounted(() => { + fetchData(id.value); }); diff --git a/src/modules/04_registryPerson/components/detail/Achievement/02_Train.vue b/src/modules/04_registryPerson/components/detail/Achievement/02_Train.vue index 66e70def4..2bec48419 100644 --- a/src/modules/04_registryPerson/components/detail/Achievement/02_Train.vue +++ b/src/modules/04_registryPerson/components/detail/Achievement/02_Train.vue @@ -353,18 +353,23 @@ const historyVisibleColumns = ref([ "lastUpdatedAt", // แก้ไขเมื่อวันที่ ]); -async function onSubmit() { +/** + * ยืนยันการบันทึกข้อมูล + */ +function onSubmit() { dialogConfirm( $q, - async () => { + () => { dialogStatus.value === "create" ? addData() : editData(editId.value); - closeDialog(); }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +/** + * เคลียร์ form ฝึกอบรม/ดูงาน + */ function clearForm() { isDate.value = "false"; trainData.name = ""; @@ -379,6 +384,9 @@ function clearForm() { trainData.endDate = new Date(); } +/** + * เปิด popoup แก้ไขข้อมูลฝึกอบรม/ดูงาน + */ function editForm(row: any) { dialogStatus.value = "edit"; editId.value = row.id; @@ -398,8 +406,12 @@ function editForm(row: any) { dialog.value = true; } -async function addData() { - await http +/** + * เพิ่มข้อมูลการฝึกอบรม/ดูงาน + */ +function addData() { + showLoader(); + http .post(config.API.profileNewTraining(empType.value), { ...trainData, startYear: undefined, @@ -408,9 +420,10 @@ async function addData() { profileId: empType.value === "" ? id.value : undefined, profileEmployeeId: empType.value !== "" ? id.value : undefined, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + closeDialog(); + await success($q, "บันทึกข้อมูลสำเร็จ"); }) .catch((err) => { messageError($q, err); @@ -420,8 +433,13 @@ async function addData() { }); } -async function editData(idData: string) { - await http +/** + * แก้ไขข้อมูลการฝึกอบรม/ดูงาน + * @param idData รายการฝึกอบรม/ดูงาน + */ +function editData(idData: string) { + showLoader(); + http .patch(config.API.profileNewTrainingByTrainingId(idData, empType.value), { ...trainData, profileId: undefined, @@ -429,9 +447,10 @@ async function editData(idData: string) { finishYear: undefined, isDate: isDate.value === "false" ? false : true, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + closeDialog(); + await success($q, "บันทึกข้อมูลสำเร็จ"); }) .catch((err) => { messageError($q, err); @@ -441,36 +460,29 @@ async function editData(idData: string) { }); } -function deleteData(idData: string) { - dialogRemove($q, () => - http - .delete(config.API.profileNewTrainingByTrainingId(idData, empType.value)) - .then(() => { - fetchData(id.value); - success($q, "ลบข้อมูลสำเร็จ"); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }) - ); +/** + * ปิด from การฝึกอบรม/ดูงาน + */ +function closeDialog() { + dialog.value = false; + clearForm(); } -function closeDialog() { - clearForm(); - dialog.value = false; -} +/** + * ปิด ประวัติการแก่ไขการฝึกอบรม/ดูงาน + */ function closeHistoryDialog() { historyDialog.value = false; } -async function fetchData(id: string) { +/** + * fetch รายการการฝึกอบรม/ดูงาน + */ +function fetchData(id: string) { showLoader(); - await http + http .get(config.API.profileNewTrainingByProfileId(id, empType.value)) - .then(async (res) => { + .then((res) => { rows.value = res.data.result; }) .catch((err) => { @@ -481,11 +493,14 @@ async function fetchData(id: string) { }); } -async function fetchHistoryData(id: string) { +/** + * fetch ประวัติรายการแก้ไขการฝึกอบรม/ดูงาน + */ +function fetchHistoryData(id: string) { showLoader(); - await http + http .get(config.API.profileNewTrainingHisByTrainingId(id, empType.value)) - .then(async (res) => { + .then((res) => { historyRows.value = res.data.result; }) .catch((err) => { @@ -496,8 +511,8 @@ async function fetchHistoryData(id: string) { }); } -onMounted(async () => { - await fetchData(id.value); +onMounted(() => { + fetchData(id.value); }); diff --git a/src/modules/04_registryPerson/components/detail/Achievement/03_Insignia.vue b/src/modules/04_registryPerson/components/detail/Achievement/03_Insignia.vue index 16df2dff7..d5baa51ea 100644 --- a/src/modules/04_registryPerson/components/detail/Achievement/03_Insignia.vue +++ b/src/modules/04_registryPerson/components/detail/Achievement/03_Insignia.vue @@ -444,9 +444,11 @@ const visibleColumnsHistory = ref([ "lastUpdatedAt", ]); +/** + * fetch ข้อมูลรายการเครื่องราชอิสริยาภรณ์ + */ async function fetchData() { if (!profileId.value) return; - showLoader(); try { const res = await http.get( @@ -460,6 +462,9 @@ async function fetchData() { } } +/** + * fetch ข้อมูลเครื่องราชอิสริยาภรณ์ + */ async function fetchInsignia() { showLoader(); try { @@ -473,9 +478,13 @@ async function fetchInsignia() { } } +/** + * บันทึกข้อมูลเครื่องราชอิสริยาภรณ์ + * @param editStatus แก้ไข,เพิ่ม + */ async function addEditData(editStatus: boolean = false) { if (!profileId.value) return; - + showLoader(); const url = editStatus ? config.API.profileNewInsignById(id.value, empType.value) : config.API.profileNewInsign(empType.value); @@ -489,8 +498,9 @@ async function addEditData(editStatus: boolean = false) { }; try { await http[method](url, reqBody); - success($q, "บันทึกข้อมูลสำเร็จ"); await fetchData(); + await success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; } catch (e) { messageError($q, e); } finally { @@ -498,6 +508,9 @@ async function addEditData(editStatus: boolean = false) { } } +/** + * เปิด form ข้อมูลเครื่องราชอิสริยาภรณ์ + */ function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) { modal.value = true; isEdit.value = editStatus; @@ -523,15 +536,20 @@ function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) { } } -async function clickClose() { +/** + * ปิด form ข้อมูลเครื่องราชอิสริยาภรณ์ + */ +function clickClose() { clearData(); modal.value = false; } +/** + * fetch ช้อมูลประวัติการแก้ไขรายการข้อมูลเครื่องราชอิสริยาภรณ์ + */ async function clickHistory(row: ResponseObject) { modalHistory.value = true; filterSearch.value = ""; - showLoader(); try { const res = await http.get( @@ -545,18 +563,26 @@ async function clickHistory(row: ResponseObject) { } } +/** + * ยืนยีนการบันทึกข้อมูล + */ function onSubmit() { dialogConfirm( $q, - async () => { + () => { addEditData(isEdit.value); - modal.value = false; }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +/** + * ฟิลเตอร์ข้อมูลจาก input + * @param val ค่าที่ป้อนให้ input + * @param update function จาก quasar + * @param refData type ที่กำหนด ของ input นั้นๆ + */ function filterSelector(val: string, update: Function, refData: string) { switch (refData) { case "insigniaOptions": @@ -571,6 +597,9 @@ function filterSelector(val: string, update: Function, refData: string) { } } +/** + * ค้นหาลำดับชั้น + */ function insigniaTypeSelection() { const insigniaTypeFilter = Ops.value.insigniaOptions.filter( (r: DataOptionInsignia) => r.id === insigniaForm.insigniaId @@ -580,6 +609,9 @@ function insigniaTypeSelection() { } } +/** + * เคลียร์ formDฟta + */ function clearData() { id.value = ""; (insigniaType.value = ""), (insigniaForm.year = 0); diff --git a/src/modules/04_registryPerson/components/detail/Achievement/04_DeclarationHonor.vue b/src/modules/04_registryPerson/components/detail/Achievement/04_DeclarationHonor.vue index 37027aee8..fb6924a17 100644 --- a/src/modules/04_registryPerson/components/detail/Achievement/04_DeclarationHonor.vue +++ b/src/modules/04_registryPerson/components/detail/Achievement/04_DeclarationHonor.vue @@ -220,6 +220,9 @@ const historyPagination = ref({ rowsPerPage: 10, }); +/** + * fetch รายการข้อมูลประกาศเกียรติคุณ + */ async function fetchData() { if (!profileId.value) return; @@ -236,9 +239,14 @@ async function fetchData() { } } +/** + * บันทึกข้อมูลประกาศเกียรติคุณ + * @param editStatus แก่ไข,เพิ่ม + */ async function addEditData(editStatus: boolean = false) { if (!profileId.value) return; + showLoader(); const url = editStatus ? config.API.profileNewHonorById(id.value, empType.value) : config.API.profileNewHonor(empType.value); @@ -258,8 +266,9 @@ async function addEditData(editStatus: boolean = false) { try { await http[method](url, reqBody); - success($q, "บันทึกข้อมูลสำเร็จ"); await fetchData(); + await success($q, "บันทึกข้อมูลสำเร็จ"); + modal.value = false; } catch (e) { messageError($q, e); } finally { @@ -267,6 +276,9 @@ async function addEditData(editStatus: boolean = false) { } } +/** + * เปิด form ข้อมูลประกาศเกียรติคุณ + */ function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) { modal.value = true; isEdit.value = editStatus; @@ -286,11 +298,17 @@ function onClickOpenDialog(editStatus: boolean = false, row?: ResponseObject) { } } +/** + * ปิด form ข้อมูลประกาศเกียรติคุณ + */ async function clickClose() { clearData(); modal.value = false; } +/** + * fetch ช้อมูลประวัติการแก้ไขรายการข้อมูลประกาศเกียรติคุณ + */ async function clickHistory(row: ResponseObject) { modalHistory.value = true; filterSearch.value = ""; @@ -308,18 +326,23 @@ async function clickHistory(row: ResponseObject) { } } +/** + * ยืนยีนการบันทึกข้อมูล + */ function onSubmit() { dialogConfirm( $q, async () => { addEditData(isEdit.value); - modal.value = false; }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +/** + * เคลียร์ formDฟta + */ function clearData() { id.value = ""; issueDateYear.value = new Date().getFullYear(); @@ -331,8 +354,8 @@ function clearData() { declHonorForm.isDate = "false"; } -onMounted(async () => { - await fetchData(); +onMounted(() => { + fetchData(); });