Files
Aislo/M02_MasterTemplete/M02_MasterTemplete_Sangeun_Pick.ts
T
eomsangdonandClaude Sonnet 5.5 39338d9e33 refactor(840-1): 상세 보기에만 있던 기능 넷 판정 · 죽은 코드 걷음 — 수식 보기가 대신하는 것 지움
- 판정 = 자체 로직 편집 · 시험 값 고침 · M02 줄 덮음 · 비목 박스 소계 모두 수식 보기로 됨(살릴 것 없음)
- M01 상세: 숨은 단가산출 상세 덩이 · 자체 로직 시트 편집기 · 시험 고침 · 셈 구동(createDrive) · 보기 이름표(View.ts) · data-view CSS 걷음
- M02 불러오기 모달 머리 [항목 추가] · [율 줄 추가] 단추와 그 창(Rate.ts · openSangeunLinePicker) 걷음
- 글 정리 = Info_Own 새 뜻 · 죽은 글 키 · No_Key · 항목 추가 글 걷음
- 낡은 시험 고침 = 722(시험 고침 · 덮기 셈) · 799-2 · 804-2 · 804-6 · 804-7 · 806-1 · 717-2b · 717-4 · 721 · 728-2 — 걷은 것이 없음 확인으로
- 남김 = M02 수식 문서 없는 줄의 단가산출 상세 몸(cover · buildHo)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 15:45:07 +09:00

68 lines
2.7 KiB
TypeScript

/* =============================================================================
* M02_MasterTemplete_Sangeun_Pick.ts
* M02 단가산출(SK) 고르기(PLAN 717-4) — 위 층 SK 목록 한 벌 · 단가산출 더한줄 고르기.
* · `listLayerDocs` = 층 목록 길(`/layers/{층}/templates` · 종류 하나)을 마스터 › 회사 › 개인 차례로 이음 ·
* 금액 = 서버가 붙인 1 단위 `기준금액` · `listSangeun` = 종류 `sangeun` · 찾아 넣기 창(`Find_Pick`) 탭 · B09 재료 창고 출처가 씀
* · 고른 SK = 참조 `{층, 주인, 키: SK-…}` — 일위대가 줄은 옛 참조 줄 꼴(서버 `M02_Labor_Expand` 가 펼침)
* ========================================================================== */
import { call } from "./M02_MasterTemplete_Api_Fetch";
import type { LaborRef } from "./M02_MasterTemplete_Labor_Calc";
export const SANGEUN_KIND = "sangeun";
/** 층 차례 — 위에서 아래 */
export const LAYER_ORDER = ["system", "company", "personal"] as const;
/** SK 목록 한 줄 */
export interface SangeunRow {
ref: LaborRef;
이름: string;
제목: string | null;
단위: string | null;
구분: string | null;
상세구분: string | null;
기준금액: number | null;
}
interface ListRow {
종류: string;
이름: string;
제목?: string | null;
단위?: string | null;
구분?: string | null;
상세구분?: string | null;
기준금액?: number | null;
}
/** 위 층 SK — 층 차례(마스터 › 회사 › 개인) · 층 안은 서버 차례 */
export const listSangeun = (scopes: Omit<LaborRef, "키">[]): Promise<SangeunRow[]> =>
listLayerDocs(scopes, SANGEUN_KIND);
/** 위 층 서고 문서 한 종류(sangeun · precombo) — 층 차례 · 층 안은 서버 차례 */
export async function listLayerDocs(
scopes: Omit<LaborRef, "키">[],
kind: string,
): Promise<SangeunRow[]> {
const rank = (x: Omit<LaborRef, "키">): number =>
LAYER_ORDER.indexOf(x.층 as (typeof LAYER_ORDER)[number]);
const sorted = [...scopes].sort((a, b) => rank(a) - rank(b));
const lists = await Promise.all(
sorted.map(async (at) => {
const q = at.주인 && at.층 !== "system" ? `?owner=${encodeURIComponent(at.주인)}` : "";
const got = await call<{ 양식: ListRow[] }>(`/layers/${at.층}/templates${q}`);
return got.양식
.filter((r) => r.종류 === kind)
.map<SangeunRow>((r) => ({
ref: { 층: at.층, 주인: at.층 === "system" ? null : at.주인, 키: r.이름 },
이름: r.이름,
제목: r.제목 ?? null,
단위: r.단위 ?? null,
구분: r.구분 ?? null,
상세구분: r.상세구분 ?? null,
기준금액: r.기준금액 ?? null,
}));
}),
);
return lists.flat();
}