2023-11-02 16:44:02 +07:00
|
|
|
<script setup lang="ts">
|
2023-11-27 16:31:45 +07:00
|
|
|
import { onMounted, ref, watch } from "vue";
|
2023-11-02 16:44:02 +07:00
|
|
|
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";
|
2023-11-06 15:08:36 +07:00
|
|
|
import DialogApprove from "@/modules/09_leave/components/4_specialTime/DialogApprove.vue";
|
2023-11-27 16:31:45 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
2023-11-02 16:44:02 +07:00
|
|
|
|
|
|
|
|
import { useRouter } from "vue-router";
|
2023-11-27 16:31:45 +07:00
|
|
|
import { identity } from "@fullcalendar/core/internal";
|
2023-11-02 16:44:02 +07:00
|
|
|
const dataSpecialTime = useSpecialTimeStore();
|
|
|
|
|
const $q = useQuasar(); // show dialog
|
|
|
|
|
const mixin = useCounterMixin();
|
|
|
|
|
const router = useRouter();
|
2023-11-27 16:31:45 +07:00
|
|
|
const { hideLoader, monthYear2Thai, messageError, showLoader, success } = mixin;
|
2023-11-02 16:44:02 +07:00
|
|
|
const modalUnapprove = ref(false);
|
2023-11-06 15:08:36 +07:00
|
|
|
const modalApprove = ref(false);
|
|
|
|
|
const detailData = ref<any>();
|
|
|
|
|
const editCheck = ref<string>("");
|
2023-11-27 16:31:45 +07:00
|
|
|
|
2023-11-02 16:44:02 +07:00
|
|
|
const pagination = ref({
|
|
|
|
|
// sortBy: "desc",
|
|
|
|
|
descending: false,
|
|
|
|
|
page: 1,
|
|
|
|
|
rowsPerPage: 10,
|
|
|
|
|
});
|
2023-11-27 16:31:45 +07:00
|
|
|
|
2023-11-02 16:44:02 +07:00
|
|
|
const dialogTitle = ref<string>("");
|
|
|
|
|
const dialogDesc = ref<string>("");
|
2023-11-06 15:08:36 +07:00
|
|
|
const name = ref<string>("");
|
2023-11-27 16:31:45 +07:00
|
|
|
const id = ref<string>("");
|
|
|
|
|
const reasonNote = ref<string>("");
|
2023-11-06 15:08:36 +07:00
|
|
|
const dateDialog = ref<string>("");
|
|
|
|
|
const dateFixDialog = ref<string>("");
|
2023-11-27 16:31:45 +07:00
|
|
|
const unapprove = async (fullname: string, personId: string) => {
|
|
|
|
|
id.value = personId;
|
2023-11-02 16:44:02 +07:00
|
|
|
dialogTitle.value = " ไม่อนุมัติการลงเวลาพิเศษของ" + fullname;
|
|
|
|
|
name.value = fullname;
|
|
|
|
|
modalUnapprove.value = true;
|
2023-11-27 16:31:45 +07:00
|
|
|
// rejectData();
|
2023-11-02 16:44:02 +07:00
|
|
|
};
|
2023-11-27 16:31:45 +07:00
|
|
|
function openModal(
|
|
|
|
|
data: any,
|
|
|
|
|
check: string,
|
|
|
|
|
date: string,
|
|
|
|
|
dateFix: string,
|
|
|
|
|
personId: string
|
|
|
|
|
) {
|
|
|
|
|
id.value = personId;
|
|
|
|
|
console.log(personId);
|
2023-11-06 15:08:36 +07:00
|
|
|
modalApprove.value = true;
|
|
|
|
|
dateDialog.value = date;
|
|
|
|
|
dateFixDialog.value = dateFix;
|
|
|
|
|
editCheck.value = check;
|
|
|
|
|
if (check === "PENDING") {
|
|
|
|
|
detailData.value = data;
|
|
|
|
|
}
|
|
|
|
|
console.log(data);
|
|
|
|
|
}
|
|
|
|
|
const closeDialog = () => {
|
2023-11-02 16:44:02 +07:00
|
|
|
modalUnapprove.value = false;
|
2023-11-06 15:08:36 +07:00
|
|
|
modalApprove.value = false;
|
|
|
|
|
editCheck.value = "PENDING";
|
2023-11-02 16:44:02 +07:00
|
|
|
};
|
2023-11-27 16:31:45 +07:00
|
|
|
|
|
|
|
|
/** API reject */
|
|
|
|
|
const clickSave = async (reason: string) => {
|
2023-11-02 16:44:02 +07:00
|
|
|
modalUnapprove.value = false;
|
2023-11-27 16:31:45 +07:00
|
|
|
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);
|
2023-11-02 16:44:02 +07:00
|
|
|
};
|
2023-11-27 16:31:45 +07:00
|
|
|
|
2023-11-02 16:44:02 +07:00
|
|
|
// ค้นหาในตาราง
|
|
|
|
|
const filterKeyword = ref<string>("");
|
|
|
|
|
const filterRef = ref<HTMLInputElement | null>(null);
|
|
|
|
|
const resetFilter = () => {
|
|
|
|
|
filterKeyword.value = "";
|
|
|
|
|
if (filterRef.value) {
|
|
|
|
|
filterRef.value.focus();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2023-11-27 16:31:45 +07: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();
|
2023-11-02 16:44:02 +07:00
|
|
|
});
|
2023-11-03 15:08:53 +07:00
|
|
|
|
|
|
|
|
const selectedDate = ref<string>("");
|
|
|
|
|
const dateMonth = ref<any>({
|
|
|
|
|
month: new Date().getMonth(),
|
|
|
|
|
year: new Date().getFullYear(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const monthYearThai = (val: any) => {
|
|
|
|
|
if (val == null) return "";
|
|
|
|
|
else return monthYear2Thai(val.month, val.year);
|
|
|
|
|
};
|
2023-11-02 16:44:02 +07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="toptitle text-dark col-12 row items-center">
|
|
|
|
|
รายการลงเวลากรณีพิเศษ
|
|
|
|
|
</div>
|
|
|
|
|
<q-card flat bordered class="col-12 q-mt-sm q-pt-sm q-pa-md">
|
2023-11-03 15:08:53 +07:00
|
|
|
<div class="row col-12 q-col-gutter-sm q-mb-sm">
|
|
|
|
|
<div class="q-gutter-sm">
|
|
|
|
|
<datepicker
|
|
|
|
|
v-model="selectedDate"
|
|
|
|
|
:locale="'th'"
|
|
|
|
|
autoApply
|
|
|
|
|
month-picker
|
|
|
|
|
:enableTimePicker="false"
|
|
|
|
|
>
|
|
|
|
|
<template #year="{ year }">{{ year + 543 }}</template>
|
|
|
|
|
<template #year-overlay-value="{ value }">{{
|
|
|
|
|
parseInt(value + 543)
|
|
|
|
|
}}</template>
|
|
|
|
|
<template #trigger>
|
|
|
|
|
<q-input
|
|
|
|
|
:model-value="monthYearThai(dateMonth)"
|
|
|
|
|
dense
|
|
|
|
|
outlined
|
|
|
|
|
hide-bottom-space
|
|
|
|
|
style="width: 130px"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:prepend>
|
|
|
|
|
<q-icon
|
|
|
|
|
name="event"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
style="color: var(--q-primary)"
|
|
|
|
|
>
|
|
|
|
|
</q-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
</template>
|
|
|
|
|
</datepicker>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<q-space />
|
|
|
|
|
|
|
|
|
|
<q-input
|
|
|
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
|
|
|
standout
|
|
|
|
|
dense
|
|
|
|
|
v-model="filterKeyword"
|
|
|
|
|
ref="filterRef"
|
|
|
|
|
outlined
|
|
|
|
|
debounce="300"
|
|
|
|
|
placeholder="ค้นหา"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:append>
|
|
|
|
|
<q-icon v-if="filterKeyword == ''" name="search" />
|
|
|
|
|
<q-icon
|
|
|
|
|
v-if="filterKeyword !== ''"
|
|
|
|
|
name="clear"
|
|
|
|
|
class="cursor-pointer"
|
|
|
|
|
@click="resetFilter"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</q-input>
|
|
|
|
|
|
|
|
|
|
<q-select
|
|
|
|
|
v-model="dataSpecialTime.visibleColumns"
|
|
|
|
|
multiple
|
|
|
|
|
outlined
|
|
|
|
|
dense
|
|
|
|
|
options-dense
|
|
|
|
|
:display-value="$q.lang.table.columns"
|
|
|
|
|
emit-value
|
|
|
|
|
map-options
|
|
|
|
|
:options="dataSpecialTime.columns"
|
|
|
|
|
option-value="name"
|
|
|
|
|
options-cover
|
|
|
|
|
style="min-width: 150px"
|
|
|
|
|
class="col-xs-12 col-sm-3 col-md-2"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-12">
|
|
|
|
|
<d-table
|
|
|
|
|
:columns="dataSpecialTime.columns"
|
|
|
|
|
:rows="dataSpecialTime.rows"
|
|
|
|
|
:filter="filterKeyword"
|
|
|
|
|
row-key="tb-list"
|
|
|
|
|
flat
|
|
|
|
|
bordered
|
|
|
|
|
:paging="true"
|
|
|
|
|
dense
|
2023-11-27 16:31:45 +07:00
|
|
|
:pagination="dataSpecialTime.initialPagination"
|
2023-11-03 15:08:53 +07:00
|
|
|
:visible-columns="dataSpecialTime.visibleColumns"
|
2023-11-27 16:31:45 +07:00
|
|
|
:rows-per-page-options="[1, 10, 25, 50, 100]"
|
|
|
|
|
@update:pagination="dataSpecialTime.updatePagination"
|
2023-11-03 15:08:53 +07:00
|
|
|
>
|
|
|
|
|
<template v-slot:header="props">
|
|
|
|
|
<q-tr :props="props">
|
|
|
|
|
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
|
|
|
|
<span class="text-weight-medium">{{ col.label }}</span>
|
|
|
|
|
</q-th>
|
|
|
|
|
<q-th auto-width />
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:body="props">
|
|
|
|
|
<q-tr :props="props" class="cursor-pointer">
|
|
|
|
|
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
|
|
|
|
<div v-if="col.name == 'no'">
|
|
|
|
|
{{ props.rowIndex + 1 }}
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else>
|
|
|
|
|
{{ col.value }}
|
|
|
|
|
</div>
|
|
|
|
|
</q-td>
|
|
|
|
|
<q-td auto-width>
|
|
|
|
|
<q-btn
|
|
|
|
|
v-if="props.row.status == 'PENDING'"
|
|
|
|
|
color="orange"
|
|
|
|
|
class="q-px-md"
|
|
|
|
|
dense
|
|
|
|
|
unelevated
|
2023-11-27 16:31:45 +07:00
|
|
|
@click="unapprove(props.row.fullname, props.row.id)"
|
2023-11-03 15:08:53 +07:00
|
|
|
>ไม่อนุมัติ</q-btn
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<q-btn
|
|
|
|
|
v-if="props.row.status == 'PENDING'"
|
|
|
|
|
color="primary"
|
|
|
|
|
class="q-px-md q-ml-sm"
|
|
|
|
|
dense
|
|
|
|
|
unelevated
|
2023-11-06 15:08:36 +07:00
|
|
|
@click="
|
|
|
|
|
openModal(
|
|
|
|
|
props.row,
|
|
|
|
|
'PENDING',
|
|
|
|
|
props.row.date,
|
2023-11-27 16:31:45 +07:00
|
|
|
props.row.dateFix,
|
|
|
|
|
props.row.id
|
2023-11-06 15:08:36 +07:00
|
|
|
)
|
|
|
|
|
"
|
2023-11-03 15:08:53 +07:00
|
|
|
>อนุมัติ</q-btn
|
|
|
|
|
>
|
2023-11-06 15:08:36 +07:00
|
|
|
<q-badge
|
|
|
|
|
v-if="props.row.status == 'APPROVE'"
|
|
|
|
|
rounded
|
|
|
|
|
outline
|
|
|
|
|
color="green"
|
|
|
|
|
label="อนุมัติ"
|
|
|
|
|
/>
|
|
|
|
|
<q-badge
|
|
|
|
|
v-if="props.row.status == 'REJECT'"
|
|
|
|
|
rounded
|
|
|
|
|
outline
|
|
|
|
|
color="red"
|
|
|
|
|
label="ไม่อนุมัติ"
|
|
|
|
|
/>
|
2023-11-03 15:08:53 +07:00
|
|
|
</q-td>
|
|
|
|
|
</q-tr>
|
|
|
|
|
</template>
|
|
|
|
|
</d-table>
|
2023-11-02 16:44:02 +07:00
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
<DialogReason
|
|
|
|
|
:modal="modalUnapprove"
|
|
|
|
|
:title="dialogTitle"
|
|
|
|
|
:desc="dialogDesc"
|
2023-11-06 15:08:36 +07:00
|
|
|
:click-close="closeDialog"
|
2023-11-02 16:44:02 +07:00
|
|
|
label="เหตุผล"
|
|
|
|
|
:savaForm="clickSave"
|
|
|
|
|
/>
|
2023-11-06 15:08:36 +07:00
|
|
|
<DialogApprove
|
|
|
|
|
:modal="modalApprove"
|
|
|
|
|
:closeDialog="closeDialog"
|
|
|
|
|
:date="dateDialog"
|
|
|
|
|
:dateFix="dateFixDialog"
|
2023-11-27 16:31:45 +07:00
|
|
|
:id="id"
|
2023-11-06 15:08:36 +07:00
|
|
|
:editCheck="editCheck"
|
|
|
|
|
:detailData="detailData"
|
|
|
|
|
/>
|
2023-11-02 16:44:02 +07:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style></style>
|