feat(848-3): 제어 구역 층 색 · 「고침」 글 걷음 · 기계 한 줄 되돌림 · M01 기초 제어 구역 엶 · 기초 [초기화] · 알림 지킴 줄 [위 값으로]
- 셈 · 산출근거 · 제어 구역 = layeredCover(문서, 위덮음) · 기본 = upperOf · putCover(…, ①) · 칸 테두리 = sourcesOf(나 파랑 · 위 주황) - 작업량 묶음 = mergeWork(①, ②) · ① 과 다른 칸만(pruneWorkLayer) · 위 층 시간당이면 일당 = 내 고침 - 기계 줄 머리 = 이름 단추 테두리 + [원래 값](그 기계 고침 통째) · 기계 보기 저장 안 한 바뀜 = 파랑 - M01 단가산출 기초 = 시스템 관리자에게 제어 구역 엶 · 머리 [초기화] = 기계 고침 목록 확인 → 걷고 저장 - 갱신 알림 = 지킴 줄 따로 표(위 값 전 → 후 · 내 값 · [위 값으로] = 그 칸 고침 지움 → [저장]) · 다시복사 · 지워짐 = 지금 꼴 - 걷기 셈 = common_util_formula_doc_cover_drop.ts(dropCover · dropPath) · 시험 test_848_3_cover_drop Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,10 +11,12 @@
|
||||
* 읽기(M01 기초) = 칸 잠김 · 단추 없음
|
||||
* 기계 보기(840-2 `line_stack_machine_sheet` · M01 기계 상세 · 내 기계) = 같은 구역(인력 · 잡품 여러 줄 · 842-3) ·
|
||||
* `lock` = 잠긴 값 칸(품셈 방식 계수 등)
|
||||
* 층(848-3 · 요구 889) — SK = ① 위 층 고침(`upper` = 읽기 답 `위덮음`) 위에 ② 내 고침 · 기본(원래 값) = `upperOf(정본 기본, ①)` ·
|
||||
* 고침 = `putCover(…, ①)`(위 층과 같은 칸 지움) · 칸 테두리 = 출처(`sourcesOf` — 나 = 파랑 · 위 = 주황 · 부품 `setUiDiff`) ·
|
||||
* 「고침」 글 배지 없음(테두리로) · 칸 풍선 = 원래 값 · M01 기초(시스템 관리자) = ① 없음 → 기초 고침 = 「나」
|
||||
* ========================================================================== */
|
||||
|
||||
import { createBadge } from "@ui/ui_template_badge";
|
||||
import { createButton, createIconButton } from "@ui/ui_template_button";
|
||||
import { createButton, createIconButton, setUiDiff, type UiDiff } from "@ui/ui_template_button";
|
||||
import { eqText } from "@ui/ui_template_equation";
|
||||
import { el, showToast } from "@ui/ui_template_elements";
|
||||
import { createInputField, createSelectField } from "@ui/ui_template_input";
|
||||
@@ -24,13 +26,19 @@ import type { DocAnswer } from "../common_util/common_util_formula_doc_calc";
|
||||
import {
|
||||
coverOf,
|
||||
defaultsOf,
|
||||
layeredCover,
|
||||
machineKey,
|
||||
MINE,
|
||||
partsOf,
|
||||
putCover,
|
||||
rowEntry,
|
||||
sourcesOf,
|
||||
upperOf,
|
||||
type Cover,
|
||||
type CrewRow,
|
||||
type CoverEntry,
|
||||
type MiscRow,
|
||||
type Source,
|
||||
} from "../common_util/common_util_formula_doc_cover";
|
||||
import { subInputs, type StackDoc } from "../common_util/common_util_line_stack";
|
||||
import type { Picked } from "../common_util/common_util_line_stack_pick";
|
||||
@@ -59,6 +67,22 @@ export interface CtlHooks {
|
||||
lock?: string[];
|
||||
/** 846-2 그 기계 작업량 줄(기계 값 칸 `작업량`) */
|
||||
work?: (machine: string) => WorkSpec[];
|
||||
/** 848-3 ① 위 층 고침(SK 읽기 답 `위덮음` · M01 = 없음) */
|
||||
upper?: Cover | null;
|
||||
}
|
||||
|
||||
/** 출처 → 부품 「바뀜」 상태(848-3) */
|
||||
export const diffOf = (src: Source | undefined): UiDiff | null =>
|
||||
src === undefined ? null : src === MINE ? "mine" : "upper";
|
||||
|
||||
/** 칸 묶음 안 입력 · 고르기 · 이름 단추에 「바뀜」 상태 · 풍선(원래 값) */
|
||||
export function markDiff(box: HTMLElement, diff: UiDiff | null, was?: string): void {
|
||||
const nodes = box.matches(".ui-input, .ui-select, .ui-btn") ? [box] : [...box.querySelectorAll<HTMLElement>(".ui-input, .ui-select, .ui-btn.lstk-res")]; // prettier-ignore
|
||||
for (const n of nodes) {
|
||||
setUiDiff(n, diff);
|
||||
if (diff && was !== undefined)
|
||||
n.title = `${n.title ? `${n.title} — ` : ""}${lt("Ctl_Was")} ${was}`;
|
||||
}
|
||||
}
|
||||
|
||||
const FUELS = ["경유", "휘발유", "실내등유"];
|
||||
@@ -69,11 +93,13 @@ export function lineCall(
|
||||
answer: DocAnswer,
|
||||
link: Link | undefined,
|
||||
at?: number,
|
||||
upper?: Cover | null,
|
||||
): { given: Record<string, unknown>; key: string; work: string; want?: WorkCover } {
|
||||
const given = subInputs(link, (answer.값 ?? {}) as Record<string, unknown>);
|
||||
const w = at === undefined ? null : workAt(answer, at);
|
||||
const work = w ? workKey(coverOf(doc), w) : machineKey(given);
|
||||
const want = w ? (coverOf(doc)[work] as CoverEntry | undefined)?.[WORK] : undefined;
|
||||
const cover = layeredCover(doc, upper); // 848-3 ① 위에 ②(셈과 같은 덮음)
|
||||
const work = w ? workKey(cover, w) : machineKey(given);
|
||||
const want = w ? (cover[work] as CoverEntry | undefined)?.[WORK] : undefined;
|
||||
if (w?.고정) given.기계 = w.고정;
|
||||
return { given, key: (w?.고정 && want?.키) || String(link?.키 ?? ""), work, want };
|
||||
}
|
||||
@@ -81,14 +107,15 @@ export function lineCall(
|
||||
/** 그 기계 줄의 기계 열쇠 · 식 · 원본 기본값 — 기계 식이 아니면 null */
|
||||
export function ctlOf(h: CtlHooks, link: Link | undefined, at?: number) {
|
||||
if (link?.갈래 !== "단가산출" || !link.키) return null;
|
||||
const { given, key } = lineCall(h.doc, h.answer, link, at);
|
||||
const { given, key } = lineCall(h.doc, h.answer, link, at, h.upper);
|
||||
const machine = machineKey(given);
|
||||
const sub = h.subDoc(key);
|
||||
if (!machine || !sub) return null;
|
||||
const orig = h.calc(sub, given);
|
||||
const vals = (orig.값 ?? {}) as Record<string, unknown>;
|
||||
const base = defaultsOf(sub, vals, rowEntry(sub, h.lists?.(given) ?? null));
|
||||
return { machine, sub, vals, base, entry: coverOf(h.doc)[machine] };
|
||||
const up = (h.upper?.[machine] as CoverEntry | undefined) ?? null;
|
||||
return { machine, sub, vals, base, up, top: upperOf(base, up), entry: coverOf(h.doc)[machine] };
|
||||
}
|
||||
|
||||
const num = (t: string): number | null => {
|
||||
@@ -140,16 +167,17 @@ export function buildMachineCtl(
|
||||
): HTMLElement | null {
|
||||
const got = ctlOf(h, link, at);
|
||||
if (!got) return null;
|
||||
const { machine, sub, vals, base } = got;
|
||||
const { machine, sub, vals, base, up, top } = got;
|
||||
const entry: CoverEntry = got.entry ?? {};
|
||||
const src = sourcesOf(up, entry);
|
||||
const ro = h.readOnly;
|
||||
const put = (next: CoverEntry): void => h.change((d) => putCover(d, machine, next, base));
|
||||
const put = (next: CoverEntry): void => h.change((d) => putCover(d, machine, next, base, up));
|
||||
const parts = partsOf(sub);
|
||||
const lines = sub.금액 ?? [];
|
||||
|
||||
// ㉠ 값 칸
|
||||
const values = parts.fields.map(({ 칸: col }) => {
|
||||
const was = base.값[col];
|
||||
const was = top.값[col];
|
||||
const mine = entry.값?.[col];
|
||||
const now = mine ?? was;
|
||||
const shut = ro || !!h.lock?.includes(col);
|
||||
@@ -182,9 +210,6 @@ export function buildMachineCtl(
|
||||
],
|
||||
});
|
||||
if (mine !== undefined) {
|
||||
const tag = createBadge(lt("Ctl_Changed"), "info", { size: 18 });
|
||||
tag.title = `${lt("Ctl_Was")} ${was === undefined ? "—" : eqText(was)}`;
|
||||
row.append(tag);
|
||||
if (!shut)
|
||||
row.append(
|
||||
createButton({
|
||||
@@ -196,12 +221,13 @@ export function buildMachineCtl(
|
||||
}),
|
||||
);
|
||||
}
|
||||
markDiff(box, diffOf(src[`값.${col}`]), was === undefined ? "—" : eqText(was));
|
||||
row.dataset.mctlField = col;
|
||||
return row;
|
||||
});
|
||||
|
||||
// ㉡ 조종원 — 인력 줄
|
||||
const crew: CrewRow[] = entry.조종원 ?? base.조종원;
|
||||
const crew: CrewRow[] = entry.조종원 ?? top.조종원;
|
||||
const setCrew = (rows: CrewRow[]): void => put({ ...entry, 조종원: rows });
|
||||
const crewName = (r: CrewRow, i: number): string => {
|
||||
if (r.이름) return r.이름;
|
||||
@@ -223,7 +249,7 @@ export function buildMachineCtl(
|
||||
);
|
||||
|
||||
// ㉢ 잡품 — 재료 줄
|
||||
const misc: MiscRow[] = entry.잡품 ?? base.잡품;
|
||||
const misc: MiscRow[] = entry.잡품 ?? top.잡품;
|
||||
const setMisc = (rows: MiscRow[]): void => put({ ...entry, 잡품: rows });
|
||||
const baseQty = (r: MiscRow): number | null => {
|
||||
const b = lines.find((l) => String(l.이름 ?? "") === r.줄);
|
||||
@@ -274,12 +300,14 @@ export function buildMachineCtl(
|
||||
),
|
||||
);
|
||||
|
||||
// 인력 · 잡품 = 목록 통째 한 칸(848-1) — 묶음 안 칸 · 이름 단추 모두 그 출처
|
||||
for (const r of crewRows) markDiff(r, diffOf(src.조종원));
|
||||
for (const r of miscRows) markDiff(r, diffOf(src.잡품));
|
||||
const head = (label: string, covered: boolean, add: (() => void) | null, reset: () => void) =>
|
||||
el("div", {
|
||||
className: "lstk-fhead",
|
||||
children: [
|
||||
el("span", { className: "lstk-kind", text: label }),
|
||||
...(covered ? [createBadge(lt("Ctl_Changed"), "info", { size: 18 })] : []),
|
||||
...(ro
|
||||
? []
|
||||
: [
|
||||
@@ -292,18 +320,20 @@ export function buildMachineCtl(
|
||||
});
|
||||
// ㉣ 시간당 작업량(846-2) — 덮음 열쇠 = 줄 기계(굳은 기계면 값 칸 열쇠와 다름 · 847-1)
|
||||
const info = (at === undefined ? null : workAt(h.answer, at)) ?? workOfMachine(h.answer, machine);
|
||||
const wkey = info ? workKey(coverOf(h.doc), info) : machine;
|
||||
const wkey = info ? workKey(layeredCover(h.doc, h.upper), info) : machine;
|
||||
const upWork = (h.upper?.[wkey] as CoverEntry | undefined)?.작업량 ?? null;
|
||||
const work = info
|
||||
? buildWorkGroup({
|
||||
doc: h.doc,
|
||||
info,
|
||||
kind: info.꼴 === "시간당" ? (sites(h.doc, h.doc.금액?.[at ?? -1]?.수량)[0]?.꼴 ?? "일당") : info.꼴, // prettier-ignore
|
||||
entry: (coverOf(h.doc)[wkey] as CoverEntry | undefined)?.작업량,
|
||||
upper: upWork,
|
||||
specs: h.work?.(info.고정 ?? wkey) ?? [],
|
||||
subDoc: h.subDoc,
|
||||
vals: (h.answer.값 ?? {}) as Record<string, unknown>,
|
||||
ro,
|
||||
put: (w) => h.change((d) => putWork(d, wkey, w)),
|
||||
put: (w, wb) => h.change((d) => putWork(d, wkey, w, upWork, wb)),
|
||||
})
|
||||
: [];
|
||||
const box = el("div", {
|
||||
|
||||
Reference in New Issue
Block a user