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
|
"use client"
import * as React from "react"
import { Download, FileText } from "lucide-react"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
import { Button } from "@/components/ui/button"
import { ScrollArea } from "@/components/ui/scroll-area"
import { Badge } from "@/components/ui/badge"
interface PosFileInfo {
fileName: string
dcmtmId: string
projNo: string
posNo: string
posRevNo: string
fileSer: string
}
interface PosFileSelectionDialogProps {
isOpen: boolean
onClose: () => void
materialCode: string
files: PosFileInfo[]
onDownload: (fileIndex: number, fileName: string) => void
downloadingIndex: number | null
}
export function PosFileSelectionDialog({
isOpen,
onClose,
materialCode,
files,
onDownload,
downloadingIndex,
}: PosFileSelectionDialogProps) {
return (
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent className="max-w-4xl">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<FileText className="h-5 w-5 text-green-600" />
POS 파일 선택
</DialogTitle>
<DialogDescription>
자재코드 <Badge variant="outline" className="font-mono">{materialCode}</Badge>에 대한
POS 파일 <Badge variant="secondary">{files.length}개</Badge>가 있습니다.
다운로드할 파일을 선택해주세요.
</DialogDescription>
</DialogHeader>
<ScrollArea className="max-h-[60vh]">
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-[50px]">번호</TableHead>
<TableHead>파일명</TableHead>
<TableHead className="w-[120px]">프로젝트</TableHead>
<TableHead className="w-[150px]">POS 번호</TableHead>
<TableHead className="w-[80px]">리비전</TableHead>
<TableHead className="w-[80px]">파일 SEQ</TableHead>
<TableHead className="w-[120px] text-center">다운로드</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{files.map((file, index) => (
<TableRow key={`${file.dcmtmId}-${index}`}>
<TableCell className="text-center font-mono text-sm">
#{index + 1}
</TableCell>
<TableCell>
<div className="flex items-center gap-2">
<FileText className="h-4 w-4 text-blue-500 flex-shrink-0" />
<span className="text-sm font-medium truncate" title={file.fileName}>
{file.fileName}
</span>
</div>
</TableCell>
<TableCell>
<span className="text-xs font-mono">{file.projNo}</span>
</TableCell>
<TableCell>
<span className="text-xs font-mono">{file.posNo}</span>
</TableCell>
<TableCell>
<Badge variant="outline" className="text-xs">
{file.posRevNo}
</Badge>
</TableCell>
<TableCell>
<span className="text-xs font-mono">{file.fileSer}</span>
</TableCell>
<TableCell className="text-center">
<Button
size="sm"
variant="default"
onClick={() => onDownload(index, file.fileName)}
disabled={downloadingIndex !== null}
className="w-full"
>
<Download className="h-3 w-3 mr-1" />
{downloadingIndex === index ? '다운로드 중...' : '다운로드'}
</Button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</ScrollArea>
{files.length === 0 && (
<div className="text-center py-8 text-muted-foreground">
<FileText className="h-12 w-12 mx-auto mb-4 text-muted-foreground" />
<p>사용 가능한 POS 파일이 없습니다.</p>
</div>
)}
</DialogContent>
</Dialog>
)
}
|