This commit is contained in:
parent
00acd58995
commit
f2ad06756b
@ -182,66 +182,72 @@ const handleSizeChange = () => {
|
|||||||
|
|
||||||
// 일반 게시물 데이터 로드
|
// 일반 게시물 데이터 로드
|
||||||
const fetchGeneralPosts = async (page = 1) => {
|
const fetchGeneralPosts = async (page = 1) => {
|
||||||
const { data } = await axios.get("board/general", {
|
try {
|
||||||
params: {
|
const { data } = await axios.get("board/general", {
|
||||||
page,
|
params: {
|
||||||
size: selectedSize.value,
|
page,
|
||||||
orderBy: selectedOrder.value,
|
size: selectedSize.value,
|
||||||
searchKeyword: searchText.value
|
orderBy: selectedOrder.value,
|
||||||
|
searchKeyword: searchText.value
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data?.data) {
|
||||||
|
const totalPosts = data.data.total;
|
||||||
|
generalList.value = data.data.list.map((post, index) => ({
|
||||||
|
realId: post.id,
|
||||||
|
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,
|
||||||
|
img: post.firstImageUrl || null,
|
||||||
|
commentCount : post.commentCount
|
||||||
|
}));
|
||||||
|
|
||||||
|
pagination.value = {
|
||||||
|
...pagination.value,
|
||||||
|
currentPage: data.data.pageNum,
|
||||||
|
pages: data.data.pages,
|
||||||
|
prePage: data.data.prePage,
|
||||||
|
nextPage: data.data.nextPage,
|
||||||
|
isFirstPage: data.data.isFirstPage,
|
||||||
|
isLastPage: data.data.isLastPage,
|
||||||
|
hasPreviousPage: data.data.hasPreviousPage,
|
||||||
|
hasNextPage: data.data.hasNextPage,
|
||||||
|
navigatePages: data.data.navigatePages,
|
||||||
|
navigatepageNums: data.data.navigatepageNums,
|
||||||
|
navigateFirstPage: data.data.navigateFirstPage,
|
||||||
|
navigateLastPage: data.data.navigateLastPage
|
||||||
|
};
|
||||||
}
|
}
|
||||||
});
|
} catch (error) {
|
||||||
|
|
||||||
if (data?.data) {
|
|
||||||
const totalPosts = data.data.total;
|
|
||||||
generalList.value = data.data.list.map((post, index) => ({
|
|
||||||
realId: post.id,
|
|
||||||
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,
|
|
||||||
img: post.firstImageUrl || null,
|
|
||||||
commentCount : post.commentCount
|
|
||||||
}));
|
|
||||||
|
|
||||||
pagination.value = {
|
|
||||||
...pagination.value,
|
|
||||||
currentPage: data.data.pageNum,
|
|
||||||
pages: data.data.pages,
|
|
||||||
prePage: data.data.prePage,
|
|
||||||
nextPage: data.data.nextPage,
|
|
||||||
isFirstPage: data.data.isFirstPage,
|
|
||||||
isLastPage: data.data.isLastPage,
|
|
||||||
hasPreviousPage: data.data.hasPreviousPage,
|
|
||||||
hasNextPage: data.data.hasNextPage,
|
|
||||||
navigatePages: data.data.navigatePages,
|
|
||||||
navigatepageNums: data.data.navigatepageNums,
|
|
||||||
navigateFirstPage: data.data.navigateFirstPage,
|
|
||||||
navigateLastPage: data.data.navigateLastPage
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 공지사항 데이터 로드
|
// 공지사항 데이터 로드
|
||||||
const fetchNoticePosts = async () => {
|
const fetchNoticePosts = async () => {
|
||||||
const { data } = await axios.get("board/notices", {
|
try {
|
||||||
params: { searchKeyword: searchText.value }
|
const { data } = await axios.get("board/notices", {
|
||||||
});
|
params: { searchKeyword: searchText.value }
|
||||||
|
});
|
||||||
|
|
||||||
if (data?.data) {
|
if (data?.data) {
|
||||||
noticeList.value = data.data.map(post => ({
|
noticeList.value = data.data.map(post => ({
|
||||||
id: post.id,
|
id: post.id,
|
||||||
title: post.title,
|
title: post.title,
|
||||||
author: post.author || '관리자',
|
author: post.author || '관리자',
|
||||||
date: formatDate(post.date),
|
date: formatDate(post.date),
|
||||||
rawDate: post.date,
|
rawDate: post.date,
|
||||||
views: post.cnt || 0,
|
views: post.cnt || 0,
|
||||||
hasAttachment: post.hasAttachment,
|
hasAttachment: post.hasAttachment,
|
||||||
img: post.firstImageUrl || null,
|
img: post.firstImageUrl || null,
|
||||||
commentCount : post.commentCount
|
commentCount : post.commentCount
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -264,21 +264,24 @@ async function loadCalendarData(year, month) {
|
|||||||
/* 프로필 구역 */
|
/* 프로필 구역 */
|
||||||
// 프로필 클릭 시 모달 열기
|
// 프로필 클릭 시 모달 열기
|
||||||
const handleProfileClick = async (user) => {
|
const handleProfileClick = async (user) => {
|
||||||
if (isModalOpen.value && user.MEMBERSEQ === userStore.user.id) {
|
try {
|
||||||
return;
|
if (isModalOpen.value && user.MEMBERSEQ === userStore.user.id) {
|
||||||
}
|
return;
|
||||||
if (isGrantModalOpen.value && selectedUser.value?.MEMBERSEQ === user.MEMBERSEQ) {
|
}
|
||||||
return;
|
if (isGrantModalOpen.value && selectedUser.value?.MEMBERSEQ === user.MEMBERSEQ) {
|
||||||
}
|
return;
|
||||||
isModalOpen.value = false;
|
}
|
||||||
isGrantModalOpen.value = false;
|
isModalOpen.value = false;
|
||||||
if (user.MEMBERSEQ === userStore.user.id) {
|
isGrantModalOpen.value = false;
|
||||||
const displayedYear = lastRemainingYear.value;
|
if (user.MEMBERSEQ === userStore.user.id) {
|
||||||
await fetchVacationHistory(displayedYear);
|
const displayedYear = lastRemainingYear.value;
|
||||||
isModalOpen.value = true;
|
await fetchVacationHistory(displayedYear);
|
||||||
} else {
|
isModalOpen.value = true;
|
||||||
selectedUser.value = user;
|
} else {
|
||||||
isGrantModalOpen.value = true;
|
selectedUser.value = user;
|
||||||
|
isGrantModalOpen.value = true;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 프로필 사원 리스트
|
// 프로필 사원 리스트
|
||||||
@ -300,17 +303,19 @@ const fetchUserList = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("📌 사용자 목록 불러오기 오류:", error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 사원별 남은 연차 개수
|
// 사원별 남은 연차 개수
|
||||||
const fetchRemainingVacation = async () => {
|
const fetchRemainingVacation = async () => {
|
||||||
const response = await axios.get("vacation/remaining");
|
try {
|
||||||
if (response.status === 200) {
|
const response = await axios.get("vacation/remaining");
|
||||||
remainingVacationData.value = response.data.data.reduce((acc, vacation) => {
|
if (response.status === 200) {
|
||||||
acc[vacation.employeeId] = vacation.remainingQuota;
|
remainingVacationData.value = response.data.data.reduce((acc, vacation) => {
|
||||||
return acc;
|
acc[vacation.employeeId] = vacation.remainingQuota;
|
||||||
}, {});
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 로그인한 사원이 사용한 휴가 필터링
|
// 로그인한 사원이 사용한 휴가 필터링
|
||||||
@ -403,42 +408,46 @@ async function saveVacationChanges() {
|
|||||||
/* 휴가 조회 */
|
/* 휴가 조회 */
|
||||||
// 로그인 사용자의 연차 사용 내역
|
// 로그인 사용자의 연차 사용 내역
|
||||||
async function fetchVacationHistory(year) {
|
async function fetchVacationHistory(year) {
|
||||||
const response = await axios.get(`vacation/history?year=${year}`);
|
try {
|
||||||
if (response.status === 200 && response.data) {
|
const response = await axios.get(`vacation/history?year=${year}`);
|
||||||
myVacations.value = response.data.data.usedVacations || [];
|
if (response.status === 200 && response.data) {
|
||||||
receivedVacations.value = response.data.data.receivedVacations || []
|
myVacations.value = response.data.data.usedVacations || [];
|
||||||
|
receivedVacations.value = response.data.data.receivedVacations || []
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 모든 사원 연차 내역 및 그래프화
|
// 모든 사원 연차 내역 및 그래프화
|
||||||
async function fetchVacationData(year, month) {
|
async function fetchVacationData(year, month) {
|
||||||
|
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 filteredVacations = vacationList.filter(vac =>
|
const filteredVacations = vacationList.filter(vac =>
|
||||||
userColors.value[vac.MEMBERSEQ] && userColors.value[vac.MEMBERSEQ] && !vac.LOCVACRMM
|
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] : "";
|
||||||
let backgroundColor = userColors.value[vac.MEMBERSEQ];
|
let backgroundColor = userColors.value[vac.MEMBERSEQ];
|
||||||
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: true,
|
||||||
memberSeq: vac.MEMBERSEQ,
|
memberSeq: vac.MEMBERSEQ,
|
||||||
};
|
};
|
||||||
}).filter(event => event.start);
|
}).filter(event => event.start);
|
||||||
return events;
|
return events;
|
||||||
} else {
|
} else {
|
||||||
console.warn("📌 휴가 데이터를 불러오지 못함");
|
console.warn("📌 휴가 데이터를 불러오지 못함");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 캘린더 이벤트 업데이트
|
// 캘린더 이벤트 업데이트
|
||||||
function updateCalendarEvents() {
|
function updateCalendarEvents() {
|
||||||
const selectedEvents = Array.from(selectedDates.value)
|
const selectedEvents = Array.from(selectedDates.value)
|
||||||
@ -499,14 +508,17 @@ const getVacationTypeClass = (type) => {
|
|||||||
};
|
};
|
||||||
// 휴가종류
|
// 휴가종류
|
||||||
const fetchVacationCodes = async () => {
|
const fetchVacationCodes = async () => {
|
||||||
const response = await axios.get("vacation/codes");
|
try {
|
||||||
if (response.status === 200 && response.data) {
|
const response = await axios.get("vacation/codes");
|
||||||
vacationCodeMap.value = response.data.data.reduce((acc, item) => {
|
if (response.status === 200 && response.data) {
|
||||||
acc[item.code] = item.name;
|
vacationCodeMap.value = response.data.data.reduce((acc, item) => {
|
||||||
return acc;
|
acc[item.code] = item.name;
|
||||||
}, {});
|
return acc;
|
||||||
} else {
|
}, {});
|
||||||
console.warn("❌ 공통 코드 데이터를 불러오지 못했습니다.");
|
} else {
|
||||||
|
console.warn("❌ 공통 코드 데이터를 불러오지 못했습니다.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const getVacationType = (typeCode) => {
|
const getVacationType = (typeCode) => {
|
||||||
@ -548,7 +560,7 @@ watch(() => lastRemainingYear.value, async (newYear, oldYear) => {
|
|||||||
await fetchVacationHistory(newYear);
|
await fetchVacationHistory(newYear);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 새로운 휴가 추가 시 반차 버튼 초기화
|
// 새로운 휴가추가 시 반차 버튼 초기화
|
||||||
watch(
|
watch(
|
||||||
() => Array.from(selectedDates.value.keys()), // 선택된 날짜 리스트 감시
|
() => Array.from(selectedDates.value.keys()), // 선택된 날짜 리스트 감시
|
||||||
(newKeys) => {
|
(newKeys) => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user