From 788eb678c45c6d3767cd2679c41ad5387ae6c3f0 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 30 Oct 2025 11:21:12 +0000 Subject: (최겸) 구매 PQ status별 로직처리(ㅌ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pq-review-table-new/vendors-table-columns.tsx | 2 +- .../vendors-table-toolbar-actions.tsx | 28 +++++++++++++--------- lib/pq/service.ts | 6 ++--- 3 files changed, 20 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/pq/pq-review-table-new/vendors-table-columns.tsx b/lib/pq/pq-review-table-new/vendors-table-columns.tsx index 3e10177d..ae4d5dc1 100644 --- a/lib/pq/pq-review-table-new/vendors-table-columns.tsx +++ b/lib/pq/pq-review-table-new/vendors-table-columns.tsx @@ -118,7 +118,7 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ExtendedC return ( { if (value) { // 전체 선택: 첫 번째 행만 선택 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 98b1cc76..a68d9b23 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 @@ -495,12 +495,15 @@ const handleOpenRequestDialog = async () => { try { setIsLoading(true) - // 완료된 실사 중 승인된 결과만 필터링 - const approvedInvestigations = selectedRows.filter(row => - row.original.investigation && - row.original.investigation.investigationStatus === "COMPLETED" && - row.original.investigation.evaluationResult === "APPROVED" - ) + // 완료된 실사 중 승인된 결과 또는 보완된 결과만 필터링 + const approvedInvestigations = selectedRows.filter(row => { + const investigation = row.original.investigation + return investigation && + (investigation.investigationStatus === "COMPLETED" || + investigation.investigationStatus === "SUPPLEMENT_REQUIRED" || + investigation.evaluationResult === "REJECTED") + + }) if (approvedInvestigations.length === 0) { toast.error("발송할 실사 결과가 없습니다. 완료되고 승인된 실사만 결과를 발송할 수 있습니다.") @@ -585,8 +588,11 @@ const handleOpenRequestDialog = async () => { const auditResults = selectedRows .filter(row => row.original.investigation && - row.original.investigation.investigationStatus === "COMPLETED" && - row.original.investigation.evaluationResult === "APPROVED" + (row.original.investigation.investigationStatus === "COMPLETED" || row.original.investigation.investigationStatus === "SUPPLEMENT_REQUIRED") && ( + (row.original.investigation.evaluationResult === "APPROVED" || + row.original.investigation.evaluationResult === "SUPPLEMENT" || + row.original.investigation.evaluationResult === "SUPPLEMENT_REINSPECT" || + row.original.investigation.evaluationResult === "SUPPLEMENT_DOCUMENT")) ) .map(row => { const investigation = row.original.investigation! @@ -734,10 +740,10 @@ const handleOpenRequestDialog = async () => { const investigation = row.original.investigation; if (!investigation) return false; - // 실사 완료 상태이거나 평가 결과가 있는 경우에만 활성화 + // 실사 완료 상태이거나 평가 결과가 있는 경우에만 활성화, 실사결과발송 상태가 아닌 경우에만 활성화 return investigation.investigationStatus === "COMPLETED" || - investigation.evaluationResult === "REJECTED" || - investigation.evaluationResult === "SUPPLEMENT"; + investigation.investigationStatus === "SUPPLEMENT_REQUIRED" || + investigation.evaluationResult === "REJECTED" }) } className="gap-2" diff --git a/lib/pq/service.ts b/lib/pq/service.ts index 0bc575a6..7cdbcafd 100644 --- a/lib/pq/service.ts +++ b/lib/pq/service.ts @@ -1933,6 +1933,7 @@ export async function getPQSubmissions(input: GetPQSubmissionsSchema) { completedAt: vendorInvestigations.completedAt, forecastedAt: vendorInvestigations.forecastedAt, evaluationScore: vendorInvestigations.evaluationScore, + hasSupplementRequested: vendorInvestigations.hasSupplementRequested, evaluationResult: vendorInvestigations.evaluationResult, investigationNotes: vendorInvestigations.investigationNotes, requesterId: vendorInvestigations.requesterId, @@ -3073,10 +3074,7 @@ export async function sendInvestigationResultsAction(input: { .leftJoin(projects, eq(vendorPQSubmissions.projectId, projects.id)) .leftJoin(users, eq(vendorInvestigations.requesterId, users.id)) .where( - and( - inArray(vendorInvestigations.id, input.investigationIds), - eq(vendorInvestigations.investigationStatus, "COMPLETED") - ) + inArray(vendorInvestigations.id, input.investigationIds) ) if (investigations.length === 0) { -- cgit v1.2.3