Merge remote-tracking branch 'origin/main' into wordDict

This commit is contained in:
Dang 2025-02-20 15:21:46 +09:00
commit 018d5fa4f9
5 changed files with 305 additions and 219 deletions

View File

@ -22,21 +22,21 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { defineEmits, ref } from "vue"; import { defineEmits, ref } from "vue";
const emit = defineEmits(["toggleHalfDay", "addVacationRequests"]); const emit = defineEmits(["toggleHalfDay", "addVacationRequests"]);
const halfDayType = ref(null); const halfDayType = ref(null);
const toggleHalfDay = (type) => { const toggleHalfDay = (type) => {
halfDayType.value = halfDayType.value === type ? null : type; halfDayType.value = halfDayType.value === type ? null : type;
emit("toggleHalfDay", halfDayType.value); emit("toggleHalfDay", halfDayType.value);
}; };
const addVacationRequests = () => { const addVacationRequests = () => {
emit("addVacationRequests"); emit("addVacationRequests");
}; };
</script> </script>
<style scoped> <style scoped>

View File

@ -68,12 +68,12 @@
{ {
date: new Date().toISOString().split("T")[0], date: new Date().toISOString().split("T")[0],
type: "700103", type: "700103",
senderId: props.targetUser.senderId,
receiverId: props.targetUser.MEMBERSEQ, receiverId: props.targetUser.MEMBERSEQ,
count: grantCount.value, count: grantCount.value,
}, },
]; ];
console.log(props.targetUser)
console.log(payload)
const response = await axios.post("vacation", payload); const response = await axios.post("vacation", payload);
console.log(response) console.log(response)
if (response.data && response.data.status === "OK") { if (response.data && response.data.status === "OK") {

View File

@ -1,116 +1,164 @@
<template> <template>
<div v-if="isOpen" class="modal-dialog" @click.self="closeModal"> <div v-if="isOpen" class="modal-dialog" @click.self="closeModal">
<div class="modal-content modal-scroll"> <div class="modal-content modal-scroll">
<h5 class="modal-title">📅 연차 사용 내역</h5> <h5 class="modal-title">📅 연차 사용 내역</h5>
<button class="close-btn" @click="closeModal"></button> <button class="close-btn" @click="closeModal"></button>
<!-- 연차 사용 받은 연차 리스트 --> <!-- 연차 목록 -->
<div class="modal-body" v-if="mergedVacations.length > 0"> <div class="modal-body" v-if="mergedVacations.length > 0">
<ol class="vacation-list"> <ol class="vacation-list">
<li v-for="(vacation, index) in mergedVacations" :key="index" class="vacation-item"> <li
<span v-if="vacation.type === 'used'" class="vacation-index"> v-for="(vac, index) in mergedVacations"
{{ getVacationIndex(index) }}) :key="vac._expandIndex"
</span> class="vacation-item"
<span :class="vacation.type === 'used' ? 'minus-symbol' : 'plus-symbol'"> >
{{ vacation.type === 'used' ? '-' : '+' }} <!-- Used 항목만 인덱스 표시 -->
</span> <span v-if="vac.category === 'used'" class="vacation-index">
<span {{ usedVacationIndexMap[vac._expandIndex] }})
:style="{ color: userColors[vacation.senderId || vacation.receiverId] || '#000' }" </span>
class="vacation-date"
>
{{ formatDate(vacation.date) }}
</span>
</li>
</ol>
</div>
<!-- 연차 데이터 없음 --> <span :class="vac.category === 'used' ? 'minus-symbol' : 'plus-symbol'">
<p v-if="mergedVacations.length === 0" class="no-data"> {{ vac.category === 'used' ? '-' : '+' }}
🚫 사용한 연차가 없습니다. </span>
</p>
<span
:style="{ color: userColors[vac.senderId || vac.receiverId] || '#000' }"
class="vacation-date"
>
{{ formatDate(vac.date) }}
</span>
</li>
</ol>
</div> </div>
<!-- 연차 데이터 없음 -->
<p v-else class="no-data">
🚫 사용한 연차가 없습니다.
</p>
</div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { defineProps, defineEmits, computed } from "vue"; import { defineProps, defineEmits, computed } from "vue";
const props = defineProps({ const props = defineProps({
isOpen: Boolean, isOpen: Boolean,
myVacations: { myVacations: {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
receivedVacations: { receivedVacations: {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
userColors: { userColors: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
}); });
const emit = defineEmits(["close"]); const emit = defineEmits(["close"]);
// + /**
const usedVacations = computed(() => * 1) Used 휴가를 used_quota만큼 펼치기
props.myVacations.map(v => ({ ...v, type: "used" })) * - category: "used"
); * - code: 휴가 코드(: LOCVACTYP)
* - _expandIndex: 항목마다 고유한 확장 인덱스 (누적 인덱스 매핑에 사용)
const receivedVacations = computed(() => */
props.receivedVacations.map(v => ({ ...v, type: "received" })) let globalCounter = 0; //
); const usedVacations = computed(() => {
const result = [];
// props.myVacations.forEach((v) => {
const mergedVacations = computed(() => { const count = v.used_quota || 1;
return [...usedVacations.value, ...receivedVacations.value].sort( for (let i = 0; i < count; i++) {
(a, b) => new Date(b.date) - new Date(a.date) result.push({
); ...v,
category: "used",
code: v.LOCVACTYP, // (700103 )
_expandIndex: globalCounter++,
});
}
});
return result;
}); });
// ( ) /**
const getVacationIndex = (index) => { * 2) Received 휴가: category: "received"
let count = 0; */
for (let i = 0; i <= index; i++) { const receivedVacations = computed(() =>
const v = mergedVacations.value[i]; props.receivedVacations.map((v) => ({
count += v.used_quota; // ...v,
} category: "received",
return count; }))
}; );
// (YYYY-MM-DD) /**
* 3) Used 휴가만 날짜 오름차순 정렬 누적 인덱스 계산
* - type === "700103"이면 +1
* - 외이면 +0.5
*/
const sortedUsedVacationsAsc = computed(() => {
return [...usedVacations.value].sort((a, b) => {
return new Date(a.date) - new Date(b.date) || (a._expandIndex - b._expandIndex);
});
});
const usedVacationIndexMap = computed(() => {
let cumulative = 0;
const map = {};
sortedUsedVacationsAsc.value.forEach((item) => {
const increment = item.type === "700103" ? 1 : 0.5;
cumulative += increment;
map[item._expandIndex] = cumulative;
});
return map;
});
/**
* 4) 최종 표시할 merged 리스트 (Used + Received)
* - 날짜 내림차순 정렬 (최신 과거)
*/
const mergedVacations = computed(() => {
const all = [...usedVacations.value, ...receivedVacations.value];
// +
all.sort((a, b) => {
const dateDiff = new Date(b.date) - new Date(a.date);
if (dateDiff !== 0) return dateDiff;
return b._expandIndex - a._expandIndex;
});
return all;
});
/** 날짜 포맷 (YYYY-MM-DD) */
const formatDate = (dateString) => { const formatDate = (dateString) => {
const date = new Date(dateString); if (!dateString) return "";
return date.toISOString().split("T")[0]; // YYYY-MM-DD // dateString "YYYY-MM-DD"
// "YYYY-MM-DD..." 10
return dateString.substring(0, 10);
}; };
/** 모달 닫기 */
const closeModal = () => { const closeModal = () => {
emit("close"); emit("close");
}; };
</script> </script>
<style scoped> <style scoped>
/* 모달 스타일 */ /* 모달 본문 */
.modal-dialog { .modal-content {
display: flex;
justify-content: center;
align-items: center;
}
/* 스크롤 가능한 모달 */
.modal-content {
max-height: 60vh;
overflow-y: auto;
padding: 20px;
width: 75%;
background: white; background: white;
border-radius: 8px; padding: 20px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); border-radius: 12px;
} width: 400px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.15);
text-align: center;
position: relative;
}
/* 닫기 버튼 */ /* 닫기 버튼 */
.close-btn { .close-btn {
position: absolute; position: absolute;
top: 10px; top: 10px;
right: 10px; right: 10px;
@ -118,18 +166,17 @@ const closeModal = () => {
border: none; border: none;
font-size: 18px; font-size: 18px;
cursor: pointer; cursor: pointer;
font-weight: bold; }
}
/* 리스트 기본 스타일 */ /* 리스트 기본 스타일 */
.vacation-list { .vacation-list {
list-style-type: none; list-style-type: none;
padding-left: 0; padding-left: 0;
margin-top: 15px; margin-top: 15px;
} }
/* 리스트 아이템 */ /* 리스트 아이템 */
.vacation-item { .vacation-item {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 16px; font-size: 16px;
@ -138,49 +185,41 @@ const closeModal = () => {
padding: 5px 10px; padding: 5px 10px;
border-radius: 5px; border-radius: 5px;
background: #f9f9f9; background: #f9f9f9;
} }
/* 인덱스 (연차 사용 개수) */ /* 인덱스 (연차 사용 개수) */
.vacation-index { .vacation-index {
font-weight: bold; font-weight: bold;
font-size: 16px; font-size: 16px;
margin-right: 8px; margin-right: 8px;
color: #333; color: #333;
} }
/* "-" 빨간색 */ /* "-" 빨간색 */
.minus-symbol { .minus-symbol {
color: red; color: red;
font-weight: bold; font-weight: bold;
margin-right: 8px; margin-right: 8px;
} }
/* "+" 파란색 */ /* "+" 파란색 */
.plus-symbol { .plus-symbol {
color: blue; color: blue;
font-weight: bold; font-weight: bold;
margin-right: 8px; margin-right: 8px;
} }
/* 날짜 스타일 */ /* 날짜 스타일 */
.vacation-date { .vacation-date {
font-size: 16px; font-size: 16px;
color: #333; color: #333;
} }
/* 연차 유형 스타일 */ /* 연차 데이터 없음 */
.vacation-type { .no-data {
font-size: 14px;
font-weight: normal;
color: gray;
margin-left: 5px;
}
/* 연차 데이터 없음 */
.no-data {
text-align: center; text-align: center;
font-size: 14px; font-size: 14px;
color: gray; color: gray;
margin-top: 10px; margin-top: 10px;
} }
</style> </style>

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="card-body d-flex justify-content-center"> <div class="card-body d-flex justify-content-center">
<ul class="list-unstyled d-flex align-items-center gap-3 mb-0 mt-2"> <ul class="list-unstyled d-flex align-items-center gap-5 mb-0 mt-2">
<li <li
v-for="(user, index) in sortedUserList" v-for="(user, index) in sortedUserList"
:key="index" :key="index"
@ -10,7 +10,7 @@
:aria-label="user.MEMBERSEQ" :aria-label="user.MEMBERSEQ"
> >
<img <img
class="rounded-circle user-avatar " class="rounded-circle"
:src="getUserProfileImage(user.MEMBERPRF)" :src="getUserProfileImage(user.MEMBERPRF)"
alt="user" alt="user"
:style="getDynamicStyle(user)" :style="getDynamicStyle(user)"
@ -96,10 +96,10 @@
const profileSize = computed(() => { const profileSize = computed(() => {
const totalUsers = userList.value.length; const totalUsers = userList.value.length;
if (totalUsers <= 7) return "120px"; // 7 if (totalUsers <= 7) return "100px"; // 7
if (totalUsers <= 10) return "100px"; // ~10 if (totalUsers <= 10) return "80px"; // ~10
if (totalUsers <= 20) return "80px"; // ~20 if (totalUsers <= 20) return "60px"; // ~20
return "60px"; // 20 return "40px"; // 20
}); });
// //

View File

@ -9,16 +9,16 @@
@profileClick="handleProfileClick" @profileClick="handleProfileClick"
:remainingVacationData="remainingVacationData" :remainingVacationData="remainingVacationData"
/> />
<div class="card-body"> <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="myVacations"
:receivedVacations="receivedVacations" :receivedVacations="receivedVacations"
:userColors="userColors" :userColors="userColors"
@click="handleProfileClick(user)"
@close="isModalOpen = false" @close="isModalOpen = false"
/> />
<VacationGrantModal <VacationGrantModal
v-if="isGrantModalOpen" v-if="isGrantModalOpen"
:isOpen="isGrantModalOpen" :isOpen="isGrantModalOpen"
@ -34,7 +34,7 @@
/> />
<HalfDayButtons <HalfDayButtons
@toggleHalfDay="toggleHalfDay" @toggleHalfDay="toggleHalfDay"
@addVacationRequests="addVacationRequests" @addVacationRequests="saveVacationChanges"
/> />
</div> </div>
</div> </div>
@ -99,7 +99,6 @@ const handleProfileClick = async (user) => {
if (user.MEMBERSEQ === userStore.user.id) { if (user.MEMBERSEQ === userStore.user.id) {
// //
const response = await axios.get(`vacation/history`); const response = await axios.get(`vacation/history`);
console.log(response)
if (response.status === 200 && response.data) { if (response.status === 200 && response.data) {
myVacations.value = response.data.data.usedVacations || []; myVacations.value = response.data.data.usedVacations || [];
@ -188,23 +187,28 @@ const getVacationType = (typeCode) => {
return vacationCodeMap.value[typeCode] || "기타"; return vacationCodeMap.value[typeCode] || "기타";
}; };
/**
* API 이벤트(fetchedEvents) 사용자가 선택한 날짜(selectedDates) 병합하여
* calendarEvents를 업데이트하는 함수
* - 선택 이벤트는 display: "background" 옵션을 사용하여 배경으로 표시
* - 선택된 타입에 따라 클래스(selected-am, selected-pm, selected-full) 부여함
*/
function updateCalendarEvents() { function updateCalendarEvents() {
const selectedEvents = Array.from(selectedDates.value).map(([date, type]) => { // ( ): type "delete"
return { const selectedEvents = Array.from(selectedDates.value)
title: getVacationType(type), .filter(([date, type]) => type !== "delete")
start: date, .map(([date, type]) => ({
backgroundColor: "rgba(0, 128, 0, 0.3)", title: getVacationType(type),
display: "background", start: date,
classNames: [getVacationTypeClass(type)], backgroundColor: "rgba(0, 128, 0, 0.3)",
}; display: "background",
}); classNames: [getVacationTypeClass(type)]
calendarEvents.value = [...fetchedEvents.value, ...selectedEvents]; }));
// ,
//
const filteredFetchedEvents = fetchedEvents.value.filter(event => {
if (event.saved) { // saved
return selectedDates.value.get(event.start) !== "delete";
}
return true;
});
calendarEvents.value = [...filteredFetchedEvents, ...selectedEvents];
} }
/** /**
@ -221,30 +225,46 @@ calendarEvents.value = [...fetchedEvents.value, ...selectedEvents];
* - 주말(, ) 공휴일은 클릭되지 않음 * - 주말(, ) 공휴일은 클릭되지 않음
* - 클릭 해당 날짜를 selectedDates에 추가 또는 제거한 updateCalendarEvents() 호출 * - 클릭 해당 날짜를 selectedDates에 추가 또는 제거한 updateCalendarEvents() 호출
*/ */
function handleDateClick(info) { function handleDateClick(info) {
const clickedDateStr = info.dateStr; const clickedDateStr = info.dateStr; // "YYYY-MM-DD"
const clickedDate = info.date; const clickedDate = info.date;
const todayStr = new Date().toISOString().split("T")[0];
// (:6, :0) // , ,
if (clickedDate.getDay() === 0 || clickedDate.getDay() === 6) { if (
clickedDate.getDay() === 0 ||
clickedDate.getDay() === 6 ||
holidayDates.value.has(clickedDateStr) ||
clickedDateStr < todayStr
) {
return; return;
} }
//
if (holidayDates.value.has(clickedDateStr)) { // :
return; if (selectedDates.value.has(clickedDateStr)) {
}
if (!selectedDates.value.has(clickedDateStr)) {
const type = halfDayType.value
? halfDayType.value === "AM"
? "700101"
: "700102"
: "700103";
selectedDates.value.set(clickedDateStr, type);
} else {
selectedDates.value.delete(clickedDateStr); selectedDates.value.delete(clickedDateStr);
} updateCalendarEvents();
halfDayType.value = null; return;
updateCalendarEvents(); }
// ( )
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);
}
halfDayType.value = null;
updateCalendarEvents();
} }
/** /**
@ -257,66 +277,93 @@ halfDayType.value = halfDayType.value === type ? null : type;
/** /**
* 백엔드에서 휴가 데이터를 가져와 이벤트로 변환 * 백엔드에서 휴가 데이터를 가져와 이벤트로 변환
*/ */
async function fetchVacationData(year, month) { 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;
const events = vacationList // ( )
myVacations.value = vacationList.filter(
(vac) => vac.MEMBERSEQ === userStore.user.id
);
// saved
const events = vacationList
.filter((vac) => !vac.LOCVACRMM) // ()
.map((vac) => { .map((vac) => {
let dateStr = vac.LOCVACUDT.split("T")[0]; let dateStr = vac.LOCVACUDT.split("T")[0];
let className = "fc-daygrid-event"; 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
};
}) })
.filter((event) => event !== null); .filter((event) => event !== null);
return events; return events;
} else { } else {
console.warn("📌 휴가 데이터를 불러오지 못함"); console.warn("📌 휴가 데이터를 불러오지 못함");
return []; return [];
} }
} catch (error) { } catch (error) {
console.error("Error fetching vacation data:", error); console.error("Error fetching vacation data:", error);
return []; return [];
} }
} }
/** /**
* 휴가 요청 추가 (선택된 날짜를 백엔드로 전송) * 휴가 요청 추가 (선택된 날짜를 백엔드로 전송)
*/ */
async function addVacationRequests() { async function saveVacationChanges() {
if (selectedDates.value.size === 0) { // : selectedDates type "delete"
alert("휴가를 선택해주세요."); const selectedDatesArray = Array.from(selectedDates.value);
return; const vacationsToAdd = selectedDatesArray
} .filter(([date, type]) => type !== "delete")
const vacationRequests = Array.from(selectedDates.value).map(([date, type]) => ({ .filter(([date, type]) =>
date, // , (LOCVACRMM)
type, !myVacations.value.some(vac => vac.LOCVACUDT.startsWith(date)) ||
})); myVacations.value.some(vac => vac.LOCVACUDT.startsWith(date) && vac.LOCVACRMM)
try { )
const response = await axios.post("vacation", vacationRequests); .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;
});
console.log("vacationsToAdd:", vacationsToAdd);
console.log("vacationsToDelete:", vacationsToDelete);
try {
const response = await axios.post("vacation/batchUpdate", {
add: vacationsToAdd,
delete: vacationsToDelete
});
if (response.data && response.data.status === "OK") { if (response.data && response.data.status === "OK") {
alert("휴가가 저장되었습니다."); alert("✅ 휴가 변경 사항이 저장되었습니다.");
await fetchRemainingVacation(); await fetchRemainingVacation();
// const currentDate = fullCalendarRef.value.getApi().getDate();
const currentDate = fullCalendarRef.value.getApi().getDate(); await loadCalendarData(currentDate.getFullYear(), currentDate.getMonth() + 1);
const year = currentDate.getFullYear(); // :
const month = String(currentDate.getMonth() + 1).padStart(2, "0"); selectedDates.value.clear();
loadCalendarData(year, month); updateCalendarEvents();
selectedDates.value.clear();
updateCalendarEvents();
} else { } else {
alert("휴가 저장 중 오류가 발생했습니다."); alert("❌ 휴가 저장 중 오류가 발생했습니다.");
} }
} catch (error) { } catch (error) {
console.error(error); console.error("🚨 휴가 변경 저장 실패:", error);
alert("휴가 저장에 실패했습니다."); alert("휴가 저장 요청에 실패했습니다.");
} }
} }
/** /**