From 93b6b8868d409c7f6c9d9222b93750848caaedde Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 5 Dec 2025 03:28:04 +0000 Subject: (최겸) 구매 입찰 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bidding/manage/create-pre-quote-rfq-dialog.tsx | 90 ++++++++-------------- 1 file changed, 31 insertions(+), 59 deletions(-) (limited to 'components/bidding/manage/create-pre-quote-rfq-dialog.tsx') diff --git a/components/bidding/manage/create-pre-quote-rfq-dialog.tsx b/components/bidding/manage/create-pre-quote-rfq-dialog.tsx index 1ab7a40f..b0cecc25 100644 --- a/components/bidding/manage/create-pre-quote-rfq-dialog.tsx +++ b/components/bidding/manage/create-pre-quote-rfq-dialog.tsx @@ -26,13 +26,6 @@ import { FormMessage, FormDescription, } from "@/components/ui/form" -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select" import { Input } from "@/components/ui/input" import { Textarea } from "@/components/ui/textarea" import { @@ -41,20 +34,15 @@ import { PopoverTrigger, } from "@/components/ui/popover" import { Calendar } from "@/components/ui/calendar" -import { Badge } from "@/components/ui/badge" import { cn } from "@/lib/utils" import { toast } from "sonner" import { ScrollArea } from "@/components/ui/scroll-area" import { Separator } from "@/components/ui/separator" import { createPreQuoteRfqAction } from "@/lib/bidding/pre-quote/service" -import { previewGeneralRfqCode } from "@/lib/rfq-last/service" -import { MaterialGroupSelectorDialogSingle } from "@/components/common/material/material-group-selector-dialog-single" -import { MaterialSearchItem } from "@/lib/material/material-group-service" -import { MaterialSelectorDialogSingle } from "@/components/common/selectors/material/material-selector-dialog-single" -import { MaterialSearchItem as SAPMaterialSearchItem } from "@/components/common/selectors/material/material-service" import { PurchaseGroupCodeSelector } from "@/components/common/selectors/purchase-group-code/purchase-group-code-selector" import type { PurchaseGroupCodeWithUser } from "@/components/common/selectors/purchase-group-code" import { getBiddingById } from "@/lib/bidding/service" +import { getProjectIdByCodeAndName } from "@/lib/bidding/manage/project-utils" // 아이템 스키마 const itemSchema = z.object({ @@ -64,6 +52,8 @@ const itemSchema = z.object({ materialName: z.string().optional(), quantity: z.number().min(1, "수량은 1 이상이어야 합니다"), uom: z.string().min(1, "단위를 입력해주세요"), + totalWeight: z.union([z.number(), z.string(), z.null()]).optional(), // 중량 추가 + weightUnit: z.string().optional().nullable(), // 중량단위 추가 remark: z.string().optional(), }) @@ -125,8 +115,6 @@ export function CreatePreQuoteRfqDialog({ onSuccess }: CreatePreQuoteRfqDialogProps) { const [isLoading, setIsLoading] = React.useState(false) - const [previewCode, setPreviewCode] = React.useState("") - const [isLoadingPreview, setIsLoadingPreview] = React.useState(false) const [selectedBidPic, setSelectedBidPic] = React.useState(undefined) const { data: session } = useSession() @@ -143,6 +131,8 @@ export function CreatePreQuoteRfqDialog({ materialName: item.materialInfo || "", quantity: item.quantity ? parseFloat(item.quantity) : 1, uom: item.quantityUnit || item.weightUnit || "EA", + totalWeight: item.totalWeight ? parseFloat(item.totalWeight) : null, + weightUnit: item.weightUnit || null, remark: "", })) }, [biddingItems]) @@ -164,6 +154,8 @@ export function CreatePreQuoteRfqDialog({ materialName: "", quantity: 1, uom: "", + totalWeight: null, + weightUnit: null, remark: "", }, ], @@ -231,6 +223,14 @@ export function CreatePreQuoteRfqDialog({ const pName = bidding.projectName || ""; setProjectInfo(pCode && pName ? `${pCode} - ${pName}` : pCode || pName || ""); + // 프로젝트 ID 조회 + if (pCode && pName) { + const fetchedProjectId = await getProjectIdByCodeAndName(pCode, pName) + if (fetchedProjectId) { + form.setValue("projectId", fetchedProjectId) + } + } + // 폼 값 설정 form.setValue("rfqTitle", rfqTitle); form.setValue("rfqType", "pre_bidding"); // 기본값 설정 @@ -264,36 +264,15 @@ export function CreatePreQuoteRfqDialog({ materialName: "", quantity: 1, uom: "", + totalWeight: null, + weightUnit: null, remark: "", }, ], }) - setPreviewCode("") } }, [open, initialItems, form, selectedBidPic, biddingId]) - // 견적담당자 선택 시 RFQ 코드 미리보기 생성 - React.useEffect(() => { - if (!selectedBidPic?.user?.id) { - setPreviewCode("") - return - } - - // 즉시 실행 함수 패턴 사용 - (async () => { - setIsLoadingPreview(true) - try { - const code = await previewGeneralRfqCode(selectedBidPic.user!.id) - setPreviewCode(code) - } catch (error) { - console.error("코드 미리보기 오류:", error) - setPreviewCode("") - } finally { - setIsLoadingPreview(false) - } - })() - }, [selectedBidPic]) - // 견적 종류 변경 const handleRfqTypeChange = (value: string) => { form.setValue("rfqType", value) @@ -315,12 +294,13 @@ export function CreatePreQuoteRfqDialog({ materialName: "", quantity: 1, uom: "", + totalWeight: null, + weightUnit: null, remark: "", }, ], }) setSelectedBidPic(undefined) - setPreviewCode("") onOpenChange(false) } @@ -350,15 +330,17 @@ export function CreatePreQuoteRfqDialog({ biddingNumber: data.biddingNumber, // 추가 contractStartDate: data.contractStartDate, // 추가 contractEndDate: data.contractEndDate, // 추가 - items: data.items as Array<{ - itemCode: string; - itemName: string; - materialCode?: string; - materialName?: string; - quantity: number; - uom: string; - remark?: string; - }>, + items: data.items.map(item => ({ + itemCode: item.itemCode || "", + itemName: item.itemName || "", + materialCode: item.materialCode, + materialName: item.materialName, + quantity: item.quantity, + uom: item.uom, + totalWeight: item.totalWeight, + weightUnit: item.weightUnit, + remark: item.remark, + })), biddingConditions: biddingConditions || undefined, createdBy: userId, updatedBy: userId, @@ -590,17 +572,7 @@ export function CreatePreQuoteRfqDialog({ )} /> - {/* RFQ 코드 미리보기 */} - {previewCode && ( -
- - 예상 RFQ 코드: {previewCode} - - {isLoadingPreview && ( - - )} -
- )} + {/* 계약기간 */}
-- cgit v1.2.3