Merge remote-tracking branch 'origin/main_laptop_1' into sub_laptop_8
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/* =============================================================================
|
||||
* M01_LB_Api.ts
|
||||
* 로직 만들기 판 Api — 고친 표로 예시값 계산(0.3초 · 최신만) · 표를 쓰는 로직(사용처) · 표 읽기
|
||||
* 서버 = `M01_LB_Calc.py`(`/api/m01/lb/*`) · 모양은 `docs/raw/M01_쉬운단가/로직판_A_정함.md` 「맞출 모양」
|
||||
* ========================================================================== */
|
||||
|
||||
import type { CalcAnswer, LogicRow } from "../M01_MasterData_UI_Logic_Api";
|
||||
|
||||
/** 표 키 → 표 사본(고친 값 포함 · 표 통째) — 서버가 메모리에서만 바꿔 끼움 */
|
||||
export type LbTables = Record<string, unknown>;
|
||||
|
||||
/** 표를 쓰는 로직 한 줄 — `via` = 표 「용도」 에 적힘 · 로직 글에 표 키가 있음 · 둘 다 */
|
||||
export interface LbTableUser {
|
||||
key: string;
|
||||
이름: string;
|
||||
via: "용도" | "글" | "둘";
|
||||
}
|
||||
|
||||
/** 표 한 벌 — `file` · `version` 은 표가 든 파일 */
|
||||
export interface LbTable {
|
||||
file: string;
|
||||
version: string;
|
||||
table: Record<string, unknown> & { 줄: Record<string, unknown>[] };
|
||||
}
|
||||
|
||||
const notReady = (): never => {
|
||||
throw new Error("준비 중");
|
||||
};
|
||||
|
||||
/** 0.3초 뒤 고친 표로 서버 계산 · 최신 응답만 `onDone` · 멈춤 · 실패는 `plain` 쉬운 말 */
|
||||
export function lbCalcLater(
|
||||
_row: LogicRow,
|
||||
_inputs: Record<string, unknown>,
|
||||
_tables: LbTables,
|
||||
_onDone: (ans: CalcAnswer | null, plain: string | null) => void,
|
||||
): void {
|
||||
notReady();
|
||||
}
|
||||
|
||||
export async function tableUsers(_key: string): Promise<LbTableUser[]> {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
export async function fetchLbTable(_key: string): Promise<LbTable> {
|
||||
return notReady();
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/* =============================================================================
|
||||
* M01_LB_Blocks.ts
|
||||
* 로직 만들기 판 — 로직 줄 ↔ 블록(① 입력값 ② 표 조회 ③ 계산 ④ 항목 연결 ⑤ 결과값) 읽기 · 쓰기
|
||||
* DOM 없음 · 모양은 `docs/raw/M01_쉬운단가/로직판_A_설계초안.md` 7-1 · `로직판_A_정함.md` 그대로
|
||||
* ========================================================================== */
|
||||
|
||||
import type { LogicInput, LogicRow } from "../M01_MasterData_UI_Logic_Api";
|
||||
import type { CondRead } from "../EasyCalc/M01_EasyCalc_Cond";
|
||||
import type { EasyDoc } from "../EasyCalc/M01_EasyCalc_Model";
|
||||
|
||||
/** 값이 오는 곳 */
|
||||
export type LbRef =
|
||||
| { k: "input"; name: string } // ① 입력값
|
||||
| { k: "fixed"; value: number | string } // 고정값
|
||||
| { k: "lookup"; id: string } // ② 표 조회 결과
|
||||
| { k: "calc"; name: string } // ③ 이름 붙은 계산값(중간)
|
||||
| { k: "logic"; key: string; field: string | null } // 다른 로직 결과값(.노무비 등)
|
||||
| { k: "cost"; name: "노무비" | "재료비" | "경비" | "사람줄합" };
|
||||
|
||||
/** 블록으로 못 나눈 조각 — 원래 글 그대로 */
|
||||
export interface LbExpr {
|
||||
k: "expr";
|
||||
text: string;
|
||||
}
|
||||
|
||||
/** 식 자리 — 중간 · 호표 수량 · 덧줄 · 결과 · 장비/일위대가 요소 */
|
||||
export type LbPart = "중간" | "수량" | "비율" | "결과" | "요소";
|
||||
|
||||
export interface LbLookup {
|
||||
/** 화면 번호 · 저장 안 함 */
|
||||
id: string;
|
||||
/** QF000421 · 현장 사본이면 QX… */
|
||||
table: string;
|
||||
conds: { col: string; from: LbRef | LbExpr }[];
|
||||
/** 결과 칸 */
|
||||
col: string;
|
||||
at: { part: LbPart; index: number; start: number; end: number }[];
|
||||
}
|
||||
|
||||
export type LbCalcKind =
|
||||
"값" | "곱나눔" | "할증" | "더하기" | "조건목록" | "최소최대" | "올림" | "단계";
|
||||
|
||||
export interface LbCalc {
|
||||
/** 중간 이름 · 수량 자리면 null */
|
||||
name: string | null;
|
||||
kind: LbCalcKind;
|
||||
/** 곱나눔 · 더하기 · 할증(바탕 · 율) */
|
||||
parts: (LbRef | LbExpr)[];
|
||||
ops?: ("*" | "/" | "+" | "-")[];
|
||||
/** 조건목록 · 최소최대 · 올림 — Cond 것 그대로 */
|
||||
cond?: CondRead;
|
||||
at: { part: Exclude<LbPart, "요소">; index: number };
|
||||
/** 원래 글(안 고치면 그대로 씀) */
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface LbLogic {
|
||||
/** ④ 항목 · ⑤ 금액 — Model 것 그대로 */
|
||||
doc: EasyDoc;
|
||||
/** ① */
|
||||
inputs: LogicInput[];
|
||||
/** ② */
|
||||
lookups: LbLookup[];
|
||||
/** ③ */
|
||||
calcs: LbCalc[];
|
||||
/** ⑤ */
|
||||
result: { kind: "금액"; unit: string } | { kind: "값"; unit: string; calc: LbCalc };
|
||||
/** 못 읽은 까닭(쉬운 말) — 비면 다 읽힘 */
|
||||
blocked: string[];
|
||||
}
|
||||
|
||||
/** 원문 표 칸 고치기(메모리 사본) */
|
||||
export interface TableEdit {
|
||||
table: string;
|
||||
row: number;
|
||||
col: string;
|
||||
value: number | string | [number | null, number | null];
|
||||
}
|
||||
|
||||
const notReady = (): never => {
|
||||
throw new Error("준비 중");
|
||||
};
|
||||
|
||||
/** 로직 줄 → 블록 */
|
||||
export function readLogic(
|
||||
_row: LogicRow,
|
||||
_meta: { key: string | null; version: string | null; isBase: boolean },
|
||||
): LbLogic {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
/** 블록 → 로직 줄 — 고친 조각 자리만 글 갈아끼우기 */
|
||||
export function writeLogic(_lb: LbLogic): LogicRow {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
/** 단계 안내가 채울 빈 로직 */
|
||||
export function newLogic(_name?: string, _per?: string): LbLogic {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
/** 표 조회 조건 칸 하나 바꾸기 · from = null 은 조건 뺌(무관) */
|
||||
export function setCond(
|
||||
_lb: LbLogic,
|
||||
_lookupId: string,
|
||||
_col: string,
|
||||
_from: LbRef | LbExpr | null,
|
||||
): LbLogic {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
/** 계산 하나 바꾸기 — patch 의 틀 · 조각 · 조건으로 그 자리 글을 다시 짬 */
|
||||
export function setCalc(_lb: LbLogic, _calc: LbCalc, _patch: Partial<LbCalc>): LbLogic {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
/** 표 조회가 보는 표 바꾸기(현장 사본 등) */
|
||||
export function setLookupTable(_lb: LbLogic, _lookupId: string, _table: string): LbLogic {
|
||||
return notReady();
|
||||
}
|
||||
Reference in New Issue
Block a user