diff --git a/.env.dev b/.env.dev new file mode 100644 index 0000000..99081c1 --- /dev/null +++ b/.env.dev @@ -0,0 +1,5 @@ +VITE_DOMAIN = http://localhost:5173/ +# VITE_LOGIN_URL = http://localhost:10325/ms/ +# VITE_FILE_URL = http://localhost:10325/ms/ +# VITE_API_URL = http://localhost:10325/api/ +VITE_API_URL = http://localhost:10325/test/ \ No newline at end of file diff --git a/public/css/custom.css b/public/css/custom.css index 9c4e7f6..85358e6 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -29,7 +29,6 @@ /* 휴가*/ - .half-day-buttons { display: flex; justify-content: center; @@ -95,8 +94,6 @@ text-align: left !important; } - /* userList */ - .grayscaleImg { filter: grayscale(100%); } diff --git a/src/common/axios-interceptor.js b/src/common/axios-interceptor.js index 05f3abd..a6ae5a1 100644 --- a/src/common/axios-interceptor.js +++ b/src/common/axios-interceptor.js @@ -1,12 +1,12 @@ -import axios from "axios"; +import axios from 'axios'; import { useRoute } from 'vue-router'; import { useToastStore } from '@s/toastStore'; const $api = axios.create({ baseURL: 'http://localhost:10325/api/', timeout: 300000, - withCredentials : true -}) + withCredentials: true, +}); /** * Default Content-Type : json @@ -14,7 +14,6 @@ const $api = axios.create({ */ $api.interceptors.request.use( function (config) { - let contentType = 'application/json'; if (config.isFormData) contentType = 'multipart/form-data'; @@ -23,21 +22,21 @@ $api.interceptors.request.use( config.headers['X-Requested-With'] = 'XMLHttpRequest'; return config; - }, function (error) { + }, + function (error) { // 요청 오류가 있는 작업 수행 return Promise.reject(error); - } + }, ); // 응답 인터셉터 추가하기 $api.interceptors.response.use( - function (response) { // 2xx 범위의 응답 처리 return response; }, function (error) { - const toastStore = useToastStore() + const toastStore = useToastStore(); const currentPage = error.config.headers['X-Page-Route']; // 오류 응답 처리 if (error.response) { @@ -70,7 +69,7 @@ $api.interceptors.response.use( } return Promise.reject(error); - } + }, ); export default $api; diff --git a/src/common/commonApi.js b/src/common/commonApi.js index 6049bd8..27a5a7f 100644 --- a/src/common/commonApi.js +++ b/src/common/commonApi.js @@ -29,7 +29,7 @@ const commonApi = (options = {}) => { onMounted(async () => { // 요청할 데이터가 옵션으로 전달 -> 그에 맞게 호출 - // color 옵션에 type 정보 포함 + // color 옵션에 type 포함 if (options.loadColor) { await CommonCode("user", "color", colorList, options.colorType); } diff --git a/src/components/board/BoardProfile.vue b/src/components/board/BoardProfile.vue index 7a4e538..5f77e63 100644 --- a/src/components/board/BoardProfile.vue +++ b/src/components/board/BoardProfile.vue @@ -25,22 +25,17 @@ -
- - - +
+
+ + +
+ {{ passwordAlert }}
@@ -71,6 +66,10 @@ import BoardRecommendBtn from '../button/BoardRecommendBtn.vue'; // Vue Router 인스턴스 const router = useRouter(); +const isPassword = ref(false); +const password = ref(''); +const passwordAlert = ref(false); +const lastClickedButton = ref(''); // Props 정의 const props = defineProps({ @@ -112,22 +111,14 @@ const props = defineProps({ } }); -const isPassword = ref(false); -const password = ref(''); -const lastClickedButton = ref(''); - -const boardId = 100; //수정필요! - const emit = defineEmits(['togglePasswordInput']); // 수정 버튼 const handleEdit = () => { - // router.push({ name: 'BoardEdit', params: { id: boardId } }); - if (props.unknown) { togglePassword('edit'); } else { - router.push({ name: 'BoardEdit', params: { id: 100 } }); // 로그인한 경우 바로 편집 + router.push({ name: 'BoardEdit', params: { id: props.boardId } }); } }; @@ -136,7 +127,7 @@ const handleDelete = () => { if (props.unknown) { togglePassword('delete'); } else { - deletePost(); // 로그인한 경우 바로 삭제 + deletePost(); } }; @@ -151,12 +142,11 @@ const togglePassword = (button) => { }; // 비밀번호 확인 -const handlePasswordSubmit = async () => { - isPassword.value = false; - lastClickedButton.value = null; - - console.log('비밀번호:', password.value); - console.log(props.boardId) +const handleSubmit = async () => { + if (!password.value) { + passwordAlert.value = '비밀번호를 입력해주세요.'; + return; + } try { const requestData = { @@ -164,47 +154,61 @@ const handlePasswordSubmit = async () => { LOCBRDSEQ: 288 } - console.log(requestData) - const postResponse = await axios.post(`board/${props.boardId}/password`, requestData); - console.log('post결과:', postResponse.data) + if (postResponse.data.code === 200) { + if (postResponse.data.data === true) { + isPassword.value = false; + - // if (response.data.code === 200 && response.data.data === true) { - // console.log("완료"); // 비밀번호가 맞으면 출력 - // } else { - // console.log("비밀번호가 틀립니다."); - // } + if (lastClickedButton.value === 'edit') { + router.push({ name: 'BoardEdit', params: { id: props.boardId } }); + } else if (lastClickedButton.value === 'delete') { + await deletePost(); + } + + lastClickedButton.value = null; + } else { + passwordAlert.value = '비밀번호가 일치하지 않습니다.'; + } + } else { + passwordAlert.value = '비밀번호가 일치하지 않습니다.'; + } } catch (error) { - console.error('비밀번호 확인 중 오류 발생:', error); + // 401 오류 + if (error.response && error.response.status === 401) { + passwordAlert.value = '비밀번호가 일치하지 않습니다.'; + } else if (error.response) { + alert(`오류 발생: ${error.response.data.message || '서버 오류'}`); + } else { + alert('네트워크 오류가 발생했습니다. 다시 시도해주세요.'); + } } }; const deletePost = async () => { if (confirm('정말 삭제하시겠습니까?')) { try { - await axios.delete(`board/100`); - alert('게시물이 삭제되었습니다.'); - router.push({ name: 'BoardList' }); + const response = await axios.delete(`board/${props.boardId}`, { + data: { LOCBRDSEQ: props.boardId } + }); + + if (response.data.code === 200) { + alert('게시물이 삭제되었습니다.'); + router.push({ name: 'BoardList' }); + } else { + alert('삭제 실패: ' + response.data.message); + } } catch (error) { - alert('삭제 중 오류 발생'); + if (error.response) { + alert(`삭제 실패: ${error.response.data.message || '서버 오류'}`); + } else { + alert('네트워크 오류가 발생했습니다. 다시 시도해주세요.'); + } } } }; -// const fetchBoardDetails = async () => { -// try { -// const response = await axios.get(`board/${props.boardId}`); -// console.log(response.data); -// } catch (error) { -// console.error('게시물 데이터 불러오기 오류:', error); -// } -// }; - -// onMounted(() => { -// // fetchBoardDetails(); -// }); - diff --git a/src/components/input/FormInputBtn.vue b/src/components/input/FormInputBtn.vue new file mode 100644 index 0000000..4e1a893 --- /dev/null +++ b/src/components/input/FormInputBtn.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/src/components/user/LoginForm.vue b/src/components/user/LoginForm.vue index b0a4082..258569d 100644 --- a/src/components/user/LoginForm.vue +++ b/src/components/user/LoginForm.vue @@ -1,13 +1,6 @@ - +/** + * 공휴일 데이터 요청 및 이벤트 변환 + */ +async function fetchHolidays(year, month) { +try { + const response = await axios.get(`vacation/${year}/${month}`); + const holidayEvents = response.data.map((holiday) => ({ + title: holiday.name, + start: holiday.date, // "YYYY-MM-DD" 형식 + backgroundColor: "#ff6666", + classNames: ["holiday-event"], + })); + return holidayEvents; +} catch (error) { + console.error("공휴일 정보를 불러오지 못했습니다.", error); + return []; +} +} + +/** + * 달력 월 변경 시 호출 (FullCalendar의 datesSet 옵션) + */ +function handleMonthChange(viewInfo) { +const currentDate = viewInfo.view.currentStart; +const year = currentDate.getFullYear(); +const month = String(currentDate.getMonth() + 1).padStart(2, "0"); +loadCalendarData(year, month); +} + +/** + * 지정한 월의 데이터를 로드 (휴가, 공휴일 데이터를 병렬 요청) + */ +async function loadCalendarData(year, month) { +fetchedEvents.value = []; +const [vacationEvents, holidayEvents] = await Promise.all([ + fetchVacationData(year, month), + fetchHolidays(year, month), +]); +// 클릭 불가 처리를 위해 공휴일 날짜 Set 업데이트 +holidayDates.value = new Set(holidayEvents.map((event) => event.start)); +fetchedEvents.value = [...vacationEvents, ...holidayEvents]; +updateCalendarEvents(); +await nextTick(); +fullCalendarRef.value.getApi().refetchEvents(); +} + +// 컴포넌트 마운트 시 현재 달의 데이터 로드 +onMounted(async () => { +await fetchUserList(); // 사용자 목록 먼저 불러오기 +const today = new Date(); +const year = today.getFullYear(); +const month = String(today.getMonth() + 1).padStart(2, "0"); +await loadCalendarData(year, month); +}); +