fix(m01-sl): 가져온 로직 장비 단가가 0 이던 흠 — 넘길 입력값을 계산값으로 · 바뀌면 바깥 값 다시 받음
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
This commit is contained in:
@@ -32,7 +32,8 @@ export const loadMods = () =>
|
||||
import("./M01_SL_Item"),
|
||||
import("./M01_SL_Result"),
|
||||
import("./M01_SL_Import"),
|
||||
]).then(([model, ev, api, diagram, panel, table, item, result, imp]) => ({
|
||||
import("../../A00_Common/spreadsheet/spreadsheet_recalc"),
|
||||
]).then(([model, ev, api, diagram, panel, table, item, result, imp, recalc]) => ({
|
||||
model,
|
||||
ev,
|
||||
api,
|
||||
@@ -42,6 +43,7 @@ export const loadMods = () =>
|
||||
item,
|
||||
result,
|
||||
imp,
|
||||
recalc,
|
||||
}));
|
||||
export type Mods = Awaited<ReturnType<typeof loadMods>>;
|
||||
|
||||
@@ -109,7 +111,8 @@ export function outsidePlaces(M: Mods, sl: SheetLogic): SlOutsideAt[] {
|
||||
if (node && c.source)
|
||||
put({ item: { id: c.id, ...c.source } as SlQuery, sheet: node.sheetId, cell: c.cell });
|
||||
}
|
||||
M.imp.outsideOf(sl).forEach(put);
|
||||
// 넘길 입력값이 수식 칸이면 계산값이 있어야 함(없으면 null 로 넘어가 단가가 0)
|
||||
M.imp.outsideOf(sl, M.recalc.recalcWorkbook(sl.workbook)).forEach(put);
|
||||
return [...at.values()];
|
||||
}
|
||||
|
||||
@@ -167,6 +170,29 @@ export function showPaper(
|
||||
let values: SlEvalResult;
|
||||
let busy = false;
|
||||
let notes = ctx.notes;
|
||||
/** 마지막으로 받은 바깥 값 물음 — 넘길 입력값이 바뀌면 다시 받음 */
|
||||
const sigOf = (x: SheetLogic): string =>
|
||||
JSON.stringify(outsidePlaces(M, x).map((p) => [p.sheet, p.cell, p.item]));
|
||||
let outsideSig = sigOf(first);
|
||||
let outsideTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
/** 바깥 값 다시 받기 — 같은 조작의 뒤끝이라 기록을 더 쌓지 않음 */
|
||||
const refreshOutside = (): void => {
|
||||
const sig = sigOf(sl);
|
||||
if (sig === outsideSig) return;
|
||||
outsideSig = sig;
|
||||
clearTimeout(outsideTimer);
|
||||
outsideTimer = setTimeout(() => {
|
||||
const from = sl;
|
||||
void fillOutside(M, from).then(({ sl: next, errors }) => {
|
||||
if (sl !== from) return; // 그 사이 또 바뀜 — 다음 그리기가 다시 받음
|
||||
if (savedSl === from) savedSl = next;
|
||||
sl = next;
|
||||
outsideSig = sigOf(next);
|
||||
notes = errors;
|
||||
redraw();
|
||||
});
|
||||
}, 300);
|
||||
};
|
||||
|
||||
const unsaved = createTag(tp("Unsaved"), "warning");
|
||||
const note = el("p", { className: "m01-sl__note", attrs: { role: "status" } });
|
||||
@@ -267,6 +293,7 @@ export function showPaper(
|
||||
|
||||
const redraw = (): void => {
|
||||
values = evalNow();
|
||||
refreshOutside();
|
||||
unsaved.hidden = sl === savedSl;
|
||||
undo.disabled = !stack.length;
|
||||
deleteButton.hidden = !sl.key;
|
||||
|
||||
Reference in New Issue
Block a user