diff --git a/src/components/Dialogs/DialogOrgSelectEmployee.vue b/src/components/Dialogs/DialogOrgSelectEmployee.vue index 23d797ac2..10abe1812 100644 --- a/src/components/Dialogs/DialogOrgSelectEmployee.vue +++ b/src/components/Dialogs/DialogOrgSelectEmployee.vue @@ -590,7 +590,7 @@ function onSubmit() { :key="index" :name="item" > -
+
(false); -const personId = ref(""); const $q = useQuasar(); const route = useRoute(); const router = useRouter(); const mixin = useCounterMixin(); +const paramsId = route.params.id; +const { + date2Thai, + messageError, + showLoader, + hideLoader, + success, + dialogConfirm, +} = mixin; +const modalPersonal = ref(false); const dataProfile = ref(); const appointment = ref({ @@ -46,16 +60,6 @@ const date = ref(null); const status = ref(""); const avatar = ref(""); -const paramsId = route.params.id; -const { - date2Thai, - messageError, - showLoader, - hideLoader, - success, - dialogConfirm, -} = mixin; - const title = ref({ fullname: "", organizationPositionOld: "", @@ -63,10 +67,12 @@ const title = ref({ positionTypeOld: "", }); -//เรียกข้อมูลตาม id -const fecthappointmentByid = async () => { +/** + * fetch รายละเอียดการปรับระดับชั้นงานลูกจ้าง + */ +function fecthappointmentByid() { showLoader(); - await http + http .get(config.API.appointEmployeeByid(paramsId.toString())) .then((res: ResponseData) => { dataProfile.value = res.data.result as unknown as DataProfile; @@ -96,58 +102,67 @@ const fecthappointmentByid = async () => { .finally(() => { hideLoader(); }); -}; +} -//ยืนยันการเเก้ไข -const clickSave = async () => { +/** + * ยืนยันการบันทึกข้อมูลเพื่อลงบัญชีแนบท้าย + */ +function clickSave() { if (myForm.value !== null) { - myForm.value.validate().then((success: any) => { - if (success) { + myForm.value.validate().then((result: any) => { + if (result) { dialogConfirm( $q, - async () => await putAppointment(), + async () => { + let data = { + citizenId: appointment.value.citizenId, + prefixId: appointment.value.prefixId, + firstname: appointment.value.firstname, + lastname: appointment.value.lastname, + educationOld: educationOld.value, + organizationPositionOld: organizationPositionOld.value, + positionTypeOld: positionTypeOld.value, + positionLevelOld: positionLevelOld.value, + positionNumberOld: posNo.value, + amountOld: salary.value.toString().replace(/,/g, ""), + reason: reason.value, + positionDate: date.value, + }; + showLoader(); + await http + .put(config.API.appointEmployeeByid(paramsId.toString()), data) + .then(async () => { + await fecthappointmentByid(); + await success($q, "บันทึกข้อมูลสำเร็จ"); + edit.value = false; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + }, "ต้องการแก้ไขข้อมูลหรือไม่?", "แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย" ); } }); } -}; -// เเก้ไขข้อมูล -const putAppointment = async () => { - let data = { - citizenId: appointment.value.citizenId, - prefixId: appointment.value.prefixId, - firstname: appointment.value.firstname, - lastname: appointment.value.lastname, - educationOld: educationOld.value, - organizationPositionOld: organizationPositionOld.value, - positionTypeOld: positionTypeOld.value, - positionLevelOld: positionLevelOld.value, - positionNumberOld: posNo.value, - amountOld: salary.value.toString().replace(/,/g, ""), - reason: reason.value, - positionDate: date.value, - }; - showLoader(); - await http - .put(config.API.appointEmployeeByid(paramsId.toString()), data) - .then(() => { - success($q, "บันทึกข้อมูลสำเร็จ"); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - fecthappointmentByid(); - edit.value = false; - }); -}; -const cancel = () => { +} + +/** + * ยกเลิกการบันทึกข้อมูลเพื่อลงบัญชีแนบท้าย + */ +function cancel() { edit.value = false; fecthappointmentByid(); myForm.value?.resetValidation(); -}; +} + +/** + * Class input + */ const getClass = (val: boolean) => { return { "full-width inputgreen cursor-pointer": val, @@ -155,17 +170,8 @@ const getClass = (val: boolean) => { }; }; -function onclickViewinfo(id: string) { - modalPersonal.value = true; - personId.value = id; -} - -function updatemodalPersonal(modal: boolean) { - modalPersonal.value = modal; -} - -onMounted(async () => { - await fecthappointmentByid(); +onMounted(() => { + fecthappointmentByid(); });