diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-05 01:16:42 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-05 01:16:42 +0000 |
| commit | ed52f5f887fa79addf0d9686cc440a626d22f6bf (patch) | |
| tree | f086a2cde7ff2be0f72d7b403f296f3270e0f45c /app | |
| parent | b6c9ac31358206ad291583d4b045cc5d83ca3987 (diff) | |
(대표님, 임수민) 벤더별 EDP 데이터 입력 진행률 페이지 개선
Diffstat (limited to 'app')
| -rw-r--r-- | app/[lng]/admin/edp-progress-debug/page.tsx | 210 | ||||
| -rw-r--r-- | app/[lng]/admin/edp-progress/page.tsx | 135 | ||||
| -rw-r--r-- | app/[lng]/evcp/(evcp)/edp-progress/page.tsx | 21 |
3 files changed, 3 insertions, 363 deletions
diff --git a/app/[lng]/admin/edp-progress-debug/page.tsx b/app/[lng]/admin/edp-progress-debug/page.tsx deleted file mode 100644 index ebaa07a2..00000000 --- a/app/[lng]/admin/edp-progress-debug/page.tsx +++ /dev/null @@ -1,210 +0,0 @@ -"use client"; - -import React from 'react'; -import { Button } from '@/components/ui/button'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; -import { Input } from '@/components/ui/input'; -import { Label } from '@/components/ui/label'; -import { Badge } from '@/components/ui/badge'; -import { ScrollArea } from '@/components/ui/scroll-area'; -import { debugVendorFieldCalculation } from '@/lib/forms/vendor-completion-stats'; -import { Loader, Search, FileText, Tag, CheckCircle, XCircle } from 'lucide-react'; -import { toast } from 'sonner'; - -export default function DebugVendorFieldsPage() { - const [loading, setLoading] = React.useState(false); - const [vendorId, setVendorId] = React.useState('1'); - const [debugData, setDebugData] = React.useState<any>(null); - - const handleDebug = async () => { - setLoading(true); - setDebugData(null); - - try { - const result = await debugVendorFieldCalculation(Number(vendorId)); - setDebugData(result); - - if (result) { - toast.success(`${result.vendorName}의 필드 계산 디버그 완료`); - } else { - toast.warning('벤더 데이터가 없습니다'); - } - } catch (error) { - console.error('Error debugging vendor fields:', error); - toast.error(`디버그 실패: ${error instanceof Error ? error.message : '알 수 없는 오류'}`); - } finally { - setLoading(false); - } - }; - - const renderFieldDetails = (fieldDetails: any[]) => ( - <div className="space-y-1"> - {fieldDetails.map((field, index) => ( - <div key={index} className="flex items-center gap-2 text-xs"> - <span className="font-mono bg-muted px-1 rounded">{field.fieldKey}</span> - <span className="text-muted-foreground">=</span> - <span className="font-mono">{String(field.fieldValue ?? 'null')}</span> - {field.isEmpty ? ( - <XCircle className="h-3 w-3 text-red-500" /> - ) : ( - <CheckCircle className="h-3 w-3 text-green-500" /> - )} - </div> - ))} - </div> - ); - - return ( - <div className="container mx-auto p-6 space-y-6"> - <div className="flex items-center gap-2 mb-6"> - <Search className="h-6 w-6" /> - <h1 className="text-3xl font-bold">벤더 필드 계산 디버그</h1> - </div> - - {/* Input */} - <Card> - <CardHeader> - <CardTitle>벤더 ID 입력</CardTitle> - </CardHeader> - <CardContent> - <div className="flex gap-4"> - <div className="space-y-2"> - <Label htmlFor="vendorId">Vendor ID</Label> - <Input - id="vendorId" - value={vendorId} - onChange={(e) => setVendorId(e.target.value)} - placeholder="1" - type="number" - /> - </div> - <div className="flex items-end"> - <Button onClick={handleDebug} disabled={loading}> - {loading ? <Loader className="h-4 w-4 animate-spin mr-2" /> : <Search className="h-4 w-4 mr-2" />} - 디버그 실행 - </Button> - </div> - </div> - </CardContent> - </Card> - - {/* Results */} - {debugData && ( - <div className="space-y-4"> - {/* Summary */} - <Card> - <CardHeader> - <CardTitle className="flex items-center gap-2"> - <FileText className="h-5 w-5" /> - {debugData.vendorName} - 전체 요약 - </CardTitle> - </CardHeader> - <CardContent> - <div className="grid grid-cols-2 md:grid-cols-4 gap-4"> - <div className="text-center"> - <div className="text-2xl font-bold text-blue-600"> - {debugData.debugInfo.grandTotal.totalRequiredFields} - </div> - <p className="text-sm text-muted-foreground">전체 필드</p> - </div> - <div className="text-center"> - <div className="text-2xl font-bold text-green-600"> - {debugData.debugInfo.grandTotal.totalFilledFields} - </div> - <p className="text-sm text-muted-foreground">입력 필드</p> - </div> - <div className="text-center"> - <div className="text-2xl font-bold text-red-600"> - {debugData.debugInfo.grandTotal.totalEmptyFields} - </div> - <p className="text-sm text-muted-foreground">빈 필드</p> - </div> - <div className="text-center"> - <div className="text-2xl font-bold text-purple-600"> - {debugData.debugInfo.grandTotal.completionPercentage}% - </div> - <p className="text-sm text-muted-foreground">완성도</p> - </div> - </div> - </CardContent> - </Card> - - {/* Detailed Breakdown */} - <Card> - <CardHeader> - <CardTitle>상세 분석</CardTitle> - </CardHeader> - <CardContent> - <ScrollArea className="h-96"> - <div className="space-y-4"> - {debugData.debugInfo.contracts.map((contract: any, contractIndex: number) => ( - <div key={contractIndex} className="border rounded-lg p-4"> - <div className="flex items-center gap-2 mb-3"> - <Tag className="h-4 w-4" /> - <span className="font-semibold"> - 계약 {contract.contractId} - {contract.projectName} - </span> - <Badge variant="outline"> - 전체: {contract.totalRequiredFields} | 입력: {contract.totalFilledFields} - </Badge> - </div> - - <div className="space-y-3 ml-4"> - {contract.forms.map((form: any, formIndex: number) => ( - <div key={formIndex} className="border-l-2 border-muted pl-4"> - <div className="flex items-center gap-2 mb-2"> - <FileText className="h-3 w-3" /> - <span className="font-medium">{form.formName} ({form.formCode})</span> - <Badge variant="secondary" className="text-xs"> - 전체: {form.totalRequiredFields} | 입력: {form.totalFilledFields} - </Badge> - </div> - - <div className="space-y-2 ml-4"> - {form.tags.map((tag: any, tagIndex: number) => ( - <div key={tagIndex} className="bg-muted/50 rounded p-2"> - <div className="flex items-center gap-2 mb-1"> - <Tag className="h-3 w-3" /> - <span className="font-mono text-sm">{tag.tagNo}</span> - <Badge variant="outline" className="text-xs"> - 전체: {tag.requiredFieldsCount} | 입력: {tag.filledFieldsCount} - </Badge> - </div> - - <div className="ml-4"> - <div className="text-xs text-muted-foreground mb-1"> - 편집 가능한 필드: {tag.editableFields.join(', ')} - </div> - {renderFieldDetails(tag.fieldDetails)} - </div> - </div> - ))} - </div> - </div> - ))} - </div> - </div> - ))} - </div> - </ScrollArea> - </CardContent> - </Card> - - {/* Raw Data */} - <Card> - <CardHeader> - <CardTitle>원시 데이터 (JSON)</CardTitle> - </CardHeader> - <CardContent> - <ScrollArea className="h-64"> - <pre className="text-xs bg-muted p-4 rounded overflow-auto"> - {JSON.stringify(debugData, null, 2)} - </pre> - </ScrollArea> - </CardContent> - </Card> - </div> - )} - </div> - ); -}
\ No newline at end of file diff --git a/app/[lng]/admin/edp-progress/page.tsx b/app/[lng]/admin/edp-progress/page.tsx deleted file mode 100644 index c42a1db7..00000000 --- a/app/[lng]/admin/edp-progress/page.tsx +++ /dev/null @@ -1,135 +0,0 @@ -"use client"; - -import React from 'react'; -import { Button } from '@/components/ui/button'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; -import { Badge } from '@/components/ui/badge'; -import { ScrollArea } from '@/components/ui/scroll-area'; -import { getAllVendorsContractsCompletionSummary } from '@/lib/forms/vendor-completion-stats'; -import { Loader, Users, RefreshCw } from 'lucide-react'; -import { toast } from 'sonner'; - -interface VendorProgress { - vendorId: number; - vendorName: string; - totalForms: number; - tagCount: number; - totalRequiredFields: number; - totalFilledFields: number; - completionPercentage: number; -} - -export default function EDPProgressTestPage() { - const [loading, setLoading] = React.useState(false); - const [vendorProgress, setVendorProgress] = React.useState<VendorProgress[]>([]); - - const loadVendorProgress = async () => { - setLoading(true); - - try { - const result = await getAllVendorsContractsCompletionSummary(); - - if (result && result.vendors) { - const progressData: VendorProgress[] = result.vendors.map(vendor => ({ - vendorId: vendor.vendorId, - vendorName: vendor.vendorName, - totalForms: vendor.totalForms, - tagCount: vendor.totalTags, - totalRequiredFields: vendor.totalRequiredFields, - totalFilledFields: vendor.totalFilledFields, - completionPercentage: vendor.overallCompletionPercentage - })); - - setVendorProgress(progressData); - toast.success(`${progressData.length}개 벤더의 진척도를 불러왔습니다`); - } else { - toast.warning('벤더 데이터가 없습니다'); - } - } catch (error) { - console.error('Error loading vendor progress:', error); - toast.error(`벤더 진척도 로드 실패: ${error instanceof Error ? error.message : '알 수 없는 오류'}`); - } finally { - setLoading(false); - } - }; - - React.useEffect(() => { - loadVendorProgress(); - }, []); - - return ( - <div className="container mx-auto p-6 space-y-6"> - <div className="flex items-center justify-between mb-6"> - <div className="flex items-center gap-2"> - <Users className="h-6 w-6" /> - <h1 className="text-3xl font-bold">벤더 진척도 현황</h1> - </div> - <Button - onClick={loadVendorProgress} - disabled={loading} - className="flex items-center gap-2" - > - {loading ? <Loader className="h-4 w-4 animate-spin" /> : <RefreshCw className="h-4 w-4" />} - 새로고침 - </Button> - </div> - - {/* Vendor Progress List */} - <Card> - <CardHeader> - <CardTitle>벤더별 작업 진척도</CardTitle> - </CardHeader> - <CardContent> - {loading ? ( - <div className="flex items-center justify-center py-8"> - <Loader className="h-6 w-6 animate-spin mr-2" /> - <span>벤더 진척도를 불러오는 중...</span> - </div> - ) : vendorProgress.length === 0 ? ( - <div className="text-center py-8 text-muted-foreground"> - 벤더 데이터가 없습니다. - </div> - ) : ( - <div className="space-y-2"> - {/* Header */} - <div className="grid grid-cols-6 gap-4 p-3 bg-muted rounded-lg font-semibold text-sm"> - <div>벤더명</div> - <div className="text-center">폼 개수</div> - <div className="text-center">태그 개수</div> - <div className="text-center">전체 필드</div> - <div className="text-center">입력 필드</div> - <div className="text-center">완성도</div> - </div> - - {/* Vendor Rows */} - <ScrollArea className="h-96"> - <div className="space-y-1"> - {vendorProgress.map((vendor) => ( - <div key={vendor.vendorId} className="grid grid-cols-6 gap-4 p-3 border rounded-lg hover:bg-muted/50"> - <div className="font-medium">{vendor.vendorName}</div> - <div className="text-center">{vendor.totalForms}</div> - <div className="text-center">{vendor.tagCount}</div> - <div className="text-center">{vendor.totalRequiredFields}</div> - <div className="text-center">{vendor.totalFilledFields}</div> - <div className="text-center"> - <Badge - variant={ - vendor.completionPercentage >= 80 ? "default" : - vendor.completionPercentage >= 50 ? "secondary" : - "destructive" - } - > - {vendor.completionPercentage}% - </Badge> - </div> - </div> - ))} - </div> - </ScrollArea> - </div> - )} - </CardContent> - </Card> - </div> - ); -}
\ No newline at end of file diff --git a/app/[lng]/evcp/(evcp)/edp-progress/page.tsx b/app/[lng]/evcp/(evcp)/edp-progress/page.tsx index 12e14b98..7edc52c9 100644 --- a/app/[lng]/evcp/(evcp)/edp-progress/page.tsx +++ b/app/[lng]/evcp/(evcp)/edp-progress/page.tsx @@ -1,27 +1,12 @@ import * as React from "react" -import { type SearchParams } from "@/types/table" -import { getValidFilters } from "@/lib/data-table" import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton" -import { EDPProgressTable } from "@/lib/edp-progress/table/edp-progress-table" -import { getEDPProgressLists } from "@/lib/edp-progress/service" import { Shell } from "@/components/shell" import { InformationButton } from "@/components/information/information-button" -import { searchParamsCache } from "@/lib/edp-progress/validations" +import { VendorFormStatusTable } from "@/components/form-data-stat/form-data-stat-table" -interface IndexPageProps { - searchParams: Promise<SearchParams> -} - -export default async function IndexPage(props: IndexPageProps) { - const searchParams = await props.searchParams - const search = searchParamsCache.parse(searchParams) - - const validFilters = getValidFilters(search.filters) - const promises = Promise.all([ - getEDPProgressLists({ filters: validFilters, sort: search.sort, search: search.search, joinOperator: search.joinOperator as any }), - ]) +export default async function IndexPage() { return ( <Shell className="gap-2"> @@ -43,7 +28,7 @@ export default async function IndexPage(props: IndexPageProps) { /> } > - <EDPProgressTable promises={promises} /> + <VendorFormStatusTable /> </React.Suspense> </Shell> ) |
