휴가 기능오류수정
This commit is contained in:
parent
6e161fc2b3
commit
10c429f9f1
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="isOpen" class="vac-modal-dialog" @click.self="closeModal">
|
<div v-if="isOpen" class="vac-modal-dialog" @click.self="closeModal">
|
||||||
<div class="vac-modal-content p-5 modal-scroll">
|
<div class="vac-modal-content p-5 modal-scroll">
|
||||||
<h5 class="vac-modal-title">📅 내 연차 상세 내역</h5>
|
<h5 class="vac-modal-title">📅 내 연차 내역</h5>
|
||||||
<button class="close-btn" @click="closeModal">✖</button>
|
<button class="close-btn" @click="closeModal">✖</button>
|
||||||
<!-- 연차 목록 -->
|
<!-- 연차 목록 -->
|
||||||
<div class="vac-modal-body" v-if="mergedVacations.length > 0">
|
<div class="vac-modal-body" v-if="mergedVacations.length > 0">
|
||||||
@ -59,16 +59,15 @@ const emit = defineEmits(["close"]);
|
|||||||
let globalCounter = 0;
|
let globalCounter = 0;
|
||||||
const usedVacations = computed(() => {
|
const usedVacations = computed(() => {
|
||||||
return props.myVacations.flatMap((v) => {
|
return props.myVacations.flatMap((v) => {
|
||||||
const count = v.used_quota || 1;
|
const count = v.used_quota || 1; // 사용한 휴가 개수
|
||||||
return Array.from({ length: count }, (_, i) => ({
|
return Array.from({ length: count }, (_, i) => ({
|
||||||
...v,
|
...v,
|
||||||
category: "used",
|
category: "used",
|
||||||
code: v.LOCVACTYP,
|
used_quota: 1, // 개별적인 휴가로 나누기 위해 1로 설정
|
||||||
_expandIndex: globalCounter++,
|
_expandIndex: globalCounter++,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 받은 휴가
|
// 받은 휴가
|
||||||
const receivedVacations = computed(() =>
|
const receivedVacations = computed(() =>
|
||||||
props.receivedVacations.map((v) => ({
|
props.receivedVacations.map((v) => ({
|
||||||
|
|||||||
@ -383,19 +383,14 @@ async function fetchVacationHistory(year) {
|
|||||||
try {
|
try {
|
||||||
const response = await axios.get(`vacation/history?year=${year}`);
|
const response = await axios.get(`vacation/history?year=${year}`);
|
||||||
if (response.status === 200 && response.data) {
|
if (response.status === 200 && response.data) {
|
||||||
const newVacations = response.data.data.usedVacations || [];
|
myVacations.value = response.data.data.usedVacations || [];
|
||||||
|
receivedVacations.value = response.data.data.receivedVacations || [];
|
||||||
const uniqueVacations = Array.from(
|
|
||||||
new Map([...myVacations.value, ...newVacations].map(v => [`${v.date}-${v.type}`, v]))
|
|
||||||
.values()
|
|
||||||
);
|
|
||||||
|
|
||||||
myVacations.value = uniqueVacations;
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`🚨 ${year}년 휴가 데이터 불러오기 실패:`, error);
|
console.error(`🚨 휴가 데이터 불러오기 실패:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 모든 사원 연차 내역 및 그래프화
|
// 모든 사원 연차 내역 및 그래프화
|
||||||
async function fetchVacationData(year, month) {
|
async function fetchVacationData(year, month) {
|
||||||
try {
|
try {
|
||||||
@ -404,7 +399,7 @@ async function fetchVacationData(year, month) {
|
|||||||
const vacationList = response.data;
|
const vacationList = response.data;
|
||||||
// 회원 정보가 없거나 색상 정보가 없는 데이터는 제외
|
// 회원 정보가 없거나 색상 정보가 없는 데이터는 제외
|
||||||
const filteredVacations = vacationList.filter(vac =>
|
const filteredVacations = vacationList.filter(vac =>
|
||||||
userColors.value[vac.MEMBERSEQ] && userColors.value[vac.MEMBERSEQ]
|
userColors.value[vac.MEMBERSEQ] && userColors.value[vac.MEMBERSEQ] && !vac.LOCVACRMM
|
||||||
);
|
);
|
||||||
const events = filteredVacations.map(vac => {
|
const events = filteredVacations.map(vac => {
|
||||||
let dateStr = vac.LOCVACUDT ? vac.LOCVACUDT.split("T")[0] : "";
|
let dateStr = vac.LOCVACUDT ? vac.LOCVACUDT.split("T")[0] : "";
|
||||||
@ -439,14 +434,12 @@ function updateCalendarEvents() {
|
|||||||
display: "background",
|
display: "background",
|
||||||
classNames: [getVacationTypeClass(type), "selected-event"]
|
classNames: [getVacationTypeClass(type), "selected-event"]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// 기존 이벤트 중 receiverId가 있는 것은 제외
|
||||||
const filteredFetchedEvents = fetchedEvents.value.filter(event => {
|
const filteredFetchedEvents = fetchedEvents.value.filter(event => {
|
||||||
if (event.saved && selectedDates.value.get(event.start) === "delete") {
|
return !(event.receiverId && event.memberSeq === userStore.user.id);
|
||||||
if (event.memberSeq === userStore.user.id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
calendarEvents.value = [...filteredFetchedEvents, ...selectedEvents];
|
calendarEvents.value = [...filteredFetchedEvents, ...selectedEvents];
|
||||||
}
|
}
|
||||||
// 휴가 종류에 따른 클래스명
|
// 휴가 종류에 따른 클래스명
|
||||||
@ -484,7 +477,6 @@ function toggleHalfDay(type) {
|
|||||||
/* 페이지 이동 시 변경 사항 확인 */
|
/* 페이지 이동 시 변경 사항 확인 */
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
if (hasChanges.value) {
|
if (hasChanges.value) {
|
||||||
console.log('휴가!!!!!');
|
|
||||||
const answer = window.confirm("저장하지 않은 변경 사항이 있습니다. 이동하시겠습니까?");
|
const answer = window.confirm("저장하지 않은 변경 사항이 있습니다. 이동하시겠습니까?");
|
||||||
if (!answer) {
|
if (!answer) {
|
||||||
return next(false);
|
return next(false);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user