하관우 하관우 05-21
2025-5-21 하관우 기록물,언론에서 바라보는 구미시 각 검색 후 엑셀 다운로드드
@5c399e45cda0cae203a8822ba2da36902f10fadf
client/resources/api/main.js
--- client/resources/api/main.js
+++ client/resources/api/main.js
@@ -14,3 +14,10 @@
 export const updateStatsByMenuId = (menuId) => {
   return apiClient.put(`/stats/${menuId}/updateStatsByMenuId.json`);
 }
+
+export const excelDownloadAll = (searchReqDTO) => {
+  return apiClient.get(`/excel/excelDownloadAll.json`, {
+    params: searchReqDTO,
+    responseType: 'blob' // 엑셀 파일을 Blob 형태로 받기 위해 설정
+  });
+}
client/views/pages/bbsDcryPhoto/PicHistorySearch.vue
--- client/views/pages/bbsDcryPhoto/PicHistorySearch.vue
+++ client/views/pages/bbsDcryPhoto/PicHistorySearch.vue
@@ -23,9 +23,14 @@
             <p>총 <b>{{ searchReqDTO.totalRecordCount }}개</b>의 사진 기록물이 검색되었습니다. </p>
           </div>
           <div class="flex">
+            <div v-if="searchResult.length > 0">
+              <button type="button" @click="fnDownload">다운로드</button>
+            </div>
             <ul class="tab-box mb-20">
-              <li v-for="(tab, idx) in tabs" :key="idx" class="tab-title" :class="{ active: selectedTabId === tab.id }" @click="selectTab(tab.id)">
-                <img :src="selectedTabId === tab.id ? tab.activeImage : tab.inactiveImage" :alt="tab.title" class="tab-icon" />
+              <li v-for="(tab, idx) in tabs" :key="idx" class="tab-title" :class="{ active: selectedTabId === tab.id }"
+                @click="selectTab(tab.id)">
+                <img :src="selectedTabId === tab.id ? tab.activeImage : tab.inactiveImage" :alt="tab.title"
+                  class="tab-icon" />
                 <p><b>{{ tab.title }}</b></p>
               </li>
             </ul>
@@ -46,11 +51,13 @@
           <div v-else class="no-results">
             <img :src="nosearch" alt="">
             <p>검색 결과가 없습니다.</p>
-            <p>단어의 철자가 정확한지 확인해 주시기 바랍니다.<br> 검색어의 단어 수를 줄이거나, 다른 검색어(유사어)로 검색해 보시기 바랍니다.<br> 일반적으로 많이 사용하는 검색어로 다시 검색해 주시기 바랍니다.</p>
+            <p>단어의 철자가 정확한지 확인해 주시기 바랍니다.<br> 검색어의 단어 수를 줄이거나, 다른 검색어(유사어)로 검색해 보시기 바랍니다.<br> 일반적으로 많이 사용하는 검색어로 다시 검색해
+              주시기 바랍니다.</p>
           </div>
         </div>
       </div>
-      <div class="btn-group flex-end mt-40"><button type="button" class="register" @click="fnMoveTo('edit')">등록</button></div>
+      <div class="btn-group flex-end mt-40"><button type="button" class="register" @click="fnMoveTo('edit')">등록</button>
+      </div>
       <DefaultPagination class="mt-40" :search="searchReqDTO" @onChange="fnChangeCurrentPage" />
     </div>
   </div>
@@ -70,6 +77,7 @@
 import DefaultPagination from '@/views/component/DefaultPagination.vue';
 // API
 import { findDcrysProc } from "@/resources/api/dcry";
+import { excelDownloadAll } from "../../../resources/api/main";
 
 export default {
   components: {
@@ -266,6 +274,53 @@
         this.$router.push(routes['list']);
       }
     },
