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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
"use client"
import * as React from "react"
import { type ColumnDef } from "@tanstack/react-table"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
Eye, Calendar, Users, CheckCircle, XCircle, Clock, AlertTriangle
} from "lucide-react"
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header"
import {
biddingStatusLabels,
contractTypeLabels,
} from "@/db/schema"
import { formatDate } from "@/lib/utils"
import { DataTableRowAction } from "@/types/table"
type BiddingReceiveItem = {
id: number
biddingNumber: string
originalBiddingNumber: string | null
title: string
status: string
contractType: string
prNumber: string | null
submissionStartDate: Date | null
submissionEndDate: Date | null
bidPicName: string | null
supplyPicName: string | null
createdBy: string | null
createdAt: Date | null
updatedAt: Date | null
// 참여 현황
participantExpected: number
participantParticipated: number
participantDeclined: number
participantPending: number
// 개찰 정보
openedAt: Date | null
openedBy: string | null
}
interface GetColumnsProps {
setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<BiddingReceiveItem> | null>>
}
// 상태별 배지 색상
const getStatusBadgeVariant = (status: string) => {
switch (status) {
case 'received_quotation':
return 'secondary'
case 'bidding_opened':
return 'default'
case 'bidding_closed':
return 'outline'
default:
return 'outline'
}
}
// 금액 포맷팅
const formatCurrency = (amount: string | number | null, currency = 'KRW') => {
if (!amount) return '-'
const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount
if (isNaN(numAmount)) return '-'
return new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: currency,
minimumFractionDigits: 0,
maximumFractionDigits: 0,
}).format(numAmount)
}
export function getBiddingsReceiveColumns({ setRowAction }: GetColumnsProps): ColumnDef<BiddingReceiveItem>[] {
return [
// ░░░ 입찰번호 ░░░
{
accessorKey: "biddingNumber",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="입찰번호" />,
cell: ({ row }) => (
<div className="font-mono text-sm">
{row.original.biddingNumber}
</div>
),
size: 120,
meta: { excelHeader: "입찰번호" },
},
// ░░░ 입찰명 ░░░
{
accessorKey: "title",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="입찰명" />,
cell: ({ row }) => (
<div className="truncate max-w-[200px]" title={row.original.title}>
<Button
variant="link"
className="p-0 h-auto text-left justify-start font-bold underline"
onClick={() => setRowAction({ row, type: "view" })}
>
<div className="whitespace-pre-line">
{row.original.title}
</div>
</Button>
</div>
),
size: 200,
meta: { excelHeader: "입찰명" },
},
// ░░░ 원입찰번호 ░░░
{
accessorKey: "originalBiddingNumber",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="원입찰번호" />,
cell: ({ row }) => (
<div className="font-mono text-sm">
{row.original.originalBiddingNumber || '-'}
</div>
),
size: 120,
meta: { excelHeader: "원입찰번호" },
},
// ░░░ 진행상태 ░░░
{
accessorKey: "status",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="진행상태" />,
cell: ({ row }) => (
<Badge variant={getStatusBadgeVariant(row.original.status)}>
{biddingStatusLabels[row.original.status]}
</Badge>
),
size: 120,
meta: { excelHeader: "진행상태" },
},
// ░░░ 계약구분 ░░░
{
accessorKey: "contractType",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="계약구분" />,
cell: ({ row }) => (
<Badge variant="outline">
{contractTypeLabels[row.original.contractType]}
</Badge>
),
size: 100,
meta: { excelHeader: "계약구분" },
},
// ░░░ 입찰서제출기간 ░░░
{
id: "submissionPeriod",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="입찰서제출기간" />,
cell: ({ row }) => {
const startDate = row.original.submissionStartDate
const endDate = row.original.submissionEndDate
if (!startDate || !endDate) return <span className="text-muted-foreground">-</span>
const now = new Date()
const isActive = now >= new Date(startDate) && now <= new Date(endDate)
const isPast = now > new Date(endDate)
return (
<div className="text-xs">
<div className={`${isActive ? 'text-green-600 font-medium' : isPast ? 'text-red-600' : 'text-gray-600'}`}>
{formatDate(startDate, "KR")} ~ {formatDate(endDate, "KR")}
</div>
{isActive && (
<Badge variant="default" className="text-xs mt-1">진행중</Badge>
)}
</div>
)
},
size: 140,
meta: { excelHeader: "입찰서제출기간" },
},
// ░░░ P/R번호 ░░░
{
accessorKey: "prNumber",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="P/R번호" />,
cell: ({ row }) => (
<span className="font-mono text-sm">{row.original.prNumber || '-'}</span>
),
size: 100,
meta: { excelHeader: "P/R번호" },
},
// ░░░ 입찰담당자 ░░░
{
accessorKey: "bidPicName",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="입찰담당자" />,
cell: ({ row }) => {
const bidPic = row.original.bidPicName
const supplyPic = row.original.supplyPicName
const displayName = bidPic || supplyPic || "-"
return <span className="text-sm">{displayName}</span>
},
size: 100,
meta: { excelHeader: "입찰담당자" },
},
// ░░░ 참여예정협력사 ░░░
{
id: "participantExpected",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="참여예정협력사" />,
cell: ({ row }) => (
<div className="flex items-center gap-1">
<Users className="h-4 w-4 text-blue-500" />
<span className="text-sm font-medium">{row.original.participantExpected}</span>
</div>
),
size: 100,
meta: { excelHeader: "참여예정협력사" },
},
// ░░░ 참여협력사 ░░░
{
id: "participantParticipated",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="참여협력사" />,
cell: ({ row }) => (
<div className="flex items-center gap-1">
<CheckCircle className="h-4 w-4 text-green-500" />
<span className="text-sm font-medium">{row.original.participantParticipated}</span>
</div>
),
size: 100,
meta: { excelHeader: "참여협력사" },
},
// ░░░ 포기협력사 ░░░
{
id: "participantDeclined",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="포기협력사" />,
cell: ({ row }) => (
<div className="flex items-center gap-1">
<XCircle className="h-4 w-4 text-red-500" />
<span className="text-sm font-medium">{row.original.participantDeclined}</span>
</div>
),
size: 100,
meta: { excelHeader: "포기협력사" },
},
// ░░░ 미제출협력사 ░░░
{
id: "participantPending",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="미제출협력사" />,
cell: ({ row }) => (
<div className="flex items-center gap-1">
<Clock className="h-4 w-4 text-yellow-500" />
<span className="text-sm font-medium">{row.original.participantPending}</span>
</div>
),
size: 100,
meta: { excelHeader: "미제출협력사" },
},
// ░░░ 개찰자명 ░░░
{
id: "openedBy",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="개찰자명" />,
cell: ({ row }) => {
const openedBy = row.original.openedBy
return <span className="text-sm">{openedBy || '-'}</span>
},
size: 100,
meta: { excelHeader: "개찰자명" },
},
// ░░░ 개찰일 ░░░
{
id: "openedAt",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="개찰일" />,
cell: ({ row }) => {
const openedAt = row.original.openedAt
return <span className="text-sm">{openedAt ? formatDate(openedAt, "KR") : '-'}</span>
},
size: 100,
meta: { excelHeader: "개찰일" },
},
// ░░░ 등록자 ░░░
{
accessorKey: "createdBy",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="등록자" />,
cell: ({ row }) => (
<span className="text-sm">{row.original.createdBy || '-'}</span>
),
size: 100,
meta: { excelHeader: "등록자" },
},
// ░░░ 등록일시 ░░░
{
accessorKey: "createdAt",
header: ({ column }) => <DataTableColumnHeaderSimple column={column} title="등록일시" />,
cell: ({ row }) => (
<span className="text-sm">{formatDate(row.original.createdAt, "KR")}</span>
),
size: 100,
meta: { excelHeader: "등록일시" },
},
// ═══════════════════════════════════════════════════════════════
// 액션
// ═══════════════════════════════════════════════════════════════
{
id: "actions",
header: "액션",
cell: ({ row }) => (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="h-8 w-8 p-0">
<span className="sr-only">메뉴 열기</span>
<AlertTriangle className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setRowAction({ row, type: "view" })}>
<Eye className="mr-2 h-4 w-4" />
상세보기
</DropdownMenuItem>
{row.original.status === 'bidding_closed' && (
<>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => setRowAction({ row, type: "open_bidding" })}>
<Calendar className="mr-2 h-4 w-4" />
개찰하기
</DropdownMenuItem>
</>
)}
</DropdownMenuContent>
</DropdownMenu>
),
size: 50,
enableSorting: false,
enableHiding: false,
},
]
}
|