fix: 견적 V2 자동 견적 산출 UI 오류 수정
- actions.ts: BomBulkResponse 타입, FinishedGoods에 has_bom/bom 필드 추가 - QuoteRegistrationV2.tsx: handleCalculate 응답 처리, DevFill BOM 필터링 - LocationDetailPanel.tsx: bomItemsByTab process_group 기반 매핑 - QuoteSummaryPanel.tsx: detailTotals grouped_items 기반 계산 해결된 문제: 1. 오른쪽 패널 제품 리스트 미표시 2. 개소별 합계(상세소계) 미표시 3. 상세별 합계(그룹) 미표시 4. 예상 견적금액 0원 표시
This commit is contained in:
@@ -40,6 +40,7 @@ import {
|
||||
getSiteNames,
|
||||
type FinishedGoods,
|
||||
type BomCalculationResult,
|
||||
type BomBulkResponse,
|
||||
} from "./actions";
|
||||
import { getClients } from "../accounting/VendorManagement/actions";
|
||||
import { isNextRedirectError } from "@/lib/utils/redirect-error";
|
||||
@@ -179,10 +180,24 @@ export function QuoteRegistrationV2({
|
||||
// handleCalculate 참조 (DevFill에서 사용)
|
||||
const calculateRef = useRef<(() => Promise<void>) | null>(null);
|
||||
|
||||
// 디버그용: formData를 window에 노출
|
||||
useEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
(window as unknown as { __QUOTE_DEBUG__: { formData: QuoteFormDataV2; selectedLocationId: string | null } }).__QUOTE_DEBUG__ = {
|
||||
formData,
|
||||
selectedLocationId,
|
||||
};
|
||||
}
|
||||
}, [formData, selectedLocationId]);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DevFill (개발/테스트용 자동 채우기)
|
||||
// ---------------------------------------------------------------------------
|
||||
useDevFill("quoteV2", useCallback(() => {
|
||||
// BOM이 있는 제품만 필터링
|
||||
const productsWithBom = finishedGoods.filter((fg) => fg.has_bom === true || (fg.bom && Array.isArray(fg.bom) && fg.bom.length > 0));
|
||||
console.log(`[DevFill] BOM 있는 제품: ${productsWithBom.length}개 / 전체: ${finishedGoods.length}개`);
|
||||
|
||||
// 랜덤 개소 생성 함수
|
||||
const createRandomLocation = (index: number): LocationItem => {
|
||||
const floors = ["B2", "B1", "1F", "2F", "3F", "4F", "5F", "R"];
|
||||
@@ -195,7 +210,9 @@ export function QuoteRegistrationV2({
|
||||
const randomPrefix = codePrefix[Math.floor(Math.random() * codePrefix.length)];
|
||||
const randomWidth = Math.floor(Math.random() * 4000) + 2000; // 2000~6000
|
||||
const randomHeight = Math.floor(Math.random() * 3000) + 2000; // 2000~5000
|
||||
const randomProduct = finishedGoods[Math.floor(Math.random() * finishedGoods.length)];
|
||||
// BOM이 있는 제품 중에서 랜덤 선택 (없으면 전체에서 선택)
|
||||
const productPool = productsWithBom.length > 0 ? productsWithBom : finishedGoods;
|
||||
const randomProduct = productPool[Math.floor(Math.random() * productPool.length)];
|
||||
|
||||
return {
|
||||
id: `loc-${Date.now()}-${index}`,
|
||||
@@ -455,19 +472,27 @@ export function QuoteRegistrationV2({
|
||||
const result = await calculateBomBulk(bomItems);
|
||||
|
||||
if (result.success && result.data) {
|
||||
// API 응답: { summary: { grand_total }, items: [{ index, result: BomCalculationResult }] }
|
||||
const apiData = result.data as {
|
||||
summary?: { grand_total: number };
|
||||
items?: Array<{ index: number; result: BomCalculationResult }>;
|
||||
};
|
||||
// API 응답: { success, summary: { grand_total, ... }, items: [{ index, result: BomCalculationResult }] }
|
||||
const apiData = result.data as BomBulkResponse;
|
||||
const bomResponseItems = apiData.items || [];
|
||||
|
||||
const bomItems = apiData.items || [];
|
||||
console.log('[QuoteRegistrationV2] BOM 계산 결과:', {
|
||||
success: apiData.success,
|
||||
summary: apiData.summary,
|
||||
itemsCount: bomResponseItems.length,
|
||||
firstItem: bomResponseItems[0],
|
||||
});
|
||||
|
||||
// 결과 반영
|
||||
const updatedLocations = formData.locations.map((loc, index) => {
|
||||
const bomItem = bomItems.find((item) => item.index === index);
|
||||
const bomItem = bomResponseItems.find((item) => item.index === index);
|
||||
const bomResult = bomItem?.result;
|
||||
if (bomResult) {
|
||||
console.log(`[QuoteRegistrationV2] Location ${index} bomResult:`, {
|
||||
items: bomResult.items?.length,
|
||||
subtotals: bomResult.subtotals,
|
||||
grand_total: bomResult.grand_total,
|
||||
});
|
||||
return {
|
||||
...loc,
|
||||
unitPrice: bomResult.grand_total,
|
||||
|
||||
Reference in New Issue
Block a user