From 935fd22e17afc034a472bc2d159de7b9f5e5dcae Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Thu, 20 Nov 2025 19:36:01 +0900 Subject: (김준회) PO, POS, swp - PO: 발주서출력기능 초안 - 벤더측 POS 다운로드 기능 추가 - Contract 생성시 Status 설정 (mapper) - swp document registration table 로직 리팩터링 - swp: 입력가능 문서번호 validation 추가 (리스트 메뉴에서 Completed 된 건) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/po/vendor-table/vendor-po-table.tsx | 53 +++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'lib/po/vendor-table/vendor-po-table.tsx') diff --git a/lib/po/vendor-table/vendor-po-table.tsx b/lib/po/vendor-table/vendor-po-table.tsx index 99b0e5eb..7e7cb78f 100644 --- a/lib/po/vendor-table/vendor-po-table.tsx +++ b/lib/po/vendor-table/vendor-po-table.tsx @@ -17,6 +17,7 @@ import { getVendorColumns } from "./vendor-po-columns" import { VendorPO, VendorPOActionType } from "./types" import { VendorPOItemsDialog } from "./vendor-po-items-dialog" import { VendorPONoteDialog } from "./vendor-po-note-dialog" +import { VendorPOPrintDialog } from "./vendor-po-print-dialog" import { VendorPOToolbarActions } from "./vendor-po-toolbar-actions" interface VendorPoTableProps { @@ -30,7 +31,7 @@ interface VendorPoTableProps { export function VendorPoTable({ promises }: VendorPoTableProps) { const router = useRouter() const params = useParams() - const lng = params.lng as string + const lng = (params?.lng as string) || 'ko' const [data, setData] = React.useState<{ data: VendorPO[]; @@ -53,16 +54,33 @@ export function VendorPoTable({ promises }: VendorPoTableProps) { // 다이얼로그 상태 const [itemsDialogOpen, setItemsDialogOpen] = React.useState(false) const [noteDialogOpen, setNoteDialogOpen] = React.useState(false) + const [printDialogOpen, setPrintDialogOpen] = React.useState(false) const [selectedPO, setSelectedPO] = React.useState(null) // 행 선택 처리 (1개만 선택 가능) - const handleRowSelect = (id: number, selected: boolean) => { + const handleRowSelect = React.useCallback((id: number, selected: boolean) => { if (selected) { setSelectedRows([id]) // 1개만 선택 } else { setSelectedRows([]) } - } + }, []) + + // 액션 처리 함수 + const handleAction = React.useCallback(async (poId: number, action: string) => { + try { + const result = await handleVendorPOAction(poId, action) + if (result.success) { + toast.success(result.message) + // 필요시 데이터 새로고침 + } else { + toast.error(result.message) + } + } catch (error) { + console.error("Action error:", error) + toast.error("액션 처리 중 오류가 발생했습니다.") + } + }, []) // 행 액션 처리 React.useEffect(() => { @@ -88,7 +106,7 @@ export function VendorPoTable({ promises }: VendorPoTableProps) { handleAction(po.id, "reject-contract") break case "print-contract": - handleAction(po.id, "print-contract") + setPrintDialogOpen(true) break case "item-status": setItemsDialogOpen(true) @@ -107,23 +125,7 @@ export function VendorPoTable({ promises }: VendorPoTableProps) { } setRowAction(null) - }, [rowAction]) - - // 액션 처리 함수 - const handleAction = async (poId: number, action: string) => { - try { - const result = await handleVendorPOAction(poId, action) - if (result.success) { - toast.success(result.message) - // 필요시 데이터 새로고침 - } else { - toast.error(result.message) - } - } catch (error) { - console.error("Action error:", error) - toast.error("액션 처리 중 오류가 발생했습니다.") - } - } + }, [rowAction, lng, router, handleAction]) const columns = React.useMemo( () => getVendorColumns({ @@ -131,7 +133,7 @@ export function VendorPoTable({ promises }: VendorPoTableProps) { selectedRows, onRowSelect: handleRowSelect }), - [selectedRows] + [selectedRows, handleRowSelect] ) const filterFields: DataTableFilterField[] = [ @@ -247,6 +249,7 @@ export function VendorPoTable({ promises }: VendorPoTableProps) { open={itemsDialogOpen} onOpenChange={setItemsDialogOpen} po={selectedPO} + viewerType="partners" /> + + ) } \ No newline at end of file -- cgit v1.2.3