From bac0228d21b7195065e9cddcc327ae33659c7bcc Mon Sep 17 00:00:00 2001 From: dujinkim Date: Sun, 1 Jun 2025 13:52:21 +0000 Subject: (대표님) 20250601까지 작업사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enhanced-document-service.ts | 38 +++---- lib/vendor-document-list/service.ts | 18 ++-- lib/vendor-document-list/table/add-doc-dialog.tsx | 28 ++++- .../table/enhanced-doc-table-columns.tsx | 114 +++++++++++++++++++-- .../table/enhanced-doc-table-toolbar-actions.tsx | 25 +++-- .../table/enhanced-documents-table.tsx | 112 +++++++------------- 6 files changed, 211 insertions(+), 124 deletions(-) (limited to 'lib/vendor-document-list') diff --git a/lib/vendor-document-list/enhanced-document-service.ts b/lib/vendor-document-list/enhanced-document-service.ts index 00f40ea6..d39dfaa4 100644 --- a/lib/vendor-document-list/enhanced-document-service.ts +++ b/lib/vendor-document-list/enhanced-document-service.ts @@ -86,8 +86,8 @@ export async function getEnhancedDocuments( input: GetEnhancedDocumentsSchema, contractId: number ) { - return unstable_cache( - async () => { + // return unstable_cache( + // async () => { try { const offset = (input.page - 1) * input.perPage @@ -140,6 +140,8 @@ export async function getEnhancedDocuments( return { data, total } }) + console.log(data) + const pageCount = Math.ceil(total / input.perPage) return { data, pageCount, total } @@ -147,19 +149,19 @@ export async function getEnhancedDocuments( console.error("Error fetching enhanced documents:", err) return { data: [], pageCount: 0, total: 0 } } - }, - [JSON.stringify(input), String(contractId)], - { - revalidate: 3600, - tags: [`enhanced-documents-${contractId}`], - } - )() + // }, + // [JSON.stringify(input), String(contractId)], + // { + // revalidate: 3600, + // tags: [`enhanced-documents-${contractId}`], + // } + // )() } // 통계 데이터 가져오기 export async function getDocumentStatistics(contractId: number) { - return unstable_cache( - async () => { + // return unstable_cache( + // async () => { try { const result = await db .select({ @@ -229,13 +231,13 @@ export async function getDocumentStatistics(contractId: number) { avgProgress: 0, } } - }, - [`document-stats-${contractId}`], - { - revalidate: 1800, // 30분 캐시 - tags: [`document-stats-${contractId}`], - } - )() + // }, + // [`document-stats-${contractId}`], + // { + // revalidate: 1800, // 30분 캐시 + // tags: [`document-stats-${contractId}`], + // } + // )() } // 빠른 필터 데이터 diff --git a/lib/vendor-document-list/service.ts b/lib/vendor-document-list/service.ts index 75c9b6cd..356bc792 100644 --- a/lib/vendor-document-list/service.ts +++ b/lib/vendor-document-list/service.ts @@ -21,8 +21,8 @@ import { revalidateTag, unstable_noStore ,revalidatePath} from "next/cache"; */ export async function getVendorDocuments(input: GetVendorDcoumentsSchema, id: number) { - return unstable_cache( - async () => { + // return unstable_cache( + // async () => { try { const offset = (input.page - 1) * input.perPage; @@ -69,13 +69,13 @@ export async function getVendorDocuments(input: GetVendorDcoumentsSchema, id: nu // 에러 발생 시 디폴트 return { data: [], pageCount: 0 }; } - }, - [JSON.stringify(input), String(id)], // 캐싱 키 - { - revalidate: 3600, - tags: [`vendor-docuemnt-list-${id}`], - } - )(); + // }, + // [JSON.stringify(input), String(id)], // 캐싱 키 + // { + // revalidate: 3600, + // tags: [`vendor-docuemnt-list-${id}`], + // } + // )(); } diff --git a/lib/vendor-document-list/table/add-doc-dialog.tsx b/lib/vendor-document-list/table/add-doc-dialog.tsx index b108721c..9bedc810 100644 --- a/lib/vendor-document-list/table/add-doc-dialog.tsx +++ b/lib/vendor-document-list/table/add-doc-dialog.tsx @@ -37,9 +37,10 @@ type CreateDocumentSchema = z.infer; interface AddDocumentListDialogProps { projectType: "ship" | "plant"; contractId: number; + onSuccess?: () => void; // ✅ onSuccess 콜백 추가 } -export function AddDocumentListDialog({ projectType, contractId }: AddDocumentListDialogProps) { +export function AddDocumentListDialog({ projectType, contractId, onSuccess }: AddDocumentListDialogProps) { const [open, setOpen] = React.useState(false); const [isSubmitting, setIsSubmitting] = React.useState(false); const router = useRouter(); @@ -98,8 +99,12 @@ export function AddDocumentListDialog({ projectType, contractId }: AddDocumentLi } as CreateDocumentInputType); if (result.success) { - // 성공 시 캐시 무효화 - await invalidateDocumentCache(contractId); + // ✅ 캐시 무효화 시도 (에러가 나더라도 계속 진행) + try { + await invalidateDocumentCache(contractId); + } catch (cacheError) { + console.warn('Cache invalidation failed:', cacheError); + } // 토스트 메시지 toast({ @@ -109,10 +114,23 @@ export function AddDocumentListDialog({ projectType, contractId }: AddDocumentLi }); // 모달 닫기 및 폼 리셋 - form.reset(); + form.reset({ + docNumber: "", + title: "", + stages: defaultStages + }); setOpen(false); - router.refresh(); + // ✅ 성공 콜백 호출 (부모 컴포넌트에서 추가 처리 가능) + if (onSuccess) { + onSuccess(); + } + + // ✅ 라우터 새로고침 (약간의 지연을 두고 실행) + setTimeout(() => { + router.refresh(); + }, 100); + } else { // 실패 시 에러 토스트 toast({ diff --git a/lib/vendor-document-list/table/enhanced-doc-table-columns.tsx b/lib/vendor-document-list/table/enhanced-doc-table-columns.tsx index 534a80a0..c8487d82 100644 --- a/lib/vendor-document-list/table/enhanced-doc-table-columns.tsx +++ b/lib/vendor-document-list/table/enhanced-doc-table-columns.tsx @@ -30,7 +30,9 @@ import { FileText, Eye, Edit, - Trash2 + Trash2, + Building, + Code } from "lucide-react" import { cn } from "@/lib/utils" @@ -140,7 +142,11 @@ export function getUpdatedEnhancedColumns({ setRowAction, projectType }: GetColumnsProps): ColumnDef[] { - return [ + const isPlantProject = projectType === "plant" + + + // 기본 컬럼들 + const baseColumns: ColumnDef[] = [ // 체크박스 선택 { id: "select", @@ -177,13 +183,8 @@ export function getUpdatedEnhancedColumns({ cell: ({ row }) => { const doc = row.original return ( -
{/* ✅ items-start 추가 */} +
{doc.docNumber} - {/* {doc.currentStagePriority && ( - - {getPriorityText(doc.currentStagePriority)} - - )} */}
) }, @@ -193,7 +194,93 @@ export function getUpdatedEnhancedColumns({ excelHeader: "문서번호" }, }, + ] + // ✅ Ship 프로젝트용 추가 컬럼들 + const plantColumns: ColumnDef[] = isPlantProject ? [ + // 벤더 문서번호 + { + accessorKey: "vendorDocNumber", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const doc = row.original + return ( +
+ {doc.vendorDocNumber ? ( + {doc.vendorDocNumber} + ) : ( + - + )} +
+ ) + }, + size: 120, + enableResizing: true, + meta: { + excelHeader: "벤더 문서번호" + }, + }, + + // 프로젝트 코드 + { + accessorKey: "projectCode", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const doc = row.original + return ( +
+ {/* */} + + {doc.projectCode || '-'} + +
+ ) + }, + size: 100, + enableResizing: true, + meta: { + excelHeader: "프로젝트 코드" + }, + }, + + // 벤더 정보 + { + accessorKey: "vendorName", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const doc = row.original + return ( +
+
+ {/* */} + + {doc.vendorName || '-'} + +
+ {doc.vendorCode && ( + + {doc.vendorCode} + + )} +
+ ) + }, + size: 150, + enableResizing: true, + meta: { + excelHeader: "벤더명" + }, + }, + ] : [] + + // 나머지 공통 컬럼들 + const commonColumns: ColumnDef[] = [ // 문서명 + 담당자 { accessorKey: "title", @@ -223,7 +310,7 @@ export function getUpdatedEnhancedColumns({
) }, - size: 250, + size: isPlantProject ? 200 : 250, // Ship 프로젝트일 때는 너비 조정 enableResizing: true, meta: { excelHeader: "문서명" @@ -341,7 +428,6 @@ export function getUpdatedEnhancedColumns({ return (
{doc.latestRevision} - {/*
{doc.latestRevisionUploaderName}
*/} {doc.latestRevisionStatus && ( {getStatusText(doc.latestRevisionStatus)} @@ -380,7 +466,6 @@ export function getUpdatedEnhancedColumns({ }, }, - // 액션 메뉴 // 액션 메뉴 { id: "actions", @@ -532,6 +617,13 @@ export function getUpdatedEnhancedColumns({ size: 40, } ] + + // ✅ 모든 컬럼을 순서대로 결합 + return [ + ...baseColumns, // 체크박스, 문서번호 + ...plantColumns, // Ship 전용 컬럼들 (조건부) + ...commonColumns // 나머지 공통 컬럼들 + ] } // 확장된 행 컨텐츠 컴포넌트 (업데이트된 버전) diff --git a/lib/vendor-document-list/table/enhanced-doc-table-toolbar-actions.tsx b/lib/vendor-document-list/table/enhanced-doc-table-toolbar-actions.tsx index 368b1e1c..fa1b957b 100644 --- a/lib/vendor-document-list/table/enhanced-doc-table-toolbar-actions.tsx +++ b/lib/vendor-document-list/table/enhanced-doc-table-toolbar-actions.tsx @@ -40,6 +40,16 @@ export function EnhancedDocTableToolbarActions({ // 필요시 추가 액션 수행 } + const handleDocumentAdded = () => { + // 테이블 새로고침 + table.resetRowSelection() + + // 추가적인 새로고침 시도 + setTimeout(() => { + window.location.reload() // 강제 새로고침 + }, 500) + } + return (
{/* 기존 액션들 */} @@ -52,14 +62,13 @@ export function EnhancedDocTableToolbarActions({ /> ) : null} - {/* 메인 액션 버튼들 */} - {projectType === "plant" && ( - - )} - + {/* ✅ AddDocumentListDialog에 필요한 props 전달 */} + + {/* 일괄 업로드 버튼 */}
- - {/* 선택된 항목 정보 */} - {/* {table.getFilteredSelectedRowModel().rows.length > 0 && ( -
- - {table.getFilteredSelectedRowModel().rows.length}개 항목이 선택되었습니다 - -
- - -
-
- )} */}
- {/* 분리된 다이얼로그들 */} + {/* ✅ 분리된 다이얼로그들 - UpdateDocumentSheet와 AddDocumentListDialog로 교체 */} - {/* ✅ 리비전 업로드 다이얼로그 - mode props 추가 */} + {/* 리비전 업로드 다이얼로그 - mode props 추가 */} { @@ -543,28 +522,15 @@ export function EnhancedDocumentsTable({ mode={uploadMode} /> - {/* 문서 편집 다이얼로그 */} - { - if (!open) closeAllDialogs() - else setEditDialogOpen(open) - }} - document={selectedDocument} - projectType={projectType} - /> - - {/* PDF 뷰어 다이얼로그 (기존 ViewDocumentDialog 재사용) */} - - {/* { if (!open) closeAllDialogs() - else setViewDialogOpen(open) + else setEditSheetOpen(open) }} - revisions={selectedRevisions} + document={convertToUpdateFormat(selectedDocument)} /> - */} ) } \ No newline at end of file -- cgit v1.2.3