+
+    // 사진 기록물 엑셀 다운로드
+    async fnDownload() {
+      this.loading = true; // 로딩 시작
+      try {
+        const params = JSON.parse(JSON.stringify(this.searchReqDTO));
+        if (this.searchReqDTO.searchCtgries && this.searchReqDTO.searchCtgries.length > 0) {
+          params.searchCtgries = this.searchReqDTO.searchCtgries.join(',');
+        } else {
+          delete params.searchCtgries;
+        }
+
+        params.usePhoto = true;
+        const response = await excelDownloadAll(params);
+
+        const url = window.URL.createObjectURL(
+          new Blob([response.data], {
+            type: response.headers["content-type"],
+          })
+        );
+
+        let today = new Date().toISOString().substring(2, 10);
+        today = today.replace(/[^0-9]/g, "");
+        const fileName = `[사진기록물]기록물_${today}.xlsx`;
+
+        const link = document.createElement("a");
+        link.href = url;
+        link.setAttribute("download", fileName);
+        document.body.appendChild(link);
+        link.click();
+
+        document.body.removeChild(link);
+        window.URL.revokeObjectURL(url);
+
+      } catch (error) {
+        console.error("엑셀 다운로드 에러:", error);
+        if (error.response) {
+          // Blob 응답이 아닐 경우 에러 메시지 처리가 다를 수 있음.
+          // 여기서는 간단히 HTTP 상태 코드만 표시.
+          alert(`엑셀 다운로드 중 에러 발생: ${error.response.status} ${error.response.statusText}`);
+        } else {
+          alert("엑셀 다운로드 중 네트워크 에러가 발생했습니다.\n관리자에게 문의해주세요.");
+        }
+      } finally {
+        this.loading = false;
+      }
+    },
   },
 };
 </script>
(파일 끝에 줄바꿈 문자 없음)
client/views/pages/bbsDcryVideo/VideoHistorySearch.vue
--- client/views/pages/bbsDcryVideo/VideoHistorySearch.vue
+++ client/views/pages/bbsDcryVideo/VideoHistorySearch.vue
@@ -23,9 +23,14 @@
             <p>총 <b>{{ searchReqDTO.totalRecordCount }}개</b>의 영상 기록물이 검색되었습니다. </p>
           </div>
           <div class="flex">
+            <div v-if="searchResult.length > 0">
+              <button type="button" @click="fnDownload">다운로드</button>
+            </div>
             <ul class="tab-box mb-20">
-              <li v-for="(tab, idx) in tabs" :key="idx" class="tab-title" :class="{ active: selectedTabId === tab.id }" @click="selectTab(tab.id)">
-                <img :src="selectedTabId === tab.id ? tab.activeImage : tab.inactiveImage" :alt="tab.title" class="tab-icon" />
+              <li v-for="(tab, idx) in tabs" :key="idx" class="tab-title" :class="{ active: selectedTabId === tab.id }"
+                @click="selectTab(tab.id)">
+                <img :src="selectedTabId === tab.id ? tab.activeImage : tab.inactiveImage" :alt="tab.title"
+                  class="tab-icon" />
                 <p><b>{{ tab.title }}</b></p>
               </li>
             </ul>
@@ -46,11 +51,13 @@
           <div v-else class="no-results">
             <img :src="nosearch" alt="">
             <p>검색 결과가 없습니다.</p>
-            <p>단어의 철자가 정확한지 확인해 주시기 바랍니다.<br> 검색어의 단어 수를 줄이거나, 다른 검색어(유사어)로 검색해 보시기 바랍니다.<br> 일반적으로 많이 사용하는 검색어로 다시 검색해 주시기 바랍니다.</p>
+            <p>단어의 철자가 정확한지 확인해 주시기 바랍니다.<br> 검색어의 단어 수를 줄이거나, 다른 검색어(유사어)로 검색해 보시기 바랍니다.<br> 일반적으로 많이 사용하는 검색어로 다시 검색해
+              주시기 바랍니다.</p>
           </div>
         </div>
       </div>
-      <div class="btn-group flex-end mt-40"><button type="button" class="register" @click="fnMoveTo('edit')">등록</button></div>
+      <div class="btn-group flex-end mt-40"><button type="button" class="register" @click="fnMoveTo('edit')">등록</button>
+      </div>
       <DefaultPagination class="mt-40" :search="searchReqDTO" @onChange="fnChangeCurrentPage" />
     </div>
   </div>
@@ -70,7 +77,7 @@
 import DefaultPagination from '@/views/component/DefaultPagination.vue';
 // API
 import { findDcrysProc } from "@/resources/api/dcry";
