jichoi / lms_front star
구자현 구자현 08-20
240820 구자현 Dashboard 수정
@245df787265c155599dfa4390ec3a7e77cb69af5
client/views/pages/main/Dashboard.vue
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
@@ -23,7 +23,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[1] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[1] ? 'block' : 'none' }">
                         </button>
-                        <p>지문1</p>
+                        <p>{{ labeledItems[0] }}</p>
                     </div>
                     <div class="race-btn" @click="goToPage('Chapter2')">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
@@ -33,7 +33,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[2] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[2] ? 'block' : 'none' }">
                         </button>
-                        <p>단어장</p>
+                        <p>{{ labeledItems[1] }}</p>
                     </div>
                 </div>
                 <div class="lcon flex justify-between mb5">
@@ -45,7 +45,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[7] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[7] ? 'block' : 'none' }">
                         </button>
-                        <p>문제1</p>
+                        <p>{{ labeledItems[6] }}</p>
                     </div>
                     <div class="race-btn" @click="goToPage('Chapter6')">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
@@ -55,7 +55,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[6] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[6] ? 'block' : 'none' }">
                         </button>
-                        <p>단어장</p>
+                        <p>{{ labeledItems[5] }}</p>
                     </div>
                     <div class="race-btn" @click="goToPage('Chapter2_8')">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
@@ -65,7 +65,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[5] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[5] ? 'block' : 'none' }">
                         </button>
-                        <p>지문2</p>
+                        <p>{{ labeledItems[4] }}</p>
                     </div>
                     <div class="race-btn" @click="goToPage('Chapter2_7')">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
@@ -75,7 +75,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[4] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[4] ? 'block' : 'none' }">
                         </button>
-                        <p>문제2</p>
+                        <p>{{ labeledItems[3] }}</p>
                     </div>
                     <div class="race-btn" @click="goToPage('Chapter2_8')">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
@@ -85,7 +85,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[3] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[3] ? 'block' : 'none' }">
                         </button>
-                        <p>문제1</p>
+                        <p>{{ labeledItems[2] }}</p>
                     </div>
                 </div>
                 <div class="rcon flex">
@@ -97,7 +97,7 @@
                             <img :src="item.imgSrc3" :style="{ display: !rabbitCompl[8] ? 'block' : 'none' }">
                             <img :src="item.imgSrc4" :style="{ display: rabbitCompl[8] ? 'block' : 'none' }">
                         </button>
-                        <p class="long">중간 평가</p>
+                        <p class="long">{{ labeledItems[7] }}</p>
                     </div>
                     <div class="race-btn" @click="goToPage('Chapter2_8')">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
@@ -107,7 +107,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[9] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[9] ? 'block' : 'none' }">
                         </button>
-                        <p>지문3</p>
+                        <p>{{ labeledItems[8] }}</p>
                     </div>
                     <div class="race-btn" @click="goToPage('Chapter10')">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
@@ -117,7 +117,7 @@
                             <img :src="item.imgSrc1" :style="{ display: !rabbitCompl[10] ? 'block' : 'none' }">
                             <img :src="item.imgSrc2" :style="{ display: rabbitCompl[10] ? 'block' : 'none' }">
                         </button>
-                        <p>단어장</p>
+                        <p>{{ labeledItems[9] }}</p>
                     </div>
 
                     <div class="race-btn" @click="goToPage('Chapter2_8')">
@@ -128,11 +128,8 @@
                             <img :src="item.imgSrc3" :style="{ display: !rabbitCompl[11] ? 'block' : 'none' }">
                             <img :src="item.imgSrc4" :style="{ display: rabbitCompl[11] ? 'block' : 'none' }">
                         </button>
-                        <p class="long">최종 평가</p>
+                        <p class="long">{{ labeledItems[10] }}</p>
                     </div>
-
-
-
                 </div>
                 <div class="race-btn">
                     <div class="rabbit-running" style="
@@ -380,6 +377,14 @@
                 bottomRight: { x: 0, y: 0 }
             },
             roadmapData: [],
+            labeledItems: [],
+            
+            problemCounter: 0,
+            wordCounter: 0,
+            textCounter: 0,
+            evalCounter: 0,
+            book_id: null,
+            unit_id: null,
 
             schedules: [],
             nowSchedule: "",
@@ -415,7 +420,7 @@
             else
                 this.rabbitPos[0] = true
         },
