ย้าย ปฏิทิน เข้าใน ฟอร์ม
This commit is contained in:
parent
ecb81632ab
commit
3b138d9bf6
6 changed files with 243 additions and 99 deletions
|
|
@ -72,24 +72,38 @@ 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;
|
||||
}
|
||||
|
||||
async function fetchCalendar() {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.disciplinaryCalendar(), {
|
||||
year: dateMonth.value.year,
|
||||
mounth: dateMonth.value.month,
|
||||
month: dateMonth.value.month,
|
||||
})
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
const event = data.map((e: CaledarDisciplinary) => ({
|
||||
const defaultColor = "#02A998";
|
||||
const gradientColors = generateGradientColors(data.length);
|
||||
|
||||
const events = data.map((e: CaledarDisciplinary, index: number) => ({
|
||||
id: e.id,
|
||||
title: e.title,
|
||||
start: e.disciplinaryDateStart,
|
||||
end: e.disciplinaryDateEnd,
|
||||
start: e.disciplinaryDateEnd,
|
||||
end: e.disciplinaryDateStart,
|
||||
allDay: true,
|
||||
color:
|
||||
data.length > 1 && index > 0 ? gradientColors[index] : defaultColor,
|
||||
}));
|
||||
|
||||
calendarOptions.value.events = event;
|
||||
calendarOptions.value.events = events;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -97,15 +111,23 @@ async function fetchCalendar() {
|
|||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
if (fullCalendar !== undefined) {
|
||||
const calen = fullCalendar.value.getApi();
|
||||
const date = new Date(dateMonth.value.year, dateMonth.value.month);
|
||||
calen.gotoDate(date);
|
||||
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++) {
|
||||
colors.push(getRandomColor());
|
||||
}
|
||||
return colors;
|
||||
}
|
||||
|
||||
/** function เปลี่ยนปฎิทิน*/
|
||||
function changCalendar() {
|
||||
fetchCalendar();
|
||||
|
|
@ -148,6 +170,26 @@ const phone = ref("000-00000000");
|
|||
const reason = ref("ยกเลิกการลา");
|
||||
const model = ref(null);
|
||||
const modeCancel = ref(true);
|
||||
|
||||
function gotoPrevMonth() {
|
||||
const calen = fullCalendar.value.getApi();
|
||||
calen.prev();
|
||||
console.log("b", calen.getDate());
|
||||
updateDateMonth(calen.getDate());
|
||||
}
|
||||
|
||||
function gotoNextMonth() {
|
||||
const calen = fullCalendar.value.getApi();
|
||||
calen.next();
|
||||
console.log("n", calen.getDate());
|
||||
updateDateMonth(calen.getDate());
|
||||
}
|
||||
|
||||
function updateDateMonth(date: Date) {
|
||||
dateMonth.value.year = date.getFullYear();
|
||||
dateMonth.value.month = date.getMonth();
|
||||
fetchCalendar();
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<q-dialog v-model="props.modal">
|
||||
|
|
@ -173,7 +215,7 @@ const modeCancel = ref(true);
|
|||
<div class="col-12">
|
||||
<div class="row q-gutter-sm q-pb-sm main-content">
|
||||
<div class="demo-app-main">
|
||||
<div class="row col-12 q-mb-sm">
|
||||
<!-- <div class="row col-12 q-mb-sm">
|
||||
<div class="col-xs-12 col-sm-3 col-md-2">
|
||||
<datepicker
|
||||
v-model="dateMonth"
|
||||
|
|
@ -206,6 +248,29 @@ const modeCancel = ref(true);
|
|||
</template>
|
||||
</datepicker>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="row q-mb-sm justify-between">
|
||||
<q-btn
|
||||
size="12px"
|
||||
dense
|
||||
icon="mdi-chevron-left"
|
||||
class="self-center items-center"
|
||||
color="primary"
|
||||
@click="gotoPrevMonth"
|
||||
></q-btn>
|
||||
|
||||
<p class="q-ma-none text-center">
|
||||
{{ monthYearThai(dateMonth) }}
|
||||
</p>
|
||||
|
||||
<q-btn
|
||||
size="12px"
|
||||
dense
|
||||
icon="mdi-chevron-right"
|
||||
class="self-center items-center"
|
||||
color="primary"
|
||||
@click="gotoNextMonth"
|
||||
></q-btn>
|
||||
</div>
|
||||
<FullCalendar
|
||||
ref="fullCalendar"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import http from "@/plugins/http";
|
|||
import config from "@/app.config";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import CalandarDialog from "@/modules/11_discipline/components/3_InvestigateDisciplinary/CalandarDialog.vue";
|
||||
/**import type*/
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
|
|
@ -32,6 +32,9 @@ import { useComplainstDataStore } from "@/modules/11_discipline/store/Complaints
|
|||
import { useInvestigateDisStore } from "@/modules/11_discipline/store/InvestigateDisStore";
|
||||
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
||||
|
||||
const calendarModal = ref<boolean>(false);
|
||||
const calendarModalclose = () => (calendarModal.value = !calendarModal.value);
|
||||
|
||||
const complainstStore = useComplainstDataStore();
|
||||
const investigateDis = useInvestigateDisStore();
|
||||
const mainStore = useDisciplineMainStore();
|
||||
|
|
@ -432,6 +435,10 @@ function changeFormData() {
|
|||
isSave.value = true;
|
||||
}
|
||||
|
||||
function calendarOpen() {
|
||||
calendarModal.value = true;
|
||||
}
|
||||
|
||||
/** Hook */
|
||||
onMounted(async () => {
|
||||
mainStore.rowsAdd = [];
|
||||
|
|
@ -779,7 +786,7 @@ onMounted(async () => {
|
|||
style="border: 1px solid #d6dee1"
|
||||
>
|
||||
<div
|
||||
class="col-xs-12 col-sm-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
|
||||
class="row col-xs-12 col-sm-12 text-weight-medium bg-grey-1 q-py-sm q-px-md"
|
||||
>
|
||||
วันที่สอบสวน
|
||||
|
||||
|
|
@ -800,6 +807,22 @@ onMounted(async () => {
|
|||
keep-color
|
||||
@update:model-value="changeFormData()"
|
||||
/>
|
||||
<q-space style="height: 1px" />
|
||||
<div>
|
||||
<q-btn
|
||||
name="calendar"
|
||||
round
|
||||
size="12px"
|
||||
flat
|
||||
dense
|
||||
icon="mdi-calendar-month"
|
||||
class="self-center items-center"
|
||||
color="primary"
|
||||
@click="calendarOpen"
|
||||
>
|
||||
<q-tooltip>ปฏิทิน</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12"><q-separator /></div>
|
||||
<div class="q-pa-sm">
|
||||
|
|
@ -1482,4 +1505,6 @@ onMounted(async () => {
|
|||
@update:pagination="updatePaging"
|
||||
@returnDirector="returnDirector"
|
||||
/>
|
||||
|
||||
<CalandarDialog :modal="calendarModal" :close="calendarModalclose" />
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, useAttrs } from "vue";
|
||||
import type { Pagination } from "@/modules/04_registry/interface/index/Main";
|
||||
import CalandarDialog from "@/modules/11_discipline/components/3_InvestigateDisciplinary/CalandarDialog.vue";
|
||||
|
||||
const calendarModal = ref<boolean>(false);
|
||||
const calendarModalclose = () => (calendarModal.value = !calendarModal.value);
|
||||
const table = ref<any>(null);
|
||||
const filterRef = ref<any>(null);
|
||||
const attrs = ref<any>(useAttrs());
|
||||
|
|
@ -46,10 +43,6 @@ const emit = defineEmits([
|
|||
"update:editvisible",
|
||||
]);
|
||||
|
||||
function calendarOpen() {
|
||||
calendarModal.value = true;
|
||||
}
|
||||
|
||||
function paginationLabel(start: string, end: string, total: string) {
|
||||
if (paging.value == true) return " " + start + "-" + end + " ใน " + total;
|
||||
else return start + "-" + end + " ใน " + total;
|
||||
|
|
@ -72,20 +65,6 @@ function resetFilter() {
|
|||
|
||||
<template>
|
||||
<div class="q-pb-sm row q-col-gutter-sm">
|
||||
<div>
|
||||
<q-btn
|
||||
name="calendar"
|
||||
round
|
||||
size="12px"
|
||||
flat
|
||||
icon="mdi-calendar-month"
|
||||
class="q-mr-sm"
|
||||
color="primary"
|
||||
@click="calendarOpen"
|
||||
>
|
||||
<q-tooltip>ปฏิทิน</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
<q-space />
|
||||
<!-- ค้นหาข้อความใน table -->
|
||||
<q-input
|
||||
|
|
@ -148,7 +127,6 @@ function resetFilter() {
|
|||
<slot v-bind="props" name="columns"></slot>
|
||||
</template>
|
||||
</d-table>
|
||||
<CalandarDialog :modal="calendarModal" :close="calendarModalclose" />
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue