diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue index a08ddbb53..7fae81928 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/01_Profile.vue @@ -345,10 +345,10 @@ function onSubmit() { route.name === "registry-employeeId" ? "TEMP" : undefined, }) .then(async () => { - await getData(); await props.fetchDataPersonal?.(); + await getData(); modal.value = false; - success($q, "บันทึกข้อมูลสำเร็จ"); + await success($q, "บันทึกข้อมูลสำเร็จ"); }) .catch((e) => { messageError($q, e); diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/02_NameChangeHistory.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/02_NameChangeHistory.vue index b60f910b6..007a3011b 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/02_NameChangeHistory.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/02_NameChangeHistory.vue @@ -331,7 +331,7 @@ async function uploadProfile(id: string) { .catch((err) => { messageError($q, err); hideLoader(); - }) + }); } async function uploadFileURL(uploadUrl: string, file: any) { @@ -576,16 +576,7 @@ watch( > เพิ่มข้อมูล - + @@ -706,24 +682,6 @@ watch( /> - -
diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/03_Address.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/03_Address.vue index 56f15c1f0..5a2d46d86 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/03_Address.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/03_Address.vue @@ -40,8 +40,6 @@ const profileId = ref( ); const empType = ref(pathRegistryEmp(route.name?.toString() ?? "")); -const currentPage = ref(1); -const maxPage = ref(1); const modal = ref(false); const modalHistory = ref(false); const rowsHistory = ref([]); @@ -375,9 +373,9 @@ async function editData() { ...formData, id: undefined, }) - .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - fetchAll(); + .then(async (res) => { + await fetchAll(); + await success($q, "บันทึกข้อมูลสำเร็จ"); modal.value = false; }) .catch((e) => { diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue index a4b4ba3d8..487363119 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/04_FamilyNew.vue @@ -169,6 +169,9 @@ const fromData = reactive({ statusMarital: "", }); +/** + * function fetch ข้อมูลบิดา + */ function fetchDataFather() { showLoader(); http @@ -194,6 +197,10 @@ function fetchDataFather() { hideLoader(); }); } + +/** + * function fetch ข้อมูลมารดา + */ function fetchDataMother() { showLoader(); http @@ -218,6 +225,10 @@ function fetchDataMother() { hideLoader(); }); } + +/** + * function fetch ข้อมูลคู่สมรส + */ function fetchDataCouple() { showLoader(); http @@ -244,6 +255,10 @@ function fetchDataCouple() { hideLoader(); }); } + +/** + * function fetch ข้อมูลบุตร + */ function fetchDataChildren() { showLoader(); http @@ -263,6 +278,10 @@ function fetchDataChildren() { }); } +/** + * function บันทึกข้อมูล + * @param type ประเภทของข้อมูล + */ function onSubmit(type: string) { dialogConfirm($q, async () => { showLoader(); @@ -288,14 +307,14 @@ function onSubmit(type: string) { const method = isEdit.value && type === "children" ? "patch" : "post"; try { await http[method](url, formBody); - success($q, "บันทึกข้อมูลสำเร็จ"); type === "father" - ? fetchDataFather() + ? await fetchDataFather() : type === "mother" - ? fetchDataMother() + ? await fetchDataMother() : type === "couple" - ? fetchDataCouple() - : fetchDataChildren(); + ? await fetchDataCouple() + : await fetchDataChildren(); + await success($q, "บันทึกข้อมูลสำเร็จ"); closeDialog(); } catch (e) { messageError($q, e); @@ -305,9 +324,13 @@ function onSubmit(type: string) { }); } +/** + * function ปิด popup + */ function closeDialog() { modal.value = false; modalHistory.value = false; + // เคลียร์ formData fromData.isLive = 1; fromData.citizenId = ""; fromData.prefix = ""; @@ -318,6 +341,12 @@ function closeDialog() { fromData.statusMarital = ""; } +/** + * function แก้ไขข้อมูล + * @param type ประเภทของบุคคล + * @param isStatusEdit สถานะแก่้ไข + * @param data ข้อมูลเดิม + */ function onOpenDialogForm( type: string, isStatusEdit: boolean = false, @@ -326,11 +355,9 @@ function onOpenDialogForm( modal.value = true; typeForm.value = type; isEdit.value = isStatusEdit; - console.log(data); if (type === "father") { titleForm.value = "บิดา"; - console.log(fatherData); fromData.isLive = fatherData.isLive === null ? 1 : fatherData.isLive ? 1 : 0; @@ -351,9 +378,11 @@ function onOpenDialogForm( fromData.job = motherData.job; } else if (type === "couple") { titleForm.value = "คู่สมรส"; + fromData.isLive = 1; } else if (type === "children") { titleForm.value = "บุตร"; + if (isStatusEdit) { childernId.value = data.id; fromData.isLive = @@ -367,6 +396,11 @@ function onOpenDialogForm( } } +/** + * function ดูประวัติการแก้ไขข้อมูล + * @param type ประเภทของบุคคล + * @param id + */ function onOpenDialogHistory(type: string, id: string = "") { modalHistory.value = true; typeForm.value = type; @@ -374,6 +408,9 @@ function onOpenDialogHistory(type: string, id: string = "") { fetchHistory(historyId, type); } +/** + * function fetch ข้อมูลความสัมพันธ์ + */ function fetchDataRelationship() { showLoader(); http @@ -393,14 +430,24 @@ function fetchDataRelationship() { }); } -const filterSelectorRelation = (val: any, update: Function) => { +/** + * function ค้นหาข้อมูลใน select + * @param val คำค้นหา + * @param update function + */ +function filterSelectorRelation(val: any, update: Function) { update(() => { optionRelationship.value = optionRelationshipMain.value.filter( (v: any) => v.name.indexOf(val) > -1 ); }); -}; +} +/** + * function fetch ข้อมูลประวัติการแก้ไขข้อมูล + * @param id + * @param type + */ function fetchHistory(id: string, type: string) { hideLoader(); http @@ -426,11 +473,13 @@ function fetchHistory(id: string, type: string) { } onMounted(() => { - fetchDataFather(); - fetchDataMother(); - fetchDataCouple(); - fetchDataChildren(); - fetchDataRelationship(); + Promise.all([ + fetchDataFather(), + fetchDataMother(), + fetchDataCouple(), + fetchDataChildren(), + fetchDataRelationship(), + ]); }); diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue index 713d4a05c..62ed821ed 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/05_Education.vue @@ -495,18 +495,26 @@ const historyVisibleColumns = ref([ "lastUpdatedAt", ]); -async function onSubmit() { +/** + * function ยืนยันการบันทึกข้อมูล + */ +function onSubmit() { dialogConfirm( $q, - async () => { + () => { dialogStatus.value === "create" ? addData() : editData(editId.value); - closeDialog(); }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +/** + * function ค้นหา คำใน option + * @param val คำค้นหา + * @param update function + * @param refData type select + */ function filterSelector(val: string, update: Function, refData: string) { switch (refData) { case "educationOption": @@ -528,6 +536,9 @@ function filterSelector(val: string, update: Function, refData: string) { } } +/** + * function เคลียร์ formData + */ function clearForm() { isDate.value = "false"; educationData.educationLevel = ""; @@ -549,6 +560,10 @@ function clearForm() { educationData.note = ""; } +/** + * function แก้ไขข้อมูลประวัติการศึกษา + * @param row ข้อมูลประวัติการศึกษา + */ function editForm(row: any) { dialogStatus.value = "edit"; editId.value = row.id; @@ -579,19 +594,30 @@ function editForm(row: any) { dialog.value = true; } +/** + * function ปิด popup มูลประวัติการศึกษา + */ function closeDialog() { clearForm(); dialog.value = false; } + +/** + * funcitob ปิด popup ประวัติการศึกษา + */ function closeHistoryDialog() { historyDialog.value = false; } -async function fetchData(id: string) { +/** + * function fetch ข้อมูลประวัตืการศึกษา + * @param id บุคคล + */ +function fetchData(id: string) { showLoader(); - await http + http .get(config.API.profileNewEducationByProfileId(id, empType.value)) - .then(async (res) => { + .then((res) => { rows.value = res.data.result; }) .catch((err) => { @@ -602,9 +628,11 @@ async function fetchData(id: string) { }); } -async function fetchEducationLevel() { - showLoader(); - await http +/** + * function fetch ข้อมูลระดับการศึกษา + */ +function fetchEducationLevel() { + http .get(config.API.orgEducationLevel) .then(async (res) => { res.data.result.map((r: any) => { @@ -617,15 +645,16 @@ async function fetchEducationLevel() { }) .catch((err) => { messageError($q, err); - }) - .finally(() => { - hideLoader(); }); } -async function fetchHistoryData(id: string) { +/** + * function fetch ประวัติการแก้ไขประวัติการศึกษา + * @param id ประวัติการศึกษา + */ +function fetchHistoryData(id: string) { showLoader(); - await http + http .get(config.API.profileNewEducationHisByEducationId(id, empType.value)) .then(async (res) => { historyRows.value = res.data.result; @@ -638,8 +667,12 @@ async function fetchHistoryData(id: string) { }); } -async function addData() { - await http +/** + * function เพิ่มข้อมูลประวัติการศึกษา + */ +function addData() { + showLoader(); + http .post(config.API.profileNewEducation(empType.value), { ...educationData, startYear: undefined, @@ -648,9 +681,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); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -660,9 +694,12 @@ async function addData() { }); } +/** + * function บันทึกการแก้ไขข้อมูล + * @param idData ประวัติการศึกษา + */ function editData(idData: string) { - console.log(educationData); - + showLoader(); http .patch(config.API.profileNewEducationByEducationId(idData, empType.value), { ...educationData, @@ -673,9 +710,10 @@ function editData(idData: string) { durationYear: educationData.durationYear === "" ? null : educationData.durationYear, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -685,23 +723,6 @@ function editData(idData: string) { }); } -// function deleteData(idData: string) { -// dialogRemove($q, () => -// http -// .delete(config.API.profileNewEducationByEducationId(idData)) -// .then(() => { -// fetchData(id.value); -// success($q, "ลบข้อมูลสำเร็จ"); -// }) -// .catch((err) => { -// messageError($q, err); -// }) -// .finally(() => { -// hideLoader(); -// }) -// ); -// } - onMounted(async () => { await fetchData(id.value); fetchEducationLevel(); diff --git a/src/modules/04_registryPerson/components/detail/PersonalInformation/06_SpecialSkill.vue b/src/modules/04_registryPerson/components/detail/PersonalInformation/06_SpecialSkill.vue index 19eaf688c..aa7b12d1e 100644 --- a/src/modules/04_registryPerson/components/detail/PersonalInformation/06_SpecialSkill.vue +++ b/src/modules/04_registryPerson/components/detail/PersonalInformation/06_SpecialSkill.vue @@ -15,7 +15,6 @@ const mixin = useCounterMixin(); const $q = useQuasar(); const mode = ref("table"); const { - dialogRemove, dialogConfirm, showLoader, hideLoader, @@ -189,6 +188,7 @@ const historyVisibleColumns = ref([ "lastUpdateFullName", "lastUpdatedAt", ]); + function closeDialog() { dialog.value = false; } @@ -197,18 +197,23 @@ function closeHistoryDialog() { historyDialog.value = false; } -async function onSubmit() { +/** + * function ยืนยันการบันทึกข้อมูล + */ +function onSubmit() { dialogConfirm( $q, - async () => { + () => { dialogStatus.value === "create" ? addData() : editData(editId.value); - closeDialog(); }, "ยืนยันการบันทึกข้อมูล", "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" ); } +/** + * function เคลียร์ formData + */ function clearForm() { specialSkill.detail = ""; specialSkill.field = ""; @@ -216,6 +221,10 @@ function clearForm() { specialSkill.remark = ""; } +/** + * function + * @param row ข้อมูลความสามารถพิเศษ + */ function editForm(row: any) { dialogStatus.value = "edit"; editId.value = row.id; @@ -226,11 +235,14 @@ function editForm(row: any) { dialog.value = true; } -async function fetchData(id: string) { +/** + * function fetch ข้อมูลความสามรรถพิเศษ + */ +function fetchData(id: string) { showLoader(); - await http + http .get(config.API.profileNewAbilityByProfileId(id, empType.value)) - .then(async (res) => { + .then((res) => { rows.value = res.data.result; }) .catch((err) => { @@ -241,11 +253,15 @@ async function fetchData(id: string) { }); } -async function fetchHistoryData(id: string) { +/** + * function fetch ประวัติการแก้ไขความสามรรถพิเศษ + * @param id ความสามรรถพิเศษ + */ +function fetchHistoryData(id: string) { showLoader(); - await http + http .get(config.API.profileNewAbilityHisByAbilityId(id, empType.value)) - .then(async (res) => { + .then((res) => { historyRows.value = res.data.result; }) .catch((err) => { @@ -256,8 +272,12 @@ async function fetchHistoryData(id: string) { }); } -async function addData() { - await http +/** + * function เพิ่มข้อมูลความสามรรถพิเศษ + */ +function addData() { + showLoader(); + http .post(config.API.profileNewAbility(empType.value), { ...specialSkill, dateStart: null, @@ -265,9 +285,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); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -277,17 +298,23 @@ async function addData() { }); } -async function editData(idData: string) { - await http +/** + * function บันทึกการแก้ไขข้อมูล + * @param idData ความสามรรถพิเศษ + */ +function editData(idData: string) { + showLoader(); + http .patch(config.API.profileNewAbilityByAbilityId(idData, empType.value), { ...specialSkill, dateStart: null, dateEnd: null, profileId: undefined, }) - .then(() => { - fetchData(id.value); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { + await fetchData(id.value); + await success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((err) => { messageError($q, err); @@ -297,25 +324,8 @@ async function editData(idData: string) { }); } -async function deleteData(idData: string) { - dialogRemove($q, () => - http - .delete(config.API.profileNewAbilityByAbilityId(idData, empType.value)) - .then(() => { - fetchData(id.value); - success($q, "ลบข้อมูลสำเร็จ"); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }) - ); -} - -onMounted(async () => { - await fetchData(id.value); +onMounted(() => { + fetchData(id.value); });