summaryrefslogtreecommitdiff
path: root/lib/avl/table/columns-detail.tsx
blob: 84ad9d9a0e355132082f70cdd03186992ad2952d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
import { Checkbox } from "@/components/ui/checkbox"
import { Badge } from "@/components/ui/badge"
import { type ColumnDef } from "@tanstack/react-table"
import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header"


// AVL 상세 아이템 타입
export type AvlDetailItem = {
  id: string
  no: number
  selected: boolean
  // AVL 리스트 ID (외래키)
  avlListId: number
  // 설계 정보
  equipBulkDivision: 'EQUIP' | 'BULK'
  disciplineCode: string
  disciplineName: string
  // 자재 정보
  materialNameCustomerSide: string
  packageCode: string
  packageName: string
  materialGroupCode: string
  materialGroupName: string
  // 협력업체 정보
  vendorId?: number
  vendorName: string
  vendorCode: string
  avlVendorName: string
  tier: string
  // FA 정보
  faTarget: boolean
  faStatus: string
  // Agent 정보
  isAgent: boolean
  agentStatus: string // UI 표시용
  // 계약 서명주체
  contractSignerId?: number
  contractSignerName: string
  contractSignerCode: string
  // 위치 정보
  headquarterLocation: string
  manufacturingLocation: string
  // SHI Qualification
  shiAvl: boolean
  shiBlacklist: boolean
  shiBcc: boolean
  // 기술영업 견적결과
  salesQuoteNumber: string
  quoteCode: string
  salesVendorInfo: string
  salesCountry: string
  totalAmount: string
  quoteReceivedDate: string
  // 업체 실적 현황(구매)
  recentQuoteDate: string
  recentQuoteNumber: string
  recentOrderDate: string
  recentOrderNumber: string
  // 기타
  remarks: string
  // 타임스탬프
  createdAt: string
  updatedAt: string
}

// 테이블 컬럼 정의
export const columns: ColumnDef<AvlDetailItem>[] = [
  // 기본 정보 그룹
  {
    header: "기본 정보",
    columns: [
      {
        accessorKey: "no",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="No." />
        ),
        size: 60,
      },
      {
        accessorKey: "equipBulkDivision",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="Equip/Bulk 구분" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("equipBulkDivision") as string
          return (
            <Badge variant="outline">
              {value || "-"}
            </Badge>
          )
        },
        size: 120,
      },
      {
        accessorKey: "disciplineName",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="설계공종" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("disciplineName") as string
          return <span>{value || "-"}</span>
        },
        size: 120,
      },
      {
        accessorKey: "materialNameCustomerSide",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="고객사 AVL 자재명" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("materialNameCustomerSide") as string
          return <span>{value || "-"}</span>
        },
        size: 150,
      },
      {
        accessorKey: "packageName",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="패키지 정보" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("packageName") as string
          return <span>{value || "-"}</span>
        },
        size: 130,
      },
      {
        accessorKey: "materialGroupCode",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="자재그룹코드" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("materialGroupCode") as string
          return <span>{value || "-"}</span>
        },
        size: 120,
      },
      {
        accessorKey: "materialGroupName",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="자재그룹명" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("materialGroupName") as string
          return <span>{value || "-"}</span>
        },
        size: 130,
      },
      {
        accessorKey: "vendorCode",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="협력업체코드" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("vendorCode") as string
          return <span>{value || "-"}</span>
        },
        size: 120,
      },
      {
        accessorKey: "vendorName",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="협력업체명" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("vendorName") as string
          return <span className="font-medium">{value || "-"}</span>
        },
        size: 140,
      },
      {
        accessorKey: "avlVendorName",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="AVL 등재업체명" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("avlVendorName") as string
          return <span>{value || "-"}</span>
        },
        size: 140,
      },
      {
        accessorKey: "tier",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="등급 (Tier)" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("tier") as string
          if (!value) return <span>-</span>
          
          const tierColor = {
            "Tier 1": "bg-green-100 text-green-800",
            "Tier 2": "bg-yellow-100 text-yellow-800", 
            "Tier 3": "bg-red-100 text-red-800"
          }[value] || "bg-gray-100 text-gray-800"
          
          return (
            <Badge className={tierColor}>
              {value}
            </Badge>
          )
        },
        size: 100,
      },
    ],
  },
  // FA 정보 그룹
  {
    header: "FA 정보",
    columns: [
      {
        accessorKey: "faTarget",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="FA 대상" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("faTarget") as boolean
          return (
            <Badge variant={value ? "default" : "secondary"}>
              {value ? "대상" : "비대상"}
            </Badge>
          )
        },
        size: 80,
      },
      {
        accessorKey: "faStatus",
        header: ({ column }) => (
          <DataTableColumnHeaderSimple column={column} title="FA 현황" />
        ),
        cell: ({ row }) => {
          const value = row.getValue("faStatus") as string
          return <span>{value || "-"}</span>
        },
        size: 100,
      },
    ],
  },
  // SHI Qualification 그룹
  {
    header: "SHI Qualification",
    columns: [
      {
        accessorKey: "shiAvl",
        header: "AVL",
        cell: ({ row }) => {
          const value = row.getValue("shiAvl") as boolean
          return (
            <Checkbox
              checked={value}
              disabled
              aria-label="SHI AVL 등재 여부"
            />
          )
        },
        size: 80,
      },
      {
        accessorKey: "shiBlacklist",
        header: "Blacklist",
        cell: ({ row }) => {
          const value = row.getValue("shiBlacklist") as boolean
          return (
            <Checkbox
              checked={value}
              disabled
              aria-label="SHI Blacklist 등재 여부"
            />
          )
        },
        size: 100,
      },
      {
        accessorKey: "shiBcc",
        header: "BCC",
        cell: ({ row }) => {
          const value = row.getValue("shiBcc") as boolean
          return (
            <Checkbox
              checked={value}
              disabled
              aria-label="SHI BCC 등재 여부"
            />
          )
        },
        size: 80,
      },
    ],
  },
]