휴가 -3개이상 사용 x
This commit is contained in:
parent
ef1f366ce2
commit
b25d6758de
@ -48,7 +48,6 @@ const myRemainingQuota = computed(() => {
|
|||||||
const isGiftButtonDisabled = computed(() => {
|
const isGiftButtonDisabled = computed(() => {
|
||||||
return myRemainingQuota.value <= 0;
|
return myRemainingQuota.value <= 0;
|
||||||
});
|
});
|
||||||
console.log(myRemainingQuota.value)
|
|
||||||
// 사원 별 남은 보내기 개수
|
// 사원 별 남은 보내기 개수
|
||||||
const fetchSentVacationCount = async () => {
|
const fetchSentVacationCount = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -179,6 +179,46 @@ function handleMonthChange(viewInfo) {
|
|||||||
const month = String(currentDate.getMonth() + 1).padStart(2, "0");
|
const month = String(currentDate.getMonth() + 1).padStart(2, "0");
|
||||||
loadCalendarData(year, month);
|
loadCalendarData(year, month);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 반차/연차 가중치 계산 함수
|
||||||
|
const getVacationWeight = (type) => {
|
||||||
|
if (type === "700101" || type === "700102") return 0.5;
|
||||||
|
if (type === "700103") return 1;
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 연차 계산 결과
|
||||||
|
const vacationUsageInfo = computed(() => {
|
||||||
|
const myId = userStore.user.id;
|
||||||
|
const myRemaining = remainingVacationData.value[myId] ?? 0;
|
||||||
|
|
||||||
|
let addAmount = 0;
|
||||||
|
let deleteAmount = 0;
|
||||||
|
|
||||||
|
for (const [date, type] of selectedDates.value.entries()) {
|
||||||
|
if (type === "delete") {
|
||||||
|
// 과거 휴가에서 삭제되는 항목은 복구 대상
|
||||||
|
const matched = myVacations.value.find(
|
||||||
|
(v) => v.date.split("T")[0] === date && !v.receiverId
|
||||||
|
);
|
||||||
|
if (matched) {
|
||||||
|
deleteAmount += getVacationWeight(matched.type);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addAmount += getVacationWeight(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const netQuota = myRemaining - addAmount + deleteAmount;
|
||||||
|
|
||||||
|
return {
|
||||||
|
myRemaining,
|
||||||
|
addAmount,
|
||||||
|
deleteAmount,
|
||||||
|
netQuota
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
// 캘린더 클릭
|
// 캘린더 클릭
|
||||||
function handleDateClick(info) {
|
function handleDateClick(info) {
|
||||||
if (!info.date || !info.dateStr) {
|
if (!info.date || !info.dateStr) {
|
||||||
@ -221,6 +261,22 @@ function handleDateClick(info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 새로 클릭 시 연차 초과 여부 검사
|
||||||
|
const upcomingType = halfDayType.value === "AM" ? "700101"
|
||||||
|
: halfDayType.value === "PM" ? "700102"
|
||||||
|
: "700103";
|
||||||
|
const upcomingWeight = getVacationWeight(upcomingType);
|
||||||
|
const isAddingNew = !selectedDates.value.has(clickedDateStr) && !isMyVacation;
|
||||||
|
|
||||||
|
if (isAddingNew) {
|
||||||
|
const projectedQuota = vacationUsageInfo.value.netQuota - upcomingWeight;
|
||||||
|
|
||||||
|
if (projectedQuota < -3) {
|
||||||
|
toastStore.onToast("연차를 더 이상 선택할 수 없습니다.", "e");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 이미 활성화된 날짜를 한 번 더 클릭하면 비활성화
|
// 이미 활성화된 날짜를 한 번 더 클릭하면 비활성화
|
||||||
if (currentValue && currentValue !== "delete") {
|
if (currentValue && currentValue !== "delete") {
|
||||||
selectedDates.value.delete(clickedDateStr);
|
selectedDates.value.delete(clickedDateStr);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user