From 7b0c7c8e56fb027c729c953b0b87dab72156f661 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Mon, 15 Sep 2025 23:42:46 +0900
Subject: (김준회) 임시 견적요청 및 AVL detail 관련 수정사항 처리
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/avl/table/avl-table-columns.tsx | 213 ++++++++++++++++--------------------
 1 file changed, 95 insertions(+), 118 deletions(-)

(limited to 'lib/avl/table/avl-table-columns.tsx')

diff --git a/lib/avl/table/avl-table-columns.tsx b/lib/avl/table/avl-table-columns.tsx
index 8caf012e..72c59aa9 100644
--- a/lib/avl/table/avl-table-columns.tsx
+++ b/lib/avl/table/avl-table-columns.tsx
@@ -2,9 +2,8 @@ import { Checkbox } from "@/components/ui/checkbox"
 import { Button } from "@/components/ui/button"
 import { Badge } from "@/components/ui/badge"
 import { Eye, Edit, Trash2, History } from "lucide-react"
-import { type ColumnDef, TableMeta } from "@tanstack/react-table"
+import { type ColumnDef } from "@tanstack/react-table"
 import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header"
-import { EditableCell } from "@/components/data-table/editable-cell"
 import { AvlListItem } from "../types"
 
 interface GetColumnsProps {
@@ -12,18 +11,12 @@ interface GetColumnsProps {
   onRowSelect?: (id: number, selected: boolean) => void
 }
 
-// 수정 여부 확인 헬퍼 함수
-const getIsModified = (table: any, rowId: string, fieldName: string) => {
-  const pendingChanges = table.options.meta?.getPendingChanges?.() || {}
-  return String(rowId) in pendingChanges && fieldName in pendingChanges[String(rowId)]
-}
-
 // 테이블 메타 타입 확장
 declare module "@tanstack/react-table" {
   interface TableMeta<TData> {
-    onCellUpdate?: (id: string, field: keyof TData, newValue: any) => Promise<void>
+    onCellUpdate?: (id: string, field: keyof TData, newValue: string | boolean) => Promise<void>
     onCellCancel?: (id: string, field: keyof TData) => void
-    onAction?: (action: string, data?: any) => void
+    onAction?: (action: string, data?: Partial<AvlListItem>) => void
     onSaveEmptyRow?: (tempId: string) => Promise<void>
     onCancelEmptyRow?: (tempId: string) => void
     isEmptyRow?: (id: string) => boolean
@@ -35,7 +28,7 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
   const columns: ColumnDef<AvlListItem>[] = [
     // 기본 정보 그룹
     {
-      header: "기본 정보",
+      header: "AVL 정보",
       columns: [
       {
         id: "select",
@@ -69,25 +62,12 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
         header: ({ column }) => (
           <DataTableColumnHeaderSimple column={column} title="AVL 분류" />
         ),
-        cell: ({ getValue, row, table }) => {
+        cell: ({ getValue }) => {
           const value = getValue() as boolean
-          const isModified = getIsModified(table, row.id, "isTemplate")
           return (
-            <EditableCell
-              value={value ? "표준 AVL" : "프로젝트 AVL"}
-              isModified={isModified}
-              type="select"
-              options={[
-                { value: false, label: "프로젝트 AVL" },
-                { value: true, label: "표준 AVL" },
-              ]}
-              onUpdate={(newValue) => {
-                table.options.meta?.onCellUpdate?.(row.id, "isTemplate", newValue === "true")
-              }}
-              onCancel={() => {
-                table.options.meta?.onCellCancel?.(row.id, "isTemplate")
-              }}
-            />
+            <div className="text-center">
+              {value ? "표준 AVL" : "프로젝트 AVL"}
+            </div>
           )
         },
         size: 120,
@@ -97,25 +77,12 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
         header: ({ column }) => (
           <DataTableColumnHeaderSimple column={column} title="공사부문" />
         ),
-        cell: ({ getValue, row, table }) => {
+        cell: ({ getValue }) => {
           const value = getValue() as string
-          const isModified = getIsModified(table, row.id, "constructionSector")
           return (
-            <EditableCell
-              value={value}
-              isModified={isModified}
-              type="select"
-              options={[
-                { value: "조선", label: "조선" },
-                { value: "해양", label: "해양" },
-              ]}
-              onUpdate={(newValue) => {
-                table.options.meta?.onCellUpdate?.(row.id, "constructionSector", newValue)
-              }}
-              onCancel={() => {
-                table.options.meta?.onCellCancel?.(row.id, "constructionSector")
-              }}
-            />
+            <div className="text-center">
+              {value}
+            </div>
           )
         },
         size: 100,
@@ -125,20 +92,12 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
         header: ({ column }) => (
           <DataTableColumnHeaderSimple column={column} title="프로젝트 코드" />
         ),
-        cell: ({ getValue, row, table }) => {
+        cell: ({ getValue }) => {
           const value = getValue() as string
-          const isModified = getIsModified(table, row.id, "projectCode")
           return (
-            <EditableCell
-              value={value}
-              isModified={isModified}
-              onUpdate={(newValue) => {
-                table.options.meta?.onCellUpdate?.(row.id, "projectCode", newValue)
-              }}
-              onCancel={() => {
-                table.options.meta?.onCellCancel?.(row.id, "projectCode")
-              }}
-            />
+            <div className="text-center">
+              {value}
+            </div>
           )
         },
         size: 140,
@@ -148,20 +107,12 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
         header: ({ column }) => (
           <DataTableColumnHeaderSimple column={column} title="선종" />
         ),
-        cell: ({ getValue, row, table }) => {
+        cell: ({ getValue }) => {
           const value = getValue() as string
-          const isModified = getIsModified(table, row.id, "shipType")
           return (
-            <EditableCell
-              value={value}
-              isModified={isModified}
-              onUpdate={(newValue) => {
-                table.options.meta?.onCellUpdate?.(row.id, "shipType", newValue)
-              }}
-              onCancel={() => {
-                table.options.meta?.onCellCancel?.(row.id, "shipType")
-              }}
-            />
+            <div className="text-center">
+              {value}
+            </div>
           )
         },
         size: 100,
@@ -171,20 +122,12 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
         header: ({ column }) => (
           <DataTableColumnHeaderSimple column={column} title="AVL 종류" />
         ),
-        cell: ({ getValue, row, table }) => {
+        cell: ({ getValue }) => {
           const value = getValue() as string
-          const isModified = getIsModified(table, row.id, "avlKind")
           return (
-            <EditableCell
-              value={value}
-              isModified={isModified}
-              onUpdate={(newValue) => {
-                table.options.meta?.onCellUpdate?.(row.id, "avlKind", newValue)
-              }}
-              onCancel={() => {
-                table.options.meta?.onCellCancel?.(row.id, "avlKind")
-              }}
-            />
+            <div className="text-center">
+              {value}
+            </div>
           )
         },
         size: 120,
@@ -194,25 +137,12 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
         header: ({ column }) => (
           <DataTableColumnHeaderSimple column={column} title="H/T 구분" />
         ),
-        cell: ({ getValue, row, table }) => {
+        cell: ({ getValue }) => {
           const value = getValue() as string
-          const isModified = getIsModified(table, row.id, "htDivision")
           return (
-            <EditableCell
-              value={value}
-              isModified={isModified}
-              type="select"
-              options={[
-                { value: "H", label: "H" },
-                { value: "T", label: "T" },
-              ]}
-              onUpdate={(newValue) => {
-                table.options.meta?.onCellUpdate?.(row.id, "htDivision", newValue)
-              }}
-              onCancel={() => {
-                table.options.meta?.onCellCancel?.(row.id, "htDivision")
-              }}
-            />
+            <div className="text-center">
+              {value}
+            </div>
           )
         },
         size: 80,
@@ -246,9 +176,52 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
     ],
   },
 
+  // 집계 그룹
+  {
+    header: "등록정보",
+    columns: [
+      {
+        accessorKey: "PKG",
+        header: ({ column }) => (
+          <DataTableColumnHeaderSimple column={column} title="PKG" />
+        ),
+      },
+      {
+        accessorKey: "materialGroup",
+        header: ({ column }) => (
+          <DataTableColumnHeaderSimple column={column} title="자재그룹" />
+        ),
+      },
+      {
+        accessorKey: "vendor",
+        header: ({ column }) => (
+          <DataTableColumnHeaderSimple column={column} title="협력업체" />
+        ),
+      },
+      {
+        accessorKey: "Tier",
+        header: ({ column }) => (
+          <DataTableColumnHeaderSimple column={column} title="Tier" />
+        ),
+      },
+      {
+        accessorKey: "ownerSuggestion",
+        header: ({ column }) => (
+          <DataTableColumnHeaderSimple column={column} title="선주 제안" />
+        ),
+      },
+      {
+        accessorKey: "shiSuggestion",
+        header: ({ column }) => (
+          <DataTableColumnHeaderSimple column={column} title="SHI 제안" />
+        ),
+      },
+    ],
+  },
+
   // 등록 정보 그룹
   {
-    header: "등록 정보",
+    header: "작성정보",
     columns: [
       {
         accessorKey: "createdAt",
@@ -261,10 +234,32 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
         },
         size: 100,
       },
+      {
+        accessorKey: "createdBy",
+        header: ({ column }) => (
+          <DataTableColumnHeaderSimple column={column} title="등재자" />
+        ),
+        cell: ({ getValue }) => {
+          const date = getValue() as string
+          return <div className="text-center text-sm">{date}</div>
+        },
+        size: 100,
+      },
       {
         accessorKey: "updatedAt",
         header: ({ column }) => (
-          <DataTableColumnHeaderSimple column={column} title="수정일" />
+          <DataTableColumnHeaderSimple column={column} title="최종변경일" />
+        ),
+        cell: ({ getValue }) => {
+          const date = getValue() as string
+          return <div className="text-center text-sm">{date}</div>
+        },
+        size: 100,
+      },
+      {
+        accessorKey: "updatedBy",
+        header: ({ column }) => (
+          <DataTableColumnHeaderSimple column={column} title="최종변경자" />
         ),
         cell: ({ getValue }) => {
           const date = getValue() as string
@@ -320,24 +315,6 @@ export function getColumns({ selectedRows = [], onRowSelect }: GetColumnsProps):
               >
                 <Eye className="h-4 w-4" />
               </Button>
-              <Button
-                variant="ghost"
-                size="sm"
-                onClick={() => table.options.meta?.onAction?.("edit", { id: row.original.id })}
-                className="h-8 w-8 p-0"
-                title="수정"
-              >
-                <Edit className="h-4 w-4" />
-              </Button>
-              <Button
-                variant="ghost"
-                size="sm"
-                onClick={() => table.options.meta?.onAction?.("delete", { id: row.original.id })}
-                className="h-8 w-8 p-0 text-destructive hover:text-destructive"
-                title="삭제"
-              >
-                <Trash2 className="h-4 w-4" />
-              </Button>
             </div>
           )
         },
-- 
cgit v1.2.3

