fix(M01): 자동값 응답 키 값 · 표 알약 모달 참조.행 = 찾기 조건으로 줄 찾아 칠함

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EY2vdBQkHjdih9GgCsp9Fd
This commit is contained in:
2026-09-24 09:21:29 +09:00
co-authored by Claude Sonnet 5
parent 27cd10a904
commit bb4500b4c3
2 changed files with 19 additions and 5 deletions
@@ -57,21 +57,35 @@ export interface ModalTarget {
export interface TableTarget {
title: string;
table: string;
/** 찾은 줄 — 줄의 키·원문번호 글, 또는 줄 차례(0부터) */
row?: string | number | null;
/** 찾은 줄 — 찾기 조건(예 {구분: 합판}) · 줄의 키·원문번호 글 · 줄 차례(0부터) */
row?: Record<string, unknown> | string | number | null;
/** 찾은 값 칸 이름 */
col?: string | null;
}
const sameCond = (have: unknown, want: unknown, range: boolean): boolean => {
if (range && Array.isArray(have)) {
const n = Number(want);
const [low, high] = have as (number | null)[];
return (low == null || n >= low) && (high == null || n <= high);
}
return String(have) === String(want);
};
function tableView(table: TableRow, target: TableTarget): HTMLElement {
const lines = table. ?? [];
const at = target.row;
const kinds = table. ?? {};
const hit =
at === undefined || at === null
? null
: typeof at === "number"
? (lines[at] ?? null)
: (lines.find((line) => line["키"] === at || line["원문번호"] === at) ?? null);
: typeof at === "string"
? (lines.find((line) => line["키"] === at || line["원문번호"] === at) ?? null)
: (lines.find((line) =>
Object.entries(at).every(([c, want]) => sameCond(line[c], want, kinds[c] === "범위")),
) ?? null);
const cols = [...Object.keys(table. ?? {}), ...Object.keys(table. ?? {})];
const rows = lines.map((line) =>
el("tr", {
@@ -210,8 +210,8 @@ export const fetchMaterials = (cond: {
/** 자동값 길(`GET /logic/auto`) — 입력 이름 → 견본값 · 서버에 아직 없거나 값이 없으면 빈 채로(화면은 그냥 안 채움) */
export const fetchAuto = (key: string): Promise<Record<string, unknown>> =>
request<{ 입력?: Record<string, unknown> }>(`/logic/auto?${query({ key })}`)
.then((d) => d. ?? {})
request<{ ?: Record<string, unknown> }>(`/logic/auto?${query({ key })}`)
.then((d) => d. ?? {})
.catch(() => ({}));
export const runCalc = (body: {