
--- client/views/pages/main/MyPlan2.vue
+++ client/views/pages/main/MyPlan2.vue
... | ... | @@ -228,27 +228,45 @@ |
228 | 228 |
return a.scheduleUnit - b.scheduleUnit; |
229 | 229 |
}); |
230 | 230 |
|
231 |
- this.DataArray = sortedArray; |
|
231 |
+ this.DataArray = sortedArray; |
|
232 | 232 |
}, |
233 | 233 |
searchBook() { |
234 |
- this.books = "" |
|
234 |
+ this.books = []; // books를 빈 배열로 초기화 |
|
235 | 235 |
axios.post("/book/search.json", { book_nm: this.keyword }, { |
236 | 236 |
headers: { |
237 | 237 |
"Content-Type": "application/json; charset=UTF-8", |
238 | 238 |
} |
239 | 239 |
}) |
240 | 240 |
.then(response => { |
241 |
- this.books = response.data.list.map(book => ({ |
|
242 |
- ...book, |
|
243 |
- isSelected: false |
|
244 |
- })); |
|
241 |
+ this.books = response.data.list; |
|
242 |
+ this.books.forEach(book => { |
|
243 |
+ this.searchUnits(book.book_id); |
|
244 |
+ }); |
|
245 | 245 |
}) |
246 |
+ .catch(error => { |
|
247 |
+ console.error("searchBook - error:", error); |
|
248 |
+ alert("단원 목록을 불러오는 중 오류가 발생했습니다."); |
|
249 |
+ }); |
|
250 |
+ }, |
|
251 |
+ searchUnits(bookId) { |
|
252 |
+ |
|
253 |
+ console.log(bookId) |
|
254 |
+ axios.post("/unit/unitList.json", { bookId: bookId }, { |
|
255 |
+ headers: { |
|
256 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
257 |
+ } |
|
258 |
+ }).then(response => { |
|
259 |
+ this.books = response.data.map(book => ({ |
|
260 |
+ ...book, |
|
261 |
+ isSelected: false |
|
262 |
+ })); |
|
263 |
+ this.searchUnit() |
|
264 |
+ }) |
|
246 | 265 |
.catch(error => { |
247 | 266 |
console.error("fetchUnits - error:", error); |
248 | 267 |
alert("단원 목록을 불러오는 중 오류가 발생했습니다."); |
249 | 268 |
}); |
250 |
- }, |
|
251 |
- fetchUnits() { |
|
269 |
+ }, fetchUnits() { |
|
252 | 270 |
axios.post("unit/findAll.json", { |
253 | 271 |
headers: { |
254 | 272 |
"Content-Type": "application/json; charset=UTF-8", |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?