diff --git a/src/modules/11_discipline/components/2_InvestigateFacts/CalandarDialog.vue b/src/modules/11_discipline/components/2_InvestigateFacts/CalandarDialog.vue index 4e7b2d407..058abf2e1 100644 --- a/src/modules/11_discipline/components/2_InvestigateFacts/CalandarDialog.vue +++ b/src/modules/11_discipline/components/2_InvestigateFacts/CalandarDialog.vue @@ -57,7 +57,7 @@ const calendarOptions = ref({ expandRows: true, nowIndicator: true, height: "100%", - eventColor: "#50a5fc", + eventColor: "#02A998", eventTextColor: "#fff", eventBorderColor: "#50a5fc", displayEventTime: false, @@ -72,23 +72,38 @@ const dateMonth = ref({ }); /** 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.investigateCalendar(), { year: dateMonth.value.year, - mounth: dateMonth.value.month, + month: dateMonth.value.month, }) .then((res) => { const data = res.data.result; - const event = data.map((e: CaledarInvestigatefacts) => ({ + 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 = event; + + calendarOptions.value.events = events; }) .catch((err) => { messageError($q, err); @@ -105,6 +120,14 @@ async function fetchCalendar() { }); } +function generateGradientColors(length: number) { + const colors = []; + for (let i = 0; i < length; i++) { + colors.push(getRandomColor()); + } + return colors; +} + /** function เปลี่ยนปฎิทิน*/ function changCalendar() { fetchCalendar(); @@ -151,6 +174,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(); +} -
-
- - สืบสวน -
-
@@ -352,6 +411,7 @@ const modeCancel = ref(true); .demo-app-main { flex-grow: 1; + /* padding: 3em; */ } diff --git a/src/modules/11_discipline/components/2_InvestigateFacts/Form.vue b/src/modules/11_discipline/components/2_InvestigateFacts/Form.vue index 3c8b525f3..3a384f1ff 100644 --- a/src/modules/11_discipline/components/2_InvestigateFacts/Form.vue +++ b/src/modules/11_discipline/components/2_InvestigateFacts/Form.vue @@ -10,6 +10,8 @@ import { useInvestigateDisStore } from "@/modules/11_discipline/store/Investigat import { useInvestigateFactStore } from "@/modules/11_discipline/store/InvestigateFactStore"; import { useDisciplineMainStore } from "@/modules/11_discipline/store/main"; +import CalandarDialog from "@/modules/11_discipline/components/2_InvestigateFacts/CalandarDialog.vue"; + import type { FormData, MyObjectInvestigateRef, @@ -139,6 +141,9 @@ const initialPagination = ref({ rowsPerPage: 0, }); +const calendarModal = ref(false); +const calendarModalclose = () =>(calendarModal.value = !calendarModal.value) + /*** ฟังก์ชั่นสำหรับ validate ฟอร์ม */ function validateForm() { const hasError = []; @@ -452,6 +457,10 @@ function changeFormData() { isSave.value = true; } +function calendarOpen() { + calendarModal.value = true; +} + onMounted(async () => { mainStore.rowsAdd = []; getOc(); @@ -717,27 +726,46 @@ onMounted(async () => { style="border: 1px solid #d6dee1" >
- วันที่สืบสวน - +
+ วันที่สืบสวน + + +
+ +
+ + ปฏิทิน + +
@@ -765,7 +793,11 @@ onMounted(async () => { for="#date" class="full-width cursor-pointer" ref="dateRef" - :input-style="isReadonly ? { color: 'black' }:{color:'teal'}" + :input-style=" + isReadonly + ? { color: 'black' } + : { color: 'teal' } + " :readonly="isReadonly" outlined dense @@ -852,7 +884,11 @@ onMounted(async () => {