ผูก API ลงเวลากรณีพิเศษ

This commit is contained in:
AnandaTon 2023-11-27 16:31:45 +07:00
parent 22688d40d0
commit 8cecc1e596
7 changed files with 296 additions and 98 deletions

View file

@ -201,6 +201,7 @@ onMounted(() => {
:editCheck="editCheck"
:DataRow="DataRow"
:personId="DataRow == null ? '' : DataRow.profileId"
@update:change-page="dataStore.changePage"
/>
</template>
<style scoped lang="scss">

View file

@ -1,40 +1,56 @@
<script setup lang="ts">
import { onMounted, ref, useAttrs } from "vue";
import { onMounted, ref, watch } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import type { Pagination } from "@/modules/03_recruiting/interface/index/Main";
import { useSpecialTimeStore } from "@/modules/09_leave/stores/SpecialTimeStore";
import DialogReason from "@/components/Dialogs/PopupReason.vue";
import DialogApprove from "@/modules/09_leave/components/4_specialTime/DialogApprove.vue";
import http from "@/plugins/http";
import config from "@/app.config";
import { useRouter } from "vue-router";
import { identity } from "@fullcalendar/core/internal";
const dataSpecialTime = useSpecialTimeStore();
const { fecthList } = dataSpecialTime;
const $q = useQuasar(); // show dialog
const mixin = useCounterMixin();
const router = useRouter();
const { hideLoader, monthYear2Thai } = mixin;
const { hideLoader, monthYear2Thai, messageError, showLoader, success } = mixin;
const modalUnapprove = ref(false);
const modalApprove = ref(false);
const detailData = ref<any>();
const editCheck = ref<string>("");
const pagination = ref({
// sortBy: "desc",
descending: false,
page: 1,
rowsPerPage: 10,
});
const dialogTitle = ref<string>("");
const dialogDesc = ref<string>("");
const name = ref<string>("");
const id = ref<string>("");
const reasonNote = ref<string>("");
const dateDialog = ref<string>("");
const dateFixDialog = ref<string>("");
const unapprove = async (fullname: string) => {
const unapprove = async (fullname: string, personId: string) => {
id.value = personId;
dialogTitle.value = " ไม่อนุมัติการลงเวลาพิเศษของ" + fullname;
name.value = fullname;
modalUnapprove.value = true;
// rejectData();
};
function openModal(data: any, check: string, date: string, dateFix: string) {
function openModal(
data: any,
check: string,
date: string,
dateFix: string,
personId: string
) {
id.value = personId;
console.log(personId);
modalApprove.value = true;
dateDialog.value = date;
dateFixDialog.value = dateFix;
@ -49,9 +65,25 @@ const closeDialog = () => {
modalApprove.value = false;
editCheck.value = "PENDING";
};
const clickSave = () => {
/** API reject */
const clickSave = async (reason: string) => {
modalUnapprove.value = false;
const body = {
reason: reason,
};
await http
.put(config.API.specialTimeReject(id.value), body)
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {});
console.log(reason);
};
//
const filterKeyword = ref<string>("");
const filterRef = ref<HTMLInputElement | null>(null);
@ -63,53 +95,54 @@ const resetFilter = () => {
};
onMounted(async () => {
fecthList([
{
id: "00000000-0000-0000-0000-000000000000",
fullname: "นางสาวณัฐกา ชมสิน",
date: "2023-11-01 08:54",
dateFix: "2023-10-30",
startTimeMorning: "08:00",
endTimeMorning: "12:00",
startTimeAfternoon: "08:00",
endTimeAfternoon: "12:00",
status: "PENDING",
checkInStatus: "normal",
checkOutStatus: "late",
checkIn: "08:00",
checkOut: "12.00",
},
{
id: "00000000-0000-0000-0000-000000000000",
fullname: "นางสาวรัชภรณ์ ภักดี",
date: "2023-10-30 08:55",
dateFix: "2023-10-29",
startTimeMorning: "08:00",
endTimeMorning: "12:00",
startTimeAfternoon: null,
endTimeAfternoon: null,
status: "APPROVE",
checkInStatus: "normal",
checkOutStatus: "late",
checkIn: "08:00",
checkOut: "12.00",
},
{
id: "00000000-0000-0000-0000-000000000000",
fullname: "นางสาวภาพรรณ ลออ",
date: "2023-10-31 18:54",
dateFix: "2023-10-30",
startTimeMorning: null,
endTimeMorning: null,
startTimeAfternoon: "13:00",
endTimeAfternoon: "16:30",
status: "REJECT",
checkInStatus: "normal",
checkOutStatus: "late",
checkIn: "08:00",
checkOut: "12.00",
},
]);
// fecthList([
// {
// id: "eefa2f4f-c507-4a42-8567-4fadb8dc1f50",
// fullname: " ",
// date: "2023-11-01 08:54",
// dateFix: "2023-10-30",
// startTimeMorning: "08:00",
// endTimeMorning: "12:00",
// startTimeAfternoon: "08:00",
// endTimeAfternoon: "12:00",
// status: "PENDING",
// checkInStatus: "normal",
// checkOutStatus: "late",
// checkIn: "08:00",
// checkOut: "12.00",
// },
// {
// id: "00000000-0000-0000-0000-000000000000",
// fullname: " ",
// date: "2023-10-30 08:55",
// dateFix: "2023-10-29",
// startTimeMorning: "08:00",
// endTimeMorning: "12:00",
// startTimeAfternoon: null,
// endTimeAfternoon: null,
// status: "APPROVE",
// checkInStatus: "normal",
// checkOutStatus: "late",
// checkIn: "08:00",
// checkOut: "12.00",
// },
// {
// id: "00000000-0000-0000-0000-000000000000",
// fullname: " ",
// date: "2023-10-31 18:54",
// dateFix: "2023-10-30",
// startTimeMorning: null,
// endTimeMorning: null,
// startTimeAfternoon: "13:00",
// endTimeAfternoon: "16:30",
// status: "REJECT",
// checkInStatus: "normal",
// checkOutStatus: "late",
// checkIn: "08:00",
// checkOut: "12.00",
// },
// ]);
dataSpecialTime.fetchData();
});
const selectedDate = ref<string>("");
@ -213,8 +246,10 @@ const monthYearThai = (val: any) => {
bordered
:paging="true"
dense
v-model:pagination="pagination"
:pagination="dataSpecialTime.initialPagination"
:visible-columns="dataSpecialTime.visibleColumns"
:rows-per-page-options="[1, 10, 25, 50, 100]"
@update:pagination="dataSpecialTime.updatePagination"
>
<template v-slot:header="props">
<q-tr :props="props">
@ -241,7 +276,7 @@ const monthYearThai = (val: any) => {
class="q-px-md"
dense
unelevated
@click="unapprove(props.row.fullname)"
@click="unapprove(props.row.fullname, props.row.id)"
>ไมอน</q-btn
>
@ -256,7 +291,8 @@ const monthYearThai = (val: any) => {
props.row,
'PENDING',
props.row.date,
props.row.dateFix
props.row.dateFix,
props.row.id
)
"
>อน</q-btn
@ -294,6 +330,7 @@ const monthYearThai = (val: any) => {
:closeDialog="closeDialog"
:date="dateDialog"
:dateFix="dateFixDialog"
:id="id"
:editCheck="editCheck"
:detailData="detailData"
/>