feat(M01): PLAN 3-4 복사해서 만들기 화면 — 별칭 꼴 식 편집·표 바꾸기·로직 부르기 갈래·시험 계산·저장

- 새 M01_MasterData_UI_LogicLab_Copy.ts — [본떠 만들기] → GET /logic/formula(별칭 폼) 편집
  → 표 바꾸기 모달(소요량·계수 검색) · 로직 부르기 그대로/같이 복사 갈래 · 식 줄 고치기·덧줄 더하기
  → POST /logic/formula/preview 로 되돌린 실제 식을 buildCalc 로 재사용해 시험 계산
  → POST /logic/formula/save 로 자체 로직(GX) 저장 · afterSave 로 LogicLab 이 새 키를 바로 엶
- 서버: POST /logic/formula/preview 새로 더함(저장 없이 별칭만 원문으로 되돌림) · 계약 7장 반영
- LogicLab.ts 는 「본떠 만들기」 단추 한 줄만 붙임(정본 로직 화면·New 화면은 안 건드림)
- ORCA 로 13-4-1 을 본떠 저장 — 안 고치면 79,279.668 로 원본과 같음 · 석공 줄 곱 2배로 고치면
  131,716.728 로 바뀜 확인 · 시험 흔적(GX000001·로직_자체.json·키대장 GX 번호) 지움·되돌림
- 시험 `test_m01_copy.py` 에 미리보기 시험 둘 더함 · M01 시험 130 통과 · typecheck 통과
This commit is contained in:
2026-09-21 21:12:43 +09:00
parent 7379379bd7
commit e73ef5d3a0
10 changed files with 563 additions and 9 deletions
@@ -214,3 +214,56 @@ export const copyLogic = (
key: string,
): Promise<{ file: string; version: string; key: string; logic: LogicRow }> =>
request("/logic/copy", { key });
/** 복사해서 만들기(계약 7장) — 찾기·로직 부르기 한 덩이를 이름 하나(별칭)로 보임 */
export interface FormulaAlias {
이름: string;
종류: "찾기" | "로직";
참조: string;
/** 되돌릴 원문 부르기 글 — 저장 때 이 글로 갈아 끼움 */
원문: string;
밑이름: string;
값칸: Record<string, string>;
결과단위: string;
자리: string[];
}
export interface FormulaLine {
자리: string;
갈래: "중간" | "호표" | "덧줄" | "결과";
차례: number;
이름: string;
단위: string;
비목: string;
식: string;
출처: string;
종류?: string;
요소?: unknown;
}
export interface LogicFormula {
file: string;
version: string;
key: string;
소유: string;
prices: Record<string, ElementBrief | null>;
로직: LogicRow;
별칭: FormulaAlias[];
줄: FormulaLine[];
}
export const fetchLogicFormula = (key: string): Promise<LogicFormula> =>
request(`/logic/formula?${query({ key })}`);
export const saveLogicFormula = (body: {
로직: LogicRow;
별칭: FormulaAlias[];
owner: string;
이름?: string;
본뜬키?: string;
}): Promise<{ file: string; version: string; key: string; logic: LogicRow }> =>
request("/logic/formula/save", body);
/** 저장 전 시험 계산용 — 별칭을 원문으로 되돌린 로직 줄만(저장 안 함) */
export const previewLogicFormula = (
로직: LogicRow,
별칭: FormulaAlias[],
): Promise<{ logic: LogicRow }> => request("/logic/formula/preview", { 로직, 별칭 });