summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-11-18 15:05:13 +0900
committerjoonhoekim <26rote@gmail.com>2025-11-18 15:05:13 +0900
commit1d1f6010704a1d655b3007887db0fe3ac866177a (patch)
treeedd906a7c3b00a7f4b3f7e462a86f32092575a5b
parent54c654260c098864a8e113d46a242a057b58aae6 (diff)
(김준회) 견적 발송: 결재 분기처리에서 누락되었던 SendRfqDialog 우선 띄우도록 처리
-rw-r--r--lib/rfq-last/vendor/rfq-vendor-table.tsx158
1 files changed, 54 insertions, 104 deletions
diff --git a/lib/rfq-last/vendor/rfq-vendor-table.tsx b/lib/rfq-last/vendor/rfq-vendor-table.tsx
index efc17171..2ee2cb73 100644
--- a/lib/rfq-last/vendor/rfq-vendor-table.tsx
+++ b/lib/rfq-last/vendor/rfq-vendor-table.tsx
@@ -463,60 +463,7 @@ export function RfqVendorTable({
return;
}
- // 🔹 attachment_type이 '구매'인 첨부파일이 있는지 확인
- const hasPurchaseAttachments = rfqSendData.attachments &&
- rfqSendData.attachments.some((att: any) => att.attachmentType === '구매');
-
- // 🔹 '구매' 타입 첨부파일이 있는 경우: 결재 프로세스 시작
- if (hasPurchaseAttachments) {
- // Knox EP ID 확인
- if (!session?.user?.epId) {
- toast.error("Knox EP ID가 없습니다. 시스템 관리자에게 문의하세요.");
- setIsLoadingSendData(false);
- return;
- }
-
- // 첨부파일 정보 변환
- const attachmentsForApproval = rfqSendData.attachments.map((att: any) => ({
- fileName: att.fileName,
- fileSize: att.fileSize,
- }));
-
- // 결재 데이터 임시 저장 (신청사유 입력 전)
- setApprovalPreviewData({
- vendors: vendorEmailInfos.map(v => ({
- vendorId: v.vendorId,
- vendorName: v.vendorName,
- vendorCode: v.vendorCode,
- vendorCountry: v.vendorCountry,
- selectedMainEmail: v.primaryEmail || v.vendorEmail || '',
- additionalEmails: [],
- customEmails: [],
- currency: v.currency,
- contractRequirements: {
- ndaYn: v.ndaYn || false,
- generalGtcYn: v.generalGtcYn || false,
- projectGtcYn: v.projectGtcYn || false,
- agreementYn: v.agreementYn || false,
- },
- isResend: v.sendVersion ? v.sendVersion > 0 : false,
- sendVersion: v.sendVersion,
- })),
- attachments: attachmentsForApproval,
- attachmentIds: rfqSendData.attachments.map((att: any) => att.id),
- message: undefined,
- generatedPdfs: undefined,
- hasToSendEmail: true,
- });
-
- // 신청사유 입력 다이얼로그 먼저 열기
- setShowApplicationReasonDialog(true);
- setIsLoadingSendData(false);
- return;
- }
-
- // 🔹 '구매' 타입 첨부파일이 없는 경우: 기존 로직 (바로 발송)
- // 다이얼로그 데이터 설정
+ // 🔹 구매 첨부파일 유무와 관계없이 SendRfqDialog 데이터 설정
setSendDialogData({
rfqInfo: rfqSendData.rfqInfo,
attachments: rfqSendData.attachments || [],
@@ -655,6 +602,57 @@ export function RfqVendorTable({
hasToSendEmail?: boolean;
}) => {
try {
+ // 🔹 구매 첨부파일이 있는지 확인
+ const hasPurchaseAttachments = sendDialogData.attachments &&
+ sendDialogData.attachments.some((att: any) => att.attachmentType === '구매');
+
+ // 🔹 구매 첨부파일이 있는 경우: 결재 프로세스로 분기
+ if (hasPurchaseAttachments) {
+ // Knox EP ID 확인
+ if (!session?.user?.epId) {
+ toast.error("Knox EP ID가 없습니다. 시스템 관리자에게 문의하세요.");
+ return {
+ success: false,
+ message: "Knox EP ID가 없습니다.",
+ totalSent: 0,
+ totalFailed: data.vendors.length,
+ totalContracts: 0,
+ totalTbeSessions: 0
+ };
+ }
+
+ // 첨부파일 정보 변환
+ const attachmentsForApproval = sendDialogData.attachments.map((att: any) => ({
+ fileName: att.fileName,
+ fileSize: att.fileSize,
+ }));
+
+ // 결재 데이터 저장
+ setApprovalPreviewData({
+ vendors: data.vendors,
+ attachments: attachmentsForApproval,
+ attachmentIds: data.attachments,
+ message: data.message,
+ generatedPdfs: data.generatedPdfs,
+ hasToSendEmail: data.hasToSendEmail,
+ });
+
+ // SendRfqDialog 닫고 신청사유 입력 다이얼로그 열기
+ setIsSendDialogOpen(false);
+ setShowApplicationReasonDialog(true);
+
+ // 결재 프로세스로 진행되므로 pending 상태 반환
+ return {
+ success: true,
+ message: "결재 프로세스로 진행합니다.",
+ totalSent: 0,
+ totalFailed: 0,
+ totalContracts: 0,
+ totalTbeSessions: 0
+ };
+ }
+
+ // 🔹 구매 첨부파일이 없는 경우: 바로 발송
// 서버 액션 호출
const result = await sendRfqToVendors({
rfqId,
@@ -706,7 +704,7 @@ export function RfqVendorTable({
totalTbeSessions: 0
};
}
- }, [rfqId, rfqCode, router]);
+ }, [rfqId, rfqCode, router, sendDialogData, session]);
// vendor status에 따른 category 분류 함수
const getVendorCategoryFromStatus = React.useCallback((status: string | null): string => {
@@ -761,55 +759,7 @@ export function RfqVendorTable({
return;
}
- // 🔹 attachment_type이 '구매'인 첨부파일이 있는지 확인
- const hasPurchaseAttachments = rfqSendData.attachments &&
- rfqSendData.attachments.some((att: any) => att.attachmentType === '구매');
-
- // 🔹 '구매' 타입 첨부파일이 있는 경우: 결재 프로세스
- if (hasPurchaseAttachments) {
- if (!session?.user?.epId) {
- toast.error("Knox EP ID가 없습니다. 시스템 관리자에게 문의하세요.");
- setIsLoadingSendData(false);
- return;
- }
-
- const attachmentsForApproval = rfqSendData.attachments.map((att: any) => ({
- fileName: att.fileName,
- fileSize: att.fileSize,
- }));
-
- setApprovalPreviewData({
- vendors: vendorEmailInfos.map(v => ({
- vendorId: v.vendorId,
- vendorName: v.vendorName,
- vendorCode: v.vendorCode,
- vendorCountry: v.vendorCountry,
- selectedMainEmail: v.primaryEmail || v.vendorEmail || '',
- additionalEmails: [],
- customEmails: [],
- currency: v.currency,
- contractRequirements: {
- ndaYn: v.ndaYn || false,
- generalGtcYn: v.generalGtcYn || false,
- projectGtcYn: v.projectGtcYn || false,
- agreementYn: v.agreementYn || false,
- },
- isResend: v.sendVersion ? v.sendVersion > 0 : false,
- sendVersion: v.sendVersion,
- })),
- attachments: attachmentsForApproval,
- attachmentIds: rfqSendData.attachments.map((att: any) => att.id),
- message: undefined,
- generatedPdfs: undefined,
- hasToSendEmail: true,
- });
-
- setShowApplicationReasonDialog(true);
- setIsLoadingSendData(false);
- return;
- }
-
- // 🔹 '구매' 타입 첨부파일이 없는 경우: 기존 로직
+ // 🔹 구매 첨부파일 유무와 관계없이 SendRfqDialog 데이터 설정
setSendDialogData({
rfqInfo: rfqSendData.rfqInfo,
attachments: rfqSendData.attachments || [],