diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-24 11:06:32 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-24 11:06:32 +0000 |
| commit | 1dc24d48e52f2e490f5603ceb02842586ecae533 (patch) | |
| tree | 8fca2c5b5b52cc10557b5ba6e55b937ae3c57cf6 /lib/vendor-evaluation-submit | |
| parent | ed0d6fcc98f671280c2ccde797b50693da88152e (diff) | |
(대표님) 정기평가 피드백 반영, 설계 피드백 반영, (최겸) 기술영업 피드백 반영
Diffstat (limited to 'lib/vendor-evaluation-submit')
| -rw-r--r-- | lib/vendor-evaluation-submit/table/esg-evaluation-form-sheet.tsx | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/lib/vendor-evaluation-submit/table/esg-evaluation-form-sheet.tsx b/lib/vendor-evaluation-submit/table/esg-evaluation-form-sheet.tsx index d90f60b8..4b48407c 100644 --- a/lib/vendor-evaluation-submit/table/esg-evaluation-form-sheet.tsx +++ b/lib/vendor-evaluation-submit/table/esg-evaluation-form-sheet.tsx @@ -4,7 +4,7 @@ import * as React from "react" import { useForm, useWatch } from "react-hook-form" import { zodResolver } from "@hookform/resolvers/zod" import * as z from "zod" -import { SaveIcon, CheckIcon, XIcon, BarChart3Icon, TrendingUpIcon } from "lucide-react" +import { SaveIcon, CheckIcon, XIcon, BarChart3Icon, TrendingUpIcon, DownloadIcon } from "lucide-react" import { Sheet, @@ -205,6 +205,52 @@ export function EsgEvaluationFormSheet({ } } + // ESG 평가 데이터 내보내기 + const handleExportData = () => { + if (!formData) return + + // CSV 데이터 생성 + const csvData = [] + csvData.push(['카테고리', '점검항목', '평가항목', '평가항목설명', '답변옵션', '옵션점수']) + + formData.evaluations.forEach(evaluation => { + evaluation.items.forEach(item => { + // 각 평가항목에 대해 모든 답변 옵션을 별도 행으로 추가 + item.answerOptions.forEach(option => { + csvData.push([ + evaluation.evaluation.category, + evaluation.evaluation.inspectionItem, + item.item.evaluationItem, + item.item.evaluationItemDescription || '', + option.answerText, + option.score + ]) + }) + }) + }) + + // CSV 문자열 생성 + const csvContent = csvData.map(row => + row.map(field => `"${String(field).replace(/"/g, '""')}"`).join(',') + ).join('\n') + + // BOM 추가 (한글 깨짐 방지) + const bom = '\uFEFF' + const blob = new Blob([bom + csvContent], { type: 'text/csv;charset=utf-8;' }) + + // 다운로드 + const link = document.createElement('a') + const url = URL.createObjectURL(blob) + link.setAttribute('href', url) + link.setAttribute('download', `ESG평가문항_${formData.submission.vendorName}_${new Date().toISOString().split('T')[0]}.csv`) + link.style.visibility = 'hidden' + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + + toast.success('ESG 평가 문항이 다운로드되었습니다.') + } + // 진행률 및 점수 계산 const getProgress = () => { if (!formData) return { @@ -281,10 +327,23 @@ export function EsgEvaluationFormSheet({ <Sheet open={open} onOpenChange={onOpenChange}> <SheetContent className="w-[900px] sm:max-w-[900px] flex flex-col" style={{width:900, maxWidth:900}}> <SheetHeader> - <SheetTitle>ESG 평가 작성</SheetTitle> - <SheetDescription> - {formData?.submission.vendorName}의 ESG 평가를 작성해주세요. - </SheetDescription> + <div className="flex items-center justify-between"> + <div> + <SheetTitle>ESG 평가 작성</SheetTitle> + <SheetDescription> + {formData?.submission.vendorName}의 ESG 평가를 작성해주세요. + </SheetDescription> + </div> + <Button + variant="outline" + size="sm" + onClick={handleExportData} + className="flex items-center gap-2" + > + <DownloadIcon className="h-4 w-4" /> + 내보내기 + </Button> + </div> </SheetHeader> {formData && ( |
