jichoi / lms_front star
구자현 구자현 2024-08-14
Merge branch 'master' of http://210.180.118.83/jichoi/lms_front
@70ec228035c433d341877da6d35a5c1c656e585a
client/views/pages/main/MyPlan2.vue
--- client/views/pages/main/MyPlan2.vue
+++ client/views/pages/main/MyPlan2.vue
@@ -228,27 +228,45 @@
                 return a.scheduleUnit - b.scheduleUnit;
             });
 
-            this.DataArray = sortedArray; 
+            this.DataArray = sortedArray;
         },
         searchBook() {
-            this.books = ""
+            this.books = []; // books를 빈 배열로 초기화
             axios.post("/book/search.json", { book_nm: this.keyword }, {
                 headers: {
                     "Content-Type": "application/json; charset=UTF-8",
                 }
             })
                 .then(response => {
-                    this.books = response.data.list.map(book => ({
-                        ...book,
-                        isSelected: false
-                    }));
+                    this.books = response.data.list;
+                    this.books.forEach(book => {
+                        this.searchUnits(book.book_id);
+                    });
                 })
+                .catch(error => {
+                    console.error("searchBook - error:", error);
+                    alert("단원 목록을 불러오는 중 오류가 발생했습니다.");
+                });
+        },
+        searchUnits(bookId) { 
+
+            console.log(bookId)
+            axios.post("/unit/unitList.json", { bookId: bookId }, {
+                headers: {
+                    "Content-Type": "application/json; charset=UTF-8",
+                }
+            }).then(response => {
+                this.books = response.data.map(book => ({
+                    ...book,
+                    isSelected: false
+                }));
+                this.searchUnit()
+            })
                 .catch(error => {
                     console.error("fetchUnits - error:", error);
                     alert("단원 목록을 불러오는 중 오류가 발생했습니다.");
                 });
-        },
-        fetchUnits() {
+        }, fetchUnits() {
             axios.post("unit/findAll.json", {
                 headers: {
                     "Content-Type": "application/json; charset=UTF-8",
Add a comment
List