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: {
type: String,
default: null,
default: '익명',
},
unknown: {
type: Boolean,

View File

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

View File

@ -149,7 +149,7 @@ const comments = ref([]);
const route = useRoute();
const router = useRouter();
const currentBoardId = ref(Number(route.params.id));
const unknown = computed(() => profileName.value === null);
const unknown = computed(() => profileName.value === '익명');
const currentUserId = ref('김자바'); // id
const authorId = ref(null); // id
@ -189,15 +189,15 @@ const fetchBoardDetails = async () => {
// API
// const boardDetail = data.boardDetail || {};
profileName.value = data.author || null;
profileName.value = data.author || '익명';
//
// profileName.value = 'null;
// :
authorId.value = data.author;
boardTitle.value = data.title || '제목 없음';
boardContent.value = data.content || '';
date.value = data.date || '';
@ -206,7 +206,7 @@ const fetchBoardDetails = async () => {
dislikes.value = data.dislikeCount || 0;
attachment.value = data.hasAttachment || null;
commentNum.value = data.commentCount || 0;
} catch (error) {
alert('게시물 데이터를 불러오는 중 오류가 발생했습니다.');
}
@ -272,12 +272,12 @@ const fetchComments = async (page = 1) => {
page
}
});
const commentsList = response.data.data.list.map(comment => ({
commentId: comment.LOCCMTSEQ, // ID
boardId: comment.LOCBRDSEQ,
parentId: comment.LOCCMTPNT, // ID
author: comment.author || null,
author: comment.author || '익명',
content: comment.LOCCMTRPY,
likeCount: comment.likeCount || 0,
dislikeCount: comment.dislikeCount || 0,
@ -458,7 +458,7 @@ const editComment = (comment) => {
// c.isCommentPassword = false;
// });
// if (comment.unknown) {
// if (comment.unknown) {
// comment.isCommentPassword = true;
// } else {
// comment.isEditTextarea = true;
@ -565,10 +565,10 @@ const submitCommentPassword = async (comment, password) => {
if (response.data.code === 200 && response.data.data === true) {
comment.isCommentPassword = false;
if (lastCommentClickedButton.value === "edit") {
comment.isEditTextarea = true;
// handleSubmitEdit(comment, comment.content);
// handleSubmitEdit(comment, comment.content);
} else if (lastCommentClickedButton.value === "delete") {
deleteReplyComment(comment)
@ -620,7 +620,7 @@ const deleteReplyComment = async (comment) => {
if (response.data.code === 200) {
// console.log(" !");
await fetchComments();
await fetchComments();
} else {
// console.log(" :", response.data.message);
alert("댓글 삭제에 실패했습니다.");
@ -641,7 +641,7 @@ const handleSubmitEdit = async (comment, editedContent) => {
//
comment.content = editedContent;
comment.isEditTextarea = false;
comment.isEditTextarea = false;
} catch (error) {
console.error("댓글 수정 중 오류 발생:", error);
}

View File

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