휴가 -3개이상 사용 x

This commit is contained in:
dyhj625 2025-03-27 10:30:15 +09:00
parent ef1f366ce2
commit b25d6758de
2 changed files with 56 additions and 1 deletions

View File

@ -48,7 +48,6 @@ const myRemainingQuota = computed(() => {
const isGiftButtonDisabled = computed(() => {
return myRemainingQuota.value <= 0;
});
console.log(myRemainingQuota.value)
//
const fetchSentVacationCount = async () => {
try {

View File

@ -179,6 +179,46 @@ function handleMonthChange(viewInfo) {
const month = String(currentDate.getMonth() + 1).padStart(2, "0");
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) {
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") {
selectedDates.value.delete(clickedDateStr);