-        fetchSchedule() {
+        fetchSchedule(unit_id, book_id) {
             axios({
                 url: "/schedule/selectSchedule.json",
                 method: "post",
@@ -437,7 +442,7 @@
                     } else {
                         this.nowSchedule = this.schedules.find(schedule => schedule.finish === null || schedule.finish === "F");
                         if (this.nowSchedule) {
-                            this.fetchRoadmapData();
+                            this.fetchRoadmapData(unit_id, book_id);
                             this.state = 'studying';
                         } else {
                             this.state = 'notRegistered';
@@ -462,7 +467,7 @@
                     finish: "T"
                 }
             })
-                .then(response => {
+            .then(response => {
                     const nextSchedule = this.schedules.find(schedule => schedule.schdl_id > this.nowSchedule.schdl_id);
                     alert("학습을 완료했습니다!");
                     window.location.reload();
@@ -477,8 +482,7 @@
                     console.error("Error updating schedule:", error);
                 });
         },
-
-        fetchRoadmapData() {
+        fetchRoadmapData(unit_id, book_id) {
             axios({
                 url: "/unitLearning/find.json",
                 method: "post",
@@ -486,21 +490,22 @@
                     "Content-Type": "application/json; charset=UTF-8",
                 },
                 data: {
-                    unit_id: this.schedules[0].unit_id,
-                    book_id: this.schedules[0].book_id
+                    unit_id: unit_id,
+                    book_id: book_id
                 }
             })
-                .then(response => {
-                    if (response.data.length != 0) {
+            .then(response => {
+                if (response.data.length != 0) {
                         this.roadmapData = response.data;
-                    } else {
+                        this.labeledItems = this.processedRoadmap;
+                } else {
                         this.state = "noProblem"
-                    }
-                })
-                .catch(error => {
+                 }
+            })
+            .catch(error => {
                     this.state = "noProblem"
                     console.error("Error fetching roadmap data:", error);
-                });
+            });
         },
         toggleImage(index) {
             this.items[index].isSecondImageVisible = !this.items[index].isSecondImageVisible;
@@ -881,13 +886,6 @@
                 });
             };
         },
-        getNonNullColumn(item) {
-            if (item.prblm_id !== null) return '문제';
-            if (item.wd_book_id !== null) return '단어장';
-            if (item.text_id !== null) return '지문';
-            if (item.eval_id !== null) return '평가';
-            return '';
-        },
         showConfirm(type) {
             let message = '';
             if (type === 'cancel') {
@@ -907,12 +905,34 @@
         SvgIcon,
     },
     mounted() {
+        const { schdl_id, book_id, unit_id } = this.$route.query;
         console.log('main mounted');
-        this.fetchSchedule();
+        this.fetchSchedule(unit_id, book_id);
         this.fetchRabbit();
     },
-    computed() {
+    computed: {
+        processedRoadmap() {
+            let problemCounter = 0;
+            let wordCounter = 0;
+            let textCounter = 0;
+            let evalCounter = 0;
 
+            return this.roadmapData.map(item => {
+                if (item.wd_book_id !== null) {
+                    wordCounter++;
+                    return `단어장${wordCounter}`;
+                } else if (item.text_id !== null) {
+                    textCounter++;
+                    return `지문${textCounter}`;
+                } else if (item.eval_id !== null) {
+                    evalCounter++;
+                    return evalCounter === 1 ? '중간평가' : '최종평가';
+                } else {
+                    problemCounter++;
+                    return `문제${problemCounter}`;
+                }
+            });
+        }
     },
     beforeDestroy() {
         // 컴포넌트가 파괴되기 전에 리스너 제거
client/views/pages/main/MyPlan.vue
--- client/views/pages/main/MyPlan.vue
+++ client/views/pages/main/MyPlan.vue
@@ -105,46 +105,54 @@
     },
     methods: {
         goToPage(page, scheduleId) {
-            const startScheduleIndex = this.schedules.findIndex(schedule => schedule.schdl_id === scheduleId);
+        const startScheduleIndex = this.schedules.findIndex(schedule => schedule.schdl_id === scheduleId);
 
-            if (startScheduleIndex === -1) {
-                console.error("해당 스케줄을 찾을 수 없습니다.");
-                return;
-            }
+        if (startScheduleIndex === -1) {
+            console.error("해당 스케줄을 찾을 수 없습니다.");
+            return;
+        }
 
-            const updates = [];
-            const currentSchedule = this.schedules[startScheduleIndex];
-            if (currentSchedule.finish === null || currentSchedule.finish === "T") {
+        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: currentSchedule.schdl_id, finish: "F" }, {
+                    axios.post("/schedule/scheduleUpdate.json", { scheduleId: nextSchedule.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("학습 계획을 업데이트하는 중 오류가 발생했습니다.");
+        Promise.all(updates)
+            .then(() => {
+                const schedule = this.schedules[startScheduleIndex];
+                this.$router.push({ 
+                    name: page,
+                    query: {
+                        schdl_id: schedule.schdl_id,
+                        book_id: schedule.book_id,
+                        unit_id: schedule.unit_id
+                    }
                 });
+            })
+            .catch(error => {
+                console.error("Error updating schedules:", error);
+                alert("학습 계획을 업데이트하는 중 오류가 발생했습니다.");
+            });
         },
         goToPage2(page) {
             this.$router.push({ name: page });
client/views/pages/main/MyPlan2.vue
--- client/views/pages/main/MyPlan2.vue
+++ client/views/pages/main/MyPlan2.vue
@@ -5,7 +5,7 @@
                 <p class="title">오늘 공부를 계획해봅시다.</p>
             </div>
             <div class="wrap">
-                <p class="title1"> 학습 교재를 선택합시다.</p>
+                <p class="title1"> 학습 단원을 선택합시다.</p>
                 <div class="search-wrap flex justify-end mb20 mt20">
                     <input class="data-wrap" type="text" placeholder="검색하세요." v-model="keyword">
                     <button type="button" title="위원회 검색" @click="searchBook">
Add a comment
List