jichoi / lms_front star
이은진 이은진 2024-08-14
240814 이은진 학습일정 머지
@6af4f9942c74054b38309f0870e31ca078eb6ce5
client/views/pages/main/MyPlan.vue
--- client/views/pages/main/MyPlan.vue
+++ client/views/pages/main/MyPlan.vue
@@ -1,12 +1,13 @@
 <template>
+
     <div class="main">
         <div class="myplan">
             <div class="title-box flex justify-between mb40">
                 <p class="title">오늘 공부할 내용을 확인해봅시다.</p>
             </div>
-            <div class="wrap" style="border-radius: 0; min-height: 197px;"> 
+            <div class="wrap" style="border-radius: 0; min-height: 197px;">
                 <p class="title1" v-if="!schedules || schedules.length === 0"> 오늘 학습할 내용이 없습니다.</p>
- 
+
                 <div class="flex-column" style="gap: 20px;" v-else v-for="(schedule, index) in schedules" :key="index">
                     <div class="flex justify-between align-center" style="gap: 70px;">
                         <div><img src="../../../resources/img/img217_22s.png" alt=""></div>
@@ -16,17 +17,27 @@
                                     <p class="title2">grade 3</p>
                                     <div class="flex align-center mb10" style="gap: 10px;">
                                         <p class="title2"><em class="gray-bd">{{ schedule.schdl_unit }}교시</em></p>
-                                        <p class="title1">{{ schedule.schedule_time }}</p> 
+                                        <p class="title1">{{ schedule.schedule_time }}</p>
                                     </div>
                                     <div class="title-box mb10">
-                                        <span class="title">{{schedule.unit_nm}}</span> 
+                                        <span class="title">{{ schedule.unit_nm }}</span>
                                     </div>
                                     <p class="title2">{{ schedule.book_nm }}</p>
+                                    <!-- <p class="title2">wirte a</p> -->
                                 </div>
-                                <div>
-                                    <p class="title" @click="goToPage('Dashboard', schedule.schdl_id)">바로가기</p>
-                                    <img src="../../../resources/img/img214_19s.png" alt=""></div>
-                                </div>
+                                <button v-if="schedule.finish == 'T'" type="button" title="바로가기" class="yellow-btn"
+                                    @click="goToPage('Dashboard')">
+                                    학습완료
+                                </button>
+                                <button v-else type="button" title="바로가기" class="yellow-btn"
+                                    @click="goToPage('Dashboard')">
+                                    바로가기
+                                </button>
+                                <div><img src="../../../resources/img/img214_19s.png" alt=""></div>
+                                <button type="button" class="popup-close-btn" @click="deleteSchedule(schedule.schdl_id)">
+                                    <svg-icon type="mdi" :path="mdiWindowClose" class="close-btn"></svg-icon>
+                                </button>
+                            </div>
                         </div>
                     </div>
                 </div>
@@ -38,7 +49,7 @@
                         <p class="title">오늘 공부를 계획해봅시다.</p>
                         <p class="title1 mt20"> 스스로 학습 일정을 바꿔볼까요?</p>
                     </div>
-                    <button type="button" title="바로가기" class="yellow-btn" @click="goToPage2('MyPlan2')">
+                    <button type="button" title="바로가기" class="yellow-btn" @click="goToPage('MyPlan2')">
                         바로가기
                     </button>
                 </div>
@@ -62,6 +73,7 @@
             </div>
         </div>
     </div>
+
 </template>
 
 <script>
@@ -87,51 +99,11 @@
                 { label: "5교시", time: "13:00 ~ 14:00", value: "5" },
                 { label: "6교시", time: "14:00 ~ 15:00", value: "6" },
             ],
-            
         }
     },
     methods: {
-        goToPage(page, scheduleId) {
-            const startScheduleIndex = this.schedules.findIndex(schedule => schedule.schdl_id === scheduleId);
-
-            if (startScheduleIndex === -1) {
-                console.error("해당 스케줄을 찾을 수 없습니다.");
-                return;
-            }
-
-            const updates = [];
-            const currentSchedule = this.schedules[startScheduleIndex];
-            if (currentSchedule.finish === null || currentSchedule.finish === "T") {
-                updates.push(
-                    axios.post("/schedule/scheduleUpdate.json", { scheduleId: currentSchedule.schdl_id, finish: "F" }, {
-                        headers: {
-                            "Content-Type": "application/json; charset=UTF-8",
-                        }
-                    })
-                );
-            }
-
-            for (let i = startScheduleIndex + 1; i < this.schedules.length; i++) {
-                const nextSchedule = this.schedules[i];
-                if (nextSchedule.finish === "T") {
-                    updates.push(
-                        axios.post("/schedule/scheduleUpdate.json", { scheduleId: nextSchedule.schdl_id, finish: "F" }, {
-                            headers: {
-                                "Content-Type": "application/json; charset=UTF-8",
-                            }
-                        })
-                    );
-                }
-            }
-
-            Promise.all(updates)
-                .then(() => {
-                    this.$router.push({ name: page });
-                })
-                .catch(error => {
-                    console.error("Error updating schedules:", error);
-                    alert("학습 계획을 업데이트하는 중 오류가 발생했습니다.");
-                });
+        goToPage(page) {
+            this.$router.push({ name: page });
         },
         showConfirm(type) {
             let message = '';
@@ -147,9 +119,6 @@
                 this.goBack();
             }
         },
-        goToPage2(page) {
-            this.$router.push({ name: page });
-        },
         closeModal() {
             this.showModal = false;
         },
@@ -159,8 +128,7 @@
         closeBtn() {
             this.searchOpen = false;
 
-        }, 
-        fetchSchedules() {
+        }, fetchSchedules() {
             axios.post("/schedule/selectSchedule.json", { stdId: this.stdId }, {
                 headers: {
                     "Content-Type": "application/json; charset=UTF-8",
@@ -180,6 +148,20 @@
                     console.error("fetchUnits - error:", error);
                     alert("단원 목록을 불러오는 중 오류가 발생했습니다.");
                 });
+        }, deleteSchedule(scheduleId){
+            axios.post("/schedule/scheduleDelete.json", { scheduleId: scheduleId }, {
+                headers: {
+                    "Content-Type": "application/json; charset=UTF-8",
+                }
+            })
+                .then(response => {
+                    alert("학습일정이 삭제되었습니다.")
+                    window.location.reload();
+                })
+                .catch(error => {
+                    console.error("fetchUnits - error:", error);
+                    alert("단원 목록을 불러오는 중 오류가 발생했습니다.");
+                });
         }
     },
     watch: {
Add a comment
List