-
+import { excelDownloadAll } from "../../../resources/api/main"
 export default {
   components: {
     SearchFormComponent,
@@ -266,6 +273,52 @@
         this.$router.push(routes['list']);
       }
     },
+    // 영상상 기록물 엑셀 다운로드
+    async fnDownload() {
+      this.loading = true; // 로딩 시작
+      try {
+        const params = JSON.parse(JSON.stringify(this.searchReqDTO));
+        if (this.searchReqDTO.searchCtgries && this.searchReqDTO.searchCtgries.length > 0) {
+          params.searchCtgries = this.searchReqDTO.searchCtgries.join(',');
+        } else {
+          delete params.searchCtgries;
+        }
+
+        params.useVideo = true;
+        const response = await excelDownloadAll(params);
+
+        const url = window.URL.createObjectURL(
+          new Blob([response.data], {
+            type: response.headers["content-type"],
+          })
+        );
+
+        let today = new Date().toISOString().substring(2, 10);
+        today = today.replace(/[^0-9]/g, "");
+        const fileName = `[영상기록물]기록물_${today}.xlsx`;
+
+        const link = document.createElement("a");
+        link.href = url;
+        link.setAttribute("download", fileName);
+        document.body.appendChild(link);
+        link.click();
+
+        document.body.removeChild(link);
+        window.URL.revokeObjectURL(url);
+
+      } catch (error) {
+        console.error("엑셀 다운로드 에러:", error);
+        if (error.response) {
+          // Blob 응답이 아닐 경우 에러 메시지 처리가 다를 수 있음.
+          // 여기서는 간단히 HTTP 상태 코드만 표시.
+          alert(`엑셀 다운로드 중 에러 발생: ${error.response.status} ${error.response.statusText}`);
+        } else {
+          alert("엑셀 다운로드 중 네트워크 에러가 발생했습니다.\n관리자에게 문의해주세요.");
+        }
+      } finally {
+        this.loading = false;
+      }
+    },
   },
 };
 </script>
(파일 끝에 줄바꿈 문자 없음)
client/views/pages/bbsMediaVido/MediaVideoSearch.vue
--- client/views/pages/bbsMediaVido/MediaVideoSearch.vue
+++ client/views/pages/bbsMediaVido/MediaVideoSearch.vue
@@ -22,6 +22,9 @@
             <p>총 <b>{{ searchReqDTO.totalRecordCount }}개</b>의 미디어 영상이 검색되었습니다. </p>
           </div>
           <div class="flex">
+            <div v-if="searchResult.length > 0">
+              <button type="button" @click="fnDownload">다운로드</button>
+            </div>
             <ul class="tab-box mb-20">
               <li v-for="(tab, idx) in tabs" :key="idx" class="tab-title" :class="{ active: selectedTabId === tab.id }" @click="selectTab(tab.id)">
                 <img :src="selectedTabId === tab.id ? tab.activeImage : tab.inactiveImage" :alt="tab.title" class="tab-icon" />
@@ -69,6 +72,7 @@
 import DefaultPagination from '@/views/component/DefaultPagination.vue';
 // API
 import { findAllMediaVidosProc } from "@/resources/api/mediaVido";
+import { excelDownloadAll } from "../../../resources/api/main";
 
 export default {
   components: {
@@ -263,6 +267,53 @@
         this.$router.push(routes['list']);
       }
     },
