diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-02 09:52:21 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-02 09:52:21 +0000 |
| commit | fccb00d15466cd0b2d861163663a5070c768ff77 (patch) | |
| tree | 4b14b27417ebeb873a9d4b4d7b5c64f6e1d78135 /lib/welding | |
| parent | 72f212f717f136e875e7623404a5ddd4c5268901 (diff) | |
(대표님) OCR 박진석프로 요청 대응, rfq 변경된 요구사항 구현
Diffstat (limited to 'lib/welding')
| -rw-r--r-- | lib/welding/table/ocr-table-toolbar-actions.tsx | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/lib/welding/table/ocr-table-toolbar-actions.tsx b/lib/welding/table/ocr-table-toolbar-actions.tsx index a6a38adc..35171c29 100644 --- a/lib/welding/table/ocr-table-toolbar-actions.tsx +++ b/lib/welding/table/ocr-table-toolbar-actions.tsx @@ -497,34 +497,47 @@ export function OcrTableToolbarActions({ table }: OcrTableToolbarActionsProps) { } // 전체 데이터 내보내기 - const exportAllData = async () => { - if (isExporting) return - setIsExporting(true) +const exportAllData = async () => { + if (isExporting) return - try { - toast.loading("전체 데이터를 가져오는 중...", { - description: "잠시만 기다려주세요." - }) - - const allData = await getOcrAllRows() - toast.dismiss() + setIsExporting(true) - if (allData.length === 0) { - toast.warning("내보낼 데이터가 없습니다.") - return - } + try { + const loadingToast = toast.loading("엑셀 파일을 생성 중입니다...", { + description: "대량 데이터 처리 중... 잠시만 기다려주세요." + }) - await exportOcrDataToExcel(allData, `OCR 결과 (전체 데이터 - ${allData.length}개 행)`) - toast.success(`전체 데이터 ${allData.length}개 행이 성공적으로 내보내졌습니다.`) + // 서버에서 직접 엑셀 파일 받기 + const response = await fetch('/api/ocr/export', { + method: 'GET', + }) - } catch (error) { - console.error('전체 데이터 내보내기 오류:', error) - toast.error('전체 데이터 내보내기 중 오류가 발생했습니다.') - } finally { - setIsExporting(false) + if (!response.ok) { + throw new Error('Export failed') } + + // Blob으로 변환 후 다운로드 + const blob = await response.blob() + const url = window.URL.createObjectURL(blob) + const a = document.createElement('a') + a.href = url + a.download = `OCR_Export_${new Date().toISOString()}.xlsx` + document.body.appendChild(a) + a.click() + document.body.removeChild(a) + window.URL.revokeObjectURL(url) + + toast.dismiss(loadingToast) + toast.success("엑셀 파일이 성공적으로 다운로드되었습니다.") + + } catch (error) { + console.error('Export error:', error) + toast.error('데이터 내보내기 중 오류가 발생했습니다.') + } finally { + setIsExporting(false) } +} // 삭제 후 콜백 - 테이블 새로고침 const handleDeleteSuccess = () => { |
