
--- client/resources/api/file.js
+++ client/resources/api/file.js
... | ... | @@ -5,6 +5,11 @@ |
5 | 5 |
return downloadService.downloadFile(file, { responseType: 'blob' }); |
6 | 6 |
} |
7 | 7 |
|
8 |
+// 엑셀 다운로드 |
|
9 |
+export const excelDownloadProc = (searchReqDTO , fileName) => { |
|
10 |
+ return downloadService.downloadExcel(searchReqDTO, fileName, { responseType: 'blob' }); |
|
11 |
+} |
|
12 |
+ |
|
8 | 13 |
// 다중 파일 다운로드 |
9 | 14 |
export const multiFileDownloadProc = (files) => { |
10 | 15 |
return downloadService.downloadMultipleFiles(files, { responseType: 'blob' }); |
--- client/resources/js/downloadService.js
+++ client/resources/js/downloadService.js
... | ... | @@ -120,6 +120,73 @@ |
120 | 120 |
} |
121 | 121 |
}, |
122 | 122 |
|
123 |
+ // 엑셀 다운로드 메서드 |
|
124 |
+ async downloadExcel(searchReqDTO, fileName, options = {}) { |
|
125 |
+ try { |
|
126 |
+ // 다운로드 상태 초기화 (현재 진행률 유지) |
|
127 |
+ const currentProgress = uploadProgressStore.totalProgress; |
|
128 |
+ uploadProgressStore.startDownload(fileName || '파일 다운로드 중...'); |
|
129 |
+ uploadProgressStore.setStage('downloading'); |
|
130 |
+ |
|
131 |
+ // 이전 진행률이 있으면 유지 |
|
132 |
+ if (currentProgress > 0) { |
|
133 |
+ uploadProgressStore.totalProgress = currentProgress; |
|
134 |
+ } |
|
135 |
+ |
|
136 |
+ // 즉시 진행률 시뮬레이션 시작 (서버 응답 전) |
|
137 |
+ this._startProgressSimulation(); |
|
138 |
+ |
|
139 |
+ // apiClient를 사용하여 다운로드 요청 |
|
140 |
+ const response = await apiClient.get(`/excel/excelDownloadAll.json`, { |
|
141 |
+ params: searchReqDTO, // 검색 조건 파라미터 전달 |
|
142 |
+ responseType: 'blob', // 엑셀 파일을 Blob 형태로 받기 위해 설정 |
|
143 |
+ ...options, // 외부에서 전달된 추가 옵션 적용 |
|
144 |
+ onDownloadProgress: (progressEvent) => { |
|
145 |
+ // 시뮬레이션 중단 |
|
146 |
+ this._stopProgressSimulation(); |
|
147 |
+ |
|
148 |
+ if (progressEvent.total) { |
|
149 |
+ // 진행 상태 계산 |
|
150 |
+ const realProgress = Math.round((progressEvent.loaded * 100) / progressEvent.total); |
|
151 |
+ |
|
152 |
+ // 실제 진행률이 시뮬레이션 진행률보다 낮으면, 시뮬레이션 진행률부터 시작 |
|
153 |
+ const startProgress = Math.max(this._lastSimulatedProgress, realProgress); |
|
154 |
+ |
|
155 |
+ // 남은 진행률을 60%~100% 범위로 매핑 |
|
156 |
+ // 예: 실제 진행률이 0%일 때 40%, 100%일 때 100%가 되도록 |
|
157 |
+ const adjustedProgress = 40 + (realProgress * 60 / 100); |
|
158 |
+ |
|
159 |
+ // 둘 중 더 큰 값을 사용 |
|
160 |
+ uploadProgressStore.totalProgress = Math.round(Math.max(startProgress, adjustedProgress)); |
|
161 |
+ } |
|
162 |
+ |
|
163 |
+ // 사용자 정의 onDownloadProgress 콜백이 있으면 호출 |
|
164 |
+ if (options.onDownloadProgress) { |
|
165 |
+ options.onDownloadProgress(progressEvent); |
|
166 |
+ } |
|
167 |
+ } |
|
168 |
+ }); |
|
169 |
+ |
|
170 |
+ // 시뮬레이션 중단 (만약 아직 실행 중이라면) |
|
171 |
+ this._stopProgressSimulation(); |
|
172 |
+ |
|
173 |
+ // 다운로드 완료 표시 |
|
174 |
+ uploadProgressStore.totalProgress = 100; |
|
175 |
+ |
|
176 |
+ // 잠시 후 응답 반환 (완료 상태를 보여줄 시간 제공) |
|
177 |
+ await new Promise(resolve => setTimeout(resolve, 300)); |
|
178 |
+ |
|
179 |
+ return response; |
|
180 |
+ } catch (error) { |
|
181 |
+ // 시뮬레이션 중단 |
|
182 |
+ this._stopProgressSimulation(); |
|
183 |
+ |
|
184 |
+ // 오류 발생 시 상태 초기화 |
|
185 |
+ uploadProgressStore.handleError(); |
|
186 |
+ throw error; |
|
187 |
+ } |
|
188 |
+ }, |
|
189 |
+ |
|
123 | 190 |
// 다중 파일 다운로드 메서드 |
124 | 191 |
async downloadMultipleFiles(files, options = {}) { |
125 | 192 |
try { |
--- client/views/pages/bbsDcryPhoto/PicHistorySearch.vue
+++ client/views/pages/bbsDcryPhoto/PicHistorySearch.vue
... | ... | @@ -77,7 +77,8 @@ |
77 | 77 |
import DefaultPagination from '@/views/component/DefaultPagination.vue'; |
78 | 78 |
// API |
79 | 79 |
import { findDcrysProc } from "@/resources/api/dcry"; |
80 |
-import { excelDownloadAll } from "../../../resources/api/main"; |
|
80 |
+import { excelDownloadProc } from '@/resources/api/file'; |
|
81 |
+import uploadProgressStore from '@/resources/js/uploadProgressStore'; |
|
81 | 82 |
|
82 | 83 |
export default { |
83 | 84 |
components: { |
... | ... | @@ -277,7 +278,6 @@ |
277 | 278 |
|
278 | 279 |
// 사진 기록물 엑셀 다운로드 |
279 | 280 |
async fnDownload() { |
280 |
- this.loading = true; // 로딩 시작 |
|
281 | 281 |
try { |
282 | 282 |
const params = JSON.parse(JSON.stringify(this.searchReqDTO)); |
283 | 283 |
if (this.searchReqDTO.searchCtgries && this.searchReqDTO.searchCtgries.length > 0) { |
... | ... | @@ -286,19 +286,18 @@ |
286 | 286 |
delete params.searchCtgries; |
287 | 287 |
} |
288 | 288 |
|
289 |
+ let today = new Date().toISOString().substring(2, 10); |
|
290 |
+ today = today.replace(/[^0-9]/g, ""); |
|
291 |
+ const fileName = `[사진 기록물]기록물_${today}.xlsx`; |
|
292 |
+ |
|
289 | 293 |
params.usePhoto = true; |
290 |
- const response = await excelDownloadAll(params); |
|
294 |
+ const response = await excelDownloadProc(params, fileName); |
|
291 | 295 |
|
292 | 296 |
const url = window.URL.createObjectURL( |
293 | 297 |
new Blob([response.data], { |
294 | 298 |
type: response.headers["content-type"], |
295 | 299 |
}) |
296 | 300 |
); |
297 |
- |
|
298 |
- let today = new Date().toISOString().substring(2, 10); |
|
299 |
- today = today.replace(/[^0-9]/g, ""); |
|
300 |
- const fileName = `[사진기록물]기록물_${today}.xlsx`; |
|
301 |
- |
|
302 | 301 |
const link = document.createElement("a"); |
303 | 302 |
link.href = url; |
304 | 303 |
link.setAttribute("download", fileName); |
... | ... | @@ -318,7 +317,7 @@ |
318 | 317 |
alert("엑셀 다운로드 중 네트워크 에러가 발생했습니다.\n관리자에게 문의해주세요."); |
319 | 318 |
} |
320 | 319 |
} finally { |
321 |
- this.loading = false; |
|
320 |
+ uploadProgressStore.closeModal(); |
|
322 | 321 |
} |
323 | 322 |
}, |
324 | 323 |
}, |
--- client/views/pages/bbsDcryVideo/VideoHistorySearch.vue
+++ client/views/pages/bbsDcryVideo/VideoHistorySearch.vue
... | ... | @@ -77,7 +77,8 @@ |
77 | 77 |
import DefaultPagination from '@/views/component/DefaultPagination.vue'; |
78 | 78 |
// API |
79 | 79 |
import { findDcrysProc } from "@/resources/api/dcry"; |
80 |
-import { excelDownloadAll } from "../../../resources/api/main" |
|
80 |
+import { excelDownloadProc } from '@/resources/api/file'; |
|
81 |
+import uploadProgressStore from '@/resources/js/uploadProgressStore'; |
|
81 | 82 |
export default { |
82 | 83 |
components: { |
83 | 84 |
SearchFormComponent, |
... | ... | @@ -275,7 +276,6 @@ |
275 | 276 |
}, |
276 | 277 |
// 영상상 기록물 엑셀 다운로드 |
277 | 278 |
async fnDownload() { |
278 |
- this.loading = true; // 로딩 시작 |
|
279 | 279 |
try { |
280 | 280 |
const params = JSON.parse(JSON.stringify(this.searchReqDTO)); |
281 | 281 |
if (this.searchReqDTO.searchCtgries && this.searchReqDTO.searchCtgries.length > 0) { |
... | ... | @@ -284,19 +284,18 @@ |
284 | 284 |
delete params.searchCtgries; |
285 | 285 |
} |
286 | 286 |
|
287 |
+ let today = new Date().toISOString().substring(2, 10); |
|
288 |
+ today = today.replace(/[^0-9]/g, ""); |
|
289 |
+ const fileName = `[영상 기록물]기록물_${today}.xlsx`; |
|
290 |
+ |
|
287 | 291 |
params.useVideo = true; |
288 |
- const response = await excelDownloadAll(params); |
|
292 |
+ const response = await excelDownloadProc(params, fileName); |
|
289 | 293 |
|
290 | 294 |
const url = window.URL.createObjectURL( |
291 | 295 |
new Blob([response.data], { |
292 | 296 |
type: response.headers["content-type"], |
293 | 297 |
}) |
294 | 298 |
); |
295 |
- |
|
296 |
- let today = new Date().toISOString().substring(2, 10); |
|
297 |
- today = today.replace(/[^0-9]/g, ""); |
|
298 |
- const fileName = `[영상기록물]기록물_${today}.xlsx`; |
|
299 |
- |
|
300 | 299 |
const link = document.createElement("a"); |
301 | 300 |
link.href = url; |
302 | 301 |
link.setAttribute("download", fileName); |
... | ... | @@ -316,7 +315,7 @@ |
316 | 315 |
alert("엑셀 다운로드 중 네트워크 에러가 발생했습니다.\n관리자에게 문의해주세요."); |
317 | 316 |
} |
318 | 317 |
} finally { |
319 |
- this.loading = false; |
|
318 |
+ uploadProgressStore.closeModal(); |
|
320 | 319 |
} |
321 | 320 |
}, |
322 | 321 |
}, |
--- client/views/pages/bbsMediaVido/MediaVideoSearch.vue
+++ client/views/pages/bbsMediaVido/MediaVideoSearch.vue
... | ... | @@ -72,7 +72,8 @@ |
72 | 72 |
import DefaultPagination from '@/views/component/DefaultPagination.vue'; |
73 | 73 |
// API |
74 | 74 |
import { findAllMediaVidosProc } from "@/resources/api/mediaVido"; |
75 |
-import { excelDownloadAll } from "../../../resources/api/main"; |
|
75 |
+import { excelDownloadProc } from '@/resources/api/file'; |
|
76 |
+import uploadProgressStore from '@/resources/js/uploadProgressStore'; |
|
76 | 77 |
|
77 | 78 |
export default { |
78 | 79 |
components: { |
... | ... | @@ -270,7 +271,6 @@ |
270 | 271 |
|
271 | 272 |
// 미디어 영상 엑셀 다운로드 |
272 | 273 |
async fnDownload() { |
273 |
- this.loading = true; // 로딩 시작 |
|
274 | 274 |
try { |
275 | 275 |
const params = JSON.parse(JSON.stringify(this.searchReqDTO)); |
276 | 276 |
if (this.searchReqDTO.searchCtgries && this.searchReqDTO.searchCtgries.length > 0) { |
... | ... | @@ -278,20 +278,19 @@ |
278 | 278 |
} else { |
279 | 279 |
delete params.searchCtgries; |
280 | 280 |
} |
281 |
- |
|
282 |
- params.useMedia =true; |
|
283 |
- const response = await excelDownloadAll(params); |
|
281 |
+ |
|
282 |
+ let today = new Date().toISOString().substring(2, 10); |
|
283 |
+ today = today.replace(/[^0-9]/g, ""); |
|
284 |
+ const fileName = `[미디어 영상]언론에서 바라보는 구미시_${today}.xlsx`; |
|
285 |
+ |
|
286 |
+ params.useMedia = true; |
|
287 |
+ const response = await excelDownloadProc(params, fileName); |
|
284 | 288 |
|
285 | 289 |
const url = window.URL.createObjectURL( |
286 | 290 |
new Blob([response.data], { |
287 | 291 |
type: response.headers["content-type"], |
288 | 292 |
}) |
289 | 293 |
); |
290 |
- |
|
291 |
- let today = new Date().toISOString().substring(2, 10); |
|
292 |
- today = today.replace(/[^0-9]/g, ""); |
|
293 |
- const fileName = `[미디어영상]언론에서 바라보는 구미시시_${today}.xlsx`; |
|
294 |
- |
|
295 | 294 |
const link = document.createElement("a"); |
296 | 295 |
link.href = url; |
297 | 296 |
link.setAttribute("download", fileName); |
... | ... | @@ -311,7 +310,7 @@ |
311 | 310 |
alert("엑셀 다운로드 중 네트워크 에러가 발생했습니다.\n관리자에게 문의해주세요."); |
312 | 311 |
} |
313 | 312 |
} finally { |
314 |
- this.loading = false; |
|
313 |
+ uploadProgressStore.closeModal(); |
|
315 | 314 |
} |
316 | 315 |
}, |
317 | 316 |
}, |
--- client/views/pages/bbsNesDta/NewsReleaseSearch.vue
+++ client/views/pages/bbsNesDta/NewsReleaseSearch.vue
... | ... | @@ -73,7 +73,8 @@ |
73 | 73 |
import DefaultPagination from '@/views/component/DefaultPagination.vue'; |
74 | 74 |
// API |
75 | 75 |
import { findAllNesDtasProc } from "@/resources/api/nesDta"; |
76 |
-import { excelDownloadAll } from "../../../resources/api/main"; |
|
76 |
+import { excelDownloadProc } from '@/resources/api/file'; |
|
77 |
+import uploadProgressStore from '@/resources/js/uploadProgressStore'; |
|
77 | 78 |
|
78 | 79 |
export default { |
79 | 80 |
components: { |
... | ... | @@ -271,7 +272,6 @@ |
271 | 272 |
|
272 | 273 |
// 스크랩 자료 엑셀 다운로드 |
273 | 274 |
async fnDownload() { |
274 |
- this.loading = true; // 로딩 시작 |
|
275 | 275 |
try { |
276 | 276 |
const params = JSON.parse(JSON.stringify(this.searchReqDTO)); |
277 | 277 |
if (this.searchReqDTO.searchCtgries && this.searchReqDTO.searchCtgries.length > 0) { |
... | ... | @@ -279,20 +279,19 @@ |
279 | 279 |
} else { |
280 | 280 |
delete params.searchCtgries; |
281 | 281 |
} |
282 |
- |
|
283 |
- params.useNews =true; |
|
284 |
- const response = await excelDownloadAll(params); |
|
282 |
+ |
|
283 |
+ let today = new Date().toISOString().substring(2, 10); |
|
284 |
+ today = today.replace(/[^0-9]/g, ""); |
|
285 |
+ const fileName = `[스크랩 자료]언론에서 바라보는 구미시_${today}.xlsx`; |
|
286 |
+ |
|
287 |
+ params.useNews = true; |
|
288 |
+ const response = await excelDownloadProc(params, fileName); |
|
285 | 289 |
|
286 | 290 |
const url = window.URL.createObjectURL( |
287 | 291 |
new Blob([response.data], { |
288 | 292 |
type: response.headers["content-type"], |
289 | 293 |
}) |
290 | 294 |
); |
291 |
- |
|
292 |
- let today = new Date().toISOString().substring(2, 10); |
|
293 |
- today = today.replace(/[^0-9]/g, ""); |
|
294 |
- const fileName = `[스크랩자료]언론에서 바라보는 구미시_${today}.xlsx`; |
|
295 |
- |
|
296 | 295 |
const link = document.createElement("a"); |
297 | 296 |
link.href = url; |
298 | 297 |
link.setAttribute("download", fileName); |
... | ... | @@ -312,7 +311,7 @@ |
312 | 311 |
alert("엑셀 다운로드 중 네트워크 에러가 발생했습니다.\n관리자에게 문의해주세요."); |
313 | 312 |
} |
314 | 313 |
} finally { |
315 |
- this.loading = false; |
|
314 |
+ uploadProgressStore.closeModal(); |
|
316 | 315 |
} |
317 | 316 |
}, |
318 | 317 |
}, |
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?