+
+    // 미디어 영상 엑셀 다운로드
+    async fnDownload() {
+      this.loading = true; // 로딩 시작
+      try {
+        const params = JSON.parse(JSON.stringify(this.searchReqDTO));
+        if (this.searchReqDTO.searchCtgries && this.searchReqDTO.searchCtgries.length > 0) {
+          params.searchCtgries = this.searchReqDTO.searchCtgries.join(',');
+        } else {
+          delete params.searchCtgries;
+        }
+        
+        params.useMedia =true;
+        const response = await excelDownloadAll(params);
+
+        const url = window.URL.createObjectURL(
+          new Blob([response.data], {
+            type: response.headers["content-type"],
+          })
+        );
+
+        let today = new Date().toISOString().substring(2, 10);
+        today = today.replace(/[^0-9]/g, "");
+        const fileName = `[미디어영상]언론에서 바라보는 구미시시_${today}.xlsx`;
+
+        const link = document.createElement("a");
+        link.href = url;
+        link.setAttribute("download", fileName);
+        document.body.appendChild(link);
+        link.click();
+
+        document.body.removeChild(link);
+        window.URL.revokeObjectURL(url);
+
+      } catch (error) {
+        console.error("엑셀 다운로드 에러:", error);
+        if (error.response) {
+          // Blob 응답이 아닐 경우 에러 메시지 처리가 다를 수 있음.
+          // 여기서는 간단히 HTTP 상태 코드만 표시.
+          alert(`엑셀 다운로드 중 에러 발생: ${error.response.status} ${error.response.statusText}`);
+        } else {
+          alert("엑셀 다운로드 중 네트워크 에러가 발생했습니다.\n관리자에게 문의해주세요.");
+        }
+      } finally {
+        this.loading = false;
+      }
+    },
   },
 };
 </script>
(파일 끝에 줄바꿈 문자 없음)
client/views/pages/bbsNesDta/NewsReleaseSearch.vue
--- client/views/pages/bbsNesDta/NewsReleaseSearch.vue
+++ client/views/pages/bbsNesDta/NewsReleaseSearch.vue
@@ -23,6 +23,9 @@
             <p>총 <b>{{ searchReqDTO.totalRecordCount }}개</b>의 스크랩 자료가 검색되었습니다. </p>
           </div>
           <div class="flex">
+            <div v-if="searchResult.length > 0">
+              <button type="button" @click="fnDownload">다운로드</button>
+            </div>
             <ul class="tab-box mb-20">
               <li v-for="(tab, idx) in tabs" :key="idx" class="tab-title" :class="{ active: selectedTabId === tab.id }" @click="selectTab(tab.id)">
                 <img :src="selectedTabId === tab.id ? tab.activeImage : tab.inactiveImage" :alt="tab.title" class="tab-icon" />
@@ -70,6 +73,7 @@
 import DefaultPagination from '@/views/component/DefaultPagination.vue';
 // API
 import { findAllNesDtasProc } from "@/resources/api/nesDta";
+import { excelDownloadAll } from "../../../resources/api/main";
 
 export default {
   components: {
@@ -264,6 +268,53 @@
         this.$router.push(routes['list']);
       }
     },
+
+    // 스크랩 자료 엑셀 다운로드
+    async fnDownload() {
+      this.loading = true; // 로딩 시작
+      try {
+        const params = JSON.parse(JSON.stringify(this.searchReqDTO));
+        if (this.searchReqDTO.searchCtgries && this.searchReqDTO.searchCtgries.length > 0) {
+          params.searchCtgries = this.searchReqDTO.searchCtgries.join(',');
+        } else {
+          delete params.searchCtgries;
+        }
+        
+        params.useNews =true;
+        const response = await excelDownloadAll(params);
+
+        const url = window.URL.createObjectURL(
+          new Blob([response.data], {
+            type: response.headers["content-type"],
+          })
+        );
+
+        let today = new Date().toISOString().substring(2, 10);
+        today = today.replace(/[^0-9]/g, "");
+        const fileName = `[스크랩자료]언론에서 바라보는 구미시_${today}.xlsx`;
+
+        const link = document.createElement("a");
+        link.href = url;
+        link.setAttribute("download", fileName);
+        document.body.appendChild(link);
+        link.click();
+
+        document.body.removeChild(link);
+        window.URL.revokeObjectURL(url);
+
+      } catch (error) {
+        console.error("엑셀 다운로드 에러:", error);
+        if (error.response) {
+          // Blob 응답이 아닐 경우 에러 메시지 처리가 다를 수 있음.
+          // 여기서는 간단히 HTTP 상태 코드만 표시.
+          alert(`엑셀 다운로드 중 에러 발생: ${error.response.status} ${error.response.statusText}`);
+        } else {
+          alert("엑셀 다운로드 중 네트워크 에러가 발생했습니다.\n관리자에게 문의해주세요.");
+        }
+      } finally {
+        this.loading = false;
+      }
+    },
   },
 };
 </script>
(파일 끝에 줄바꿈 문자 없음)
Add a comment
List