jichoi / lms_front star
woals 2024-08-22
240822 권민수 일단 대시보드에서 단어 컨텐츠 설정된대로 페이지 이동되도록 설정
@2410d421635cc95fd8b39a9c7bcc5550c73f5f1e
client/views/pages/main/Chapter/Chapter2.vue
--- client/views/pages/main/Chapter/Chapter2.vue
+++ client/views/pages/main/Chapter/Chapter2.vue
@@ -110,7 +110,7 @@
         })
         .catch((error) => {
           console.error("단어 컨텐츠 목록을 불러오는 중 오류 발생:", error);
-        })
+        });
     },
 
     async fetchWordList() {
client/views/pages/main/Dashboard.vue
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
@@ -27,7 +27,7 @@
                         </button>
                         <p>{{ labeledItems[0].label }}</p>
                     </div>
-                    <div class="race-btn" @click="[goToPage('Chapter2'), storeLearningId(labeledItems[1])]">
+                    <div class="race-btn" @click="[storeLearningId(labeledItems[1])]">
                         <div class="rabbit-running"><img src="../../../resources/img/img09_s.png" alt=""
                                 :style="{ display: rabbitPos[2] ? 'block' : 'none' }"></div>
                         <button class="popTxt" v-for="(item, index) in items" :key="index" @click="toggleImage(index)"
@@ -341,6 +341,8 @@
             isHeartFilled: false, // 하트가 채워졌는지 여부
 
             problemType: null,
+            wordBookType: null,
+            wordContentList: [],
         }
     },
     methods: {
@@ -588,13 +590,72 @@
             this.$router.push({ name: page });
         },
         storeLearningId(labeledItems) {
-            this.$store.dispatch('updateLearningData', labeledItems)
-            console.log("레이블된 아이템이라매: ", labeledItems);
+            this.$store.dispatch('updateLearningData', labeledItems);
+            this.$store.dispatch('updateLearningId', labeledItems.learning_id) // 단어장에 사용중..
+            console.log("레이블된 아이템: ", labeledItems);
             if (labeledItems.label.startsWith('문제')) {
                 this.handleProblemDetail(this.$store.getters.currentLearningId)
                 this.goToPage(this.problemType)
+            } else if (labeledItems.label.startsWith('단어장')) {
+                this.handleWordBookContent(this.$store.getters.getLearningId);
             }
         },
+        handleWordBookContent(item) {
+            console.log("처리할 단어장 콘텐츠 id: ", item);
+
+            // 단어장 ID 가져오기
+            axios.post("/wordContent/selectWordContent.json", {
+                wordContentId: item,
+            })
+            .then((response) => {
+                this.wordContentList = response.data;
+
+                // 단어장 ID 리스트에서 첫 번째 단어장 ID를 사용
+                const wdBookId = this.wordContentList[0].wd_book_id;
+
+                // 단어장 정보 가져오기
+                return axios.post("/wordbook/find.json", {
+                    wdBookId: wdBookId,
+                });
+            })
+            .then((response) => {
+                const wordbookData = response.data;
+                console.log("wordbookData: ", wordbookData); // 응답 데이터 확인
+
+                // 단어장 타입에 따라 페이지 설정
+                if (wordbookData && wordbookData.wdBookTypeId) {
+                    switch (wordbookData.wdBookTypeId) {
+                        case "1":
+                            this.wordBookType = "Chapter2";
+                            break;
+                        case "2":
+                            this.wordBookType = "Chapter2_3";
+                            break;
+                        case "3":
+                            this.wordBookType = "Chapter2_2";
+                            break;
+                        case "4":
+                            this.wordBookType = "Chapter2_9";
+                            break;
+                        case "5":
+                            this.wordBookType = "Chapter2_4";
+                            break;
+                        default:
+                            this.wordBookType = null;
+                    }
+                } else {
+                    console.error("wdBookTypeId가 없습니다.");
+                    this.wordBookType = null;
+                }
+
+                console.log("현재 단어장 타입: ", this.wordBookType);
+                this.goToPage(this.wordBookType);
+            })
+            .catch((error) => {
+                console.error("단어장 정보를 불러오는 중 오류 발생:", error);
+                this.wordBookType = null;
+            });
+        },
         handleProblemDetail(item) {
             if (item.prblm_type_id === "prblm_type_001") {
                 this.problemType = "Chapter3";
Add a comment
List