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 --- components/pq-input/pq-review-wrapper.tsx | 92 +++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 10 deletions(-) (limited to 'components/pq-input/pq-review-wrapper.tsx') diff --git a/components/pq-input/pq-review-wrapper.tsx b/components/pq-input/pq-review-wrapper.tsx index 9b719644..bcb384d9 100644 --- a/components/pq-input/pq-review-wrapper.tsx +++ b/components/pq-input/pq-review-wrapper.tsx @@ -23,7 +23,7 @@ import { import { useToast } from "@/hooks/use-toast" import { CheckCircle, AlertCircle, Paperclip, Square } from "lucide-react" import { PQGroupData } from "@/lib/pq/service" -import { approvePQAction, rejectPQAction, updateSHICommentAction, approveQMReviewAction, rejectQMReviewAction } from "@/lib/pq/service" +import { approvePQAction, rejectPQAction, updateSHICommentAction, approveQMReviewAction, rejectQMReviewAction, requestPqSupplementAction } from "@/lib/pq/service" // import * as ExcelJS from 'exceljs'; // import { saveAs } from "file-saver"; @@ -67,10 +67,13 @@ export function PQReviewWrapper({ const [showRejectDialog, setShowRejectDialog] = React.useState(false) const [showQMApproveDialog, setShowQMApproveDialog] = React.useState(false) const [showQMRejectDialog, setShowQMRejectDialog] = React.useState(false) + const [showSupplementDialog, setShowSupplementDialog] = React.useState(false) const [rejectReason, setRejectReason] = React.useState("") const [qmRejectReason, setQmRejectReason] = React.useState("") + const [supplementComment, setSupplementComment] = React.useState("") const [shiComments, setShiComments] = React.useState>({}) const [isUpdatingComment, setIsUpdatingComment] = React.useState(null) + const [isSendingSupplement, setIsSendingSupplement] = React.useState(false) // 코드 순서로 정렬하는 함수 (1-1-1, 1-1-2, 1-2-1 순서) @@ -108,7 +111,7 @@ export function PQReviewWrapper({ setShiComments(initialComments) }, [pqData]) - // PQ 승인 처리 (구매 담당자) + // PQ 승인 처리 const handleApprove = async () => { try { setIsApproving(true) @@ -121,10 +124,10 @@ export function PQReviewWrapper({ if (result.ok) { toast({ title: "PQ 승인 완료", - description: "PQ가 QM 검토 단계로 전환되었습니다.", + description: "PQ가 성공적으로 승인되었습니다.", }) // 페이지 새로고침 - router.refresh() + router.push(`/evcp/pq_new/`) } else { toast({ title: "승인 실패", @@ -182,6 +185,35 @@ export function PQReviewWrapper({ } } + // 보완요청 처리 + const handleRequestSupplement = async () => { + if (!supplementComment.trim()) { + toast({ title: "보완요청 내용 필요", description: "보완요청 사유를 입력해주세요.", variant: "destructive" }) + return + } + try { + setIsSendingSupplement(true) + const result = await requestPqSupplementAction({ + pqSubmissionId: pqSubmission.id, + vendorId, + comment: supplementComment, + }) + if (result.ok) { + toast({ title: "보완요청 전송", description: "보완요청 메일을 발송했습니다." }) + setShowSupplementDialog(false) + setSupplementComment("") + router.refresh() + } else { + toast({ title: "전송 실패", description: result.error || "보완요청 전송 중 오류가 발생했습니다.", variant: "destructive" }) + } + } catch (e) { + console.error(e) + toast({ title: "전송 실패", description: "보완요청 전송 중 오류가 발생했습니다.", variant: "destructive" }) + } finally { + setIsSendingSupplement(false) + } + } + // QM 거절 처리 const handleQMReject = async () => { if (!qmRejectReason.trim()) { @@ -426,8 +458,8 @@ export function PQReviewWrapper({ title: "PQ 거부 완료", description: "PQ가 거부되었습니다.", }) - // 페이지 새로고침 - router.refresh() + // 페이지 리다이렉트 + router.push(`/evcp/pq_new/`) } else { toast({ title: "거부 실패", @@ -745,6 +777,13 @@ export function PQReviewWrapper({ > {isRejecting ? "거부 중..." : "거부"} + +