미완성

This commit is contained in:
yoon 2025-02-25 14:18:56 +09:00
parent 8ffb483aa1
commit 6ecf2d5aa1

View File

@ -2,9 +2,32 @@
<div class="container-xxl flex-grow-1 container-p-y"> <div class="container-xxl flex-grow-1 container-p-y">
<div class="card app-calendar-wrapper"> <div class="card app-calendar-wrapper">
<div class="row g-0"> <div class="row g-0">
<div class="col app-calendar-sidebar border-end text-center" id="app-calendar-sidebar"> <div class="col-3 border-end text-center">
<div class="card-body pb-0"> <div class="card-body pb-0">
<img v-if="user" :src="`http://localhost:10325/upload/img/profile/${user.profile}`" alt="Profile Image" class="w-px-50 h-auto rounded-circle"/> <img v-if="user" :src="`${baseUrl}upload/img/profile/${user.profile}`" alt="Profile Image" class="w-px-50 h-auto rounded-circle" @error="$event.target.src = '/img/icons/icon.png'"/>
<p class="mt-2">
{{ user.name }}
</p>
<div class="row g-0">
<div class="col-6 pe-1">
<p>출근시간</p>
<button class="btn btn-outline-primary border-3 w-100 py-0">
<i class='bx bx-run fs-2'></i>
</button>
</div>
<div class="col-6 ps-1">
<p>퇴근시간</p>
<button class="btn btn-outline-secondary border-3 w-100 py-0">
<i class='bx bxs-door-open fs-2'></i>
</button>
</div>
<div v-for="post in project" :key="post.PROJCTSEQ" class="border border-2 mt-3" :style="`border-color: ${post.projctcolor} !important; color: ${post.projctcolor} !important;`">
{{ post.PROJCTNAM }}
</div>
</div>
</div> </div>
</div> </div>
@ -62,15 +85,16 @@ import { isEmpty } from '@/common/utils';
import FormInput from '../input/FormInput.vue'; import FormInput from '../input/FormInput.vue';
import 'flatpickr/dist/flatpickr.min.css'; import 'flatpickr/dist/flatpickr.min.css';
import '@/assets/css/app-calendar.css'; import '@/assets/css/app-calendar.css';
import { useThemeStore } from '@s/darkmode';
import { fetchHolidays } from '@c/calendar/holiday'; import { fetchHolidays } from '@c/calendar/holiday';
import { useUserInfoStore } from '@/stores/useUserInfoStore'; import { useUserInfoStore } from '@/stores/useUserInfoStore';
import { useProjectStore } from '@/stores/useProjectStore';
const user = ref(null); const baseUrl = $api.defaults.baseURL.replace(/api\/$/, '');
const user = ref({});
const project = ref({});
const userStore = useUserInfoStore(); const userStore = useUserInfoStore();
const projectStore = useProjectStore();
const themeStore = useThemeStore();
const dayjs = inject('dayjs'); const dayjs = inject('dayjs');
const fullCalendarRef = ref(null); const fullCalendarRef = ref(null);
const calendarEvents = ref([]); const calendarEvents = ref([]);
@ -85,118 +109,139 @@ const selectedDate = ref(null);
// //
const handleDateSelect = (selectedDates) => { const handleDateSelect = (selectedDates) => {
if (selectedDates.length > 0) { if (selectedDates.length > 0) {
// YYYY-MM-DD
const selectedDate = dayjs(selectedDates[0]).format('YYYY-MM-DD'); const selectedDate = dayjs(selectedDates[0]).format('YYYY-MM-DD');
eventDate.value = selectedDate; eventDate.value = selectedDate;
showModal(); showModal(); //
} }
}; };
// //
const fetchData = async () => { const fetchData = async () => {
// FullCalendar API
const calendarApi = fullCalendarRef.value?.getApi(); const calendarApi = fullCalendarRef.value?.getApi();
if (!calendarApi) return; if (!calendarApi) return;
// ,
const date = calendarApi.currentData.viewTitle; const date = calendarApi.currentData.viewTitle;
const dateArr = date.split(' '); const dateArr = date.split(' ');
let currentYear = dateArr[0].trim(); let currentYear = dateArr[0].trim();
let currentMonth = dateArr[1].trim(); let currentMonth = dateArr[1].trim();
const regex = /\D/g; const regex = /\D/g;
//
currentYear = parseInt(currentYear.replace(regex, ''), 10); currentYear = parseInt(currentYear.replace(regex, ''), 10);
currentMonth = parseInt(currentMonth.replace(regex, ''), 10); currentMonth = parseInt(currentMonth.replace(regex, ''), 10);
try { try {
//
const holidayEvents = await fetchHolidays(currentYear, String(currentMonth).padStart(2, '0')); const holidayEvents = await fetchHolidays(currentYear, String(currentMonth).padStart(2, '0'));
//
const existingEvents = calendarEvents.value.filter(event => !event.classNames?.includes('holiday-event')); const existingEvents = calendarEvents.value.filter(event => !event.classNames?.includes('holiday-event'));
//
calendarEvents.value = [...existingEvents, ...holidayEvents]; calendarEvents.value = [...existingEvents, ...holidayEvents];
} catch (error) { } catch (error) {
console.error('공휴일 정보 로딩 실패:', error); console.error('공휴일 정보 로딩 실패:', error);
} }
}; };
// // (, , )
const moveCalendar = async (value = 0) => { const moveCalendar = async (value = 0) => {
const calendarApi = fullCalendarRef.value?.getApi(); const calendarApi = fullCalendarRef.value?.getApi();
if (value === 1) { if (value === 1) {
calendarApi.prev(); calendarApi.prev(); //
} else if (value === 2) { } else if (value === 2) {
calendarApi.next(); calendarApi.next(); //
} else if (value === 3) { } else if (value === 3) {
calendarApi.today(); calendarApi.today(); //
} }
//
await fetchData(); await fetchData();
}; };
//
const showModal = () => { const showModal = () => {
isModalVisible.value = true; isModalVisible.value = true;
}; };
//
const closeModal = () => { const closeModal = () => {
isModalVisible.value = false; isModalVisible.value = false;
//
eventTitle.value = ''; eventTitle.value = '';
eventDate.value = ''; eventDate.value = '';
}; };
//
const addEvent = () => { const addEvent = () => {
//
if (!checkEvent()) { if (!checkEvent()) {
//
calendarEvents.value.push({ calendarEvents.value.push({
title: eventTitle.value, title: eventTitle.value,
start: eventDate.value, start: eventDate.value,
backgroundColor: '#4CAF50' // backgroundColor: '#4CAF50' //
}); });
closeModal(); closeModal(); //
} }
}; };
//
const checkEvent = () => { const checkEvent = () => {
//
eventAlert.value = isEmpty(eventTitle.value); eventAlert.value = isEmpty(eventTitle.value);
eventDateAlert.value = isEmpty(eventDate.value); eventDateAlert.value = isEmpty(eventDate.value);
// true ( )
return eventAlert.value || eventDateAlert.value; return eventAlert.value || eventDateAlert.value;
}; };
//
const calendarOptions = reactive({ const calendarOptions = reactive({
plugins: [dayGridPlugin, interactionPlugin], plugins: [dayGridPlugin, interactionPlugin], //
initialView: 'dayGridMonth', initialView: 'dayGridMonth', // ()
headerToolbar: { headerToolbar: { //
left: 'today', left: 'today', // :
center: 'title', center: 'title', // : ()
right: 'prev,next', right: 'prev,next', // : /
}, },
locale: 'kr', locale: 'kr', //
events: calendarEvents, events: calendarEvents, //
eventOrder: 'sortIdx', eventOrder: 'sortIdx', //
selectable: true, selectable: true, //
dateClick: handleDateSelect, dateClick: handleDateSelect, //
droppable: false, droppable: false, //
eventDisplay: 'block', eventDisplay: 'block', //
//
customButtons: { customButtons: {
prev: { prev: {
text: 'PREV', text: 'PREV', //
click: () => moveCalendar(1), click: () => moveCalendar(1), //
}, },
today: { today: {
text: 'TODAY', text: 'TODAY', //
click: () => moveCalendar(3), click: () => moveCalendar(3), //
}, },
next: { next: {
text: 'NEXT', text: 'NEXT', //
click: () => moveCalendar(2), click: () => moveCalendar(2), //
}, },
}, },
}); });
// // ( )
watch(() => fullCalendarRef.value?.getApi().currentData.viewTitle, async () => { watch(() => fullCalendarRef.value?.getApi().currentData.viewTitle, async () => {
await fetchData(); await fetchData();
}); });
console.log(project)
onMounted(async () => { onMounted(async () => {
await fetchData(); await fetchData();
await userStore.userInfo(); await userStore.userInfo();
user.value = userStore.user; user.value = userStore.user;
await projectStore.getProjectList();
project.value = projectStore.projectList;
}); });
</script> </script>