feat(859-3): 보이는 수 자릿수 규칙 한 쌍 — 줄 쌓기 화면 · 서버 계산서 글(셈 · 금액 그대로)
- 규칙 한 벌 = common_util_show_digits.ts ↔ master_doc_digits.py(짝 · 거울 시험 test_859_3) 표 값 = 고른 줄의 원문 글자 자리(끝 0 살림 · 서버 표 캐시에 줄마다 `자리` 실음) · 식 값 = Q 3 · n 2 · cm 3(8-1 주①) › 원 단위 · 비목 이름 = 소수 한 자리 › 그 밖 유효숫자 3(소수 2~6) · 입력 · 요소 = 자료 그대로 · 만약으로 고른 기호 하나인 식은 그 값의 갈래를 따름 - 줄 쌓기 오른쪽(공식 줄 · 값 묶음 · 금액 줄 수량 · 단가 식 · 결과) · 왼쪽 값 · 작업량 줄 · M02 계산서 글 - test_845_2 기대 글 고침(노무비 계수 0.208333 → 0.208 — 뜻한 바뀜 · 금액 59,020.2 그대로) - 관련 시험 + 관문 256 통과 · typecheck 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
|
||||
import { createBadge } from "@ui/ui_template_badge";
|
||||
import { el } from "@ui/ui_template_elements";
|
||||
import { eqText } from "@ui/ui_template_equation";
|
||||
import { varId, type FormulaDoc, type Node } from "../common_util/common_util_formula_doc";
|
||||
import { showDigits, showValue } from "../common_util/common_util_show_digits";
|
||||
import {
|
||||
calcDoc,
|
||||
isNum,
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
restOfQty,
|
||||
workUnit,
|
||||
} from "../common_util/common_util_line_stack_work";
|
||||
import { katexNode, symTex, tex, txt, valTex } from "./line_stack_tex";
|
||||
import { katexNode, symTex, tex, txt } from "./line_stack_tex";
|
||||
import { lt, type LsKey } from "./line_stack_text";
|
||||
|
||||
export interface WorkRow {
|
||||
@@ -51,7 +51,15 @@ export function workTag(kind: string, title = ""): HTMLElement {
|
||||
const chain = (...xs: string[]): (string | HTMLElement)[] =>
|
||||
xs.flatMap((x, i) => (i ? [" = ", katexNode(x)] : [katexNode(x)]));
|
||||
const unitTex = (u: string): string => (u ? `\\ ${txt(u)}` : "");
|
||||
const amount = (v: unknown, u: string): string => `${valTex(v)}${unitTex(u)}`;
|
||||
/** 859-3 시간당 작업량 Q = 소수 3 자리(건설 8-1 [주]① 계산값의 맺음) */
|
||||
const workText = (v: unknown): string => showDigits(v, "식", "Q");
|
||||
const workAmount = (v: unknown, u: string): string =>
|
||||
`${workText(v).replace(/,/g, "{,}")}${unitTex(u)}`;
|
||||
/** 859-3 문서 값 글(보이는 자리 규칙 · TeX 쉼표) */
|
||||
const docShow =
|
||||
(doc: FormulaDoc, vals: Values) =>
|
||||
(id: string, v: unknown): string =>
|
||||
showValue(doc, id, v, vals).replace(/,/g, "{,}");
|
||||
|
||||
/** 작업량 틀 풀이 — 값 줄 + 결과 식 줄(없으면 빈 목록) */
|
||||
export function hourlyRows(
|
||||
@@ -64,13 +72,15 @@ export function hourlyRows(
|
||||
const vals = (a.값 ?? {}) as Values;
|
||||
const vars = new Map((tpl.변수 ?? []).map((v) => [varId(v), v]));
|
||||
const unit = (id: string): string => workUnit(shownUnitOf(vars.get(id), vals, look));
|
||||
const pack = parts.uses.map((id) =>
|
||||
katexNode(`${symTex(id)} = ${isNum(vals[id]) ? amount(vals[id], unit(id)) : txt("—")}`),
|
||||
const show = docShow(tpl, vals);
|
||||
const pack = parts.uses.map(
|
||||
(id) =>
|
||||
katexNode(`${symTex(id)} = ${isNum(vals[id]) ? `${show(id, vals[id])}${unitTex(unit(id))}` : txt("—")}`), // prettier-ignore
|
||||
);
|
||||
const res = vals[parts.id];
|
||||
const sym = tex(parts.node, { side: "sym", vals, frac: 1 });
|
||||
const val = tex(parts.node, { side: "val", vals, frac: 1 });
|
||||
const end = isNum(res) ? amount(res, workUnit(tpl.결과단위)) : txt("—");
|
||||
const val = tex(parts.node, { side: "val", vals, frac: 1, show });
|
||||
const end = isNum(res) ? workAmount(res, workUnit(tpl.결과단위)) : txt("—");
|
||||
return [
|
||||
...(pack.length ? [{ h: pack, cls: "packs" }] : []),
|
||||
{ h: chain(symTex(parts.id), sym, val, end), cls: "work" },
|
||||
@@ -99,14 +109,14 @@ export function workRows(w: WorkInfo, c: WorkCtx): WorkRow[] {
|
||||
c.miss();
|
||||
}
|
||||
const tag = workTag(w.꼴, tpl?.이름 ?? w.율);
|
||||
if (!tpl) return [{ h: [tag, `${head} = `, isNum(w.값) ? `${eqText(w.값)} ${u}`.trim() : lt("Work_Wait")] }]; // prettier-ignore
|
||||
if (!tpl) return [{ h: [tag, `${head} = `, isNum(w.값) ? `${workText(w.값)} ${u}`.trim() : lt("Work_Wait")] }]; // prettier-ignore
|
||||
const a = calcDoc(tpl, c.links!, w.변수 ?? {}, [], new Map(), {});
|
||||
const name = el("span", { className: "lstk-hint", text: tpl.이름 ?? w.율 });
|
||||
return [{ h: [tag, name] }, ...hourlyRows(tpl, a, c.look)];
|
||||
}
|
||||
if (!isNum(w.값)) return [];
|
||||
const tag = workTag(w.꼴 || "일당");
|
||||
const res = amount(w.값, u);
|
||||
const res = workAmount(w.값, u);
|
||||
const parts = w.꼴 === "일당" ? dailyParts(w.율) : null;
|
||||
if (parts) {
|
||||
const val = (n: Node): string => tex(n, { side: "val", vals: c.vals, inline: true });
|
||||
@@ -130,13 +140,14 @@ export function workQty(
|
||||
w: WorkInfo | null,
|
||||
scope: Values,
|
||||
alias?: Record<string, string>,
|
||||
show?: (id: string, v: unknown) => string,
|
||||
): HTMLElement[] | null {
|
||||
if (!w || !isNum(w.값) || w.값 <= 0) return null;
|
||||
const got = restOfQty(doc, qty);
|
||||
if (!got) return null;
|
||||
const by = katexNode(`{}\\div ${amount(w.값, workUnit(w.단위))}`); // {} = 두 항 사이 ÷ 간격
|
||||
const by = katexNode(`{}\\div ${workAmount(w.값, workUnit(w.단위))}`); // {} = 두 항 사이 ÷ 간격
|
||||
if (!got.rest) return [by];
|
||||
return [by, katexNode(`\\times ${tex(got.rest, { side: "val", vals: scope, inline: true, alias })}`)]; // prettier-ignore
|
||||
return [by, katexNode(`\\times ${tex(got.rest, { side: "val", vals: scope, inline: true, alias, show: show ?? docShow(doc, scope) })}`)]; // prettier-ignore
|
||||
}
|
||||
|
||||
const nameOf = (doc: FormulaDoc, id: string): string =>
|
||||
|
||||
Reference in New Issue
Block a user