jichoi / lms_front star
PsHooN7979 08-09
240809 박세훈 ClassDetail 화면 게시판 화면 연결
@b216abbf9f09633e2ff04f10ebd61fdaad7c724c
client/views/pages/teacher/Board.vue
--- client/views/pages/teacher/Board.vue
+++ client/views/pages/teacher/Board.vue
@@ -1,8 +1,12 @@
 <template>
   <div class="title-box flex justify-between mb40">
     <p class="title">게시판</p>
-    <select>
-      <option v-for="(item, index) in classList" :key="item.id">
+    <select v-model="sclsId" @change="handleClassId()">
+      <option
+        v-for="(item, index) in classList"
+        :key="index"
+        :value="item.sclsId"
+      >
         {{ item.sclsNm }}
       </option>
     </select>
@@ -226,6 +230,10 @@
           console.log("classData - error : ", error);
         });
     },
+    handleClassId() {
+      sessionStorage.setItem("sclsId", JSON.stringify(this.sclsId));
+      this.boardList();
+    },
 
     createNo(index) {
       return this.totalPosts - (this.currentPage * this.itemsPerPage + index);
@@ -264,7 +272,6 @@
   mounted() {
     console.log("Main2 mounted");
     this.boardList();
-    this.setClassId();
   },
 };
 </script>
client/views/pages/teacher/ClassDetail.vue
--- client/views/pages/teacher/ClassDetail.vue
+++ client/views/pages/teacher/ClassDetail.vue
@@ -4,7 +4,7 @@
   </div>
   <div class="wrap mb30">
     <div class="flex justify-between mb30 align-center">
-      <label for="" class="title1">학습 현황</label>
+      <label for="" class="title1">게시판</label>
       <div class="look-btn flex align-center" @click="goToPage('Board')">
         <p>자세히 보기</p>
         <svg-icon type="mdi" :path="mdilArrowRight" class="ml10"></svg-icon>
@@ -20,12 +20,17 @@
           <td>등록일</td>
         </thead>
         <tbody>
-          <tr>
-            <td></td>
-            <td></td>
-            <td></td>
-            <td></td>
-            <td></td>
+          <tr
+            v-for="(item, index) in dataList"
+            :key="item.id"
+            :class="{ 'selected-row': selectedRow == item.dataList }"
+            @click="[goToPage('noticeDetail'), selectBoardList(item)]"
+          >
+            <td>{{ totalPosts - index }}</td>
+            <td>{{ item.bbsTtl }}</td>
+            <td>{{ item.bbsCls }}</td>
+            <td>{{ userNm }}</td>
+            <td>{{ item.bbsTm.substr(0, 16) }}</td>
           </tr>
         </tbody>
       </table>
@@ -106,6 +111,7 @@
 import { mdiMagnify } from "@mdi/js";
 import { mdilArrowRight } from "@mdi/light-js";
 import ProgressBar from "../../component/ProgressBar.vue";
+import axios from "axios";
 
 export default {
   data() {
@@ -117,6 +123,19 @@
 
       // 교사 홈페이지에서 쿼리 파라미터로부터 전달받은 선택된 반의 아이디
       selectedClassId: this.$route.query.sclsId,
+
+      // 게시글 정보
+      dataList: [],
+      totalPosts: 0,
+      selectedRow: "",
+      bbsTm: "",
+
+      // 페이징
+      currentPage: 0,
+      itemsPerPage: 5,
+
+      // 반 아이디
+      sclsId: "",
     };
   },
   methods: {
@@ -142,8 +161,46 @@
         this.goBack();
       }
     },
+
+    // 게시글 조회
+    boardList() {
+      const vm = this;
+      axios({
+        url: "/board/findAll.json",
+        method: "post",
+        headers: {
+          "Content-Type": "application/json; charset=UTF-8",
+        },
+        data: {
+          page: vm.currentPage + 1,
+          pageSize: vm.itemsPerPage,
+          sclsId: vm.selectedClassId,
+        },
+      })
+        .then(function (res) {
+          console.log("dataList - response : ", res.data);
+
+          vm.dataList = res.data.result[0].boardClass[0].board;
+          vm.userNm = res.data.result[0].userNm;
+          vm.userId = res.data.result[0].userId;
+          vm.totalPosts = res.data.totalBoard;
+
+          console.log(vm.userId);
+        })
+        .catch(function (error) {
+          console.log("result - error : ", error);
+        });
+    },
     setClassId() {
       sessionStorage.setItem("sclsId", JSON.stringify(this.selectedClassId));
+      sessionStorage.removeItem("selectedBoardList");
+      sessionStorage.removeItem("file");
+      this.boardList();
+    },
+
+    // 게시글 정보 세션에 저장
+    selectBoardList(item) {
+      sessionStorage.setItem("selectedBoardList", JSON.stringify(item));
     },
   },
   watch: {},
client/views/pages/teacher/noticeDetail.vue
--- client/views/pages/teacher/noticeDetail.vue
+++ client/views/pages/teacher/noticeDetail.vue
@@ -140,6 +140,10 @@
             "selectedBoardList",
             JSON.stringify(vm.dataList)
           );
+          vm.title = vm.dataList.bbsTtl;
+          vm.content = vm.dataList.bbsCnt;
+          vm.category = vm.dataList.bbsCls;
+          vm.time = vm.dataList.bbsTm;
           vm.findFile();
           console.log(vm.dataList);
         })
@@ -169,6 +173,10 @@
             "selectedBoardList",
             JSON.stringify(vm.dataList)
           );
+          vm.title = vm.dataList.bbsTtl;
+          vm.content = vm.dataList.bbsCnt;
+          vm.category = vm.dataList.bbsCls;
+          vm.time = vm.dataList.bbsTm;
           vm.findFile();
           console.log(vm.dataList);
         })
Add a comment
List