diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/tbe-last/table/tbe-last-table-columns.tsx | 55 | ||||
| -rw-r--r-- | lib/tbe-last/table/tbe-last-table.tsx | 91 |
2 files changed, 123 insertions, 23 deletions
diff --git a/lib/tbe-last/table/tbe-last-table-columns.tsx b/lib/tbe-last/table/tbe-last-table-columns.tsx index b18e51c0..886a41ba 100644 --- a/lib/tbe-last/table/tbe-last-table-columns.tsx +++ b/lib/tbe-last/table/tbe-last-table-columns.tsx @@ -15,8 +15,9 @@ import { TbeLastView } from "@/db/schema/tbeLastView" interface GetColumnsProps { onOpenSessionDetail: (sessionId: number) => void; onOpenDocuments: (sessionId: number) => void; - onOpenPrItems: (rfqId: number) => void; + onOpenPrItems: (sessionId: number) => void; onOpenEvaluation: (session: TbeLastView) => void; + getPrCountsOverride?: (sessionId: number) => { total: number, major: number } | undefined; } export function getColumns({ @@ -24,6 +25,7 @@ export function getColumns({ onOpenDocuments, onOpenPrItems, onOpenEvaluation, + getPrCountsOverride, }: GetColumnsProps): ColumnDef<TbeLastView>[] { const columns: ColumnDef<TbeLastView>[] = [ @@ -60,6 +62,9 @@ export function getColumns({ header: ({ column }) => ( <DataTableColumnHeaderSimple column={column} title="TBE Code" /> ), + meta: { + excelHeader: "TBE Code" + }, cell: ({ row }) => { const sessionId = row.original.tbeSessionId; const sessionCode = row.original.sessionCode; @@ -85,6 +90,9 @@ export function getColumns({ ), cell: ({ row }) => row.original.rfqCode, size: 120, + meta: { + excelHeader: "RFQ Code" + }, }, { @@ -144,6 +152,9 @@ export function getColumns({ ), cell: ({ row }) => row.original.rfqTitle || "-", size: 200, + meta: { + excelHeader: "RFQ Title" + }, }, // RFQ Due Date @@ -157,6 +168,9 @@ export function getColumns({ return date ? formatDate(date, "KR") : "-"; }, size: 100, + meta: { + excelHeader: "Due Date" + }, }, // Package No @@ -181,6 +195,9 @@ export function getColumns({ ); }, size: 150, + meta: { + excelHeader: "Package No" + }, }, // Project @@ -205,6 +222,9 @@ export function getColumns({ ); }, size: 150, + meta: { + excelHeader: "Project" + }, }, // Vendor Code @@ -215,6 +235,9 @@ export function getColumns({ ), cell: ({ row }) => row.original.vendorCode || "-", size: 100, + meta: { + excelHeader: "Vendor Code" + }, }, // Vendor Name @@ -225,6 +248,9 @@ export function getColumns({ ), cell: ({ row }) => row.original.vendorName, size: 200, + meta: { + excelHeader: "Vendor Name" + }, }, // 구매담당자 (PIC Name) @@ -235,6 +261,9 @@ export function getColumns({ ), cell: ({ row }) => row.original.picName || "-", size: 120, + meta: { + excelHeader: "구매담당자" + }, }, // 설계담당자 (Engineering PIC Name) @@ -245,6 +274,9 @@ export function getColumns({ ), cell: ({ row }) => row.original.EngPicName || "-", size: 120, + meta: { + excelHeader: "설계담당자" + }, }, // TBE Status @@ -253,6 +285,9 @@ export function getColumns({ header: ({ column }) => ( <DataTableColumnHeaderSimple column={column} title="Status" /> ), + meta: { + excelHeader: "Status" + }, cell: ({ row }) => { const status = row.original.sessionStatus; @@ -287,6 +322,9 @@ export function getColumns({ header: ({ column }) => ( <DataTableColumnHeaderSimple column={column} title="Result" /> ), + meta: { + excelHeader: "Result" + }, cell: ({ row }) => { const result = row.original.evaluationResult; const session = row.original; @@ -340,17 +378,23 @@ export function getColumns({ header: ({ column }) => ( <DataTableColumnHeaderSimple column={column} title="PR Items" /> ), + meta: { + excelHeader: "PR Items" + }, cell: ({ row }) => { + const sessionId = row.original.tbeSessionId; const rfqId = row.original.rfqId; - const totalCount = row.original.prItemsCount; - const majorCount = row.original.majorItemsCount; + const override = getPrCountsOverride?.(sessionId) + const totalCount = override?.total ?? row.original.prItemsCount; + const majorCount = override?.major ?? row.original.majorItemsCount; + // counts rendered from override when available return ( <Button variant="ghost" size="sm" className="h-8 px-2" - onClick={() => onOpenPrItems(rfqId)} + onClick={() => onOpenPrItems(sessionId)} > <ListChecks className="h-4 w-4 mr-1" /> <span className="text-xs"> @@ -369,6 +413,9 @@ export function getColumns({ header: ({ column }) => ( <DataTableColumnHeaderSimple column={column} title="Documents" /> ), + meta: { + excelHeader: "Documents" + }, cell: ({ row }) => { const sessionId = row.original.tbeSessionId; const buyerDocs = Number(row.original.buyerDocumentsCount); diff --git a/lib/tbe-last/table/tbe-last-table.tsx b/lib/tbe-last/table/tbe-last-table.tsx index c18768cd..fbb334d0 100644 --- a/lib/tbe-last/table/tbe-last-table.tsx +++ b/lib/tbe-last/table/tbe-last-table.tsx @@ -45,6 +45,8 @@ export function TbeLastTable({ promises }: TbeLastTableProps) { const [selectedSession, setSelectedSession] = React.useState<TbeLastView | null>(null) const [sessionDetail, setSessionDetail] = React.useState<any>(null) const [isLoadingDetail, setIsLoadingDetail] = React.useState(false) + // PR Items count overrides per sessionId (sourced from dialog detail) + const [prItemsCountsBySessionId, setPrItemsCountsBySessionId] = React.useState<Record<number, { total: number, major: number }>>({}) // Load session detail when needed const loadSessionDetail = React.useCallback(async (sessionId: number) => { @@ -52,6 +54,14 @@ export function TbeLastTable({ promises }: TbeLastTableProps) { try { const detail = await getTBESessionDetail(sessionId) setSessionDetail(detail) + // Update PR items count override for this session + if (detail?.session?.tbeSessionId) { + const sid = detail.session.tbeSessionId as number + const items = Array.isArray(detail?.prItems) ? detail.prItems : [] + const total = items.length + const major = items.filter((it: any) => it?.majorYn === true).length + setPrItemsCountsBySessionId(prev => ({ ...prev, [sid]: { total, major } })) + } } catch (error) { console.error("Failed to load session detail:", error) } finally { @@ -72,10 +82,10 @@ export function TbeLastTable({ promises }: TbeLastTableProps) { loadSessionDetail(sessionId) }, [loadSessionDetail]) - const handleOpenPrItems = React.useCallback((rfqId: number) => { - setSelectedRfqId(rfqId) + const handleOpenPrItems = React.useCallback((sessionId: number) => { + setSelectedSessionId(sessionId) setPrItemsOpen(true) - loadSessionDetail(rfqId) + loadSessionDetail(sessionId) }, [loadSessionDetail]) const handleOpenEvaluation = React.useCallback((session: TbeLastView) => { @@ -85,9 +95,7 @@ export function TbeLastTable({ promises }: TbeLastTableProps) { }, []) - const handleRefresh = React.useCallback(() => { - router.refresh() - }, [router]) + // Refresh 기능 제거됨 // Table columns const columns = React.useMemo( @@ -97,13 +105,64 @@ export function TbeLastTable({ promises }: TbeLastTableProps) { onOpenDocuments: handleOpenDocuments, onOpenPrItems: handleOpenPrItems, onOpenEvaluation: handleOpenEvaluation, + getPrCountsOverride: (sessionId: number) => prItemsCountsBySessionId[sessionId] }), - [handleOpenSessionDetail, handleOpenDocuments, handleOpenPrItems, handleOpenEvaluation] + [handleOpenSessionDetail, handleOpenDocuments, handleOpenPrItems, handleOpenEvaluation, prItemsCountsBySessionId] ) // Filter fields const filterFields: DataTableAdvancedFilterField<TbeLastView>[] = [ { + id: "sessionCode", + label: "TBE Code", + type: "text", + }, + { + id: "rfqCode", + label: "RFQ Code", + type: "text", + }, + { + id: "rfqTitle", + label: "RFQ Title", + type: "text", + }, + { + id: "rfqDueDate", + label: "Due Date", + type: "date", + }, + { + id: "packageNo", + label: "Package No", + type: "text", + }, + { + id: "projectCode", + label: "Project", + type: "text", + }, + { + id: "vendorCode", + label: "Vendor Code", + type: "text", + }, + { + id: "vendorName", + label: "Vendor Name", + type: "text", + }, + { + id: "picName", + label: "구매담당자", + type: "text", + }, + { + id: "EngPicName", + label: "설계담당자", + type: "text", + }, + { id: "sessionStatus", label: "Status", type: "select", @@ -120,9 +179,10 @@ export function TbeLastTable({ promises }: TbeLastTableProps) { label: "Result", type: "select", options: [ - { label: "Pass", value: "pass" }, - { label: "Conditional Pass", value: "conditional_pass" }, - { label: "Non-Pass", value: "non_pass" }, + { label: "Acceptable", value: "Acceptable" }, + { label: "Conditional", value: "Acceptable with Comment" }, + { label: "Not Acceptable", value: "Not Acceptable" }, + { label: "Pending", value: "" }, ], }, ] @@ -234,15 +294,7 @@ export function TbeLastTable({ promises }: TbeLastTableProps) { 선택된 항목 TBE 요청 ({table.getFilteredSelectedRowModel().rows.length}) </Button> )} - <Button - variant="outline" - size="sm" - onClick={handleRefresh} - className="gap-2" - > - <RefreshCw className="size-4" /> - <span>Refresh</span> - </Button> + {/* Refresh 버튼 제거됨 */} <Button variant="outline" size="sm" @@ -250,6 +302,7 @@ export function TbeLastTable({ promises }: TbeLastTableProps) { exportTableToExcel(table, { filename: "tbe-sessions", excludeColumns: ["select", "actions"], + useGroupHeader: true }) } className="gap-2" |
