- 길: sangeun from-line · formula-check · copy · equation(셋) · block · labor copy · 프로젝트 양식 reset · apply · save-as · sources · drawing-import · drawing-fields · logic-lib machine-parts · logic-lib/auto - 본체: Calc.from_line · Formula.check_doc 외 셋 · Equation 읽기 · 미리 셈 · Equation_Full 파일 · Block 끊기 · 잇기 · 수식 탭 · Labor_Copy.preview · Router_Layers 가져오기 도우미 - 화면: Api_Fetch 래퍼 여덟 · sangeunFromLine - 시험: 죽은 길만 보던 796-2c · 796-2e 파일 지움 · 함수째 지움(715-3 · 733-2 · 792-1 · 796-2b · router_drawing · template_layers · structure_panel 글자 시험) · 살아 있는 결과는 [저장] 길로 고침(795-2 · 796-2b) · 813-2 = M01 parts.of_machine 바로 - 남김: Sangeun_Copy.preview(옛 엔진 셈 거울 — 걸음 2) · B07 이 쓰는 reset_project · B09 가 쓰는 _company_projects - 검증: /openapi.json 524 → 508(뜻한 16 만) · 빌더 --check 같음 · 핵심 시험 99 통과 · 관련 시험 687 통과 · typecheck 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.7 KiB
TypeScript
73 lines
2.7 KiB
TypeScript
/* =============================================================================
|
|
* M02_MasterTemplete_Sangeun_Cover.ts
|
|
* 단가산출(SK) 셈 길 부름 · 뺀 줄 띠(PLAN 717-2b · 717-3 · 724-1)
|
|
* · 셈 = `calcSangeun`(`POST /layers/{층}/sangeun/calc` · 저장 안 함 · 부르는 쪽이 최신 응답만 받음)
|
|
* · 고침 표는 공용 상세(`M01_MasterData_UI_LogicLab_Ho` · 724-1) — 여기는 뺀 줄 되살림 띠만
|
|
* ========================================================================== */
|
|
|
|
import { createBadge } from "@ui/ui_template_badge";
|
|
import { createButton } from "@ui/ui_template_button";
|
|
import { el } from "@ui/ui_template_elements";
|
|
import { t as L } from "@ui/ui_template_locale";
|
|
import { createText } from "@ui/ui_template_text";
|
|
import { call, type Layer } from "./M02_MasterTemplete_Api_Fetch";
|
|
import type { SkAnswer } from "./logic/M02_Sangeun_Cover_Model";
|
|
import "./M02_MasterTemplete_Sangeun.css";
|
|
|
|
export interface SkScope {
|
|
layer: Layer;
|
|
owner: string | null;
|
|
}
|
|
const q = (scope: SkScope): string =>
|
|
scope.owner && scope.layer !== "system" ? `?owner=${encodeURIComponent(scope.owner)}` : "";
|
|
|
|
/** 셈(저장 안 함) — 문서 = 화면 문서 · `given` = 시험 입력(빈 칸 뺌) · 서버가 M01 엔진 한 벌로 셈 */
|
|
export function calcSangeun<T = SkAnswer>(
|
|
scope: SkScope,
|
|
doc: Record<string, unknown>,
|
|
given: Record<string, string> = {},
|
|
seen = true,
|
|
): Promise<T> {
|
|
const 입력값 = Object.fromEntries(Object.entries(given).filter(([, v]) => String(v).trim()));
|
|
return call<T>(`/layers/${scope.layer}/sangeun/calc${q(scope)}`, {
|
|
method: "POST",
|
|
body: JSON.stringify({ 문서: doc, 입력값, 보기: seen }), // 보기 false = 글 · 중간 덧칸 안 지음(바탕 원값 셈)
|
|
});
|
|
}
|
|
|
|
/** 뺀 줄(cid · 이름) 띠 — 고칠 수 있으면 [되살림] */
|
|
export function removedStrip(
|
|
removed: { cid: string; 이름: string }[],
|
|
edit: boolean,
|
|
onRestore: (cid: string) => void,
|
|
): HTMLElement[] {
|
|
if (!removed.length) return [];
|
|
return [
|
|
el("div", {
|
|
className: "m02-sk__removed",
|
|
attrs: { "data-removed": "" },
|
|
children: [
|
|
createText(L("M02_SangeunRemoved")),
|
|
...removed.map((x) =>
|
|
el("span", {
|
|
className: "m02-sk__removed-item",
|
|
children: [
|
|
createBadge(x.이름, "neutral"),
|
|
...(edit
|
|
? [
|
|
createButton({
|
|
label: L("M02_SangeunRestore"),
|
|
variant: "ghost",
|
|
size: 22,
|
|
onClick: () => onRestore(x.cid),
|
|
}),
|
|
]
|
|
: []),
|
|
],
|
|
}),
|
|
),
|
|
],
|
|
}),
|
|
];
|
|
}
|