diff --git a/src/api/09_leave/api.leave.ts b/src/api/09_leave/api.leave.ts index 895ef2019..0ef73073e 100644 --- a/src/api/09_leave/api.leave.ts +++ b/src/api/09_leave/api.leave.ts @@ -9,6 +9,8 @@ export default { logRecord: () => `${leave}/log-record`, timeRecord: () => `${leave}/time-record`, recordById: (id: string, type: string) => `${leave}/${type}/${id}`, + leaveEditCheckin: (id: string) => `${leave}/admin/edit/checkin/${id}`, + /** เปลี่ยนแปลงลงเวลา*/ leaveSearch: () => `${leave}/search`, leaveRound: () => `${leave}/round`, diff --git a/src/modules/09_leave/components/1_Work/DialogEdit.vue b/src/modules/09_leave/components/1_Work/DialogEdit.vue index a6140e6ca..767f3ea06 100644 --- a/src/modules/09_leave/components/1_Work/DialogEdit.vue +++ b/src/modules/09_leave/components/1_Work/DialogEdit.vue @@ -12,7 +12,7 @@ import { useCounterMixin } from "@/stores/mixin"; const $q = useQuasar(); const mixin = useCounterMixin(); -const { dialogConfirm, success } = mixin; +const { dialogConfirm, success, showLoader, hideLoader, messageError } = mixin; const props = defineProps({ modal: { @@ -27,6 +27,10 @@ const props = defineProps({ type: Function, require: true, }, + fetchData: { + type: Function, + require: true, + }, }); const morningStatus = ref(""); @@ -48,15 +52,26 @@ async function onClickSave() { afternoonStatusRef.value?.validate(); if (!morningStatusRef.value.hasError && !afternoonStatusRef.value.hasError) { const body = { - morningStatus: morningStatus.value, - afternoonStatus: afternoonStatus.value, + checkInStatus: morningStatus.value, + checkOutStatus: afternoonStatus.value, reason: reason.value, }; - dialogConfirm($q, async () => { - console.log(body); - success($q, "บันทึกข้อมูลสำเร็จ"); - props.close?.(); + dialogConfirm($q, async () => { + showLoader(); + await http + .put(config.API.leaveEditCheckin(props.detail?.id), body) + .then(() => { + success($q, "บันทึกข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + props.fetchData?.(); + props.close?.(); + }); }); } } diff --git a/src/modules/09_leave/components/1_Work/Tab1.vue b/src/modules/09_leave/components/1_Work/Tab1.vue index ec4859380..0629258b9 100644 --- a/src/modules/09_leave/components/1_Work/Tab1.vue +++ b/src/modules/09_leave/components/1_Work/Tab1.vue @@ -206,6 +206,7 @@ onMounted(async () => { :maxPage="maxPage" @update:pagination="updatePaging" :tab="'time-record'" + :fetchData="fetchListTimeRecord" /> diff --git a/src/modules/09_leave/components/1_Work/TableList.vue b/src/modules/09_leave/components/1_Work/TableList.vue index 9c52c2e43..e286ee364 100644 --- a/src/modules/09_leave/components/1_Work/TableList.vue +++ b/src/modules/09_leave/components/1_Work/TableList.vue @@ -39,6 +39,10 @@ const props = defineProps({ type: String, require: true, }, + fetchData: { + type: Function, + require: true, + }, }); const emit = defineEmits(["update:pagination"]); @@ -203,6 +207,11 @@ onMounted(() => { :close="closeDetail" /> - +