엑셀업로드 제어로직 개선
This commit is contained in:
@@ -28,6 +28,14 @@ const OPERATOR_LABELS: Record<string, string> = {
|
||||
"%": "%",
|
||||
};
|
||||
|
||||
// 피연산자를 문자열로 변환
|
||||
function getOperandStr(operand: any): string {
|
||||
if (!operand) return "?";
|
||||
if (operand.type === "static") return String(operand.value || "?");
|
||||
if (operand.fieldLabel) return operand.fieldLabel;
|
||||
return operand.field || operand.resultField || "?";
|
||||
}
|
||||
|
||||
// 수식 요약 생성
|
||||
function getFormulaSummary(transformation: FormulaTransformNodeData["transformations"][0]): string {
|
||||
const { formulaType, arithmetic, function: func, condition, staticValue } = transformation;
|
||||
@@ -35,11 +43,19 @@ function getFormulaSummary(transformation: FormulaTransformNodeData["transformat
|
||||
switch (formulaType) {
|
||||
case "arithmetic": {
|
||||
if (!arithmetic) return "미설정";
|
||||
const left = arithmetic.leftOperand;
|
||||
const right = arithmetic.rightOperand;
|
||||
const leftStr = left.type === "static" ? left.value : `${left.type}.${left.field || left.resultField}`;
|
||||
const rightStr = right.type === "static" ? right.value : `${right.type}.${right.field || right.resultField}`;
|
||||
return `${leftStr} ${OPERATOR_LABELS[arithmetic.operator]} ${rightStr}`;
|
||||
const leftStr = getOperandStr(arithmetic.leftOperand);
|
||||
const rightStr = getOperandStr(arithmetic.rightOperand);
|
||||
let formula = `${leftStr} ${OPERATOR_LABELS[arithmetic.operator]} ${rightStr}`;
|
||||
|
||||
// 추가 연산 표시
|
||||
if (arithmetic.additionalOperations && arithmetic.additionalOperations.length > 0) {
|
||||
for (const addOp of arithmetic.additionalOperations) {
|
||||
const opStr = getOperandStr(addOp.operand);
|
||||
formula += ` ${OPERATOR_LABELS[addOp.operator] || addOp.operator} ${opStr}`;
|
||||
}
|
||||
}
|
||||
|
||||
return formula;
|
||||
}
|
||||
case "function": {
|
||||
if (!func) return "미설정";
|
||||
|
||||
@@ -797,6 +797,85 @@ export function FormulaTransformProperties({ nodeId, data }: FormulaTransformPro
|
||||
index,
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 추가 연산 목록 */}
|
||||
{trans.arithmetic.additionalOperations && trans.arithmetic.additionalOperations.length > 0 && (
|
||||
<div className="space-y-2 border-t pt-2">
|
||||
<Label className="text-xs text-gray-500">추가 연산</Label>
|
||||
{trans.arithmetic.additionalOperations.map((addOp: any, addIndex: number) => (
|
||||
<div key={addIndex} className="flex items-center gap-2 rounded bg-orange-50 p-2">
|
||||
<Select
|
||||
value={addOp.operator}
|
||||
onValueChange={(value) => {
|
||||
const newAdditionalOps = [...(trans.arithmetic!.additionalOperations || [])];
|
||||
newAdditionalOps[addIndex] = { ...newAdditionalOps[addIndex], operator: value };
|
||||
handleTransformationChange(index, {
|
||||
arithmetic: { ...trans.arithmetic!, additionalOperations: newAdditionalOps },
|
||||
});
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="h-7 w-20 text-xs">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{ARITHMETIC_OPERATORS.map((op) => (
|
||||
<SelectItem key={op.value} value={op.value}>
|
||||
{op.value}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div className="flex-1">
|
||||
{renderOperandSelector(
|
||||
addOp.operand,
|
||||
(updates) => {
|
||||
const newAdditionalOps = [...(trans.arithmetic!.additionalOperations || [])];
|
||||
newAdditionalOps[addIndex] = { ...newAdditionalOps[addIndex], operand: updates };
|
||||
handleTransformationChange(index, {
|
||||
arithmetic: { ...trans.arithmetic!, additionalOperations: newAdditionalOps },
|
||||
});
|
||||
},
|
||||
index,
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 w-7 p-0 text-red-500 hover:text-red-700"
|
||||
onClick={() => {
|
||||
const newAdditionalOps = trans.arithmetic!.additionalOperations!.filter(
|
||||
(_: any, i: number) => i !== addIndex
|
||||
);
|
||||
handleTransformationChange(index, {
|
||||
arithmetic: { ...trans.arithmetic!, additionalOperations: newAdditionalOps },
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-3 w-3" />
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 추가 연산 버튼 */}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-7 w-full text-xs"
|
||||
onClick={() => {
|
||||
const newAdditionalOps = [
|
||||
...(trans.arithmetic!.additionalOperations || []),
|
||||
{ operator: "*", operand: { type: "static" as const, value: "" } },
|
||||
];
|
||||
handleTransformationChange(index, {
|
||||
arithmetic: { ...trans.arithmetic!, additionalOperations: newAdditionalOps },
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Plus className="mr-1 h-3 w-3" />
|
||||
연산 추가
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -231,6 +231,17 @@ export interface FormulaTransformNodeData {
|
||||
value?: string | number;
|
||||
resultField?: string;
|
||||
};
|
||||
// 추가 연산 (다중 연산 지원: (left op right) op1 val1 op2 val2 ...)
|
||||
additionalOperations?: Array<{
|
||||
operator: "+" | "-" | "*" | "/" | "%";
|
||||
operand: {
|
||||
type: "source" | "target" | "static" | "result";
|
||||
field?: string;
|
||||
fieldLabel?: string;
|
||||
value?: string | number;
|
||||
resultField?: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
|
||||
// 함수 (formulaType === "function")
|
||||
|
||||
Reference in New Issue
Block a user