API แก้ไขสถานะการเข้า-ออกงาน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-01-09 16:34:26 +07:00
parent 8c4cacd3e5
commit 53cbf74f52
4 changed files with 35 additions and 8 deletions

View file

@ -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<string>("");
@ -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?.();
});
});
}
}

View file

@ -206,6 +206,7 @@ onMounted(async () => {
:maxPage="maxPage"
@update:pagination="updatePaging"
:tab="'time-record'"
:fetchData="fetchListTimeRecord"
/>
</template>

View file

@ -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"
/>
<DialogEdit :modal="modalEdit" :detail="dataDetail" :close="onClickEdit" />
<DialogEdit
:modal="modalEdit"
:detail="dataDetail"
:close="onClickEdit"
:fetchData="props.fetchData"
/>
</template>
<style scoped></style>