From f6c3e25c5d47aeaae4690769f1c2b99881d76f15 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Mon, 21 Sep 2026 23:16:40 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix(M01):=20=EC=9D=B4=EB=A6=84=20=EB=A7=9E?= =?UTF-8?q?=EC=B6=94=EA=B8=B0=20=E2=80=94=20=E3=80=8C=EC=9D=BC=EC=9C=84?= =?UTF-8?q?=EB=8C=80=EA=B0=80=20=EB=A1=9C=EC=A7=81=E3=80=8D=20=E2=86=92=20?= =?UTF-8?q?=E3=80=8C=EB=8B=A8=EA=B0=80=EC=82=B0=EC=B6=9C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=E3=80=8D=20=C2=B7=20=E3=80=8C=EC=9D=BC=EC=9C=84?= =?UTF-8?q?=EB=8C=80=EA=B0=80=20=ED=98=B8=ED=91=9C=E3=80=8D=20=E2=86=92=20?= =?UTF-8?q?=E3=80=8C=EB=8B=A8=EA=B0=80=EC=82=B0=EC=B6=9C=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=E3=80=8D=20(=ED=99=94=EB=A9=B4=20=EB=AC=B8=EA=B5=AC?= =?UTF-8?q?=EC=99=80=20=EC=A3=BC=EC=84=9D=EB=A7=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 키(GF·GC·GX) · 파일 이름 · 데이터 안의 말은 그대로 - _틀.md 의 같은 말도 바꿈 Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT --- M01_MasterData/M01_MasterData_UI_LogicLab.ts | 4 ++-- M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts | 2 +- M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts | 2 +- M01_MasterData/M01_MasterData_UI_Logic_Edit.ts | 2 +- M01_MasterData/M01_MasterData_UI_Logic_Page.ts | 4 ++-- M01_MasterData/M01_MasterData_UI_Logic_Style.css | 2 +- M01_MasterData/M01_MasterData_UI_Logic_Text.ts | 2 +- M01_MasterData/M01_MasterData_UI_Page.ts | 2 +- M01_MasterData/M01_MasterData_UI_Side.ts | 4 ++-- resources/master_data/_틀.md | 4 ++-- ui_template/ui_template_locale_m1.ts | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab.ts b/M01_MasterData/M01_MasterData_UI_LogicLab.ts index 4894effa..dcccdb38 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab.ts @@ -1,7 +1,7 @@ /* ============================================================================= * M01_MasterData_UI_LogicLab.ts - * 관리자 화면 — 로직 칸. 가운데 일위대가표(호표) 고치기 / 오른쪽 시험 계산 - * 로직 목록(원문·장 고르기 · 찾기 · 막힘 거름)은 왼쪽 패널 「일위대가 로직」 컨테이너(`listHost`) 안 + * 관리자 화면 — 로직 칸. 가운데 단가산출 상세(호표) 고치기 / 오른쪽 시험 계산 + * 로직 목록(원문·장 고르기 · 찾기 · 막힘 거름)은 왼쪽 패널 「단가산출 로직」 컨테이너(`listHost`) 안 * * 데이터 흐름(CLAUDE.md 5장) — 고친 것은 캐시(sessionStorage)에 쌓고 [저장] 한 번에 `POST /save`. * 409 = 그 사이 파일이 바뀜 · 422 = 검사 걸림(아무것도 안 씀) — 까닭은 서버 글 그대로 보임. diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts b/M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts index e6db241e..037450ae 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts @@ -1,7 +1,7 @@ /* ============================================================================= * M01_MasterData_UI_LogicLab_Detail.ts * 「로직 개선 시험」 상세 화면 — 컨테이너 넷을 위에서 아래로 - * ① 기본정보(정본은 읽기 전용 · 비고만 고침) ② 일위대가 호표(인력·자재·경비·그 밖 묶음 + 소계) + * ① 기본정보(정본은 읽기 전용 · 비고만 고침) ② 단가산출 상세(인력·자재·경비·그 밖 묶음 + 소계) * ③ 텍스트 수식(자리 — `_LogicLab_Formula.ts`) ④ 시험 계산(입력값 + 결과값 — `Logic_Calc` 그대로) * 호표 줄을 누르면 그 줄이 쓰는 자료 모달(`_LogicLab_Modal.ts`) * ========================================================================== */ diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts b/M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts index c73c5063..7218d2c3 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts @@ -20,7 +20,7 @@ const TEXT = { "Edit (lines · middles · extras · rounding)", ], Ho_Fold: ["묶음 소계 표 (읽기용 — 고치기는 위 편집기)", "Group subtotals (read-only)"], - Ho_Title: ["일위대가 호표", "Unit-cost table"], + Ho_Title: ["단가산출 상세", "Unit-price detail"], Formula_Title: ["텍스트 수식", "Text formula"], Formula_Slot: ["시험 계산을 누르면 식이 글로 나옴", "Run the trial calc to see the formula"], Calc_Title: ["시험 계산", "Trial calculation"], diff --git a/M01_MasterData/M01_MasterData_UI_Logic_Edit.ts b/M01_MasterData/M01_MasterData_UI_Logic_Edit.ts index 9a19ce1d..f39ddf08 100644 --- a/M01_MasterData/M01_MasterData_UI_Logic_Edit.ts +++ b/M01_MasterData/M01_MasterData_UI_Logic_Edit.ts @@ -1,6 +1,6 @@ /* ============================================================================= * M01_MasterData_UI_Logic_Edit.ts - * 로직 한 줄 고치기 — 실무 일위대가표(호표) 모양 + * 로직 한 줄 고치기 — 실무 단가산출 상세(호표) 모양 * 머리(이름·결과단위·출처·소유) · 설계에서 받을 값 · 호표 줄 · 중간 값 · 결과 식 · 덧줄 · 끝수 * * 칸을 고치면 `row` 를 그 자리에서 바꾸고 `onChange` 만 부름(다시 그리지 않음). diff --git a/M01_MasterData/M01_MasterData_UI_Logic_Page.ts b/M01_MasterData/M01_MasterData_UI_Logic_Page.ts index 36fd199d..21f961e0 100644 --- a/M01_MasterData/M01_MasterData_UI_Logic_Page.ts +++ b/M01_MasterData/M01_MasterData_UI_Logic_Page.ts @@ -1,7 +1,7 @@ /* ============================================================================= * M01_MasterData_UI_Logic_Page.ts - * 관리자 화면 — 로직 칸. 가운데 일위대가표(호표) 고치기 / 오른쪽 시험 계산 - * 로직 목록(원문·장 고르기 · 찾기 · 막힘 거름)은 왼쪽 패널 「일위대가 로직」 컨테이너(`listHost`) 안 + * 관리자 화면 — 로직 칸. 가운데 단가산출 상세(호표) 고치기 / 오른쪽 시험 계산 + * 로직 목록(원문·장 고르기 · 찾기 · 막힘 거름)은 왼쪽 패널 「단가산출 로직」 컨테이너(`listHost`) 안 * * 데이터 흐름(CLAUDE.md 5장) — 고친 것은 캐시(sessionStorage)에 쌓고 [저장] 한 번에 `POST /save`. * 409 = 그 사이 파일이 바뀜 · 422 = 검사 걸림(아무것도 안 씀) — 까닭은 서버 글 그대로 보임. diff --git a/M01_MasterData/M01_MasterData_UI_Logic_Style.css b/M01_MasterData/M01_MasterData_UI_Logic_Style.css index 296aee62..7ed2e74d 100644 --- a/M01_MasterData/M01_MasterData_UI_Logic_Style.css +++ b/M01_MasterData/M01_MasterData_UI_Logic_Style.css @@ -1,4 +1,4 @@ -/* M01 로직 칸 — 가운데 로직 목록 · 일위대가표 / 오른쪽 시험 계산 (거름은 왼쪽 패널) */ +/* M01 로직 칸 — 가운데 로직 목록 · 단가산출 상세 / 오른쪽 시험 계산 (거름은 왼쪽 패널) */ .m01-logic [hidden] { display: none !important; } diff --git a/M01_MasterData/M01_MasterData_UI_Logic_Text.ts b/M01_MasterData/M01_MasterData_UI_Logic_Text.ts index 3c6cba36..2aa6ae68 100644 --- a/M01_MasterData/M01_MasterData_UI_Logic_Text.ts +++ b/M01_MasterData/M01_MasterData_UI_Logic_Text.ts @@ -6,7 +6,7 @@ import { currentLanguageIndex } from "@ui/ui_template_locale"; const TEXT = { - Title: ["일위대가 로직", "Unit-cost logic"], + Title: ["단가산출 로직", "Unit-price logic"], List_Search: ["이름 찾기", "Search name"], List_AllBooks: ["원문 모두", "All sources"], List_AllChapters: ["장 모두", "All chapters"], diff --git a/M01_MasterData/M01_MasterData_UI_Page.ts b/M01_MasterData/M01_MasterData_UI_Page.ts index ef5c116d..95579b46 100644 --- a/M01_MasterData/M01_MasterData_UI_Page.ts +++ b/M01_MasterData/M01_MasterData_UI_Page.ts @@ -1,6 +1,6 @@ /* ============================================================================= * M01_MasterData_UI_Page.ts - * 마스터 요소 화면 — 좌측 도킹 패널(컨테이너: 인력·재료·기계·소요량·계수·환율·요율·일위대가 로직·로직 테스트) + * 마스터 요소 화면 — 좌측 도킹 패널(컨테이너: 인력·재료·기계·소요량·계수·환율·요율·단가산출 로직·로직 테스트) * / 우측 요소 표 · 표 목록 · 로직 편집 * * 시스템 관리자만. 고친 것은 초안(sessionStorage)에 쌓이고 [저장] 한 번에 서버로 — diff --git a/M01_MasterData/M01_MasterData_UI_Side.ts b/M01_MasterData/M01_MasterData_UI_Side.ts index 7567367b..bbd4269c 100644 --- a/M01_MasterData/M01_MasterData_UI_Side.ts +++ b/M01_MasterData/M01_MasterData_UI_Side.ts @@ -1,7 +1,7 @@ /* ============================================================================= * M01_MasterData_UI_Side.ts * 왼쪽 패널 — 공용 접기 컨테이너(`ui-collapsible ui-sidebar-section`) 여덟 개 - * 인력 · 재료 · 기계 · 소요량 · 계수 · 환율 · 요율 · 일위대가 로직 + * 인력 · 재료 · 기계 · 소요량 · 계수 · 환율 · 요율 · 단가산출 로직 * 펼치면 하위 목록(거름 · 파일) · 환율/요율은 누르면 바로 표 · 로직은 안에 로직 목록 * ========================================================================== */ @@ -73,7 +73,7 @@ export interface Pick { export interface SideHandle { root: HTMLElement; - /** 일위대가 로직 컨테이너 안(로직 목록이 들어갈 자리) */ + /** 단가산출 로직 컨테이너 안(로직 목록이 들어갈 자리) */ logicHost: HTMLElement; /** 「로직 개선 시험」 컨테이너 안 */ labHost: HTMLElement; diff --git a/resources/master_data/_틀.md b/resources/master_data/_틀.md index 20d0f130..0e5dcecc 100644 --- a/resources/master_data/_틀.md +++ b/resources/master_data/_틀.md @@ -5,7 +5,7 @@ ## 1. 용어 - **요소** = 원문에 적힌 이름·수 그대로. 계산하지 않음. -- **일위대가 로직** = 요소를 변수로 끌어와 조립한 단위당 계산법. 설계 값 자리는 비움. +- **단가산출 로직** = 요소를 변수로 끌어와 조립한 단위당 계산법. 설계 값 자리는 비움. - 다른 것을 끌어와 계산하면 로직(기계 시간당 경비 · 기계 작업량 식 포함). ## 2. 파일 @@ -200,7 +200,7 @@ } ``` -- `호표` 줄 = 실무 일위대가표 한 줄(종류 · 이름·규격 · 단위 · 수량 · 단가 · 금액). 단가는 적지 않음 — `요소` 에서 옴. 금액 = 수량 × 단가. +- `호표` 줄 = 실무 단가산출 상세 한 줄(종류 · 이름·규격 · 단위 · 수량 · 단가 · 금액). 단가는 적지 않음 — `요소` 에서 옴. 금액 = 수량 × 단가. - `종류` = 인력 · 재료 · 기계 · 로직(하위 로직의 결과를 단가로 씀) — 요소 키의 테이블ID 그룹과 같음. - `비목` = 노무비 · 재료비 · 경비. `덧줄` 식에서 비목 합을 이름으로 씀. - `결과단위` 가 돈이 아닌 로직(㎥/시간)은 `호표` 없이 `중간` + `결과` 식. diff --git a/ui_template/ui_template_locale_m1.ts b/ui_template/ui_template_locale_m1.ts index 3d0af7c7..5eaef3b9 100644 --- a/ui_template/ui_template_locale_m1.ts +++ b/ui_template/ui_template_locale_m1.ts @@ -71,6 +71,6 @@ export const ui_locales_m1 = { M01_GroupFactor: ["계수", "Factors"], M01_GroupExchange: ["환율", "Exchange rates"], M01_GroupRate: ["요율", "Rates"], - M01_GroupLogic: ["일위대가 로직", "Unit-cost logic"], - M01_GroupTest: ["일위대가 로직 테스트", "Logic test"], + M01_GroupLogic: ["단가산출 로직", "Unit-price logic"], + M01_GroupTest: ["단가산출 로직 테스트", "Logic test"], } as const; From 7009a94e7c21c266e893698d90b94fc15878104e Mon Sep 17 00:00:00 2001 From: umsangdon Date: Mon, 21 Sep 2026 23:18:46 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix(M01):=20=EB=A1=9C=EC=A7=81=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0=20=EC=8B=9C=ED=97=98=20=E2=80=94=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=20=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=20=EB=84=B7=EC=9D=98=20?= =?UTF-8?q?=EB=B0=94=EA=B9=A5=20=EA=B0=84=EA=B2=A9=20=C2=B7=20=EC=95=88?= =?UTF-8?q?=EC=AA=BD=20=EC=B9=B8=20=EA=B0=84=EA=B2=A9=20=C2=B7=20=EC=A0=9C?= =?UTF-8?q?=EB=AA=A9=20=ED=81=AC=EA=B8=B0=EB=A5=BC=20=ED=95=9C=20=EC=96=91?= =?UTF-8?q?=EC=8B=9D=EC=9C=BC=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 컨테이너 사이 12px · 안쪽 칸 사이 8px · 제목 16px 굵게(넓은 화면 · 340px 폭 모두 같은 규칙) Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT --- .../M01_MasterData_UI_LogicLab_Style.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab_Style.css b/M01_MasterData/M01_MasterData_UI_LogicLab_Style.css index 8a773818..4d973fd1 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab_Style.css +++ b/M01_MasterData/M01_MasterData_UI_LogicLab_Style.css @@ -5,6 +5,20 @@ border-radius: var(--radius-lg); } +/* 컨테이너 넷 한 양식 — 바깥 간격 · 안쪽 칸 사이 간격 · 제목 크기(폭이 좁아도 같은 규칙) */ +.m01lab__box + .m01lab__box { + margin-top: var(--spacing-12); +} + +.m01lab__box.m01-logic__section { + gap: var(--spacing-8); +} + +.m01lab__box > .m01-logic__section-head h3 { + font-size: var(--text-body); + font-weight: 600; +} + .m01lab__info { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); From 241926e79fdc29b2e21900aa248db51b0bf5ce75 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Mon, 21 Sep 2026 23:24:39 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat(M01):=20=EC=9D=BD=EB=8A=94=20=EC=8B=9D?= =?UTF-8?q?=20=EC=A4=84=EC=97=90=20=EB=B3=80=EC=88=98=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EA=BC=B4=EC=9D=84=20=EB=8D=94=ED=95=A8=20=E2=80=94=20?= =?UTF-8?q?=EB=91=90=20=EC=B9=B8=20=EC=A4=84=20=EB=A7=9E=EC=B6=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POST /text 가 줄마다 「이름글」(석공노임 * 메쌓기인력.석공 * (1 + 증가율 %) = 석공비)과 「글」(값 꼴)을 같이 주고 짝 번호를 붙임 — 두 꼴이 한 줄 안에 있어 개수·차례가 늘 같음. 표 찾기·로직 부르기는 3-4 별칭 규칙 그대로(답에 별칭 목록 포함) · 단가 자리는 노임·손료·단가 꼬리 · 만약()은 두 꼴 모두 걸린 쪽만. 계약 3장 갱신 · 로직 1,291개 전수 점검(짝 어긋남 0 · 함수 샘 0) · 시험 20 통과. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01JgUhN55Z3BCYhUJTjwTNfj --- resources/master_data/_화면_계약.md | 8 +- resources/master_data/scripts/master_copy.py | 19 ++- resources/master_data/scripts/master_text.py | 145 +++++++++++++++---- resources/tester/test_m01_text.py | 30 ++++ 4 files changed, 171 insertions(+), 31 deletions(-) diff --git a/resources/master_data/_화면_계약.md b/resources/master_data/_화면_계약.md index caedb89f..6ed8ec27 100644 --- a/resources/master_data/_화면_계약.md +++ b/resources/master_data/_화면_계약.md @@ -58,8 +58,14 @@ `POST /text` — 몸은 `/calc` 와 같고, 같은 계산을 **사람이 읽는 식 줄**로 돌려줌(화면은 받은 글을 그대로 찍음). -- 됨 — `{ok: true, groups: [{비목, 줄: [{이름, 글, 금액, 까닭?}], 소계, 끝수}], 계}` · 멈춤은 `/calc` 와 같은 `{ok: false, reason}`. +- 됨 — `{ok: true, groups: [{비목, 줄: [{이름, 글, 이름글, 짝, 금액, 까닭?}], 소계, 끝수}], 계, 별칭: […]}` · 멈춤은 `/calc` 와 같은 `{ok: false, reason}`. - `글` = 호표 줄은 「단가 \* 수량식 = 금액」 · 덧줄은 「식 = 금액」. 중간 값 · 요소 · `찾기()` · `로직()` · `만약()` 은 글자로 안 나오고 **그 자리에서 나온 수**로 · 「… / 100」 은 「… %」 로 · 수는 화면과 같은 자릿수(소수 넷째 자리까지 · 천 단위 쉼표). +- `이름글` = 같은 줄을 **변수 이름으로** 적은 것(「석공노임 \* 메쌓기인력.석공 \* (1 + 증가율 %) = 석공비」) — 화면 왼쪽 칸 · `글` 은 오른쪽 칸. + - 단가 자리 = 「요소 이름 + 노임(인력) · 손료(기계) · 단가(그 밖)」 · 비목이 나뉜 줄은 「이름 + 비목 + 단가」. + - 금액 자리 = 「이름 + 비」 · 비목이 나뉜 줄은 「이름 + 비목」 · 덧줄·결과는 그 줄 이름. + - 표 찾기 · 로직 부르기 = **별칭 이름**(7장 규칙 그대로 · 값 칸은 `.석공` 처럼 뒤에 붙음) · 중간 값 · 입력 · 비목 이름은 그대로 · `만약()` 은 두 꼴 모두 **걸린 쪽만** 적어 줄이 어긋나지 않음. +- `짝` = 1 부터 매긴 줄 번호(답 전체에서 하나씩 · 묶음을 가로질러 차례대로) — 두 칸을 줄 맞춰 놓고 한쪽을 누르면 다른 쪽을 밝히는 데 씀. 두 꼴은 한 줄 안에 나란히 오므로 **줄 수와 차례가 늘 같음**. +- `별칭` = `이름글` 에 쓰인 표·로직 이름 목록 — 7장 `별칭` 과 같은 모양(`{이름, 종류, 참조, 원문, 밑이름, 값칸, 결과단위, 자리}`). - `비목` = `노무비` · `재료비` · `경비`(돈 아닌 로직은 묶음 하나 `결과`) · 줄이 없는 비목은 빠짐 · `소계` 는 끝수까지 붙은 값이고 `끝수` 는 그 한 마디(「원 미만 버림」 · 없으면 "") — 끝수는 따로 줄로 안 보임. - 하위 로직 줄처럼 한 줄이 여러 비목에 걸리면 비목마다 한 줄씩 · 그 비목 몫으로 단가를 되계산해 적음. - `까닭` = 단가가 0 이거나 못 구한 줄의 한 마디(「수량 0 — 이 조건에서는 안 쓰는 줄」 · 「단가 0 — 「MP000082」 값이 아직 없음」). diff --git a/resources/master_data/scripts/master_copy.py b/resources/master_data/scripts/master_copy.py index f053181d..355164f4 100644 --- a/resources/master_data/scripts/master_copy.py +++ b/resources/master_data/scripts/master_copy.py @@ -93,10 +93,15 @@ def _taken(row: dict) -> set[str]: # ── 별칭 짓기 ───────────────────────────────────────────────────────── +def plain(text) -> str: + """이름에 쓸 수 있는 글자만 남김 — 별칭과 변수 이름이 같은 규칙을 씀.""" + return _DROP.sub("", str(text or "")) + + def _base(ref: str, master) -> str: """별칭 밑이름 — 표·로직의 `이름` 칸에서 · 비거나 너무 길면 키를 그대로 보임.""" try: - name = _DROP.sub("", str(master.get(ref).get("이름") or "")) + name = plain(master.get(ref).get("이름")) except mf.FormulaError: name = "" if not name or len(name) > MAX_NAME or name[0].isdigit(): @@ -170,6 +175,16 @@ def _about(kind: str, ref: str, master) -> dict: # ── 펴기 · 되돌리기 ──────────────────────────────────────────────────── +def names(marks: list[dict]) -> dict[str, str]: + """별칭 목록 → {원문 서명: 별칭 이름} — 식 글을 별칭으로 갈아 끼울 때 씀.""" + return {_SPACE.sub(" ", str(one["원문"])): str(one["이름"]) for one in marks} + + +def mask(text, name_of: dict[str, str]) -> str: + """부르기 한 덩이를 별칭 이름으로 — `spread` 와 같은 규칙(다른 모듈도 씀).""" + return _mask(str(text), name_of) + + def _mask(text: str, name_of: dict[str, str]) -> str: """부르기 한 덩이를 별칭 이름으로 — 뒤에서부터 갈아 끼움(자리가 밀리지 않게).""" out = text @@ -206,7 +221,7 @@ def _unmask(text: str, raw_of: dict[str, str]) -> str: def spread(master, row: dict) -> dict: """로직 한 줄 → 별칭 꼴 식 묶음. `로직` = 식만 별칭으로 바뀐 줄 통째 · `별칭` 에 원문.""" marks = aliases(row, master) - name_of = {_SPACE.sub(" ", one["원문"]): one["이름"] for one in marks} + name_of = names(marks) shown = copy.deepcopy(row) for _, _, _, col, box in slots(shown): box[col] = _mask(box[col], name_of) diff --git a/resources/master_data/scripts/master_text.py b/resources/master_data/scripts/master_text.py index 17cc4ddf..cfdf7203 100644 --- a/resources/master_data/scripts/master_text.py +++ b/resources/master_data/scripts/master_text.py @@ -1,18 +1,25 @@ # -*- coding: utf-8 -*- """사람이 읽는 식 줄 — 비목 묶음마다 「이름 : 단가 * 수량식 = 금액」 과 소계. -수는 화면과 같은 자릿수(소수 넷째 자리까지 · 천 단위 쉼표) · `찾기`·`로직`·중간 값·요소는 -글자로 내보내지 않고 그 자리에서 나온 수로 적음 · 끝수는 줄이 아니라 소계에 녹여 적음. -계산 자체는 `master_formula.run` 이 한 벌만 함 — 이 글은 그 결과를 되읽어 적음. +줄마다 글 두 꼴 — + · `글` 값 꼴: 수는 화면과 같은 자릿수(소수 넷째 자리까지 · 천 단위 쉼표) · `찾기`·`로직`· + 중간 값·요소는 글자로 내보내지 않고 그 자리에서 나온 수로 적음 + · `이름글` 이름 꼴: 「석공노임 * 메쌓기인력.석공 * (1 + 증가율) = 석공비」 — 표 찾기·로직 + 부르기는 별칭 이름(`master_copy` 3-4 규칙) · 중간 값·입력은 그 이름 그대로 +두 꼴은 같은 줄에 나란히 있고 `짝` 번호가 붙음 — 화면 두 칸이 줄 맞춤으로 놓임. +끝수는 줄이 아니라 소계에 녹여 적음. 계산 자체는 `master_formula.run` 이 한 벌만 함. """ from __future__ import annotations from decimal import Decimal +import master_copy as mc import master_formula as mf PLACES = Decimal("0.0001") # 화면 `formatNumber` 와 같음(소수 넷째 자리까지) +PRICE_TAIL = {"인력": "노임", "기계": "손료"} # 단가 자리의 이름 꼬리(그 밖은 「단가」) +ELEM_TAIL = {"LB": "노임", "EQ": "손료"} # 식 안 요소 키의 이름 꼬리(그 밖은 「단가」) _PREC = {"또는": 1, "그리고": 2, "==": 3, "!=": 3, "<": 3, "<=": 3, ">": 3, ">=": 3} _PREC |= {"+": 4, "-": 4, "*": 5, "/": 5} _RIGHT_TIGHT = ("-", "/") # 오른쪽 짝은 같은 세기라도 괄호가 필요함 @@ -30,22 +37,60 @@ def fmt(value) -> str: return sign + f"{int(whole):,}" + (f".{rest}" if rest else "") -# ── 식을 수로 풀어 글로 ──────────────────────────────────────────────── +# ── 식을 글로 — 값 꼴과 이름 꼴 ──────────────────────────────────────── def render(node, env: dict, master, depth: int = 0) -> str: - """식 한 마디 → 글. 값이 정해지는 마디(요소 · 찾기 · 로직 · 이름)는 그 수로 바뀜.""" - kind = node[0] + """식 한 마디 → 값 꼴 글. 값이 정해지는 마디(요소 · 찾기 · 로직 · 이름)는 그 수로 바뀜.""" + return _draw(node, node, env, master, depth) + + +def _draw(show, real, env: dict, master, depth: int) -> str: + kind = show[0] if kind == "num": - return fmt(node[1]) + return fmt(show[1]) if kind == "str": - return f"'{node[1]}'" + return f"'{show[1]}'" if kind == "neg": - return "-" + render(node[1], env, master, depth) + return "-" + _draw(show[1], real[1], env, master, depth) if kind == "bin": - return _bin(node, env, master, depth) - if kind == "call" and node[1] == "만약": # 걸린 쪽만 적음 - test = mf.evaluate(node[2][0], env, master, depth) - return render(node[2][1] if test else node[2][2], env, master, depth) - return _value(node, env, master, depth) + return _bin(show, real, env, master, depth, _draw) + if kind == "call" and show[1] == "만약": # 걸린 쪽만 적음 + at = 1 if mf.evaluate(real[2][0], env, master, depth) else 2 + return _draw(show[2][at], real[2][at], env, master, depth) + return _value(real, env, master, depth) + + +def named(show, real, env: dict, master, depth: int = 0) -> str: + """식 한 마디 → 이름 꼴 글. `show` = 부르기를 별칭으로 갈아 끼운 나무 · `real` = 원래 나무. + 이름·중간 값은 그대로 · 표 찾기·로직 부르기는 별칭 이름 · 요소는 그 이름.""" + kind = show[0] + if kind == "name": + return show[1] + if kind == "ref": + return _elem_name(master, show[1]) + if kind == "field": + return f"{named(show[1], real[1], env, master, depth)}.{show[2]}" + if kind == "neg": + return "-" + named(show[1], real[1], env, master, depth) + if kind == "bin": + return _bin(show, real, env, master, depth, named) + if kind == "call": + if show[1] == "만약": # 값 꼴과 같은 쪽만 적어 두 칸이 짝이 되게 + at = 1 if mf.evaluate(real[2][0], env, master, depth) else 2 + return named(show[2][at], real[2][at], env, master, depth) + args = ", ".join(named(s, r, env, master, depth) for s, r in zip(show[2], real[2])) + return f"{show[1]}({args})" + if kind in ("num", "str"): + return _draw(show, real, env, master, depth) + return _value(real, env, master, depth) # 별칭이 안 붙은 부르기 — 값으로 + + +def _elem_name(master, ref: str) -> str: + """식 안 요소 한 줄의 이름 — 「석공노임」 꼴(같은 이름의 중간 값과 헷갈리지 않게).""" + try: + name = mc.plain(master.get(ref).get("이름")) + except mf.FormulaError: + name = "" + return f"{name}{ELEM_TAIL.get(str(ref)[:2], '단가')}" if name else ref def _value(node, env: dict, master, depth: int) -> str: @@ -55,21 +100,21 @@ def _value(node, env: dict, master, depth: int) -> str: return fmt(value) -def _bin(node, env: dict, master, depth: int) -> str: - _, op, left, right = node +def _bin(show, real, env: dict, master, depth: int, draw) -> str: + _, op, left, right = show if op == "/" and right[0] == "num" and right[1] == 100: # 「… / 100」 은 퍼센트로 - return f"{_side(left, node, env, master, depth, False)} %" + return f"{_side(left, real[2], show, env, master, depth, draw, False)} %" return ( - f"{_side(left, node, env, master, depth, False)} {op} " - f"{_side(right, node, env, master, depth, True)}" + f"{_side(left, real[2], show, env, master, depth, draw, False)} {op} " + f"{_side(right, real[3], show, env, master, depth, draw, True)}" ) -def _side(child, parent, env: dict, master, depth: int, right: bool) -> str: - text = render(child, env, master, depth) - if child[0] != "bin": +def _side(show, real, parent, env: dict, master, depth: int, draw, right: bool) -> str: + text = draw(show, real, env, master, depth) + if show[0] != "bin": return text - mine, up = _PREC[child[1]], _PREC[parent[1]] + mine, up = _PREC[show[1]], _PREC[parent[1]] if mine < up or (mine == up and right and parent[1] in _RIGHT_TIGHT): return f"({text})" return text @@ -118,26 +163,58 @@ def _line_text(item: dict, line: dict, env: dict, master, part: str | None) -> s return f"{fmt(price)} * {qty} = {fmt(money)}" +def _line_names(item: dict, line: dict, env: dict, master, part: str | None, name_of: dict) -> str: + """같은 줄을 변수 이름으로 — 「석공노임 * 메쌓기인력.석공 * (1 + 증가율) = 석공비」.""" + name = mc.plain(item.get("이름") or line.get("이름")) or "값" + tail = PRICE_TAIL.get(str(item.get("종류") or ""), "단가") + price = f"{name}{part or ''}{tail}" + money = f"{name}{part}" if part else f"{name}비" + return f"{price} * {_names(item['수량'], env, master, name_of)} = {money}" + + def _extra_text(extra: dict, line: dict, env: dict, master) -> str: return f"{render(mf.parse(extra['식']), env, master)} = {fmt(line['금액'])}" +def _extra_names(extra: dict, env: dict, master, name_of: dict) -> str: + got = mc.plain(extra.get("이름")) or "덧줄" + return f"{_names(extra['식'], env, master, name_of)} = {got}" + + +def _names(text, env: dict, master, name_of: dict) -> str: + """식 글 한 줄을 이름 꼴로 — 별칭을 씌운 나무와 원래 나무를 나란히 읽음.""" + real = mf.parse(text) + try: + show = mf.parse(mc.mask(text, name_of)) + except mf.FormulaError: # 별칭을 씌우면 못 읽는 글 — 값 꼴로 물러남 + show = real + return named(show, real, env, master) + + def lines(files: dict, key: str, given: dict) -> dict: """로직 한 줄의 읽는 식 — 비목 묶음마다 줄과 소계 · 돈 아닌 로직은 「결과」 묶음 하나.""" master = mf.Master(files) row = master.logic(key) result = mf.run(master, key, given) env = _env_of(master, row, given) + marks = mc.aliases(row, master) + name_of = mc.names(marks) if "결과" in row: text = f"{render(mf.parse(row['결과']['식']), env, master)} = {fmt(result['결과'])}" - one = {"이름": row.get("이름") or "", "글": text, "금액": result["결과"]} + got = mc.plain(row.get("이름")) or "결과" + one = { + "이름": row.get("이름") or "", + "글": text, + "이름글": f"{_names(row['결과']['식'], env, master, name_of)} = {got}", + "금액": result["결과"], + } group = { "비목": "결과", "줄": [one], "소계": result["결과"], "끝수": _cut_note(row, "결과"), } - return {"ok": True, "groups": [group], "계": result["결과"]} + return _paired({"ok": True, "groups": [group], "계": result["결과"], "별칭": marks}) made: dict[str, list] = {name: [] for name in mf.COST_ITEMS} shown = result["줄"] env["줄"] = {r["이름"]: r["금액"] for r in shown if r["이름"]} @@ -148,11 +225,12 @@ def lines(files: dict, key: str, given: dict) -> dict: one = { "이름": _label(item, line), "글": _line_text(item, line, env, master, split), + "이름글": _line_names(item, line, env, master, split, name_of), "금액": money, } why = _why(item, line) made[part].append({**one, "까닭": why} if why else one) - _extras(row, shown[len(items) :], made, env, master) + _extras(row, shown[len(items) :], made, env, master, name_of) groups = [ { "비목": name, @@ -163,10 +241,20 @@ def lines(files: dict, key: str, given: dict) -> dict: for name in mf.COST_ITEMS if made[name] ] - return {"ok": True, "groups": groups, "계": result["계"]} + return _paired({"ok": True, "groups": groups, "계": result["계"], "별칭": marks}) -def _extras(row: dict, shown: list, made: dict, env: dict, master) -> None: +def _paired(answer: dict) -> dict: + """줄마다 짝 번호 — 두 칸(이름 꼴 · 값 꼴)이 같은 차례로 놓이게 1 부터.""" + at = 0 + for group in answer["groups"]: + for one in group["줄"]: + at += 1 + one["짝"] = at + return answer + + +def _extras(row: dict, shown: list, made: dict, env: dict, master, name_of: dict) -> None: """덧줄 — 앞선 줄까지의 비목 합을 넣고 한 줄씩(식 안의 비목 이름은 그 수로 바뀜).""" sums = {name: sum((one["금액"] for one in made[name]), Decimal(0)) for name in mf.COST_ITEMS} for extra, line in zip(row.get("덧줄") or [], shown): @@ -174,6 +262,7 @@ def _extras(row: dict, shown: list, made: dict, env: dict, master) -> None: one = { "이름": extra["이름"], "글": _extra_text(extra, line, env, master), + "이름글": _extra_names(extra, env, master, name_of), "금액": line["금액"], } made[extra["비목"]].append(one) diff --git a/resources/tester/test_m01_text.py b/resources/tester/test_m01_text.py index eed49ada..22479b75 100644 --- a/resources/tester/test_m01_text.py +++ b/resources/tester/test_m01_text.py @@ -106,6 +106,36 @@ def test_몫이_모두_0인_장비_줄도_글에_남는다(client: TestClient) - assert Decimal(str(group["소계"])) == Decimal(str(calc["sums"][group["비목"]])) +def test_이름_꼴_식이_값_꼴과_짝이_된다(client: TestClient) -> None: + """왼쪽 칸(이름 꼴)과 오른쪽 칸(값 꼴)이 같은 개수·같은 차례 · 짝 번호는 1 부터.""" + for key in (STACK, PUMP, FORM): + got, _ = _both(client, key) + rows = _all_lines(got) + assert [one["짝"] for one in rows] == list(range(1, len(rows) + 1)) + for one in rows: + assert one["이름글"].count(" = ") == 1 + assert not any(x in one["이름글"] for x in ("찾기(", "로직(", "만약(")) + + +def test_이름_꼴_식은_요소_이름과_별칭으로_적힌다(client: TestClient) -> None: + """13-4-1 석공 줄 — 「석공노임 * 메쌓기인력.석공 * (1 + 증가율 %) = 석공비」.""" + got, _ = _both(client, STACK) + mason = _all_lines(got)[0] + table = next(one for one in got["별칭"] if one["참조"] == "QF000421") + assert mason["이름글"] == f"석공노임 * {table['이름']}.석공 * (1 + 증가율 %) = 석공비" + assert mason["글"].startswith("268,908 * ") # 같은 줄의 값 꼴 + pump, _ = _both(client, PUMP) + lines = _all_lines(pump) + split = [one for one in lines if one["이름"] == "콘크리트펌프차"] + assert [one["이름글"].split(" = ")[-1] for one in split] == [ + "콘크리트펌프차노무비", + "콘크리트펌프차재료비", + "콘크리트펌프차경비", + ] + extra = next(one for one in lines if one["이름"].startswith("공구손료")) + assert extra["이름글"] == "노무비 * 5 % = 공구손료및경장비" + + def test_멈추는_로직은_까닭_한_줄(client: TestClient) -> None: got = client.post("/api/m01/text", json={"key": STACK, "inputs": {}}).json() assert got["ok"] is False and "입력" in got["reason"] From ca5c2649e31149e87d9853028391c6608619a751 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Mon, 21 Sep 2026 23:27:47 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat(M01):=20=EC=9D=BC=EC=9C=84=EB=8C=80?= =?UTF-8?q?=EA=B0=80=20=EC=A1=B0=ED=95=A9=20=ED=99=94=EB=A9=B4=20=EB=BC=88?= =?UTF-8?q?=EB=8C=80=20=E2=80=94=20=EC=99=BC=EC=AA=BD=20=EC=BB=A8=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=84=88=20=C2=B7=20=EB=AA=A9=EB=A1=9D=20=C2=B7=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=C2=B7=20=EB=A1=9C=EC=A7=81=20=EB=8D=94?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=C2=B7=20=EB=AF=B8=EB=A6=AC=20=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 왼쪽 패널 「일위대가 조합」 컨테이너(단가산출 로직 아래) · 구분/상세구분 거름 · 새 조합 · 지우기 · 저장 - 상세: 이름·구분·단위·비고 + 담은 로직 표(올리기/내리기/빼기) · 로직 줄을 누르면 단가산출 로직 상세로 감 - 로직 더하기 창: 구분 → 상세구분 → 찾기로 하나씩 고름 - 미리 보기: 담은 로직별 입력값으로 계산해 노무비·재료비·경비 합계(보기만) - 서버 길(조합 목록·저장·지우기)은 아직 없어 Combo_Api 한 곳에 가정 이름으로 둠 Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT --- M01_MasterData/M01_MasterData_UI_Combo.ts | 314 ++++++++++++++++++ M01_MasterData/M01_MasterData_UI_Combo_Api.ts | 56 ++++ .../M01_MasterData_UI_Combo_Pick.ts | 116 +++++++ .../M01_MasterData_UI_Combo_Preview.ts | 148 +++++++++ .../M01_MasterData_UI_Combo_Text.ts | 67 ++++ M01_MasterData/M01_MasterData_UI_Page.ts | 28 +- M01_MasterData/M01_MasterData_UI_Side.ts | 21 +- 7 files changed, 742 insertions(+), 8 deletions(-) create mode 100644 M01_MasterData/M01_MasterData_UI_Combo.ts create mode 100644 M01_MasterData/M01_MasterData_UI_Combo_Api.ts create mode 100644 M01_MasterData/M01_MasterData_UI_Combo_Pick.ts create mode 100644 M01_MasterData/M01_MasterData_UI_Combo_Preview.ts create mode 100644 M01_MasterData/M01_MasterData_UI_Combo_Text.ts diff --git a/M01_MasterData/M01_MasterData_UI_Combo.ts b/M01_MasterData/M01_MasterData_UI_Combo.ts new file mode 100644 index 00000000..93e428dc --- /dev/null +++ b/M01_MasterData/M01_MasterData_UI_Combo.ts @@ -0,0 +1,314 @@ +/* ============================================================================= + * M01_MasterData_UI_Combo.ts + * 일위대가 조합 화면 — 왼쪽 컨테이너(구분 · 상세구분 거름) / 오른쪽 목록 · 상세 + * 상세 = 이름·구분·단위·비고 + 담은 로직 표(차례 · 키 · 이름 · 결과 단위 · 메모 · 순서) + 미리 보기 + * 저장·지우기는 서버 조합 마스터(`일위대가조합.json` · 키 UA) — 길은 `Combo_Api` 한 곳 + * ========================================================================== */ + +import { + createButton, + createInputField, + el, + showConfirmDialog, + showToast, +} from "@ui/ui_template_elements"; +import { fetchLogics, type LogicSummary } from "./M01_MasterData_UI_Logic_Api"; +import { + deleteCombo, + fetchCombo, + fetchCombos, + saveCombo, + type Combo, + type ComboSummary, +} from "./M01_MasterData_UI_Combo_Api"; +import { openLogicPicker } from "./M01_MasterData_UI_Combo_Pick"; +import { buildPreview } from "./M01_MasterData_UI_Combo_Preview"; +import { tc } from "./M01_MasterData_UI_Combo_Text"; +import type { SideHandle } from "./M01_MasterData_UI_Side"; +import "./M01_MasterData_UI_Logic_Style.css"; +import "./M01_MasterData_UI_LogicLab_Style.css"; + +const FILTER_ID = "조합|"; +const blankCombo = (): Combo => ({ + 키: "", + 이름: "", + 구분: "", + 상세구분: "", + 단위: "", + 비고: "", + 로직: [], +}); + +export interface ComboHandle { + /** 컨테이너를 펼칠 때 — 목록을 새로 받아 그림 */ + show: () => Promise; +} + +export function mountM01Combo( + host: HTMLElement, + side: SideHandle, + onOpenLogic: (key: string) => void, +): ComboHandle { + let items: ComboSummary[] = []; + let logics = new Map(); + let pick = { sub: "", detail: "" }; + const filterHost = el("div"); + side.comboHost.replaceChildren(filterHost); + const view = el("div", { className: "m01-logic__editor" }); + host.replaceChildren(view); + + const load = async (): Promise => { + try { + const [combos, all] = await Promise.all([fetchCombos(), fetchLogics()]); + items = combos; + logics = new Map(all.map((x) => [x.키, x])); + } catch (error) { + showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error"); + } + drawFilter(); + drawList(); + }; + + /* --- 왼쪽 거름 --- */ + const drawFilter = (): void => { + const subs = [...new Set(items.map((x) => x.구분).filter(Boolean))].map((name) => ({ + name, + book: null, + details: [...new Set(items.filter((x) => x.구분 === name).map((x) => x.상세구분))].filter( + Boolean, + ), + })); + filterHost.replaceChildren( + side.filter({ + id: FILTER_ID, + store: "m01.filter.조합", + subs, + total: items.length, + subLabel: tc("Sub"), + detailLabel: tc("Detail"), + onPick: (sub, detail) => { + pick = { sub, detail }; + drawList(); + }, + }), + ); + }; + + /* --- 목록 --- */ + const toolbar = (...more: HTMLElement[]): HTMLElement => + el("div", { + className: "m01-logic__section-head", + children: [ + createButton({ label: tc("New"), variant: "filled", onClick: () => draw(blankCombo()) }), + ...more, + ], + }); + + const drawList = (): void => { + const shown = items.filter( + (x) => (!pick.sub || x.구분 === pick.sub) && (!pick.detail || x.상세구분 === pick.detail), + ); + const heads = [ + tc("Head_Key"), + tc("Head_Name"), + tc("Sub"), + tc("Detail"), + tc("Head_Unit"), + tc("Head_Count"), + ]; + const rows = shown.map((x) => { + const tr = el("tr", { + className: "m01-master__table-row", + attrs: { "data-combo-key": x.키 }, + children: [x.키, x.이름, x.구분, x.상세구분, x.단위, String(x.로직수)].map((v) => + el("td", { text: v }), + ), + }); + tr.addEventListener("click", () => void open(x.키)); + return tr; + }); + view.replaceChildren( + toolbar(), + shown.length + ? el("div", { + className: "m01-master__grid-wrap", + children: [ + el("table", { + className: "m01-master__grid", + children: [ + el("thead", { + children: [el("tr", { children: heads.map((t) => el("th", { text: t })) })], + }), + el("tbody", { children: rows }), + ], + }), + ], + }) + : el("p", { className: "m01-logic__muted", text: tc("Empty") }), + ); + }; + + const open = async (key: string): Promise => { + try { + draw(await fetchCombo(key)); + } catch (error) { + showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error"); + } + }; + + /* --- 상세 --- */ + const draw = (combo: Combo): void => { + const field = (label: string, name: "이름" | "구분" | "상세구분" | "단위" | "비고") => { + const f = createInputField({ type: "text", label }); + f.input.value = combo[name]; + f.input.setAttribute("data-combo-field", name); + f.input.addEventListener("input", () => (combo[name] = f.input.value)); + return f.root; + }; + const preview = buildPreview(() => combo.로직); + const table = el("div"); + const drawTable = (): void => { + const move = (i: number, d: number): void => { + const j = i + d; + if (j < 0 || j >= combo.로직.length) return; + [combo.로직[i], combo.로직[j]] = [combo.로직[j], combo.로직[i]]; + drawTable(); + }; + const trs = combo.로직.map((row, i) => { + const info = logics.get(row.키); + const memo = createInputField({ type: "text" }); + memo.input.value = row.메모; + memo.input.addEventListener("input", () => (row.메모 = memo.input.value)); + const name = el("button", { + className: "ui-btn ui-btn--ghost", + text: info?.이름 ?? row.키, + attrs: { type: "button", title: tc("Open") }, + }); + name.addEventListener("click", () => onOpenLogic(row.키)); + const btns = el("div", { + className: "m01-logic__chips", + children: [ + createButton({ label: tc("Up"), variant: "ghost", onClick: () => move(i, -1) }), + createButton({ label: tc("Down"), variant: "ghost", onClick: () => move(i, 1) }), + createButton({ + label: tc("Remove"), + variant: "ghost", + onClick: () => { + combo.로직.splice(i, 1); + drawTable(); + }, + }), + ], + }); + return el("tr", { + attrs: { "data-combo-logic": row.키 }, + children: [ + el("td", { text: String(i + 1) }), + el("td", { text: row.키 }), + el("td", { children: [name] }), + el("td", { text: info?.결과단위 ?? "" }), + el("td", { children: [memo.root] }), + el("td", { children: [btns] }), + ], + }); + }); + const heads = [ + tc("Col_Order"), + tc("Col_Key"), + tc("Col_Name"), + tc("Col_Unit"), + tc("Col_Memo"), + tc("Col_Move"), + ]; + table.replaceChildren( + el("table", { + className: "m01-master__grid", + children: [ + el("thead", { + children: [el("tr", { children: heads.map((t) => el("th", { text: t })) })], + }), + el("tbody", { children: trs }), + ], + }), + ...(trs.length ? [] : [el("p", { className: "m01-logic__muted", text: tc("NoLogic") })]), + ); + void preview.redraw(); + }; + + const add = createButton({ + label: tc("AddLogic"), + variant: "filled", + onClick: () => + openLogicPicker((x) => { + if (!logics.has(x.키)) logics.set(x.키, x); + combo.로직.push({ 키: x.키, 메모: "", 입력: {} }); + drawTable(); + }), + }); + const save = createButton({ + label: tc("Save"), + variant: "filled", + onClick: async () => { + if (!combo.이름.trim()) return showToast(tc("NeedName"), "error"); + try { + const saved = await saveCombo(combo); + showToast(tc("Saved"), "success"); + await load(); + draw(saved); + } catch (error) { + showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error"); + } + }, + }); + const remove = createButton({ + label: tc("Delete"), + variant: "ghost", + onClick: async () => { + if (!combo.키 || !(await showConfirmDialog(tc("DeleteAsk")))) return; + try { + await deleteCombo(combo.키); + showToast(tc("Deleted"), "success"); + await load(); + } catch (error) { + showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error"); + } + }, + }); + const back = createButton({ label: "←", variant: "ghost", onClick: () => drawList() }); + view.replaceChildren( + el("div", { + className: "m01-logic__section-head", + children: [back, el("h3", { text: combo.키 || tc("New") }), remove, save], + }), + el("section", { + className: "m01lab__box m01-logic__section", + children: [ + el("div", { + className: "m01lab__info", + children: [ + field(tc("Head_Name"), "이름"), + field(tc("Sub"), "구분"), + field(tc("Detail"), "상세구분"), + field(tc("Head_Unit"), "단위"), + field(tc("Head_Note"), "비고"), + ], + }), + ], + }), + el("section", { + className: "m01lab__box m01-logic__section", + children: [ + el("div", { + className: "m01-logic__section-head", + children: [el("h3", { text: tc("Logics_Title") }), add], + }), + table, + ], + }), + preview.root, + ); + drawTable(); + }; + + return { show: load }; +} diff --git a/M01_MasterData/M01_MasterData_UI_Combo_Api.ts b/M01_MasterData/M01_MasterData_UI_Combo_Api.ts new file mode 100644 index 00000000..cb0518e5 --- /dev/null +++ b/M01_MasterData/M01_MasterData_UI_Combo_Api.ts @@ -0,0 +1,56 @@ +/* ============================================================================= + * M01_MasterData_UI_Combo_Api.ts + * 일위대가 조합 화면이 부르는 서버 길 — 조합 마스터 `일위대가조합.json`(키 UA) + * 길 이름은 계약(PLAN 4-2)이 오면 이 파일만 맞춤 · 미리 보기는 로직마다 `/calc` 를 불러 화면에서 합침 + * ========================================================================== */ + +import { API_BASE_URL } from "@config/config_frontend"; +import { ApiError } from "./M01_MasterData_UI_Logic_Api"; + +/** 조합에 담은 로직 한 줄 — 입력 = 그 로직을 셀 때 넣을 값 */ +export interface ComboLogic { + 키: string; + 메모: string; + 입력: Record; +} +export interface Combo { + 키: string; + 이름: string; + 구분: string; + 상세구분: string; + 단위: string; + 비고: string; + 로직: ComboLogic[]; +} +export interface ComboSummary { + 키: string; + 이름: string; + 구분: string; + 상세구분: string; + 단위: string; + 로직수: number; +} + +async function request(path: string, body?: unknown): Promise { + const response = await fetch(`${API_BASE_URL}/m01${path}`, { + method: body === undefined ? "GET" : "POST", + credentials: "include", + headers: { "Content-Type": "application/json" }, + body: body === undefined ? undefined : JSON.stringify(body), + }); + const data = (await response.json().catch(() => ({}))) as { detail?: unknown } & T; + if (!response.ok) throw new ApiError(response.status, data.detail ?? response.statusText); + return data; +} + +export const fetchCombos = (): Promise => + request<{ combos: ComboSummary[] }>("/combos").then((d) => d.combos); + +export const fetchCombo = (key: string): Promise => + request<{ combo: Combo }>(`/combo?key=${encodeURIComponent(key)}`).then((d) => d.combo); + +/** 키가 비면 새 조합 — 서버가 다음 번호(UA…)를 줌 */ +export const saveCombo = (combo: Combo): Promise => + request<{ combo: Combo }>("/combo/save", { combo }).then((d) => d.combo); + +export const deleteCombo = (key: string): Promise => request("/combo/delete", { key }); diff --git a/M01_MasterData/M01_MasterData_UI_Combo_Pick.ts b/M01_MasterData/M01_MasterData_UI_Combo_Pick.ts new file mode 100644 index 00000000..1cf268d1 --- /dev/null +++ b/M01_MasterData/M01_MasterData_UI_Combo_Pick.ts @@ -0,0 +1,116 @@ +/* ============================================================================= + * M01_MasterData_UI_Combo_Pick.ts + * [로직 더하기] 창 — 구분 → 상세구분 → 찾기로 사용자가 로직을 하나씩 고름(자동 추천 없음) + * ========================================================================== */ + +import { + createButton, + createInputField, + createSelectField, + el, + showToast, +} from "@ui/ui_template_elements"; +import { t as L } from "@ui/ui_template_locale"; +import { + fetchLogics, + fetchLogicSubs, + type LogicSummary, + type SubBrief, +} from "./M01_MasterData_UI_Logic_Api"; +import { tc } from "./M01_MasterData_UI_Combo_Text"; + +const opts = (values: string[]): { value: string; text: string }[] => + [L("M01_All"), ...values].map((v, i) => ({ value: i ? v : "", text: v })); + +export function openLogicPicker(done: (logic: LogicSummary) => void): void { + const subs: SubBrief[] = []; + let all: LogicSummary[] = []; + const sub = createSelectField({ options: opts([]), compact: true, label: tc("Sub") }); + const detail = createSelectField({ options: opts([]), compact: true, label: tc("Detail") }); + detail.select.disabled = true; + const searchField = createInputField({ type: "search", placeholder: tc("Pick_Search") }); + const list = el("div", { className: "m01-logic__pick-list" }); + const hint = el("p", { className: "m01-logic__muted", text: tc("Pick_Hint") }); + const close = (): void => backdrop.remove(); + + const find = (): void => { + const q = searchField.input.value.trim().toLowerCase(); + const found = all.filter( + (x) => + (!sub.select.value || x.구분 === sub.select.value) && + (!detail.select.value || x.상세구분 === detail.select.value) && + (!q || `${x.키} ${x.이름}`.toLowerCase().includes(q)), + ); + hint.textContent = found.length ? `${found.length} / ${all.length}` : tc("Pick_None"); + list.replaceChildren( + ...found.slice(0, 100).map((x) => { + const row = el("button", { + className: "m01-logic__pick-row m01-logic__pick-row--button", + attrs: { type: "button", "data-pick": x.키 }, + children: [ + el("div", { + className: "m01-logic__stack", + children: [ + el("strong", { text: x.이름 }), + el("span", { + className: "m01-logic__muted", + text: `${x.키} · ${x.구분} ${x.상세구분}`.trim(), + }), + ], + }), + el("span", { text: `${x.결과단위}${x.blocked ? ` · ${tc("Pick_Blocked")}` : ""}` }), + ], + }); + row.addEventListener("click", () => { + close(); + done(x); + }); + return row; + }), + ); + }; + sub.select.addEventListener("change", () => { + const d = subs.find((s) => s.name === sub.select.value)?.details ?? []; + detail.setOptions(opts(d), ""); + detail.select.disabled = d.length === 0; + }); + + const dialog = el("div", { + className: "m01-logic__pick", + attrs: { role: "dialog", "aria-label": tc("Pick_Title") }, + children: [ + el("div", { + className: "m01-logic__section-head", + children: [ + el("h3", { text: tc("Pick_Title") }), + createButton({ label: tc("Pick_Close"), variant: "ghost", onClick: close }), + ], + }), + el("div", { + className: "m01-logic__filters", + children: [ + sub.root, + detail.root, + searchField.root, + createButton({ label: tc("Pick_Find"), variant: "filled", onClick: find }), + ], + }), + hint, + list, + ], + }); + const backdrop = el("div", { className: "m01-logic__backdrop", children: [dialog] }); + backdrop.addEventListener("click", (ev) => ev.target === backdrop && close()); + backdrop.addEventListener("keydown", (ev) => ev.key === "Escape" && close()); + document.body.append(backdrop); + + void Promise.all([fetchLogicSubs(), fetchLogics()]) + .then(([s, l]) => { + subs.push(...s); + all = l; + sub.setOptions(opts(s.map((x) => x.name)), ""); + }) + .catch((error) => + showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error"), + ); +} diff --git a/M01_MasterData/M01_MasterData_UI_Combo_Preview.ts b/M01_MasterData/M01_MasterData_UI_Combo_Preview.ts new file mode 100644 index 00000000..99aa134f --- /dev/null +++ b/M01_MasterData/M01_MasterData_UI_Combo_Preview.ts @@ -0,0 +1,148 @@ +/* ============================================================================= + * M01_MasterData_UI_Combo_Preview.ts + * 조합 미리 보기 — 담은 로직 저마다 입력값으로 `/calc` 를 불러 노무비·재료비·경비로 갈라 합침(보기만 · 저장 없음) + * ========================================================================== */ + +import { createInputField, createSelectField, el } from "@ui/ui_template_elements"; +import { fetchLogic, runCalc, type LogicInput } from "./M01_MasterData_UI_Logic_Api"; +import type { ComboLogic } from "./M01_MasterData_UI_Combo_Api"; +import { tc, type ComboTextKey } from "./M01_MasterData_UI_Combo_Text"; + +const COSTS = ["노무비", "재료비", "경비"] as const; +type Costs = Record<(typeof COSTS)[number], number>; +const LABEL: Record<(typeof COSTS)[number], ComboTextKey> = { + 노무비: "Prev_Labor", + 재료비: "Prev_Material", + 경비: "Prev_Expense", +}; + +const num = (v: string): number | string => (v.trim() !== "" && !isNaN(Number(v)) ? Number(v) : v); +const fmt = (n: number): string => n.toLocaleString("ko-KR", { maximumFractionDigits: 4 }); +const total = (c: Costs): number => c.노무비 + c.재료비 + c.경비; +const blank = (): Costs => ({ 노무비: 0, 재료비: 0, 경비: 0 }); + +/** 로직 입력 정의 → 처음 값(고르기 첫째 · 범위 아래끝) */ +const initial = (i: LogicInput): string => String(i.고르기?.[0] ?? i.범위?.[0] ?? ""); + +/** 입력 칸 — 바꾸면 그 줄의 입력에 바로 적음(조합과 함께 저장됨) */ +function inputCell(input: LogicInput, row: ComboLogic): HTMLElement { + const value = row.입력[input.이름] ?? initial(input); + row.입력[input.이름] = value; + const choices = input.고르기?.map((v) => ({ value: String(v), text: String(v) })); + const field = choices + ? createSelectField({ options: choices, value, compact: true, label: input.이름 }) + : createInputField({ type: "text", label: input.이름 }); + const control = "select" in field ? field.select : field.input; + control.value = value; + control.setAttribute("data-input", `${row.키}|${input.이름}`); + control.addEventListener("input", () => (row.입력[input.이름] = control.value)); + control.addEventListener("change", () => (row.입력[input.이름] = control.value)); + return field.root; +} + +export interface PreviewHandle { + root: HTMLElement; + /** 담은 로직이 바뀐 뒤 입력 칸을 다시 그림 */ + redraw: () => Promise; +} + +export function buildPreview(rows: () => ComboLogic[]): PreviewHandle { + const inputs = el("div", { className: "m01-logic__stack" }); + const out = el("div", { attrs: { "data-combo": "preview" } }); + const rowOf = (cells: string[], note = "", bold = false): HTMLElement => + el("tr", { + className: bold ? "m01lab__subtotal" : "", + children: cells.map((t, i) => el("td", { text: i === 0 && note ? `${t} — ${note}` : t })), + }); + + const run = async (): Promise => { + out.replaceChildren(el("p", { className: "m01-logic__muted", text: "…" })); + const sum = blank(); + const trs: HTMLElement[] = []; + for (const row of rows()) { + const cost = blank(); + let name = row.키; + let note = ""; + try { + const one = await fetchLogic(row.키); + name = one.logic.이름; + const values: Record = {}; + for (const i of one.logic.입력) { + const raw = row.입력[i.이름] ?? initial(i); + if (raw.trim() === "") continue; // 빈 칸은 안 보냄(로직 화면과 같음) + values[i.이름] = i.고르기?.find((o) => String(o) === raw) ?? num(raw); + } + const got = await runCalc({ key: row.키, inputs: values }); + if (got.ok) { + for (const line of got.lines ?? []) for (const c of COSTS) cost[c] += line.비목?.[c] ?? 0; + } else note = `${tc("Prev_Fail")}: ${got.reason}`; + } catch (error) { + note = `${tc("Prev_Fail")}: ${error instanceof Error ? error.message : ""}`; + } + for (const c of COSTS) sum[c] += cost[c]; + trs.push( + rowOf([`${row.키} ${name}`, ...COSTS.map((c) => fmt(cost[c])), fmt(total(cost))], note), + ); + } + trs.push(rowOf([tc("Prev_Sum"), ...COSTS.map((c) => fmt(sum[c])), fmt(total(sum))], "", true)); + const heads = [tc("Prev_Row"), ...COSTS.map((c) => tc(LABEL[c])), tc("Prev_Sum")]; + out.replaceChildren( + el("table", { + className: "m01-master__grid", + children: [ + el("thead", { + children: [el("tr", { children: heads.map((t) => el("th", { text: t })) })], + }), + el("tbody", { children: trs }), + ], + }), + ); + }; + + const button = el("button", { + className: "ui-btn ui-btn--filled", + text: tc("Prev_Run"), + attrs: { type: "button", "data-combo": "run" }, + }); + button.addEventListener("click", () => void run()); + + const redraw = async (): Promise => { + const blocks: HTMLElement[] = []; + for (const row of rows()) { + try { + const one = await fetchLogic(row.키); + blocks.push( + el("div", { + className: "m01lab__info", + children: [ + el("strong", { + className: "m01lab__cell--wide", + text: `${row.키} ${one.logic.이름}`, + }), + ...one.logic.입력.map((i) => inputCell(i, row)), + ], + }), + ); + } catch { + /* 못 읽은 로직은 계산 때 까닭이 뜸 */ + } + } + inputs.replaceChildren(...blocks); + out.replaceChildren(el("p", { className: "m01-logic__muted", text: tc("Prev_Wait") })); + }; + + const root = el("section", { + className: "m01lab__box m01-logic__section", + children: [ + el("div", { + className: "m01-logic__section-head", + children: [el("h3", { text: tc("Prev_Title") })], + }), + el("h4", { text: tc("Prev_Inputs") }), + inputs, + button, + out, + ], + }); + return { root, redraw }; +} diff --git a/M01_MasterData/M01_MasterData_UI_Combo_Text.ts b/M01_MasterData/M01_MasterData_UI_Combo_Text.ts new file mode 100644 index 00000000..4d6bfad1 --- /dev/null +++ b/M01_MasterData/M01_MasterData_UI_Combo_Text.ts @@ -0,0 +1,67 @@ +/* ============================================================================= + * M01_MasterData_UI_Combo_Text.ts + * 일위대가 조합 화면 글자 — [한국어, 영어] + * ========================================================================== */ + +import { currentLanguageIndex } from "@ui/ui_template_locale"; + +const TEXT = { + Title: ["일위대가 조합", "Unit-price combination"], + Sub: ["구분", "Category"], + Detail: ["상세구분", "Detail"], + All: ["전체", "All"], + Empty: ["조합이 없음 — [새 조합]으로 만듦", "No combinations — press [New combination]"], + New: ["새 조합", "New combination"], + Delete: ["지우기", "Delete"], + Save: ["저장", "Save"], + DeleteAsk: ["이 조합을 지울까요?", "Delete this combination?"], + Saved: ["저장함", "Saved"], + Deleted: ["지움", "Deleted"], + NeedName: ["이름을 적어야 저장됨", "A name is required"], + Load_Failed: ["불러오지 못함", "Load failed"], + Head_Key: ["키", "Key"], + Head_Name: ["이름", "Name"], + Head_Unit: ["단위", "Unit"], + Head_Note: ["비고", "Note"], + Head_Count: ["로직 수", "Logics"], + Logics_Title: ["담은 로직", "Logics in it"], + Col_Order: ["차례", "No."], + Col_Key: ["로직 키", "Logic key"], + Col_Name: ["이름", "Name"], + Col_Unit: ["결과 단위", "Result unit"], + Col_Memo: ["메모", "Memo"], + Col_Move: ["순서", "Move"], + Up: ["올리기", "Up"], + Down: ["내리기", "Down"], + Remove: ["빼기", "Remove"], + AddLogic: ["로직 더하기", "Add logic"], + NoLogic: ["담은 로직 없음", "No logics yet"], + Open: ["열기", "Open"], + Pick_Title: ["로직 고르기", "Pick a logic"], + Pick_Search: ["이름·키로 찾기", "Search by name or key"], + Pick_Find: ["찾기", "Find"], + Pick_Hint: [ + "구분 → 상세구분을 고르고 [찾기]를 누름 — 하나씩 직접 고름", + "Choose category, detail, then Find — pick one by one", + ], + Pick_None: ["찾은 로직 없음", "No logics found"], + Pick_Close: ["닫기", "Close"], + Pick_Blocked: ["막힘", "Blocked"], + Prev_Title: ["미리 보기 (보기만 · 저장 안 함)", "Preview (view only)"], + Prev_Inputs: ["넣을 값", "Inputs"], + Prev_Run: ["미리 보기 계산", "Run preview"], + Prev_Labor: ["노무비", "Labor"], + Prev_Material: ["재료비", "Material"], + Prev_Expense: ["경비", "Expense"], + Prev_Sum: ["합계", "Total"], + Prev_Row: ["로직", "Logic"], + Prev_Fail: ["못 셈", "Failed"], + Prev_Wait: ["미리 보기 계산을 누르면 값이 나옴", "Press the button to see values"], +} as const satisfies Record; + +export type ComboTextKey = keyof typeof TEXT; + +export function tc(key: ComboTextKey): string { + const entry = TEXT[key]; + return entry[currentLanguageIndex as 0 | 1] ?? entry[0]; +} diff --git a/M01_MasterData/M01_MasterData_UI_Page.ts b/M01_MasterData/M01_MasterData_UI_Page.ts index 95579b46..ae12a8b3 100644 --- a/M01_MasterData/M01_MasterData_UI_Page.ts +++ b/M01_MasterData/M01_MasterData_UI_Page.ts @@ -1,6 +1,6 @@ /* ============================================================================= * M01_MasterData_UI_Page.ts - * 마스터 요소 화면 — 좌측 도킹 패널(컨테이너: 인력·재료·기계·소요량·계수·환율·요율·단가산출 로직·로직 테스트) + * 마스터 요소 화면 — 좌측 도킹 패널(컨테이너: 인력·재료·기계·소요량·계수·환율·요율·단가산출 로직·일위대가 조합·로직 테스트) * / 우측 요소 표 · 표 목록 · 로직 편집 * * 시스템 관리자만. 고친 것은 초안(sessionStorage)에 쌓이고 [저장] 한 번에 서버로 — @@ -34,6 +34,7 @@ import { } from "./M01_MasterData_UI_Side"; import { renderTables } from "./M01_MasterData_UI_Tables"; import type { LogicHandle } from "./M01_MasterData_UI_Logic_Page"; +import type { ComboHandle } from "./M01_MasterData_UI_Combo"; import "./M01_MasterData_UI_Style.css"; const TABLE_GROUPS = ["소요량", "계수"]; @@ -55,6 +56,7 @@ function buildPage(): HTMLElement { let dispose = (): void => {}; let logicMounted = false; let labMounted = false; + let comboHandle: ComboHandle | null = null; /* --- 우측: 머리(제목·찾기·저장) + 알림 + 본문 --- */ const title = el("h2", { className: "m01-master__title", text: L("M01_PickFile") }); @@ -71,6 +73,7 @@ function buildPage(): HTMLElement { }); const logicHost = el("div", { className: "m01-master__logic", attrs: { hidden: "" } }); const labHost = el("div", { className: "m01-master__logic", attrs: { hidden: "" } }); + const comboHost = el("div", { className: "m01-master__logic", attrs: { hidden: "" } }); const elementView = el("div", { className: "m01-master__elements", children: [head, notice, body], @@ -88,9 +91,10 @@ function buildPage(): HTMLElement { onDraftChange(refreshBar); refreshBar(); - const showMode = (mode: "elements" | "logic" | "lab"): void => { + const showMode = (mode: "elements" | "logic" | "lab" | "combo"): void => { logicHost.hidden = mode !== "logic"; labHost.hidden = mode !== "lab"; + comboHost.hidden = mode !== "combo"; elementView.hidden = mode !== "elements"; }; @@ -207,8 +211,24 @@ function buildPage(): HTMLElement { void import("./M01_MasterData_UI_LogicLab").then((m) => m.mountM01LogicLab(labHost, side)); }; + /** 「일위대가 조합」 — 목록을 새로 받아 그림 · 로직 줄을 누르면 단가산출 로직 탭으로 */ + const openComboTab = (): void => { + dispose(); + dispose = (): void => {}; + current = null; + showMode("combo"); + if (comboHandle) { + void comboHandle.show(); + return; + } + void import("./M01_MasterData_UI_Combo").then((m) => { + comboHandle = m.mountM01Combo(comboHost, side, (key) => openLogicTab(key)); + void comboHandle.show(); + }); + }; + /* --- 좌측: 컨테이너 --- */ - const side = buildSide(openFile, () => openLogicTab(), openLabTab); + const side = buildSide(openFile, () => openLogicTab(), openLabTab, openComboTab); const layout = el("div", { className: "ui-workflow-layout m01-master" }); const main = el("main", { @@ -216,7 +236,7 @@ function buildPage(): HTMLElement { children: [ el("div", { className: "m01-master__panel", - children: [elementView, logicHost, labHost], + children: [elementView, logicHost, labHost, comboHost], }), ], }); diff --git a/M01_MasterData/M01_MasterData_UI_Side.ts b/M01_MasterData/M01_MasterData_UI_Side.ts index bbd4269c..1e30922d 100644 --- a/M01_MasterData/M01_MasterData_UI_Side.ts +++ b/M01_MasterData/M01_MasterData_UI_Side.ts @@ -1,7 +1,7 @@ /* ============================================================================= * M01_MasterData_UI_Side.ts - * 왼쪽 패널 — 공용 접기 컨테이너(`ui-collapsible ui-sidebar-section`) 여덟 개 - * 인력 · 재료 · 기계 · 소요량 · 계수 · 환율 · 요율 · 단가산출 로직 + * 왼쪽 패널 — 공용 접기 컨테이너(`ui-collapsible ui-sidebar-section`) 아홉 개 + * 인력 · 재료 · 기계 · 소요량 · 계수 · 환율 · 요율 · 단가산출 로직 · 일위대가 조합 * 펼치면 하위 목록(거름 · 파일) · 환율/요율은 누르면 바로 표 · 로직은 안에 로직 목록 * ========================================================================== */ @@ -10,6 +10,7 @@ import { attachCollapsible } from "@ui/ui_template_collapsible"; import { t as L } from "@ui/ui_template_locale"; import { fetchFiles, fetchSubsAll, type FileInfo, type SubInfo } from "./M01_MasterData_Api_Fetch"; import { tx } from "./M01_MasterData_UI_Logic_Text"; +import { tc } from "./M01_MasterData_UI_Combo_Text"; import { renderTree, type MakeRow } from "./M01_MasterData_UI_Tree"; /** 컨테이너마다 기억하는 화면 상태 — 찾기 글 · 쪽 · 소요량·계수 표의 용도 대상 거름 (거름은 `m01.filter.*`) */ @@ -75,6 +76,8 @@ export interface SideHandle { root: HTMLElement; /** 단가산출 로직 컨테이너 안(로직 목록이 들어갈 자리) */ logicHost: HTMLElement; + /** 일위대가 조합 컨테이너 안(구분 · 상세구분 거름이 들어갈 자리) */ + comboHost: HTMLElement; /** 「로직 개선 시험」 컨테이너 안 */ labHost: HTMLElement; /** 그룹의 파일 판본을 다시 받음(저장 뒤) — 돌려받는 것 = 새 목록 */ @@ -133,11 +136,13 @@ const LEAF: Group[] = ["환율", "요율"]; const FILTERED: Group[] = ["인력", "기계", "소요량", "계수"]; const LOGIC_ID = "로직|"; const LAB_ID = "로직시험|"; +const COMBO_ID = "조합|"; export function buildSide( onOpen: (pick: Pick) => void, onLogic: () => void, onLab: () => void, + onCombo: () => void = () => {}, ): SideHandle { const lists = new Map(); const bodies = new Map(); @@ -427,6 +432,14 @@ export function buildSide( onLogic(); }); + const comboHost = el("div", { className: "m01-side__items" }); + const combo = section(tc("Title"), comboHost); + combo.querySelector(".ui-collapsible__title")?.addEventListener("click", () => { + if (!combo.classList.contains("is-collapsed")) return; + setActive(buttons.has(COMBO_ID) ? COMBO_ID : null); + onCombo(); + }); + const labHost = el("div", { className: "m01-side__items" }); const lab = section(tx("Lab_Title"), labHost); lab.querySelector(".ui-collapsible__title")?.addEventListener("click", () => { @@ -435,7 +448,7 @@ export function buildSide( onLab(); }); - const root = el("div", { className: "m01-side", children: [...groups, logic, lab] }); + const root = el("div", { className: "m01-side", children: [...groups, logic, combo, lab] }); attachCollapsible(root); void Promise.all(GROUPS.map(refresh)).catch((error) => showToast(error instanceof Error ? error.message : L("M01_LoadFailed"), "error"), @@ -443,5 +456,5 @@ export function buildSide( const setOnPicked = (fn: () => void): void => { onPicked = fn; }; - return { root, logicHost, labHost, refresh, setActive, setOnPicked, filter }; + return { root, logicHost, comboHost, labHost, refresh, setActive, setOnPicked, filter }; }