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
|
'use client'
import * as React from 'react'
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog'
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/components/ui/table'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { formatDate } from '@/lib/utils'
import { History, Eye } from 'lucide-react'
interface QuotationHistoryItem {
id: string
round: number
submittedAt: Date
totalAmount: number
currency: string
vsTargetPrice: number // 퍼센트
items: Array<{
itemCode: string
itemName: string
specification: string
quantity: number
unit: string
unitPrice: number
totalPrice: number
deliveryDate: Date
}>
}
interface QuotationHistoryDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
vendorName: string
history: QuotationHistoryItem[]
biddingCurrency: string
targetPrice?: number
}
export function QuotationHistoryDialog({
open,
onOpenChange,
vendorName,
history,
biddingCurrency,
targetPrice
}: QuotationHistoryDialogProps) {
const [selectedHistory, setSelectedHistory] = React.useState<QuotationHistoryItem | null>(null)
const [detailDialogOpen, setDetailDialogOpen] = React.useState(false)
const handleViewDetail = (historyItem: QuotationHistoryItem) => {
setSelectedHistory(historyItem)
setDetailDialogOpen(true)
}
const handleDetailDialogClose = () => {
setDetailDialogOpen(false)
setSelectedHistory(null)
}
return (
<>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-4xl max-h-[80vh] overflow-y-auto">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<History className="h-5 w-5" />
견적 히스토리 - {vendorName}
</DialogTitle>
<DialogDescription>
{vendorName} 업체의 제출한 견적 내역을 확인할 수 있습니다.
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
{history.length > 0 ? (
<Table>
<TableHeader>
<TableRow>
<TableHead>차수</TableHead>
<TableHead>제출일시</TableHead>
<TableHead className="text-right">견적금액</TableHead>
<TableHead className="text-right">내정가대비 (%)</TableHead>
<TableHead className="text-center">액션</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{history.map((item) => (
<TableRow key={item.id}>
<TableCell className="font-medium">
{item.round}차
</TableCell>
<TableCell>
{formatDate(item.submittedAt, 'KR')}
</TableCell>
<TableCell className="text-right font-mono">
{item.totalAmount.toLocaleString()} {item.currency}
</TableCell>
<TableCell className="text-right">
{targetPrice && targetPrice > 0 ? (
<Badge
variant={item.vsTargetPrice <= 0 ? 'default' : 'destructive'}
>
{item.vsTargetPrice > 0 ? '+' : ''}{item.vsTargetPrice.toFixed(1)}%
</Badge>
) : (
'-'
)}
</TableCell>
<TableCell className="text-center">
<Button
variant="outline"
size="sm"
onClick={() => handleViewDetail(item)}
>
<Eye className="h-4 w-4 mr-1" />
상세
</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
) : (
<div className="text-center py-8 text-muted-foreground">
제출된 견적 내역이 없습니다.
</div>
)}
</div>
</DialogContent>
</Dialog>
{/* 상세 다이얼로그 */}
{selectedHistory && (
<QuotationHistoryDetailDialog
open={detailDialogOpen}
onOpenChange={handleDetailDialogClose}
vendorName={vendorName}
historyItem={selectedHistory}
/>
)}
</>
)
}
// 견적 히스토리 상세 다이얼로그
interface QuotationHistoryDetailDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
vendorName: string
historyItem: QuotationHistoryItem
}
function QuotationHistoryDetailDialog({
open,
onOpenChange,
vendorName,
historyItem
}: QuotationHistoryDetailDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-6xl max-h-[90vh] overflow-y-auto">
<DialogHeader>
<DialogTitle>
견적 상세 - {vendorName} ({historyItem.round}차)
</DialogTitle>
<DialogDescription>
제출일시: {formatDate(historyItem.submittedAt, 'KR')}
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
{/* 요약 정보 */}
<div className="grid grid-cols-3 gap-4 p-4 bg-muted/50 rounded-lg">
<div>
<label className="text-sm font-medium text-muted-foreground">총 견적금액</label>
<div className="text-lg font-bold">
{historyItem.totalAmount.toLocaleString()} {historyItem.currency}
</div>
</div>
<div>
<label className="text-sm font-medium text-muted-foreground">품목 수</label>
<div className="text-lg font-bold">
{historyItem.items.length}개
</div>
</div>
<div>
<label className="text-sm font-medium text-muted-foreground">제출일시</label>
<div className="text-sm">
{formatDate(historyItem.submittedAt, 'KR')}
</div>
</div>
</div>
{/* 품목 상세 테이블 */}
<Table>
<TableHeader>
<TableRow>
<TableHead>품목코드</TableHead>
<TableHead>품목명</TableHead>
<TableHead>규격</TableHead>
<TableHead className="text-right">수량</TableHead>
<TableHead>단위</TableHead>
<TableHead className="text-right">단가</TableHead>
<TableHead className="text-right">금액</TableHead>
<TableHead>납기요청일</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{historyItem.items.map((item, index) => (
<TableRow key={index}>
<TableCell className="font-mono text-sm">
{item.itemCode}
</TableCell>
<TableCell className="font-medium">
{item.itemName}
</TableCell>
<TableCell className="text-sm">
{item.specification || '-'}
</TableCell>
<TableCell className="text-right">
{item.quantity.toLocaleString()}
</TableCell>
<TableCell>{item.unit}</TableCell>
<TableCell className="text-right font-mono">
{item.unitPrice.toLocaleString()} {historyItem.currency}
</TableCell>
<TableCell className="text-right font-mono">
{item.totalPrice.toLocaleString()} {historyItem.currency}
</TableCell>
<TableCell className="text-sm">
{formatDate(item.deliveryDate, 'KR')}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</DialogContent>
</Dialog>
)
}
|