jichoi / lms_front star
이은진 이은진 2024-08-13
240813 이은진 학습일정계획 중복 핸들링
@58eeafbdd67200e8465a2408e318520e32c192b8
client/views/pages/main/MyPlan2.vue
--- client/views/pages/main/MyPlan2.vue
+++ client/views/pages/main/MyPlan2.vue
@@ -174,7 +174,7 @@
                 alert('교재를 선택해 주세요.');
             } else {
                 if (this.checkedItems.length === 1) {
-                    if (this.unitList.find(item => item === this.checkedItems[0])) {
+                    if (this.unitList.find(item => item === this.checkedItems[0].value)) {
                         alert('이미 지정된 시간입니다.');
                     } else {
                         this.addToNewDataArray(this.checkedItems[0]);
@@ -182,7 +182,7 @@
                         this.nowID = ""
                         this.nowunitID = ""
                         this.nowName = ""
-                        this.unitList.push(this.checkedItems[0])
+                        this.unitList.push(this.checkedItems[0].value)
                         this.checkedItems = []
                     }
                 } else if (this.checkedItems.length > 1) {
@@ -259,12 +259,28 @@
                         ...book,
                         isSelected: false
                     }));
+                    this.searchUnit()
                 })
                 .catch(error => {
                     console.error("fetchBooks - error: ", error);
                     alert("교재 목록을 불러오는 중 오류가 발생했습니다.");
                 });
-        },
+        }, searchUnit() {
+            axios.post("schedule/selectSchedule.json", {stdId:"2"}, {
+                headers: {
+                    "Content-Type": "application/json; charset=UTF-8",
+                }
+            })
+                .then(response => { 
+                    const units = response.data.map(item => item.schdl_unit); 
+                    this.unitList.push(...units);
+                    console.log(this.unitList)
+                })
+                .catch(error => {
+                    console.error("searchUnit - error: ", error);
+                    alert("교재 목록을 불러오는 중 오류가 발생했습니다.");
+                });
+        }
     },
     watch: {
         // Watchers for reactivity (if needed)
Add a comment
List