summaryrefslogtreecommitdiff
path: root/lib/techsales-rfq/table/rfq-table.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/techsales-rfq/table/rfq-table.tsx')
-rw-r--r--lib/techsales-rfq/table/rfq-table.tsx127
1 files changed, 47 insertions, 80 deletions
diff --git a/lib/techsales-rfq/table/rfq-table.tsx b/lib/techsales-rfq/table/rfq-table.tsx
index f1570577..424ca70e 100644
--- a/lib/techsales-rfq/table/rfq-table.tsx
+++ b/lib/techsales-rfq/table/rfq-table.tsx
@@ -23,24 +23,22 @@ import { RFQTableToolbarActions } from "./rfq-table-toolbar-actions"
import { getTechSalesRfqsWithJoin, getTechSalesRfqAttachments } from "@/lib/techsales-rfq/service"
import { toast } from "sonner"
import { useTablePresets } from "@/components/data-table/use-table-presets"
-import { TablePresetManager } from "@/components/data-table/data-table-preset"
import { RfqDetailTables } from "./detail-table/rfq-detail-table"
import { cn } from "@/lib/utils"
import { ProjectDetailDialog } from "./project-detail-dialog"
import { RFQFilterSheet } from "./rfq-filter-sheet"
import { TechSalesRfqAttachmentsSheet, ExistingTechSalesAttachment } from "./tech-sales-rfq-attachments-sheet"
-
+import { RfqItemsViewDialog } from "./rfq-items-view-dialog"
// 기본적인 RFQ 타입 정의 (repository selectTechSalesRfqsWithJoin 반환 타입에 맞춤)
interface TechSalesRfq {
id: number
rfqCode: string | null
- itemId: number
- itemName: string | null
+ biddingProjectId: number | null
materialCode: string | null
dueDate: Date
rfqSendDate: Date | null
status: "RFQ Created" | "RFQ Vendor Assignned" | "RFQ Sent" | "Quotation Analysis" | "Closed"
- picCode: string | null
+ description: string | null
remark: string | null
cancelReason: string | null
createdAt: Date
@@ -51,40 +49,7 @@ interface TechSalesRfq {
updatedByName: string
sentBy: number | null
sentByName: string | null
- // 스키마와 일치하도록 타입 수정
- projectSnapshot: {
- pspid: string;
- projNm?: string;
- sector?: string;
- projMsrm?: number;
- kunnr?: string;
- kunnrNm?: string;
- cls1?: string;
- cls1Nm?: string;
- ptype?: string;
- ptypeNm?: string;
- pmodelCd?: string;
- pmodelNm?: string;
- pmodelSz?: string;
- pmodelUom?: string;
- txt04?: string;
- txt30?: string;
- estmPm?: string;
- pspCreatedAt?: Date | string;
- pspUpdatedAt?: Date | string;
- } | Record<string, unknown> // legacy 호환성을 위해 유지
- seriesSnapshot: Array<{
- pspid: string;
- sersNo: string;
- scDt?: string;
- klDt?: string;
- lcDt?: string;
- dlDt?: string;
- dockNo?: string;
- dockNm?: string;
- projNo?: string;
- post1?: string;
- }> | Record<string, unknown> // legacy 호환성을 위해 유지
+ // 조인된 프로젝트 정보
pspid: string
projNm: string
sector: string
@@ -100,12 +65,14 @@ interface RFQListTableProps {
promises: Promise<[Awaited<ReturnType<typeof getTechSalesRfqsWithJoin>>]>
className?: string;
calculatedHeight?: string; // 계산된 높이 추가
+ rfqType: "SHIP" | "TOP" | "HULL";
}
export function RFQListTable({
promises,
className,
- calculatedHeight
+ calculatedHeight,
+ rfqType
}: RFQListTableProps) {
const searchParams = useSearchParams()
@@ -124,6 +91,10 @@ export function RFQListTable({
const [selectedRfqForAttachments, setSelectedRfqForAttachments] = React.useState<TechSalesRfq | null>(null)
const [attachmentsDefault, setAttachmentsDefault] = React.useState<ExistingTechSalesAttachment[]>([])
+ // 아이템 다이얼로그 상태
+ const [itemsDialogOpen, setItemsDialogOpen] = React.useState(false)
+ const [selectedRfqForItems, setSelectedRfqForItems] = React.useState<TechSalesRfq | null>(null)
+
// 패널 collapse 상태
const [panelHeight, setPanelHeight] = React.useState<number>(55)
@@ -164,23 +135,23 @@ export function RFQListTable({
to: searchParams?.get('to') || undefined,
columnVisibility: {},
columnOrder: [],
- pinnedColumns: { left: [], right: [] },
+ pinnedColumns: { left: [], right: ["items", "attachments"] },
groupBy: [],
expandedRows: []
}), [searchParams])
// DB 기반 프리셋 훅 사용
const {
- presets,
- activePresetId,
- hasUnsavedChanges,
- isLoading: presetsLoading,
- createPreset,
- applyPreset,
- updatePreset,
- deletePreset,
- setDefaultPreset,
- renamePreset,
+ // presets,
+ // activePresetId,
+ // hasUnsavedChanges,
+ // isLoading: presetsLoading,
+ // createPreset,
+ // applyPreset,
+ // updatePreset,
+ // deletePreset,
+ // setDefaultPreset,
+ // renamePreset,
getCurrentSettings,
} = useTablePresets<TechSalesRfq>('rfq-list-table', initialSettings)
@@ -199,13 +170,12 @@ export function RFQListTable({
setSelectedRfq({
id: rfqData.id,
rfqCode: rfqData.rfqCode,
- itemId: rfqData.itemId,
- itemName: rfqData.itemName,
+ biddingProjectId: rfqData.biddingProjectId,
materialCode: rfqData.materialCode,
dueDate: rfqData.dueDate,
rfqSendDate: rfqData.rfqSendDate,
status: rfqData.status,
- picCode: rfqData.picCode,
+ description: rfqData.description,
remark: rfqData.remark,
cancelReason: rfqData.cancelReason,
createdAt: rfqData.createdAt,
@@ -216,8 +186,6 @@ export function RFQListTable({
updatedByName: rfqData.updatedByName,
sentBy: rfqData.sentBy,
sentByName: rfqData.sentByName,
- projectSnapshot: rfqData.projectSnapshot,
- seriesSnapshot: rfqData.seriesSnapshot,
pspid: rfqData.pspid,
projNm: rfqData.projNm,
sector: rfqData.sector,
@@ -233,13 +201,12 @@ export function RFQListTable({
setProjectDetailRfq({
id: projectRfqData.id,
rfqCode: projectRfqData.rfqCode,
- itemId: projectRfqData.itemId,
- itemName: projectRfqData.itemName,
+ biddingProjectId: projectRfqData.biddingProjectId,
materialCode: projectRfqData.materialCode,
dueDate: projectRfqData.dueDate,
rfqSendDate: projectRfqData.rfqSendDate,
status: projectRfqData.status,
- picCode: projectRfqData.picCode,
+ description: projectRfqData.description,
remark: projectRfqData.remark,
cancelReason: projectRfqData.cancelReason,
createdAt: projectRfqData.createdAt,
@@ -250,8 +217,6 @@ export function RFQListTable({
updatedByName: projectRfqData.updatedByName,
sentBy: projectRfqData.sentBy,
sentByName: projectRfqData.sentByName,
- projectSnapshot: projectRfqData.projectSnapshot || {},
- seriesSnapshot: projectRfqData.seriesSnapshot || {},
pspid: projectRfqData.pspid,
projNm: projectRfqData.projNm,
sector: projectRfqData.sector,
@@ -307,11 +272,7 @@ export function RFQListTable({
}))
setAttachmentsDefault(attachments)
- setSelectedRfqForAttachments({
- ...rfq,
- projectSnapshot: rfq.projectSnapshot || {},
- seriesSnapshot: Array.isArray(rfq.seriesSnapshot) ? rfq.seriesSnapshot : {},
- })
+ setSelectedRfqForAttachments(rfq as unknown as TechSalesRfq)
setAttachmentsOpen(true)
} catch (error) {
console.error("첨부파일 조회 오류:", error)
@@ -332,12 +293,20 @@ export function RFQListTable({
}, 500)
}, [])
+ // 아이템 다이얼로그 열기 함수
+ const openItemsDialog = React.useCallback((rfq: TechSalesRfq) => {
+ console.log("Opening items dialog for RFQ:", rfq.id, rfq)
+ setSelectedRfqForItems(rfq as unknown as TechSalesRfq)
+ setItemsDialogOpen(true)
+ }, [])
+
const columns = React.useMemo(
() => getColumns({
setRowAction,
- openAttachmentsSheet
+ openAttachmentsSheet,
+ openItemsDialog
}),
- [openAttachmentsSheet]
+ [openAttachmentsSheet, openItemsDialog]
)
// 고급 필터 필드 정의
@@ -348,13 +317,8 @@ export function RFQListTable({
type: "text",
},
{
- id: "materialCode",
- label: "자재코드",
- type: "text",
- },
- {
- id: "itemName",
- label: "자재명",
+ id: "description",
+ label: "설명",
type: "text",
},
{
@@ -363,11 +327,6 @@ export function RFQListTable({
type: "text",
},
{
- id: "ptypeNm",
- label: "선종명",
- type: "text",
- },
- {
id: "rfqSendDate",
label: "RFQ 전송일",
type: "date",
@@ -563,6 +522,7 @@ export function RFQListTable({
<RFQTableToolbarActions
selection={table}
onRefresh={() => {}}
+ rfqType={rfqType}
/>
</div>
</DataTableAdvancedToolbar>
@@ -603,6 +563,13 @@ export function RFQListTable({
rfq={selectedRfqForAttachments}
onAttachmentsUpdated={handleAttachmentsUpdated}
/>
+
+ {/* 아이템 보기 다이얼로그 */}
+ <RfqItemsViewDialog
+ open={itemsDialogOpen}
+ onOpenChange={setItemsDialogOpen}
+ rfq={selectedRfqForItems}
+ />
</div>
)
} \ No newline at end of file