중간저장

This commit is contained in:
leeheejin 2025-12-10 10:27:54 +09:00
parent 990f667481
commit 3608d9f9c3
4 changed files with 26 additions and 14 deletions

View File

@ -48,8 +48,17 @@ export function SimpleRepeaterTableComponent({
allowAdd: propAllowAdd, allowAdd: propAllowAdd,
maxHeight: propMaxHeight, maxHeight: propMaxHeight,
// DOM에 전달되면 안 되는 props 명시적 제거 (부모에서 전달될 수 있음)
initialData: _initialData,
originalData: _originalData,
groupedData: _groupedData,
...props ...props
}: SimpleRepeaterTableComponentProps) { }: SimpleRepeaterTableComponentProps & {
initialData?: any;
originalData?: any;
groupedData?: any;
}) {
// config 또는 component.config 또는 개별 prop 우선순위로 병합 // config 또는 component.config 또는 개별 prop 우선순위로 병합
const componentConfig = { const componentConfig = {
...config, ...config,
@ -265,7 +274,7 @@ export function SimpleRepeaterTableComponent({
useEffect(() => { useEffect(() => {
const handleSaveRequest = async (event: Event) => { const handleSaveRequest = async (event: Event) => {
if (value.length === 0) { if (value.length === 0) {
console.warn("⚠️ [SimpleRepeaterTable] 저장할 데이터 없음"); // console.warn("⚠️ [SimpleRepeaterTable] 저장할 데이터 없음");
return; return;
} }
@ -306,7 +315,7 @@ export function SimpleRepeaterTableComponent({
}); });
}); });
console.log("✅ [SimpleRepeaterTable] 테이블별 저장 데이터:", dataByTable); // console.log("✅ [SimpleRepeaterTable] 테이블별 저장 데이터:", dataByTable);
// CustomEvent의 detail에 테이블별 데이터 추가 // CustomEvent의 detail에 테이블별 데이터 추가
if (event instanceof CustomEvent && event.detail) { if (event instanceof CustomEvent && event.detail) {
@ -319,10 +328,10 @@ export function SimpleRepeaterTableComponent({
})); }));
}); });
console.log("✅ [SimpleRepeaterTable] 저장 데이터 준비:", { // console.log("✅ [SimpleRepeaterTable] 저장 데이터 준비:", {
tables: Object.keys(dataByTable), // tables: Object.keys(dataByTable),
totalRows: Object.values(dataByTable).reduce((sum, rows) => sum + rows.length, 0), // totalRows: Object.values(dataByTable).reduce((sum, rows) => sum + rows.length, 0),
}); // });
} }
// 기존 onFormDataChange도 호출 (호환성) // 기존 onFormDataChange도 호출 (호환성)

View File

@ -1316,11 +1316,13 @@ export function SimpleRepeaterTableConfigPanel({
</SelectValue> </SelectValue>
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
{(localConfig.columns || []).map((col, colIndex) => ( {(localConfig.columns || [])
<SelectItem key={col.field || `empty-${colIndex}`} value={col.field || ""}> .filter((col) => col.field && col.field.trim() !== "")
{col.label} ({col.field || '미설정'}) .map((col, colIndex) => (
</SelectItem> <SelectItem key={col.field || `col-${colIndex}`} value={col.field}>
))} {col.label} ({col.field})
</SelectItem>
))}
</SelectContent> </SelectContent>
</Select> </Select>
<p className="text-[10px] text-muted-foreground"> <p className="text-[10px] text-muted-foreground">

View File

@ -9,7 +9,7 @@ import { ComponentRendererProps } from "@/types/component";
// 컴포넌트 자동 등록 // 컴포넌트 자동 등록
ComponentRegistry.registerComponent(SimpleRepeaterTableDefinition); ComponentRegistry.registerComponent(SimpleRepeaterTableDefinition);
console.log("✅ SimpleRepeaterTable 컴포넌트 등록 완료"); // console.log("✅ SimpleRepeaterTable 컴포넌트 등록 완료");
export function SimpleRepeaterTableRenderer(props: ComponentRendererProps) { export function SimpleRepeaterTableRenderer(props: ComponentRendererProps) {
return <SimpleRepeaterTableComponent {...props} />; return <SimpleRepeaterTableComponent {...props} />;

View File

@ -30,7 +30,8 @@ export function useCalculation(calculationRules: CalculationRule[] = []) {
// 결과 필드는 제외 // 결과 필드는 제외
if (dep === rule.result) continue; if (dep === rule.result) continue;
const value = parseFloat(row[dep]) || 0; // 이전 계산 결과(updatedRow)를 우선 사용, 없으면 원본(row) 사용
const value = parseFloat(updatedRow[dep] ?? row[dep]) || 0;
// 정확한 필드명만 대체 (단어 경계 사용) // 정확한 필드명만 대체 (단어 경계 사용)
formula = formula.replace(new RegExp(`\\b${dep}\\b`, "g"), value.toString()); formula = formula.replace(new RegExp(`\\b${dep}\\b`, "g"), value.toString());
} }