summaryrefslogtreecommitdiff
path: root/lib/techsales-rfq/table/detail-table
diff options
context:
space:
mode:
Diffstat (limited to 'lib/techsales-rfq/table/detail-table')
-rw-r--r--lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx6
-rw-r--r--lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx163
-rw-r--r--lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx18
-rw-r--r--lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx4
-rw-r--r--lib/techsales-rfq/table/detail-table/vendor-communication-drawer.tsx6
-rw-r--r--lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx6
6 files changed, 136 insertions, 67 deletions
diff --git a/lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx b/lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx
index 3e793b62..61c97b1b 100644
--- a/lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx
+++ b/lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx
@@ -20,6 +20,7 @@ interface QuotationContact {
contactId: number
contactName: string
contactPosition: string | null
+ contactTitle: string | null
contactEmail: string
contactPhone: string | null
contactCountry: string | null
@@ -129,6 +130,11 @@ export function QuotationContactsViewDialog({
{contact.contactPosition}
</p>
)}
+ {contact.contactTitle && (
+ <p className="text-sm text-muted-foreground">
+ {contact.contactTitle}
+ </p>
+ )}
{contact.contactCountry && (
<p className="text-xs text-muted-foreground">
{contact.contactCountry}
diff --git a/lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx b/lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx
index 0f5158d9..7d972b91 100644
--- a/lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx
+++ b/lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx
@@ -1,5 +1,4 @@
"use client"
-
import * as React from "react"
import { useState, useEffect } from "react"
import {
@@ -16,6 +15,8 @@ import { Skeleton } from "@/components/ui/skeleton"
import { Clock, User, AlertCircle, Paperclip } from "lucide-react"
import { formatDate } from "@/lib/utils"
import { toast } from "sonner"
+import { Button } from "@/components/ui/button"
+import { updateSHIComment } from "@/lib/techsales-rfq/service";
interface QuotationAttachment {
id: number
@@ -37,7 +38,7 @@ interface QuotationSnapshot {
totalPrice: string | null
validUntil: Date | null
remark: string | null
- status: string | null
+ status: string
quotationVersion: number | null
submittedAt: Date | null
acceptedAt: Date | null
@@ -93,7 +94,9 @@ function QuotationCard({
isCurrent = false,
revisedBy,
revisedAt,
- attachments
+ attachments,
+ revisionId,
+ revisionNote,
}: {
data: QuotationSnapshot | QuotationHistoryData["current"]
version: number
@@ -101,9 +104,36 @@ function QuotationCard({
revisedBy?: string | null
revisedAt?: Date
attachments?: QuotationAttachment[]
+ revisionId?: number
+ revisionNote?: string | null
}) {
const statusInfo = statusConfig[data.status as keyof typeof statusConfig] ||
{ label: data.status || "알 수 없음", color: "bg-gray-100 text-gray-800" }
+
+ const [editValue, setEditValue] = React.useState(revisionNote || "");
+ const [isSaving, setIsSaving] = React.useState(false);
+
+ React.useEffect(() => {
+ setEditValue(revisionNote || "");
+ }, [revisionNote]);
+
+ const handleSave = async () => {
+ if (!revisionId) return;
+
+ setIsSaving(true);
+ try {
+ const result = await updateSHIComment(revisionId, editValue);
+ if (result.error) {
+ toast.error(result.error);
+ } else {
+ toast.success("저장 완료");
+ }
+ } catch (error) {
+ toast.error("저장 중 오류가 발생했습니다");
+ } finally {
+ setIsSaving(false);
+ }
+ };
return (
<Card className={`${isCurrent ? "border-blue-500 shadow-md" : "border-gray-200"}`}>
@@ -117,12 +147,6 @@ function QuotationCard({
{statusInfo.label}
</Badge>
</div>
- {/* {changeReason && (
- <div className="flex items-center gap-2 text-sm text-muted-foreground">
- <FileText className="size-4" />
- <span>{changeReason}</span>
- </div>
- )} */}
</CardHeader>
<CardContent className="space-y-3">
<div className="grid grid-cols-2 gap-4">
@@ -147,6 +171,21 @@ function QuotationCard({
</div>
)}
+ {revisionId && (
+ <div>
+ <p className="text-sm font-medium text-muted-foreground mt-2">SHI Comment</p>
+ <textarea
+ className="w-full min-h-[60px] p-2 border rounded bg-gray-50 text-sm"
+ value={editValue}
+ onChange={e => setEditValue(e.target.value)}
+ disabled={isSaving}
+ />
+ <Button size="sm" onClick={handleSave} disabled={isSaving} className="mt-2">
+ 저장
+ </Button>
+ </div>
+)}
+
{/* 첨부파일 섹션 */}
{attachments && attachments.length > 0 && (
<div>
@@ -209,16 +248,15 @@ export function QuotationHistoryDialog({
}: QuotationHistoryDialogProps) {
const [data, setData] = useState<QuotationHistoryData | null>(null)
const [isLoading, setIsLoading] = useState(false)
-
+
useEffect(() => {
if (open && quotationId) {
loadQuotationHistory()
}
}, [open, quotationId])
-
+
const loadQuotationHistory = async () => {
if (!quotationId) return
-
try {
setIsLoading(true)
const { getTechSalesVendorQuotationWithRevisions } = await import("@/lib/techsales-rfq/service")
@@ -238,14 +276,14 @@ export function QuotationHistoryDialog({
setIsLoading(false)
}
}
-
+
const handleOpenChange = (newOpen: boolean) => {
onOpenChange(newOpen)
if (!newOpen) {
setData(null) // 다이얼로그 닫을 때 데이터 초기화
}
}
-
+
return (
<Dialog open={open} onOpenChange={handleOpenChange}>
<DialogContent className="w-[80vw] max-h-[90vh] overflow-y-auto">
@@ -257,54 +295,55 @@ export function QuotationHistoryDialog({
</DialogHeader>
<div className="space-y-4 overflow-x-auto">
- {isLoading ? (
- <div className="space-y-4">
- {[1, 2, 3].map((i) => (
- <div key={i} className="space-y-3">
- <Skeleton className="h-6 w-32" />
- <Skeleton className="h-32 w-full" />
- </div>
- ))}
- </div>
- ) : data ? (
- <>
- {/* 현재 버전 */}
- <QuotationCard
- data={data.current}
- version={data.current.quotationVersion || 1}
- isCurrent={true}
- attachments={data.current.attachments}
- />
-
- {/* 이전 버전들 */}
- {data.revisions.length > 0 ? (
- data.revisions.map((revision) => (
- <QuotationCard
- key={revision.id}
- data={revision.snapshot}
- version={revision.version}
- changeReason={revision.changeReason}
- revisedBy={revision.revisedByName}
- revisedAt={revision.revisedAt}
- attachments={revision.attachments}
- />
- ))
- ) : (
- <div className="text-center py-8 text-muted-foreground">
- <AlertCircle className="size-12 mx-auto mb-2 opacity-50" />
- <p>수정 이력이 없습니다.</p>
- <p className="text-sm">이 견적서는 아직 수정되지 않았습니다.</p>
- </div>
- )}
- </>
- ) : (
- <div className="text-center py-8 text-muted-foreground">
- <AlertCircle className="size-12 mx-auto mb-2 opacity-50" />
- <p>견적서 정보를 불러올 수 없습니다.</p>
- </div>
- )}
- </div>
+ {isLoading ? (
+ <div className="space-y-4">
+ {[1, 2, 3].map((i) => (
+ <div key={i} className="space-y-3">
+ <Skeleton className="h-6 w-32" />
+ <Skeleton className="h-32 w-full" />
+ </div>
+ ))}
+ </div>
+ ) : data ? (
+ <>
+ {/* 현재 버전 - SHI Comment 없이 표시 */}
+ <QuotationCard
+ data={data.current}
+ version={data.current.quotationVersion || 1}
+ isCurrent={true}
+ attachments={data.current.attachments}
+ />
+
+ {/* 이전 버전들 (스냅샷) - SHI Comment 포함 */}
+ {data.revisions.length > 0 ? (
+ data.revisions.map((revision) => (
+ <QuotationCard
+ key={revision.id}
+ data={revision.snapshot}
+ version={revision.version}
+ revisedBy={revision.revisedByName}
+ revisedAt={revision.revisedAt}
+ attachments={revision.attachments}
+ revisionId={revision.id}
+ revisionNote={revision.revisionNote}
+ />
+ ))
+ ) : (
+ <div className="text-center py-8 text-muted-foreground">
+ <AlertCircle className="size-12 mx-auto mb-2 opacity-50" />
+ <p>수정 이력이 없습니다.</p>
+ <p className="text-sm">이 견적서는 아직 수정되지 않았습니다.</p>
+ </div>
+ )}
+ </>
+ ) : (
+ <div className="text-center py-8 text-muted-foreground">
+ <AlertCircle className="size-12 mx-auto mb-2 opacity-50" />
+ <p>견적서 정보를 불러올 수 없습니다.</p>
+ </div>
+ )}
+ </div>
</DialogContent>
</Dialog>
)
-} \ No newline at end of file
+} \ No newline at end of file
diff --git a/lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx b/lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx
index e4141520..7ece2406 100644
--- a/lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx
+++ b/lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx
@@ -46,6 +46,7 @@ export interface RfqDetailView {
createdByName: string | null
quotationCode?: string | null
rfqCode?: string | null
+ quotationVersion?: number | null
quotationAttachments?: Array<{
id: number
revisionId: number
@@ -185,6 +186,22 @@ export function getRfqDetailColumns({
enableResizing: true,
size: 160,
},
+ // [Rev 컬럼 추가]
+ {
+ id: "rev",
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="Rev" />
+ ),
+ cell: ({ row }) => {
+ const version = row.original.quotationVersion ?? 0;
+ return <div className="text-center font-mono">{version}</div>;
+ },
+ meta: {
+ excelHeader: "Rev"
+ },
+ enableResizing: false,
+ size: 60,
+ },
{
accessorKey: "totalPrice",
header: ({ column }) => (
@@ -227,6 +244,7 @@ export function getRfqDetailColumns({
enableResizing: true,
size: 140,
},
+
{
accessorKey: "quotationAttachments",
header: ({ column }) => (
diff --git a/lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx b/lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx
index acf67497..8bfb8299 100644
--- a/lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx
+++ b/lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx
@@ -730,8 +730,8 @@ export function RfqDetailTables({ selectedRfq, maxHeight }: RfqDetailTablesProps
onSuccess={handleRefreshData}
/>
- {/* 다중 벤더 삭제 확인 다이얼로그
- <DeleteVendorDialog
+ {/* 다중 벤더 삭제 확인 다이얼로그 */}
+ {/* <DeleteVendorDialog
open={deleteConfirmDialogOpen}
onOpenChange={setDeleteConfirmDialogOpen}
vendors={selectedRows}
diff --git a/lib/techsales-rfq/table/detail-table/vendor-communication-drawer.tsx b/lib/techsales-rfq/table/detail-table/vendor-communication-drawer.tsx
index e6cd32a9..5b60ef0f 100644
--- a/lib/techsales-rfq/table/detail-table/vendor-communication-drawer.tsx
+++ b/lib/techsales-rfq/table/detail-table/vendor-communication-drawer.tsx
@@ -320,9 +320,9 @@ export function VendorCommunicationDrawer({
};
// 첨부파일 다운로드
- const handleAttachmentDownload = async (attachment: Attachment) => {
- const { downloadFile } = await import("@/lib/file-download");
- await downloadFile(attachment.filePath, attachment.originalFileName);
+ const handleAttachmentDownload = (attachment: Attachment) => {
+ // TODO: 실제 다운로드 구현
+ window.open(attachment.filePath, '_blank');
};
// 파일 아이콘 선택
diff --git a/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx b/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx
index aa6f6c2f..031f4aa2 100644
--- a/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx
+++ b/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx
@@ -21,6 +21,7 @@ interface VendorContact {
id: number
contactName: string
contactPosition: string | null
+ contactTitle: string | null
contactEmail: string
contactPhone: string | null
isPrimary: boolean
@@ -283,6 +284,11 @@ export function VendorContactSelectionDialog({
{contact.contactPosition}
</p>
)}
+ {contact.contactTitle && (
+ <p className="text-sm text-muted-foreground">
+ {contact.contactTitle}
+ </p>
+ )}
</div>
</div>
</div>