board-comment 다시머지지

This commit is contained in:
dyhj625 2025-02-21 14:34:35 +09:00
parent 692d363756
commit 6e4382f473
4 changed files with 337 additions and 352 deletions

View File

@ -61,7 +61,7 @@ const props = defineProps({
}, },
profileName: { profileName: {
type: String, type: String,
default: null, default: '익명',
}, },
unknown: { unknown: {
type: Boolean, type: Boolean,

View File

@ -61,7 +61,7 @@
📌 {{ notice.title }} 📌 {{ notice.title }}
<i v-if="notice.img" class="bi bi-image me-1"></i> <i v-if="notice.img" class="bi bi-image me-1"></i>
<i v-if="notice.hasAttachment" class="bi bi-paperclip"></i> <i v-if="notice.hasAttachment" class="bi bi-paperclip"></i>
<span v-if="isNewPost(notice.date)" class="badge bg-danger text-white ms-2 fs-tiny">N</span> <span v-if="isNewPost(notice.rawDate)" class="badge bg-danger text-white ms-2 fs-tiny">N</span>
</td> </td>
<td class="text-center">{{ notice.author }}</td> <td class="text-center">{{ notice.author }}</td>
<td class="text-center">{{ notice.date }}</td> <td class="text-center">{{ notice.date }}</td>
@ -78,7 +78,7 @@
{{ post.title }} {{ post.title }}
<i v-if="post.img" class="bi bi-image me-1"></i> <i v-if="post.img" class="bi bi-image me-1"></i>
<i v-if="post.hasAttachment" class="bi bi-paperclip"></i> <i v-if="post.hasAttachment" class="bi bi-paperclip"></i>
<span v-if="isNewPost(post.date)" class="badge bg-danger text-white ms-2 fs-tiny">N</span> <span v-if="isNewPost(post.rawDate)" class="badge bg-danger text-white ms-2 fs-tiny">N</span>
</td> </td>
<td class="text-center">{{ post.author }}</td> <td class="text-center">{{ post.author }}</td>
<td class="text-center">{{ post.date }}</td> <td class="text-center">{{ post.date }}</td>
@ -199,6 +199,7 @@ const fetchGeneralPosts = async (page = 1) => {
id: totalPosts - ((page - 1) * selectedSize.value) - index, id: totalPosts - ((page - 1) * selectedSize.value) - index,
title: post.title, title: post.title,
author: post.author || '익명', author: post.author || '익명',
rawDate: post.date,
date: formatDate(post.date), // date: formatDate(post.date), //
views: post.cnt || 0, views: post.cnt || 0,
hasAttachment: post.hasAttachment || false, hasAttachment: post.hasAttachment || false,
@ -239,6 +240,7 @@ const fetchNoticePosts = async () => {
title: post.title, title: post.title,
author: post.author || '관리자', author: post.author || '관리자',
date: formatDate(post.date), date: formatDate(post.date),
rawDate: post.date,
views: post.cnt || 0, views: post.cnt || 0,
hasAttachment: post.hasAttachment || false, hasAttachment: post.hasAttachment || false,
img: post.firstImageUrl || null img: post.firstImageUrl || null

View File

@ -149,7 +149,7 @@ const comments = ref([]);
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const currentBoardId = ref(Number(route.params.id)); const currentBoardId = ref(Number(route.params.id));
const unknown = computed(() => profileName.value === null); const unknown = computed(() => profileName.value === '익명');
const currentUserId = ref('김자바'); // id const currentUserId = ref('김자바'); // id
const authorId = ref(null); // id const authorId = ref(null); // id
@ -190,7 +190,7 @@ const fetchBoardDetails = async () => {
// API // API
// const boardDetail = data.boardDetail || {}; // const boardDetail = data.boardDetail || {};
profileName.value = data.author || null; profileName.value = data.author || '익명';
// //
// profileName.value = 'null; // profileName.value = 'null;
@ -277,7 +277,7 @@ const fetchComments = async (page = 1) => {
commentId: comment.LOCCMTSEQ, // ID commentId: comment.LOCCMTSEQ, // ID
boardId: comment.LOCBRDSEQ, boardId: comment.LOCBRDSEQ,
parentId: comment.LOCCMTPNT, // ID parentId: comment.LOCCMTPNT, // ID
author: comment.author || null, author: comment.author || '익명',
content: comment.LOCCMTRPY, content: comment.LOCCMTRPY,
likeCount: comment.likeCount || 0, likeCount: comment.likeCount || 0,
dislikeCount: comment.dislikeCount || 0, dislikeCount: comment.dislikeCount || 0,

View File

@ -1,307 +1,304 @@
<template> <template>
<div class="vacation-management"> <div class="vacation-management">
<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-content"> <div class="col app-calendar-content">
<div class="card shadow-none border-0"> <div class="card shadow-none border-0">
<ProfileList <ProfileList
@profileClick="handleProfileClick" @profileClick="handleProfileClick"
:remainingVacationData="remainingVacationData" :remainingVacationData="remainingVacationData"
/> />
<div class="card-body w-75 p-3 align-self-center"> <div class="card-body w-75 p-3 align-self-center">
<VacationModal <!-- 모달에 필터링된 연차 목록 전달 -->
<VacationModal
v-if="isModalOpen" v-if="isModalOpen"
:isOpen="isModalOpen" :isOpen="isModalOpen"
:myVacations="myVacations" :myVacations="filteredMyVacations"
:receivedVacations="receivedVacations" :receivedVacations="filteredReceivedVacations"
:userColors="userColors" :userColors="userColors"
@close="isModalOpen = false" @close="isModalOpen = false"
/> />
<VacationGrantModal <VacationGrantModal
v-if="isGrantModalOpen" v-if="isGrantModalOpen"
:isOpen="isGrantModalOpen" :isOpen="isGrantModalOpen"
:targetUser="selectedUser" :targetUser="selectedUser"
:remainingQuota="remainingVacationData[selectedUser?.MEMBERSEQ] || 0" :remainingQuota="remainingVacationData[selectedUser?.MEMBERSEQ] || 0"
@close="isGrantModalOpen = false" @close="isGrantModalOpen = false"
@updateVacation="fetchRemainingVacation" @updateVacation="fetchRemainingVacation"
/> />
<full-calendar <full-calendar
ref="fullCalendarRef" ref="fullCalendarRef"
:options="calendarOptions" :options="calendarOptions"
class="flatpickr-calendar-only" class="flatpickr-calendar-only"
/> />
<HalfDayButtons <HalfDayButtons
@toggleHalfDay="toggleHalfDay" @toggleHalfDay="toggleHalfDay"
@addVacationRequests="saveVacationChanges" @addVacationRequests="saveVacationChanges"
/> />
</div>
</div> </div>
</div>
</div> </div>
</div> </div>
</div>
</div> </div>
</div>
</div> </div>
</template> </template>
<script setup> <script setup>
import FullCalendar from "@fullcalendar/vue3"; import { reactive, ref, onMounted, nextTick, computed } from "vue";
import dayGridPlugin from "@fullcalendar/daygrid"; import axios from "@api";
import interactionPlugin from "@fullcalendar/interaction"; import FullCalendar from "@fullcalendar/vue3";
import "flatpickr/dist/flatpickr.min.css"; import dayGridPlugin from "@fullcalendar/daygrid";
import "@/assets/css/app-calendar.css"; import interactionPlugin from "@fullcalendar/interaction";
import { reactive, ref, onMounted, nextTick } from "vue"; import "flatpickr/dist/flatpickr.min.css";
import axios from "@api"; import "@/assets/css/app-calendar.css";
import "bootstrap-icons/font/bootstrap-icons.css"; import "bootstrap-icons/font/bootstrap-icons.css";
import HalfDayButtons from "@c/button/HalfDayButtons.vue"; import HalfDayButtons from "@c/button/HalfDayButtons.vue";
import ProfileList from "@c/vacation/ProfileList.vue"; import ProfileList from "@c/vacation/ProfileList.vue";
import { useUserStore } from "@s/userList"; import VacationModal from "@c/modal/VacationModal.vue";
import VacationModal from "@c/modal/VacationModal.vue" import VacationGrantModal from "@c/modal/VacationGrantModal.vue";
import { useUserInfoStore } from "@s/useUserInfoStore"; import { useUserStore } from "@s/userList";
import VacationGrantModal from "@c/modal/VacationGrantModal.vue"; import { useUserInfoStore } from "@s/useUserInfoStore";
import { fetchHolidays } from "@c/calendar/holiday.js"; import { fetchHolidays } from "@c/calendar/holiday.js";
const userStore = useUserInfoStore(); const userStore = useUserInfoStore();
const userListStore = useUserStore(); const userListStore = useUserStore();
const userList = ref([]); const userList = ref([]);
const userColors = ref({}); const userColors = ref({});
const myVacations = ref([]); // const myVacations = ref([]); // " "
const receivedVacations = ref([]); // const receivedVacations = ref([]); // " "
const isModalOpen = ref(false); const isModalOpen = ref(false);
const remainingVacationData = ref({}); const remainingVacationData = ref({});
// ( )
const modalYear = ref(new Date().getFullYear());
const modalMonth = ref(String(new Date().getMonth() + 1).padStart(2, "0"));
const lastRemainingYear = ref(new Date().getFullYear());
const isGrantModalOpen = ref(false); const isGrantModalOpen = ref(false);
const selectedUser = ref(null); const selectedUser = ref(null);
// FullCalendar // FullCalendar
const fullCalendarRef = ref(null); const fullCalendarRef = ref(null);
const calendarEvents = ref([]); // FullCalendar (API + ) const calendarEvents = ref([]);
const selectedDates = ref(new Map()); // const selectedDates = ref(new Map());
const halfDayType = ref(null); const halfDayType = ref(null);
const vacationCodeMap = ref({}); // const vacationCodeMap = ref({});
const holidayDates = ref(new Set());
const fetchedEvents = ref([]);
// (YYYY-MM-DD ) ( ) const calendarOptions = reactive({
const holidayDates = ref(new Set()); plugins: [dayGridPlugin, interactionPlugin],
const fetchedEvents = ref([]); // API (, ) initialView: "dayGridMonth",
headerToolbar: {
left: "today",
center: "title",
right: "prev,next",
},
locale: "ko",
selectable: false,
dateClick: handleDateClick,
datesSet: handleMonthChange,
events: calendarEvents,
});
// FullCalendar (events calendarEvents ) onMounted(async () => {
const calendarOptions = reactive({ await userStore.userInfo();
plugins: [dayGridPlugin, interactionPlugin], await fetchRemainingVacation();
initialView: "dayGridMonth", });
headerToolbar: {
left: "today",
center: "title",
right: "prev,next",
},
locale: "ko",
selectable: false,
dateClick: handleDateClick,
datesSet: handleMonthChange,
events: calendarEvents,
});
onMounted(async () => { const fetchRemainingVacation = async () => {
await userStore.userInfo(); try {
await fetchRemainingVacation(); const response = await axios.get("vacation/remaining");
}); if (response.status === 200) {
remainingVacationData.value = response.data.data.reduce((acc, vacation) => {
const fetchRemainingVacation = async () => { acc[vacation.employeeId] = vacation.remainingQuota;
try { return acc;
const response = await axios.get("vacation/remaining"); }, {});
if (response.status === 200) {
remainingVacationData.value = response.data.data.reduce((acc, vacation) => {
acc[vacation.employeeId] = vacation.remainingQuota;
return acc;
}, {});
}
} catch (error) {
console.error("🚨 남은 연차 데이터를 불러오지 못했습니다:", error);
}
};
//
const handleProfileClick = async (user) => {
try {
if (user.MEMBERSEQ === userStore.user.id) {
//
const response = await axios.get(`vacation/history`);
if (response.status === 200 && response.data) {
myVacations.value = response.data.data.usedVacations || [];
receivedVacations.value = response.data.data.receivedVacations || [];
isModalOpen.value = true; //
isGrantModalOpen.value = false;
} else {
console.warn("❌ 연차 내역을 불러오지 못했습니다.");
} }
} else { } catch (error) {
// console.error("🚨 남은 연차 데이터를 불러오지 못했습니다:", error);
selectedUser.value = user;
isGrantModalOpen.value = true; //
isModalOpen.value = false;
} }
} catch (error) { };
console.error("🚨 연차 데이터 불러오기 실패:", error);
//
const handleProfileClick = async (user) => {
try {
if (user.MEMBERSEQ === userStore.user.id) {
const response = await axios.get(`vacation/history`);
if (response.status === 200 && response.data) {
myVacations.value = response.data.data.usedVacations || [];
receivedVacations.value = response.data.data.receivedVacations || [];
isModalOpen.value = true;
//
modalYear.value = new Date().getFullYear();
modalMonth.value = String(new Date().getMonth() + 1).padStart(2, "0");
isGrantModalOpen.value = false;
} else {
console.warn("❌ 연차 내역을 불러오지 못했습니다.");
}
} else {
selectedUser.value = user;
isGrantModalOpen.value = true;
isModalOpen.value = false;
}
} catch (error) {
console.error("🚨 연차 데이터 불러오기 실패:", error);
}
};
const fetchUserList = async () => {
try {
await userListStore.fetchUserList();
userList.value = userListStore.userList;
if (!userList.value.length) {
console.warn("📌 사용자 목록이 비어 있음!");
return;
}
userColors.value = {};
userList.value.forEach((user) => {
userColors.value[user.MEMBERSEQ] = user.usercolor || "#FFFFFF";
});
} catch (error) {
console.error("📌 사용자 목록 불러오기 오류:", error);
}
};
const fetchVacationCodes = async () => {
try {
const response = await axios.get("vacation/codes");
if (response.status === 200 && response.data) {
vacationCodeMap.value = response.data.data.reduce((acc, item) => {
acc[item.code] = item.name;
return acc;
}, {});
} else {
console.warn("❌ 공통 코드 데이터를 불러오지 못했습니다.");
}
} catch (error) {
console.error("🚨 공통 코드 API 호출 실패:", error);
}
};
const getVacationType = (typeCode) => {
return vacationCodeMap.value[typeCode] || "기타";
};
// computed: modalYear
const filteredMyVacations = computed(() => {
const filtered = myVacations.value.filter(vac => {
console.log(vac)
const year = vac.date ? vac.date.split("T")[0].substring(0, 4) : null;
console.log("vacation year:", year, "modalYear:", modalYear.value);
return year === String(modalYear.value);
});
console.log("filteredMyVacations:", filtered);
return filtered;
});
const filteredReceivedVacations = computed(() => {
return receivedVacations.value.filter(vac => {
console.log(
vac.date,
vac.date ? vac.date.split("T")[0].substring(0, 4) : null,
modalYear.value
);
return vac.date && vac.date.split("T")[0].substring(0, 4) === String(modalYear.value);
});
});
function updateCalendarEvents() {
const selectedEvents = Array.from(selectedDates.value)
.filter(([date, type]) => type !== "delete")
.map(([date, type]) => ({
title: getVacationType(type),
start: date,
backgroundColor: "rgb(113 212 243 / 76%)",
textColor: "#fff",
display: "background",
classNames: [getVacationTypeClass(type), "selected-event"]
}));
const filteredFetchedEvents = fetchedEvents.value.filter(event => {
if (event.saved) {
return selectedDates.value.get(event.start) !== "delete";
}
return true;
});
calendarEvents.value = [...filteredFetchedEvents, ...selectedEvents];
} }
};
const fetchUserList = async () => { const getVacationTypeClass = (type) => {
try { if (type === "700101") return "half-day-am";
await userListStore.fetchUserList(); if (type === "700102") return "half-day-pm";
userList.value = userListStore.userList; return "full-day";
};
if (!userList.value.length) { function handleDateClick(info) {
console.warn("📌 사용자 목록이 비어 있음!"); const clickedDateStr = info.dateStr;
const clickedDate = info.date;
const todayStr = new Date().toISOString().split("T")[0];
if (
clickedDate.getDay() === 0 ||
clickedDate.getDay() === 6 ||
holidayDates.value.has(clickedDateStr) ||
clickedDateStr < todayStr
) {
return; return;
} }
if (selectedDates.value.has(clickedDateStr)) {
userColors.value = {}; selectedDates.value.delete(clickedDateStr);
userList.value.forEach((user) => { updateCalendarEvents();
userColors.value[user.MEMBERSEQ] = user.usercolor || "#FFFFFF"; return;
}); }
} catch (error) { const unsentVacation = myVacations.value.find(
console.error("📌 사용자 목록 불러오기 오류:", error); (vac) => vac.LOCVACUDT && vac.LOCVACUDT.startsWith(clickedDateStr) && !vac.LOCVACRMM
} );
}; if (unsentVacation) {
selectedDates.value.set(clickedDateStr, "delete");
const fetchVacationCodes = async () => {
try {
const response = await axios.get("vacation/codes");
if (response.status === 200 && response.data) {
//
vacationCodeMap.value = response.data.data.reduce((acc, item) => {
acc[item.code] = item.name; // code key, name value
return acc;
}, {});
} else { } else {
console.warn("❌ 공통 코드 데이터를 불러오지 못했습니다."); const type = halfDayType.value
? (halfDayType.value === "AM" ? "700101" : "700102")
: "700103";
selectedDates.value.set(clickedDateStr, type);
} }
} catch (error) { halfDayType.value = null;
console.error("🚨 공통 코드 API 호출 실패:", error);
}
};
// 🔹 typeCode code
const getVacationType = (typeCode) => {
return vacationCodeMap.value[typeCode] || "기타";
};
function updateCalendarEvents() {
// ( ): type "delete"
const selectedEvents = Array.from(selectedDates.value)
.filter(([date, type]) => type !== "delete")
.map(([date, type]) => ({
title: getVacationType(type),
start: date,
backgroundColor: "rgb(113 212 243 / 76%)",
textColor: "#fff", //
display: "background",
classNames: [getVacationTypeClass(type), "selected-event"]
}));
// ,
//
const filteredFetchedEvents = fetchedEvents.value.filter(event => {
if (event.saved) { // saved
return selectedDates.value.get(event.start) !== "delete";
}
return true;
});
calendarEvents.value = [...filteredFetchedEvents, ...selectedEvents];
}
/**
* 반차 유형에 따라 클래스명 지정 (색상 변경 없이 영역만 조정)
*/
const getVacationTypeClass = (type) => {
if (type === "700101") return "half-day-am"; //
if (type === "700102") return "half-day-pm"; //
return "full-day"; //
};
/**
* 날짜 클릭 이벤트
* - 주말(, ) 공휴일은 클릭되지 않음
* - 클릭 해당 날짜를 selectedDates에 추가 또는 제거한 updateCalendarEvents() 호출
*/
function handleDateClick(info) {
const clickedDateStr = info.dateStr; // "YYYY-MM-DD"
const clickedDate = info.date;
const todayStr = new Date().toISOString().split("T")[0];
// , ,
if (
clickedDate.getDay() === 0 ||
clickedDate.getDay() === 6 ||
holidayDates.value.has(clickedDateStr) ||
clickedDateStr < todayStr
) {
return;
}
// :
if (selectedDates.value.has(clickedDateStr)) {
selectedDates.value.delete(clickedDateStr);
updateCalendarEvents(); updateCalendarEvents();
return;
} }
// ( ) function toggleHalfDay(type) {
const unsentVacation = myVacations.value.find( halfDayType.value = halfDayType.value === type ? null : type;
(vac) => vac.LOCVACUDT && vac.LOCVACUDT.startsWith(clickedDateStr) && !vac.LOCVACRMM
);
if (unsentVacation) {
// , "delete" (, )
selectedDates.value.set(clickedDateStr, "delete");
} else {
// : halfDayType
const type = halfDayType.value
? (halfDayType.value === "AM" ? "700101" : "700102")
: "700103";
selectedDates.value.set(clickedDateStr, type);
} }
halfDayType.value = null; async function fetchVacationData(year, month) {
updateCalendarEvents();
}
/**
* 오전/오후 반차 버튼 토글
*/
function toggleHalfDay(type) {
halfDayType.value = halfDayType.value === type ? null : type;
}
/**
* 백엔드에서 휴가 데이터를 가져와 이벤트로 변환
*/
async function fetchVacationData(year, month) {
try { try {
const response = await axios.get(`vacation/list/${year}/${month}`); const response = await axios.get(`vacation/list/${year}/${month}`);
if (response.status === 200) { if (response.status === 200) {
const vacationList = response.data; const vacationList = response.data;
// ( ) // modalYear
myVacations.value = vacationList.filter( if (modalYear.value !== year) {
(vac) => vac.MEMBERSEQ === userStore.user.id myVacations.value = vacationList.filter(
); (vac) => vac.MEMBERSEQ === userStore.user.id
// saved );
modalYear.value = year;
// modalMonth ( )
}
//
const events = vacationList const events = vacationList
.filter((vac) => !vac.LOCVACRMM) // () .filter((vac) => !vac.LOCVACRMM)
.map((vac) => { .map((vac) => {
let dateStr = vac.LOCVACUDT.split("T")[0]; let dateStr = vac.LOCVACUDT ? vac.LOCVACUDT.split("T")[0] : "";
let backgroundColor = userColors.value[vac.MEMBERSEQ] || "#FFFFFF"; let backgroundColor = userColors.value[vac.MEMBERSEQ] || "#FFFFFF";
return { return {
title: getVacationType(vac.LOCVACTYP), title: getVacationType(vac.LOCVACTYP),
start: dateStr, start: dateStr,
backgroundColor, backgroundColor,
classNames: [getVacationTypeClass(vac.LOCVACTYP)], classNames: [getVacationTypeClass(vac.LOCVACTYP)],
saved: true, // saved saved: true,
}; };
}) })
.filter((event) => event !== null); .filter((event) => event.start);
return events; return events;
} else { } else {
console.warn("📌 휴가 데이터를 불러오지 못함"); console.warn("📌 휴가 데이터를 불러오지 못함");
@ -313,94 +310,80 @@ halfDayType.value = halfDayType.value === type ? null : type;
} }
} }
/** async function saveVacationChanges() {
* 휴가 요청 추가 (선택된 날짜를 백엔드로 전송) const selectedDatesArray = Array.from(selectedDates.value);
*/ const vacationsToAdd = selectedDatesArray
async function saveVacationChanges() { .filter(([date, type]) => type !== "delete")
// : selectedDates type "delete" .filter(([date, type]) =>
const selectedDatesArray = Array.from(selectedDates.value); !myVacations.value.some(vac => vac.LOCVACUDT && vac.LOCVACUDT.startsWith(date)) ||
const vacationsToAdd = selectedDatesArray myVacations.value.some(vac => vac.LOCVACUDT && vac.LOCVACUDT.startsWith(date) && vac.LOCVACRMM)
.filter(([date, type]) => type !== "delete") )
.filter(([date, type]) => .map(([date, type]) => ({ date, type }));
// , (LOCVACRMM) const vacationsToDelete = myVacations.value
!myVacations.value.some(vac => vac.LOCVACUDT.startsWith(date)) || .filter(vac => {
myVacations.value.some(vac => vac.LOCVACUDT.startsWith(date) && vac.LOCVACRMM) if (!vac.LOCVACUDT) return false;
) const date = vac.LOCVACUDT.split("T")[0];
.map(([date, type]) => ({ date, type })); return selectedDates.value.get(date) === "delete" && !vac.LOCVACRMM;
})
// : , .map(vac => {
// "delete" const id = vac.LOCVACSEQ;
const vacationsToDelete = myVacations.value return typeof id === "number" ? Number(id) : id;
.filter(vac => { });
const date = vac.LOCVACUDT.split("T")[0]; try {
// "delete" const response = await axios.post("vacation/batchUpdate", {
return selectedDates.value.get(date) === "delete" && !vac.LOCVACRMM; add: vacationsToAdd,
}) delete: vacationsToDelete
.map(vac => { });
const id = vac.LOCVACSEQ ; if (response.data && response.data.status === "OK") {
return typeof id === "number" ? Number(id) : id; alert("✅ 휴가 변경 사항이 저장되었습니다.");
}); await fetchRemainingVacation();
const currentDate = fullCalendarRef.value.getApi().getDate();
try { await loadCalendarData(currentDate.getFullYear(), currentDate.getMonth() + 1);
const response = await axios.post("vacation/batchUpdate", { selectedDates.value.clear();
add: vacationsToAdd, updateCalendarEvents();
delete: vacationsToDelete } else {
}); alert("❌ 휴가 저장 중 오류가 발생했습니다.");
if (response.data && response.data.status === "OK") { }
alert("✅ 휴가 변경 사항이 저장되었습니다."); } catch (error) {
await fetchRemainingVacation(); console.error("🚨 휴가 변경 저장 실패:", error);
const currentDate = fullCalendarRef.value.getApi().getDate(); alert("❌ 휴가 저장 요청에 실패했습니다.");
await loadCalendarData(currentDate.getFullYear(), currentDate.getMonth() + 1);
// :
selectedDates.value.clear();
updateCalendarEvents();
} else {
alert("❌ 휴가 저장 중 오류가 발생했습니다.");
} }
} catch (error) {
console.error("🚨 휴가 변경 저장 실패:", error);
alert("❌ 휴가 저장 요청에 실패했습니다.");
} }
}
/** function handleMonthChange(viewInfo) {
* 달력 변경 호출 (FullCalendar의 datesSet 옵션) const currentDate = viewInfo.view.currentStart;
*/ const year = currentDate.getFullYear();
function handleMonthChange(viewInfo) { const month = String(currentDate.getMonth() + 1).padStart(2, "0");
const currentDate = viewInfo.view.currentStart; loadCalendarData(year, month);
const year = currentDate.getFullYear(); }
const month = String(currentDate.getMonth() + 1).padStart(2, "0");
loadCalendarData(year, month);
}
/** async function loadCalendarData(year, month) {
* 지정한 월의 데이터를 로드 (휴가, 공휴일 데이터를 병렬 요청) if (lastRemainingYear.value !== year) {
*/ await fetchRemainingVacation();
async function loadCalendarData(year, month) { lastRemainingYear.value = year;
fetchedEvents.value = []; }
const [vacationEvents, holidayEvents] = await Promise.all([ fetchedEvents.value = [];
fetchVacationData(year, month), const [vacationEvents, holidayEvents] = await Promise.all([
fetchHolidays(year, month), fetchVacationData(year, month),
]); fetchHolidays(year, month),
// Set ]);
holidayDates.value = new Set(holidayEvents.map((event) => event.start)); holidayDates.value = new Set(holidayEvents.map((event) => event.start));
fetchedEvents.value = [...vacationEvents, ...holidayEvents]; fetchedEvents.value = [...vacationEvents, ...holidayEvents];
updateCalendarEvents(); updateCalendarEvents();
await nextTick(); await nextTick();
fullCalendarRef.value.getApi().refetchEvents(); fullCalendarRef.value.getApi().refetchEvents();
} }
// onMounted(async () => {
onMounted(async () => { await fetchUserList();
await fetchUserList(); // await fetchVacationCodes();
await fetchVacationCodes(); const today = new Date();
const today = new Date(); const year = today.getFullYear();
const year = today.getFullYear(); const month = String(today.getMonth() + 1).padStart(2, "0");
const month = String(today.getMonth() + 1).padStart(2, "0"); await loadCalendarData(year, month);
await loadCalendarData(year, month); });
}); </script>
</script>
<style> <style>
/* 스타일 정의 */
</style> </style>