jichoi / lms_front star
woals 2024-08-20
240820 권민수 대시보드 페이지 아이디 전달방식 변경
@6b8bb1c536ff530fa9c9b199bebb9d86a0b84ba6
client/views/pages/main/Dashboard.vue
--- client/views/pages/main/Dashboard.vue
+++ client/views/pages/main/Dashboard.vue
@@ -238,6 +238,7 @@
 import SvgIcon from '@jamescoyle/vue-icon';
 import { mdiMagnify, mdiHeart, mdiWindowClose } from '@mdi/js';
 import axios from 'axios';
+import { mapGetters } from 'vuex';
 
 export default {
     data() {
@@ -289,6 +290,29 @@
         }
     },
     methods: {
+        checkAndFetchData() {
+            console.log("받은 Book ID:", this.getBookId);
+            console.log("받은 Unit ID:", this.getUnitId);
+            const book_id = this.getBookId;
+            const unit_id = this.getUnitId;
+
+            if (!book_id || !unit_id) {
+                console.error("book_id 또는 unit_id가 설정되지 않았습니다.");
+                return;
+            }
+            this.fetchImage();
+            this.fetchSchedule(unit_id, book_id);
+            this.fetchRoadmapData(unit_id, book_id);
+            this.fetchRabbit();
+
+            this.unit_id = unit_id
+            this.book_id = book_id
+
+            if (this.$route.query.reCapture == 'true') {
+                this.openCameraModal()
+            }
+        },
+
         //은진
         async findFile(file_mng_id) {
             try {
@@ -560,22 +584,21 @@
         SvgIcon,
     },
     mounted() {
-        this.fetchImage();
-        const { book_id, unit_id } = this.$route.query;
-
         console.log('main mounted');
-        this.fetchSchedule(unit_id, book_id);
-        this.fetchRoadmapData(unit_id, book_id);
-        this.fetchRabbit();
-
-        this.unit_id = unit_id
-        this.book_id = book_id
-
-        if (this.$route.query.reCapture == 'true') {
-            this.openCameraModal()
+        this.checkAndFetchData();
+        // const { book_id, unit_id } = this.$route.query;
+    },
+    watch: {
+        getBookId(newBookId) {
+            this.checkAndFetchData();
+        },
+        getUnitId(newUnitId) {
+            this.checkAndFetchData();
         }
     },
     computed: {
+        ...mapGetters(['getBookId', 'getUnitId']),
+
         processedRoadmap() {
             let problemCounter = 0;
             let wordCounter = 0;
Add a comment
List