From 871a6d46a769cbe9e87146434f4bcb2d6792ab81 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 30 Oct 2025 10:44:47 +0000 Subject: (최겸) 구매 PQ/실사 재개발(테스트 필요), 정규업체등록 결재 개발, 실사 의뢰 결재 후처리 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vendors-table-toolbar-actions.tsx | 91 +++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) (limited to 'lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx') diff --git a/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx b/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx index ea6b6189..98b1cc76 100644 --- a/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx +++ b/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx @@ -15,6 +15,7 @@ import { getFactoryLocationAnswer, getQMManagers } from "@/lib/pq/service" +import { SiteVisitDialog } from "./site-visit-dialog" import { RequestInvestigationDialog } from "./request-investigation-dialog" import { CancelInvestigationDialog, ReRequestInvestigationDialog } from "./cancel-investigation-dialog" import { SendResultsDialog } from "./send-results-dialog" @@ -49,6 +50,7 @@ export function VendorsTableToolbarActions({ table }: VendorsTableToolbarActions const [isCancelDialogOpen, setIsCancelDialogOpen] = React.useState(false) const [isSendResultsDialogOpen, setIsSendResultsDialogOpen] = React.useState(false) const [isReRequestDialogOpen, setIsReRequestDialogOpen] = React.useState(false) + const [isReinspectionDialogOpen, setIsReinspectionDialogOpen] = React.useState(false) const [isApprovalDialogOpen, setIsApprovalDialogOpen] = React.useState(false) const [isReRequestApprovalDialogOpen, setIsReRequestApprovalDialogOpen] = React.useState(false) @@ -441,6 +443,53 @@ const handleOpenRequestDialog = async () => { } } + // 재실사 요청 처리 + const handleRequestReinspection = async (data: { + qmManagerId: number, + forecastedAt: Date, + investigationAddress: string, + investigationNotes?: string + }) => { + try { + // 보완-재실사 대상 실사만 필터링 + const supplementReinspectInvestigations = selectedRows.filter(row => + row.original.investigation && + row.original.investigation.evaluationResult === "SUPPLEMENT_REINSPECT" + ); + + if (supplementReinspectInvestigations.length === 0) { + toast.error("보완-재실사 대상 실사가 없습니다."); + return; + } + + // 첫 번째 대상 실사로 재실사 요청 생성 + const targetInvestigation = supplementReinspectInvestigations[0].original.investigation!; + const { requestSupplementReinspectionAction } = await import('@/lib/vendor-investigation/service'); + + const result = await requestSupplementReinspectionAction({ + investigationId: targetInvestigation.id, + siteVisitData: { + inspectionDuration: 1.0, // 기본 1일 + requestedStartDate: data.forecastedAt, + requestedEndDate: new Date(data.forecastedAt.getTime() + 24 * 60 * 60 * 1000), // 1일 후 + shiAttendees: {}, + vendorRequests: {}, + additionalRequests: data.investigationNotes || "보완을 위한 재실사 요청입니다.", + } + }); + + if (result.success) { + toast.success("재실사 요청이 생성되었습니다."); + window.location.reload(); + } else { + toast.error(result.error || "재실사 요청 생성 중 오류가 발생했습니다."); + } + } catch (error) { + console.error("재실사 요청 오류:", error); + toast.error("재실사 요청 중 오류가 발생했습니다."); + } + }; + // 실사 결과 발송 처리 const handleSendInvestigationResults = async (data: { purchaseComment?: string }) => { try { @@ -505,8 +554,14 @@ const handleOpenRequestDialog = async () => { row.original.investigation.investigationStatus === "CANCELED" ).length + // 재실사 요청 대상 수 확인 (보완-재실사 결과만) + const reinspectInvestigationsCount = selectedRows.filter(row => + row.original.investigation && + row.original.investigation.evaluationResult === "SUPPLEMENT_REINSPECT" + ).length + // 미실사 PQ가 선택되었는지 확인 - const hasNonInspectionPQ = selectedRows.some(row => + const hasNonInspectionPQ = selectedRows.some(row => row.original.type === "NON_INSPECTION" ) @@ -651,6 +706,22 @@ const handleOpenRequestDialog = async () => { 실사 재의뢰 + {/* 재실사 요청 버튼 */} + + {/* 실사 결과 발송 버튼 */}