ปรับวันที่สืบสวน

This commit is contained in:
Warunee Tamkoo 2023-12-07 13:18:42 +07:00
parent c50e00968c
commit fabc55134c
6 changed files with 348 additions and 323 deletions

View file

@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import config from "@/app.config";
import http from "@/plugins/http";
import { ref, watch, type PropType } from "vue";
// import config from "@/app.config";
// import http from "@/plugins/http";
import { useQuasar } from "quasar";
import FullCalendar from "@fullcalendar/vue3";
import dayGridPlugin from "@fullcalendar/daygrid";
@ -12,7 +12,7 @@ import allLocales from "@fullcalendar/core/locales-all";
import listPlugin from "@fullcalendar/list";
import type { DataDateMonthObject } from "@/modules/09_leave/interface/response/leave";
import type { CaledarInvestigatefacts } from "@/modules/11_discipline/interface/response/Main";
import type { ExtendHistoryObject } from "@/modules/11_discipline/interface/response/Main";
import { useCounterMixin } from "@/stores/mixin";
@ -23,6 +23,10 @@ const { monthYear2Thai, showLoader, hideLoader, messageError, dateToISO } =
const $q = useQuasar();
const props = defineProps({
lists: {
type: Array as PropType<ExtendHistoryObject[]>,
default: [],
},
modal: {
type: Boolean,
default: false,
@ -57,8 +61,8 @@ const calendarOptions = ref<CalendarOptions>({
expandRows: true,
nowIndicator: true,
height: "100%",
eventColor: "#02A998",
eventTextColor: "#fff",
eventColor: "#E3FDDA",
eventTextColor: "#000000",
eventBorderColor: "#50a5fc",
displayEventTime: false,
editable: true,
@ -73,53 +77,86 @@ const dateMonth = ref<DataDateMonthObject>({
/** function เรียกข่อมูล calendar*/
function getRandomColor() {
const letters = "0123456789ABCDEF";
let color = "#";
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
return (
"hsl(" +
360 * Math.random() +
"," +
(25 + 70 * Math.random()) +
"%," +
(85 + 10 * Math.random()) +
"%)"
);
}
async function fetchCalendar() {
showLoader();
await http
.post(config.API.investigateCalendar(), {
year: dateMonth.value.year,
month: dateMonth.value.month,
})
.then((res) => {
const data = res.data.result;
const defaultColor = "#02A998";
const gradientColors = generateGradientColors(data.length);
const defaultColor = "#E3FDDA";
const gradientColors = generateGradientColors(props.lists.length);
const events = data.map((e: CaledarInvestigatefacts, index: number) => ({
id: e.id,
title: e.title,
start: e.investigationDateStart,
end: e.investigationDateEnd,
allDay: true,
color:
data.length > 1 && index > 0 ? gradientColors[index] : defaultColor,
}));
const events = await props.lists.map(
(e: ExtendHistoryObject, index: number) => ({
id: index.toString(),
title: e.name,
start: e.dateStart,
end: e.dateEnd,
allDay: false,
color:
props.lists.length > 1 && index > 0
? gradientColors[index]
: defaultColor,
})
);
calendarOptions.value.events = events;
calendarOptions.value.events = events;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
setTimeout(() => {
if (fullCalendar !== undefined) {
const calen = fullCalendar.value.getApi();
const date = new Date(dateMonth.value.year, dateMonth.value.month);
calen.gotoDate(date);
}
hideLoader();
}, 1000);
});
setTimeout(() => {
if (fullCalendar !== undefined) {
const calen = fullCalendar.value.getApi();
const date = new Date(dateMonth.value.year, dateMonth.value.month);
calen.gotoDate(date);
}
hideLoader();
}, 1000);
}
// async function fetchCalendar() {
// showLoader();
// await http
// .post(config.API.investigateCalendar(), {
// year: dateMonth.value.year,
// month: dateMonth.value.month,
// })
// .then((res) => {
// const data = res.data.result;
// const defaultColor = "#02A998";
// const gradientColors = generateGradientColors(data.length);
// const events = data.map((e: CaledarInvestigatefacts, index: number) => ({
// id: e.id,
// title: e.title,
// start: e.investigationDateStart,
// end: e.investigationDateEnd,
// allDay: true,
// color:
// data.length > 1 && index > 0 ? gradientColors[index] : defaultColor,
// }));
// calendarOptions.value.events = events;
// })
// .catch((err) => {
// messageError($q, err);
// })
// .finally(() => {
// setTimeout(() => {
// if (fullCalendar !== undefined) {
// const calen = fullCalendar.value.getApi();
// const date = new Date(dateMonth.value.year, dateMonth.value.month);
// calen.gotoDate(date);
// }
// hideLoader();
// }, 1000);
// });
// }
function generateGradientColors(length: number) {
const colors = [];
for (let i = 0; i < length; i++) {
@ -128,11 +165,6 @@ function generateGradientColors(length: number) {
return colors;
}
/** function เปลี่ยนปฎิทิน*/
function changCalendar() {
fetchCalendar();
}
/**
* function convert เดอนป
* @param val เดอนป
@ -164,15 +196,6 @@ watch(
*/
const modalCancel = ref(false);
const title = ref("");
const location = ref("บ้าน");
const subject = ref("ลาป่วย");
const dateStart = ref("20 ส.ค. 2566");
const dateEnd = ref("21 ส.ค. 2566");
const numDate = ref("20");
const place = ref("บ้าน");
const phone = ref("000-00000000");
const reason = ref("ยกเลิกการลา");
const model = ref(null);
const modeCancel = ref(true);
function gotoPrevMonth() {
@ -195,13 +218,14 @@ function updateDateMonth(date: Date) {
fetchCalendar();
}
</script>
<template>
<q-dialog v-model="props.modal">
<q-card style="min-width: 60vw">
<q-toolbar>
<q-toolbar-title class="text-subtitle2 text-bold"
>ปฎ</q-toolbar-title
>
<q-toolbar-title class="text-subtitle2 text-bold">
ปฎแสดงวนทบสวน
</q-toolbar-title>
<q-btn
icon="close"
unelevated
@ -213,6 +237,7 @@ function updateDateMonth(date: Date) {
</q-toolbar>
<q-separator />
<q-card-section class="q-pa-md bg-grey-1 scroll">
<div class="q-ma-sm">
<div class="row q-gutter-sm">
@ -317,84 +342,6 @@ function updateDateMonth(date: Date) {
</q-card-section>
</q-card>
</q-dialog>
<!-- 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>
</template>
<style scope lang="scss">
.main-content {