API รายการลา

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-12-07 14:25:13 +07:00
parent 908e756c42
commit da5dd5095c
20 changed files with 2105 additions and 526 deletions

View file

@ -1,171 +1,200 @@
<script setup lang="ts">
import { ref, onMounted } from "vue"
import { useQuasar } from "quasar"
import http from "@/plugins/http"
import config from "@/app.config"
import { ref, reactive, onMounted, watch } from "vue";
import { useQuasar } from "quasar";
import keycloak from "@/plugins/keycloak";
import http from "@/plugins/http";
import config from "@/app.config";
/**import calendar*/
import FullCalendar from "@fullcalendar/vue3"
import dayGridPlugin from "@fullcalendar/daygrid"
import type { CalendarOptions } from "@fullcalendar/core"
import timeGridPlugin from "@fullcalendar/timegrid"
import interactionPlugin from "@fullcalendar/interaction"
import allLocales from "@fullcalendar/core/locales-all"
import listPlugin from "@fullcalendar/list"
import FullCalendar from "@fullcalendar/vue3";
import dayGridPlugin from "@fullcalendar/daygrid";
import type { CalendarOptions } from "@fullcalendar/core";
import timeGridPlugin from "@fullcalendar/timegrid";
import interactionPlugin from "@fullcalendar/interaction";
import allLocales from "@fullcalendar/core/locales-all";
import listPlugin from "@fullcalendar/list";
import { useCounterMixin } from "@/stores/mixin"
import type { DataDateMonthObject } from "@/modules/05_leave/interface/request/Calendar.ts"
import type { DataDateMonthObject } from "@/modules/05_leave/interface/request/Calendar.ts";
const mixin = useCounterMixin()
const { showLoader, hideLoader, messageError, date2Thai, monthYear2Thai } = mixin
import DialogDetail from "@/modules/05_leave/componenst/DialogDetail.vue";
// import FormMain from "@/modules/05_leave/componenst/formDetail/formMain.vue";
import FormLeave from "@/modules/05_leave/componenst/formDetail/formLeave.vue";
import FormChildbirth from "@/modules/05_leave/componenst/formDetail/formChildbirth.vue";
import FormHoliday from "@/modules/05_leave/componenst/formDetail/formHoliday.vue";
import FormUpasom from "@/modules/05_leave/componenst/formDetail/formUpasom.vue";
import FormHajj from "@/modules/05_leave/componenst/formDetail/formHajj.vue";
import FormCheckSelect from "@/modules/05_leave/componenst/formDetail/formCheckSelect.vue";
import FormStudy from "@/modules/05_leave/componenst/formDetail/formStudy.vue";
import FormLeaveToTraining from "@/modules/05_leave/componenst/formDetail/formLeaveToTraining.vue";
import FormLeaveToWorkInternational from "@/modules/05_leave/componenst/formDetail/formLeaveToWorkInternational.vue";
import FormSpouse from "@/modules/05_leave/componenst/formDetail/formSpouse.vue";
import FormVocationalRehabilitation from "@/modules/05_leave/componenst/formDetail/formVocationalRehabilitation.vue";
const $q = useQuasar()
import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, date2Thai, monthYear2Thai } =
mixin;
const $q = useQuasar();
const emit = defineEmits(["update:dateYear"]);
/**
* วแปรทงหมด
*/
const typeId = ref<string>("eefa2f4f-c507-4a42-8567-4fadb8dc1f50")
const modalCancel = ref<boolean>(false)
const title = ref<string>("")
const location = ref<string>("บ้าน")
const subject = ref<string>("ลาป่วย")
const dateStart = ref<string>("20 ส.ค. 2566")
const dateEnd = ref<string>("21 ส.ค. 2566")
const numDate = ref<string>("20")
const place = ref<string>("บ้าน")
const phone = ref<string>("000-00000000")
const reason = ref<string>("ยกเลิกการลา")
const model = ref(null)
const modeCancel = ref<boolean>(true)
const dateYear = ref<number>(new Date().getFullYear())
const fullName = ref<string>("");
const mainData = ref<any>([]);
async function fetchDataCalendar() {
showLoader
await http
.post(config.API.leaveCalendar(), { year: dateYear.value })
.then(res => {
console.log(res)
})
.catch(err => {
messageError($q, err)
})
.finally(() => {
hideLoader()
})
}
async function fetchDataDetail() {
showLoader
await http
.get(config.API.leaveUserId(typeId.value), {})
.then(res => {
let data = res.data.result
title.value = data.fullname
location.value = data.leaveWrote
console.log(res)
})
.catch(err => {
messageError($q, err)
})
.finally(() => {
hideLoader()
})
}
const modalCancel = ref<boolean>(false);
const modeCancel = ref<boolean>(true);
const title = ref<string>("");
/**
* Option ของปฏ
*/
const fullCalendar = ref<any>() //ref calendar
const fullCalendar = ref<any>(); //ref calendar
const calendarOptions = ref<CalendarOptions>({
plugins: [
dayGridPlugin,
timeGridPlugin,
interactionPlugin, // needed for dateClick
listPlugin,
],
// buttonText: {
// listYear: "",
// dayGridMonth: "",
// test: "",
// },
headerToolbar: false,
initialView: "dayGridMonth",
initialEvents: [], // alternatively, use the `events` setting to fetch from a feed
selectable: true,
dayMaxEvents: true,
weekends: true,
locale: "th",
locales: allLocales,
expandRows: true,
nowIndicator: true,
height: "100%",
eventColor: "#fff",
eventTextColor: "#4A5568",
eventBorderColor: "#50a5fc",
displayEventTime: false,
editable: true,
events: [
{
groupId: "2",
title: "ลาป่วย",
start: "2023-11-24",
end: "2023-11-25",
allDay: true,
color: "#4CAF4F",
textColor: "white",
},
{
groupId: "4",
title: "ลากิจ",
start: "2023-11-15",
allDay: true,
color: "#4CAF4F",
textColor: "white",
},
{
groupId: "4",
title: "นางสาวสมศรี ใจดี (ลากิจ)",
start: "2023-11-21",
end: "2023-11-23",
allDay: true,
color: "#ddd",
},
{
groupId: "4",
title: "นายสมชาย สุขใจ",
start: "2023-11-21",
allDay: true,
color: "#ddd",
},
],
})
plugins: [
dayGridPlugin,
timeGridPlugin,
interactionPlugin, // needed for dateClick
listPlugin,
],
headerToolbar: false,
initialView: "dayGridMonth",
initialEvents: [], // alternatively, use the `events` setting to fetch from a feed
selectable: true,
dayMaxEvents: true,
weekends: true,
locale: "th",
locales: allLocales,
expandRows: true,
nowIndicator: true,
height: "100%",
eventColor: "#4CAF4F",
eventTextColor: "#fff",
eventBorderColor: "#50a5fc",
displayEventTime: false,
editable: true,
events: [
{
groupId: "2",
title: "ลาป่วย",
start: "2023-11-24",
end: "2023-11-25",
color: "#4CAF4F",
textColor: "white",
},
{
groupId: "4",
title: "ลากิจ",
start: "2023-11-15",
allDay: true,
color: "#4CAF4F",
textColor: "white",
},
{
groupId: "4",
title: "นางสาวสมศรี ใจดี (ลากิจ)",
start: "2023-11-21",
end: "2023-11-23",
allDay: true,
color: "#ddd",
},
{
groupId: "4",
title: "นายสมชาย สุขใจ",
start: "2023-11-21",
allDay: true,
color: "#ddd",
},
],
});
const dateMonth = ref<DataDateMonthObject>({
month: new Date().getMonth(),
year: new Date().getFullYear(),
})
month: new Date().getMonth(),
year: new Date().getFullYear(),
});
const emit = defineEmits(["update:dateYear"])
async function fetchDataCalendar() {
showLoader;
await http
.post(config.API.leaveCalendar(), {
year: dateMonth.value.year,
})
.then((res) => {
console.log(res);
mainData.value = res.data.result;
const double_name = [
...new Set(mainData.value.map((item: any) => item.fullName)),
];
for (let i = 1; i <= double_name.length; i++) {
filterLists.value = [];
const name = double_name[i - 1];
const filterName = {
id: name,
name: name,
color: name === "นางสาวสาวิตรี ศรีสมัย" ? "green" : "grey",
};
filterLists.value.push(filterName);
}
const data = mainData.value.filter(
(e: any) => e.fullName === "นางสาวสาวิตรี ศรีสมัย"
);
console.log(data);
const event = data.map((e: any) => ({
id: e.id,
title: e.leaveTypeName,
start: e.leaveStartDate,
end: e.leaveEndDate,
allDay: true,
}));
calendarOptions.value.events = event;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
const leaveType = ref<any>();
async function fectOptionType() {
await http
.get(config.API.leaveType())
.then(async (res) => {
leaveType.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
});
}
/**Status Form การลา*/
/**
* แปลง และเดอนเปนภาษาไทย
* @param val datepicker แบบเลอกปและเดอน
*/
function monthYearThai(val: DataDateMonthObject) {
if (val == null) return ""
else return monthYear2Thai(val.month, val.year)
if (val == null) return "";
else return monthYear2Thai(val.month, val.year);
}
function updateMonth(e: DataDateMonthObject) {
// console.log(dateMonth.value);
if (e != null) {
dateYear.value = e.year
emit("update:dateYear", e.year)
const calen = fullCalendar.value.getApi()
const date = new Date(dateMonth.value.year, dateMonth.value.month)
calen.gotoDate(date)
}
async function updateMonth() {
await fetchDataCalendar();
const calen = fullCalendar.value.getApi();
const date = new Date(dateMonth.value.year, dateMonth.value.month);
calen.gotoDate(date);
}
/**
@ -173,116 +202,187 @@ function updateMonth(e: DataDateMonthObject) {
* @param text
*/
async function cancel(text: string) {
title.value = text
modalCancel.value = true
modeCancel.value = true
title.value = text;
modalCancel.value = true;
modeCancel.value = true;
}
const modal = ref<boolean>(false);
const leaveId = ref<string>("");
/**
* งกนเป model
* @param text
* @param id
*/
async function view(text: string) {
title.value = text
modalCancel.value = true
modeCancel.value = false
async function onCilckview(id: string) {
modal.value = true;
leaveId.value = id;
}
async function onClickClose() {
modal.value = false;
}
// filter calendar left
const filterLists = ref<any[]>([
{
id: "x1",
name: "นางสาววารุณี แต้มคู",
color: "green",
},
{
id: "x2",
name: "นางสาวสมศรี ใจดี",
color: "grey",
},
{
id: "x3",
name: "นายสมชาย สุขใจ",
color: "grey",
},
])
const filterVal = ref(["x1"])
const filterLists = ref<any[]>([]);
const filterVal = ref(["นางสาวสาวิตรี ศรีสมัย"]);
watch(
() => filterVal.value,
() => {
const eventData = filterVal.value.map((item: any) => {
return mainData.value
.filter((e: any) => e.fullName === item)
.map((e: any) => ({
id: e.id,
title: e.leaveTypeName,
start: e.leaveStartDate,
end: e.leaveEndDate,
allDay: true,
}));
});
calendarOptions.value.events = eventData[0];
}
);
onMounted(async () => {
// await fetchDataCalendar();
// await fetchDataDetail()
})
if (keycloak.tokenParsed != null) {
fullName.value = keycloak.tokenParsed.name;
}
console.log(fullName.value);
await fetchDataCalendar();
await fectOptionType();
});
</script>
<template>
<div class="row">
<!-- Filter ตามคนและประเภทการลา -->
<div class="col-sm-12 col-md-3 q-mt-sm q-pr-sm">
<q-card class="col-12">
<div class="q-gutter-sm">
<q-list bordered class="rounded-borders">
<!-- <q-item-label header>User</q-item-label> -->
<q-item v-for="(item, i) in filterLists" :key="i" tag="label" v-ripple>
<q-checkbox size="sm" v-model="filterVal" :val="item.id" :color="item.color" />
<q-item-section>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</div>
<div class="row">
<!-- Filter ตามคนและประเภทการลา -->
<div class="col-sm-12 col-md-3 q-mt-sm q-pr-sm">
<q-card class="col-12">
<div class="q-gutter-sm">
<q-list bordered class="rounded-borders">
<!-- <q-item-label header>User</q-item-label> -->
<q-item
v-for="(item, i) in filterLists"
:key="i"
tag="label"
v-ripple
>
<q-checkbox
size="sm"
v-model="filterVal"
:val="item.id"
:color="item.color"
/>
<q-item-section>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</div>
<!-- show value filterVal -->
<!-- <div class="q-px-sm q-mt-sm">
<!-- show value filterVal -->
<!-- <div class="q-px-sm q-mt-sm">
Your selection is: <strong>{{ filterVal }}</strong>
</div> -->
</q-card>
</div>
</q-card>
</div>
<div class="col-sm-12 col-md-9">
<div class="q-mt-sm">
<div class="row col-12 q-gutter-sm">
<div class="demo-app-main">
<q-card bordered flat class="q-pa-sm col-12 row bg-grey-1 shadow-0">
<div class="items-center col-12 row q-col-gutter-sm">
<!-- filter เลอกเดอนป -->
<datepicker v-model="dateMonth" :locale="'th'" autoApply month-picker :enableTimePicker="false" @update:modelValue="updateMonth">
<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 bg-color="white" 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-card>
<div class="col-sm-12 col-md-9">
<div class="q-mt-sm">
<div class="row col-12 q-gutter-sm">
<div class="demo-app-main">
<q-card bordered flat class="q-pa-sm col-12 row bg-grey-1 shadow-0">
<div class="items-center col-12 row q-col-gutter-sm">
<!-- filter เลอกเดอนป -->
<datepicker
v-model="dateMonth"
:locale="'th'"
autoApply
month-picker
:enableTimePicker="false"
@update:modelValue="updateMonth"
>
<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
bg-color="white"
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-card>
<div class="main-content">
<FullCalendar ref="fullCalendar" class="demo-app-calendar" :options="calendarOptions">
<template v-slot:eventContent="arg">
<div class="row col-12 items-center no-wrap" :style="`background: + ${arg.event.color}`">
<!-- <b>{{ arg.timeText }}</b> -->
<div class="textHover col-10" @click="view(arg.event.title)">
{{ arg.event.title }}
</div>
<q-btn dense v-if="arg.event.groupId == 1" icon="mdi-close" flat round size="8px" @click="cancel(arg.event.title)" />
</div>
</template>
</FullCalendar>
</div>
</div>
</div>
<div class="row q-col-gutter-lg justify-end">
<div class="items-center row">
<q-icon size="10px" color="green-7" name="mdi-circle" class="q-mr-sm" />
<span class="text-caption text-grey-8">การลาของฉ</span>
</div>
<div class="items-center row">
<q-icon size="10px" color="grey-6" name="mdi-circle" class="q-mr-sm" />
<span class="text-caption text-grey-8">การลาของบคคลอ</span>
</div>
<!-- <div class="items-center row">
<div class="main-content">
<FullCalendar
ref="fullCalendar"
class="demo-app-calendar"
:options="calendarOptions"
>
<template v-slot:eventContent="arg">
<div
class="row col-12 items-center no-wrap"
:style="`background: + ${arg.event.color}`"
>
<!-- <b>{{ arg.timeText }}</b> -->
<div
class="textHover col-10"
@click="onCilckview(arg.event.id)"
>
{{ arg.event.title }}
</div>
<q-btn
dense
v-if="arg.event.groupId == 1"
icon="mdi-close"
flat
round
size="8px"
@click="cancel(arg.event.title)"
/>
</div>
</template>
</FullCalendar>
</div>
</div>
</div>
<div class="row q-col-gutter-lg justify-end">
<div class="items-center row">
<q-icon
size="10px"
color="green-7"
name="mdi-circle"
class="q-mr-sm"
/>
<span class="text-caption text-grey-8">การลาของฉ</span>
</div>
<div class="items-center row">
<q-icon
size="10px"
color="grey-6"
name="mdi-circle"
class="q-mr-sm"
/>
<span class="text-caption text-grey-8">การลาของบคคลอ</span>
</div>
<!-- <div class="items-center row">
<q-icon size="10px" color="light-blue-14" name="mdi-circle" class="q-mr-sm" />
<span class="text-caption text-grey-8">สถานะอยระหวางดำเนนการ</span>
</div>
@ -290,90 +390,51 @@ onMounted(async () => {
<q-icon size="10px" color="orange" name="mdi-circle" class="q-mr-sm" />
<span class="text-caption text-grey-8">สถานะใหม</span>
</div> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- modal รายละเอยด -->
<q-dialog v-model="modalCancel" persistent>
<q-card :style="modeCancel == true ? 'min-width: 50%;' : 'min-width:30%'">
<q-card-section class="row items-center q-pa-sm">
<div v-if="modeCancel == false" class="text-bold q-pl-sm">รายละเอียดของ{{ title }}</div>
<div v-else class="text-bold q-pl-sm">ขอยกเล{{ title }}</div>
<q-space />
<q-btn icon="close" unelevated round dense v-close-popup style="color: #ff8080; background-color: #ffdede" />
</q-card-section>
<q-separator />
<q-card-section class="q-p-md row q-gutter-y-md">
<div flat :class="modeCancel == true ? 'col-xs-6 col-sm-6' : 'col-12'">
<div class="col-12 q-col-gutter-sm row items-center">
<div class="col-6 text-grey-7">เขยนท</div>
<div class="col-6 text-black">{{ location }}</div>
<div class="col-6 text-grey-7">เรองและเหตผลการลา</div>
<div class="col-6 text-black">{{ subject }}</div>
<div class="col-6 text-grey-7"> เดอน เรมต</div>
<div class="col-6 text-black">{{ dateStart }}</div>
<div class="col-6 text-grey-7"> เดอน นส</div>
<div class="col-6 text-black">{{ dateEnd }}</div>
<div class="col-6 text-grey-7">จำนวนวนทลา</div>
<div class="col-6 text-black">{{ numDate }}</div>
<div class="col-6 text-grey-7">สถานทดตอขณะลา</div>
<div class="col-6 text-black">{{ place }}</div>
<div class="col-6 text-grey-7">หมายเลขโทรศพท</div>
<div class="col-6 text-black">{{ phone }}</div>
</div>
</div>
<div flat class="col-xs-6 col-sm-6" v-if="modeCancel == true">
<q-input v-model="reason" type="textarea" label="กรอกเหตุผล" outlined dense />
<q-file outlined v-model="model" label="เลือกไฟล์เอกสารหลักฐาน" class="q-mt-md" use-chips dense>
<template v-slot:prepend>
<q-icon name="attach_file" />
</template>
</q-file>
</div>
</q-card-section>
<q-separator />
<q-card-section class="row items-center q-pa-sm" v-if="modeCancel == true">
<q-space />
<q-btn label="ยืนยัน" unelevated color="secondary" dense class="q-px-md" v-close-popup />
</q-card-section>
</q-card>
</q-dialog>
<DialogDetail
:modal="modal"
:leaveId="leaveId"
:onClickClose="onClickClose"
:leaveType="leaveType"
/>
</template>
<style scope lang="scss">
.main-content {
height: 70vh;
height: 70vh;
}
.padding-content {
padding: 10px;
padding: 10px;
}
.demo-app-main {
flex-grow: 1;
/* padding: 3em; */
flex-grow: 1;
/* padding: 3em; */
}
.fc {
/* the calendar root */
max-width: 1100px;
margin: 0 auto;
background-color: white;
border-radius: 10px;
/* the calendar root */
max-width: 1100px;
margin: 0 auto;
background-color: white;
border-radius: 10px;
}
.fc-day-today {
background-color: #f8f8f8 !important;
background-color: #f8f8f8 !important;
}
.fc-day-today .fc-daygrid-day-number {
display: flex;
justify-content: center;
align-items: center;
/* border: 2px solid #17a259; */
/* border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
/* border: 2px solid #17a259; */
/* border-radius: 50%;
height: 25px;
width: 25px;
font-weight: bold;
@ -382,123 +443,123 @@ onMounted(async () => {
}
.fc-day-today .fc-daygrid-day-frame {
padding: 5%;
padding: 5%;
}
.fc .fc-button-group > .fc-button {
color: black;
background-color: #fafafa;
border: none;
color: black;
background-color: #fafafa;
border: none;
}
.fc .fc-button-group > .fc-button:active {
color: white;
background-color: #22a15e;
border: none;
color: white;
background-color: #22a15e;
border: none;
}
.fc .fc-button-group > .fc-button.fc-button-active {
color: white;
background-color: #22a15e;
border: none;
color: white;
background-color: #22a15e;
border: none;
}
.fc-header-toolbar {
background-color: white;
padding: 0px 10px 0px 10px;
border-radius: 10px 10px 0px 0px;
background-color: white;
padding: 0px 10px 0px 10px;
border-radius: 10px 10px 0px 0px;
}
.fc .fc-scrollgrid-liquid > thead {
background-color: white;
background-color: white;
}
.dp-custom-cell {
border-radius: 50%;
border-radius: 50%;
}
.dp__today {
border: 1px solid var(--q-primary);
border: 1px solid var(--q-primary);
}
.dp__range_end,
.dp__range_start,
.dp__active_date {
background: var(--q-primary);
color: var(--dp-primary-text-color);
background: var(--q-primary);
color: var(--dp-primary-text-color);
}
.datepicker .q-field__label {
padding-left: 5px;
padding-left: 5px;
}
.datepicker .q-field__messages {
padding-left: 20px;
padding-left: 20px;
}
.datepicker .q-field__native {
padding-left: 5px;
color: var(--q-primary) !important;
padding-left: 5px;
color: var(--q-primary) !important;
}
.datepicker .q-field__prepend {
padding-left: 6px;
padding-left: 6px;
}
.datepicker .q-field__append {
padding-right: 6px;
padding-right: 6px;
}
.datepicker .q-field__after {
display: flex;
justify-content: flex-end;
align-items: center;
font-weight: 500;
display: flex;
justify-content: flex-end;
align-items: center;
font-weight: 500;
}
.fc .fc-popover {
z-index: 6000;
z-index: 6000;
}
.fc-direction-ltr .fc-daygrid-event.fc-event-end,
.fc-direction-rtl .fc-daygrid-event.fc-event-start {
cursor: pointer;
cursor: pointer;
}
.subName {
display: flex;
justify-content: flex-end;
align-items: center;
font-weight: 500;
display: flex;
justify-content: flex-end;
align-items: center;
font-weight: 500;
}
.subInput {
display: flex;
align-items: center;
display: flex;
align-items: center;
}
.fc-event {
overflow: hidden;
border-color: transparent !important;
font-weight: 500;
overflow: hidden;
border-color: transparent !important;
font-weight: 500;
}
.fc-event-main {
text-align: left;
padding: 0px 5px;
text-align: left;
padding: 0px 5px;
}
.fc-direction-ltr .fc-daygrid-event.fc-event-end,
.fc-direction-rtl .fc-daygrid-event.fc-event-start {
padding-left: 0px;
padding-left: 0px;
}
.fc-theme-standard td,
.fc-theme-standard th {
border: 1px solid #ebe9f1;
border: 1px solid #ebe9f1;
}
.textHover:hover {
color: var(--q-primary);
color: #b5ec9f;
}
</style>