feat(m01-easycalc): 쉬운 단가산출 Model 타입 · 함수 머리 올림
설계.md 3절 CardKind · CostKind · EasyCard · EasyDoc · PickResult 와 함수 머리(속은 준비 중) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBToTCGk5dqDKeXCEP3vhk
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
/* =============================================================================
|
||||
* M01_EasyCalc_Model.ts
|
||||
* 쉬운 단가산출 Model — 로직 줄(LogicRow) ↔ 카드(EasyDoc · EasyCard) 바꾸기 · 카드 조작 · 검사 · 되돌리기
|
||||
* DOM 없음 · 모양은 `docs/raw/M01_쉬운단가/설계.md` 3절 그대로
|
||||
* ========================================================================== */
|
||||
|
||||
import type { LogicInput, LogicRow } from "../M01_MasterData_UI_Logic_Api";
|
||||
|
||||
export type CardKind = "person" | "material" | "machine" | "logic" | "percent" | "locked";
|
||||
export type CostKind = "노무비" | "재료비" | "경비";
|
||||
|
||||
export interface EasyCard {
|
||||
/** 화면 번호 · 저장 안 함 */
|
||||
id: string;
|
||||
kind: CardKind;
|
||||
/** 보이는 이름(호표 · 덧줄 이름) */
|
||||
name: string;
|
||||
/** 크기(규격) · 없으면 "" */
|
||||
spec: string;
|
||||
/** 인 · ㎥ · 시간 · % … */
|
||||
unit: string;
|
||||
/** 숫자 수량 · 식이면 null */
|
||||
qty: number | null;
|
||||
/** 잠금 식(원문 그대로) · 숫자면 null */
|
||||
qtyFormula: string | null;
|
||||
/** 넣을 자리 · 다른 일위대가 · 기계는 null(엔진이 나눔) */
|
||||
cost: CostKind | null;
|
||||
/** 덧붙임 바탕 · 덧붙임 아니면 null */
|
||||
percentBase: CostKind | "사람줄합" | null;
|
||||
/** 호표 「요소」 칸 값 그대로(인력 LB 키 · 재료 검색어 묶음 · 로직 부름 글) */
|
||||
element: unknown;
|
||||
/** 잠금 까닭 쉬운 말 · 아니면 null */
|
||||
lockedWhy: string | null;
|
||||
/** 원래 자리 · 새 카드 null */
|
||||
source: { part: "호표" | "덧줄"; index: number } | null;
|
||||
/** 원래 줄 통째 — 카드가 안 다룬 칸을 저장 때 그대로 살림 */
|
||||
raw: unknown;
|
||||
}
|
||||
|
||||
export interface EasyDoc {
|
||||
/** 새 로직 null */
|
||||
key: string | null;
|
||||
/** 판본(409 대조) */
|
||||
version: string | null;
|
||||
/** 품셈 기본 = 읽기만 */
|
||||
isBase: boolean;
|
||||
name: string;
|
||||
spec: string;
|
||||
/** 결과단위 「원/㎡」 */
|
||||
resultUnit: string;
|
||||
/** 설계 때 정하는 값 */
|
||||
inputs: LogicInput[];
|
||||
cards: EasyCard[];
|
||||
/** 원래 로직 줄(새 로직은 최소 칸 줄) */
|
||||
row: LogicRow;
|
||||
}
|
||||
|
||||
/** 물음 셋 고르기 결과 — Pick 이 가져다 씀 */
|
||||
export interface PickResult {
|
||||
kind: "person" | "material" | "machine" | "logic";
|
||||
name: string;
|
||||
spec: string;
|
||||
unit: string;
|
||||
element: unknown;
|
||||
qty: number | null;
|
||||
needInputs?: LogicInput[];
|
||||
}
|
||||
|
||||
const notReady = (): never => {
|
||||
throw new Error("준비 중");
|
||||
};
|
||||
|
||||
export function toDoc(
|
||||
_row: LogicRow,
|
||||
_meta: { key: string | null; version: string | null; isBase: boolean },
|
||||
): EasyDoc {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
export function toRow(_doc: EasyDoc): LogicRow {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
export function addCard(_doc: EasyDoc, _pick: PickResult): EasyDoc {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
export function updateCard(_doc: EasyDoc, _id: string, _patch: Partial<EasyCard>): EasyDoc {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
export function removeCard(_doc: EasyDoc, _id: string): EasyDoc {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
export function moveCard(_doc: EasyDoc, _id: string, _step: -1 | 1): EasyDoc {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
export function checkCard(_card: EasyCard, _doc: EasyDoc): string | null {
|
||||
return notReady();
|
||||
}
|
||||
|
||||
export class EasyHistory {
|
||||
push(_doc: EasyDoc): void {
|
||||
notReady();
|
||||
}
|
||||
undo(): EasyDoc | null {
|
||||
return notReady();
|
||||
}
|
||||
get canUndo(): boolean {
|
||||
return notReady();
|
||||
}
|
||||
get dirty(): boolean {
|
||||
return notReady();
|
||||
}
|
||||
markSaved(): void {
|
||||
notReady();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user