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

@ -10,11 +10,12 @@
: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"
/> />
@ -46,46 +47,47 @@
</template> </template>
<script setup> <script setup>
import { reactive, ref, onMounted, nextTick, computed } from "vue";
import axios from "@api";
import FullCalendar from "@fullcalendar/vue3"; import FullCalendar from "@fullcalendar/vue3";
import dayGridPlugin from "@fullcalendar/daygrid"; import dayGridPlugin from "@fullcalendar/daygrid";
import interactionPlugin from "@fullcalendar/interaction"; import interactionPlugin from "@fullcalendar/interaction";
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 { reactive, ref, onMounted, nextTick } from "vue";
import axios from "@api";
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 { useUserInfoStore } from "@s/useUserInfoStore";
import VacationGrantModal from "@c/modal/VacationGrantModal.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"; 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({});
// (YYYY-MM-DD ) ( )
const holidayDates = ref(new Set()); const holidayDates = ref(new Set());
const fetchedEvents = ref([]); // API (, ) const fetchedEvents = ref([]);
// FullCalendar (events calendarEvents )
const calendarOptions = reactive({ const calendarOptions = reactive({
plugins: [dayGridPlugin, interactionPlugin], plugins: [dayGridPlugin, interactionPlugin],
initialView: "dayGridMonth", initialView: "dayGridMonth",
@ -124,21 +126,21 @@ const fetchRemainingVacation = async () => {
const handleProfileClick = async (user) => { const handleProfileClick = async (user) => {
try { try {
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`);
if (response.status === 200 && response.data) { if (response.status === 200 && response.data) {
myVacations.value = response.data.data.usedVacations || []; myVacations.value = response.data.data.usedVacations || [];
receivedVacations.value = response.data.data.receivedVacations || []; receivedVacations.value = response.data.data.receivedVacations || [];
isModalOpen.value = true; // isModalOpen.value = true;
//
modalYear.value = new Date().getFullYear();
modalMonth.value = String(new Date().getMonth() + 1).padStart(2, "0");
isGrantModalOpen.value = false; isGrantModalOpen.value = false;
} else { } else {
console.warn("❌ 연차 내역을 불러오지 못했습니다."); console.warn("❌ 연차 내역을 불러오지 못했습니다.");
} }
} else { } else {
//
selectedUser.value = user; selectedUser.value = user;
isGrantModalOpen.value = true; // isGrantModalOpen.value = true;
isModalOpen.value = false; isModalOpen.value = false;
} }
} catch (error) { } catch (error) {
@ -150,12 +152,10 @@ const fetchUserList = async () => {
try { try {
await userListStore.fetchUserList(); await userListStore.fetchUserList();
userList.value = userListStore.userList; userList.value = userListStore.userList;
if (!userList.value.length) { if (!userList.value.length) {
console.warn("📌 사용자 목록이 비어 있음!"); console.warn("📌 사용자 목록이 비어 있음!");
return; return;
} }
userColors.value = {}; userColors.value = {};
userList.value.forEach((user) => { userList.value.forEach((user) => {
userColors.value[user.MEMBERSEQ] = user.usercolor || "#FFFFFF"; userColors.value[user.MEMBERSEQ] = user.usercolor || "#FFFFFF";
@ -169,9 +169,8 @@ const fetchVacationCodes = async () => {
try { try {
const response = await axios.get("vacation/codes"); const response = await axios.get("vacation/codes");
if (response.status === 200 && response.data) { if (response.status === 200 && response.data) {
//
vacationCodeMap.value = response.data.data.reduce((acc, item) => { vacationCodeMap.value = response.data.data.reduce((acc, item) => {
acc[item.code] = item.name; // code key, name value acc[item.code] = item.name;
return acc; return acc;
}, {}); }, {});
} else { } else {
@ -182,29 +181,47 @@ const fetchVacationCodes = async () => {
} }
}; };
// 🔹 typeCode code
const getVacationType = (typeCode) => { const getVacationType = (typeCode) => {
return vacationCodeMap.value[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() { function updateCalendarEvents() {
// ( ): type "delete"
const selectedEvents = Array.from(selectedDates.value) const selectedEvents = Array.from(selectedDates.value)
.filter(([date, type]) => type !== "delete") .filter(([date, type]) => type !== "delete")
.map(([date, type]) => ({ .map(([date, type]) => ({
title: getVacationType(type), title: getVacationType(type),
start: date, start: date,
backgroundColor: "rgb(113 212 243 / 76%)", backgroundColor: "rgb(113 212 243 / 76%)",
textColor: "#fff", // textColor: "#fff",
display: "background", display: "background",
classNames: [getVacationTypeClass(type), "selected-event"] classNames: [getVacationTypeClass(type), "selected-event"]
})); }));
// ,
//
const filteredFetchedEvents = fetchedEvents.value.filter(event => { const filteredFetchedEvents = fetchedEvents.value.filter(event => {
if (event.saved) { // saved if (event.saved) {
return selectedDates.value.get(event.start) !== "delete"; return selectedDates.value.get(event.start) !== "delete";
} }
return true; return true;
@ -212,26 +229,16 @@ function updateCalendarEvents() {
calendarEvents.value = [...filteredFetchedEvents, ...selectedEvents]; calendarEvents.value = [...filteredFetchedEvents, ...selectedEvents];
} }
/**
* 반차 유형에 따라 클래스명 지정 (색상 변경 없이 영역만 조정)
*/
const getVacationTypeClass = (type) => { const getVacationTypeClass = (type) => {
if (type === "700101") return "half-day-am"; // if (type === "700101") return "half-day-am";
if (type === "700102") return "half-day-pm"; // if (type === "700102") return "half-day-pm";
return "full-day"; // return "full-day";
}; };
/**
* 날짜 클릭 이벤트
* - 주말(, ) 공휴일은 클릭되지 않음
* - 클릭 해당 날짜를 selectedDates에 추가 또는 제거한 updateCalendarEvents() 호출
*/
function handleDateClick(info) { function handleDateClick(info) {
const clickedDateStr = info.dateStr; // "YYYY-MM-DD" const clickedDateStr = info.dateStr;
const clickedDate = info.date; const clickedDate = info.date;
const todayStr = new Date().toISOString().split("T")[0]; const todayStr = new Date().toISOString().split("T")[0];
// , ,
if ( if (
clickedDate.getDay() === 0 || clickedDate.getDay() === 0 ||
clickedDate.getDay() === 6 || clickedDate.getDay() === 6 ||
@ -240,68 +247,58 @@ function updateCalendarEvents() {
) { ) {
return; return;
} }
// :
if (selectedDates.value.has(clickedDateStr)) { if (selectedDates.value.has(clickedDateStr)) {
selectedDates.value.delete(clickedDateStr); selectedDates.value.delete(clickedDateStr);
updateCalendarEvents(); updateCalendarEvents();
return; return;
} }
// ( )
const unsentVacation = myVacations.value.find( const unsentVacation = myVacations.value.find(
(vac) => vac.LOCVACUDT && vac.LOCVACUDT.startsWith(clickedDateStr) && !vac.LOCVACRMM (vac) => vac.LOCVACUDT && vac.LOCVACUDT.startsWith(clickedDateStr) && !vac.LOCVACRMM
); );
if (unsentVacation) { if (unsentVacation) {
// , "delete" (, )
selectedDates.value.set(clickedDateStr, "delete"); selectedDates.value.set(clickedDateStr, "delete");
} else { } else {
// : halfDayType
const type = halfDayType.value const type = halfDayType.value
? (halfDayType.value === "AM" ? "700101" : "700102") ? (halfDayType.value === "AM" ? "700101" : "700102")
: "700103"; : "700103";
selectedDates.value.set(clickedDateStr, type); selectedDates.value.set(clickedDateStr, type);
} }
halfDayType.value = null; halfDayType.value = null;
updateCalendarEvents(); updateCalendarEvents();
} }
/**
* 오전/오후 반차 버튼 토글
*/
function toggleHalfDay(type) { function toggleHalfDay(type) {
halfDayType.value = halfDayType.value === type ? null : type; 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;
// ( ) // modalYear
if (modalYear.value !== year) {
myVacations.value = vacationList.filter( myVacations.value = vacationList.filter(
(vac) => vac.MEMBERSEQ === userStore.user.id (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,34 +310,25 @@ halfDayType.value = halfDayType.value === type ? null : type;
} }
} }
/**
* 휴가 요청 추가 (선택된 날짜를 백엔드로 전송)
*/
async function saveVacationChanges() { async function saveVacationChanges() {
// : selectedDates type "delete"
const selectedDatesArray = Array.from(selectedDates.value); const selectedDatesArray = Array.from(selectedDates.value);
const vacationsToAdd = selectedDatesArray const vacationsToAdd = selectedDatesArray
.filter(([date, type]) => type !== "delete") .filter(([date, type]) => type !== "delete")
.filter(([date, type]) => .filter(([date, type]) =>
// , (LOCVACRMM) !myVacations.value.some(vac => vac.LOCVACUDT && vac.LOCVACUDT.startsWith(date)) ||
!myVacations.value.some(vac => vac.LOCVACUDT.startsWith(date)) || myVacations.value.some(vac => vac.LOCVACUDT && vac.LOCVACUDT.startsWith(date) && vac.LOCVACRMM)
myVacations.value.some(vac => vac.LOCVACUDT.startsWith(date) && vac.LOCVACRMM)
) )
.map(([date, type]) => ({ date, type })); .map(([date, type]) => ({ date, type }));
// : ,
// "delete"
const vacationsToDelete = myVacations.value const vacationsToDelete = myVacations.value
.filter(vac => { .filter(vac => {
if (!vac.LOCVACUDT) return false;
const date = vac.LOCVACUDT.split("T")[0]; const date = vac.LOCVACUDT.split("T")[0];
// "delete"
return selectedDates.value.get(date) === "delete" && !vac.LOCVACRMM; return selectedDates.value.get(date) === "delete" && !vac.LOCVACRMM;
}) })
.map(vac => { .map(vac => {
const id = vac.LOCVACSEQ; const id = vac.LOCVACSEQ;
return typeof id === "number" ? Number(id) : id; return typeof id === "number" ? Number(id) : id;
}); });
try { try {
const response = await axios.post("vacation/batchUpdate", { const response = await axios.post("vacation/batchUpdate", {
add: vacationsToAdd, add: vacationsToAdd,
@ -351,7 +339,6 @@ halfDayType.value = halfDayType.value === type ? null : type;
await fetchRemainingVacation(); await fetchRemainingVacation();
const currentDate = fullCalendarRef.value.getApi().getDate(); const currentDate = fullCalendarRef.value.getApi().getDate();
await loadCalendarData(currentDate.getFullYear(), currentDate.getMonth() + 1); await loadCalendarData(currentDate.getFullYear(), currentDate.getMonth() + 1);
// :
selectedDates.value.clear(); selectedDates.value.clear();
updateCalendarEvents(); updateCalendarEvents();
} else { } else {
@ -363,9 +350,6 @@ halfDayType.value = halfDayType.value === type ? null : type;
} }
} }
/**
* 달력 변경 호출 (FullCalendar의 datesSet 옵션)
*/
function handleMonthChange(viewInfo) { function handleMonthChange(viewInfo) {
const currentDate = viewInfo.view.currentStart; const currentDate = viewInfo.view.currentStart;
const year = currentDate.getFullYear(); const year = currentDate.getFullYear();
@ -373,16 +357,16 @@ const month = String(currentDate.getMonth() + 1).padStart(2, "0");
loadCalendarData(year, month); loadCalendarData(year, month);
} }
/**
* 지정한 월의 데이터를 로드 (휴가, 공휴일 데이터를 병렬 요청)
*/
async function loadCalendarData(year, month) { async function loadCalendarData(year, month) {
if (lastRemainingYear.value !== year) {
await fetchRemainingVacation();
lastRemainingYear.value = year;
}
fetchedEvents.value = []; fetchedEvents.value = [];
const [vacationEvents, holidayEvents] = await Promise.all([ const [vacationEvents, holidayEvents] = await Promise.all([
fetchVacationData(year, month), fetchVacationData(year, month),
fetchHolidays(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();
@ -390,9 +374,8 @@ 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();
@ -402,5 +385,5 @@ await loadCalendarData(year, month);
</script> </script>
<style> <style>
/* 스타일 정의 */
</style> </style>