- 값(원문번호)은 그대로 · 글만 바꿈 — M02 사본 저장 · 로직 부름 · 엑셀 이음 그대로 - 서버 GET /api/m02/df/machine-names(로그인만) = 기계 원문번호 → 이름 규격 · 브라우저는 한 번 받아 둠 - 수식 탭 옵션(formula_doc_options) · 단가산출 상세 옵션(calc_sheet varRow) 같은 도우미 · M01 · M02 같이 - 목록이 모두 원문번호 꼴일 때만(빈 칸 뺌) · 문서 선택 목록 원문번호 전수 이름 있음 - test_804_10 셋 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.5 KiB
TypeScript
31 lines
1.5 KiB
TypeScript
/* =============================================================================
|
|
* M02_DF_Api.ts
|
|
* 단위 · 금액 표준 표 읽기 — 서버 `GET /api/m02/df/standards`(`M02_DF_Router.py`)
|
|
* 부르는 곳 = 단위 고르기(`M02_DF_UnitPick`) · 끝수 표준(`M02_DF_Round`) · 옵션 기계 이름(`formula_doc_options`)
|
|
* ========================================================================== */
|
|
|
|
import { API_BASE_URL } from "@config/config_frontend";
|
|
|
|
/** 단위 · 금액 표준 표 */
|
|
export interface CfStandards {
|
|
unit: { 이름: string; 줄: Record<string, unknown>[]; [k: string]: unknown };
|
|
money: { 이름: string; 줄: Record<string, unknown>[]; [k: string]: unknown };
|
|
saved: boolean;
|
|
}
|
|
|
|
export async function cfStandards(): Promise<CfStandards> {
|
|
const response = await fetch(`${API_BASE_URL}/m02/df/standards`, { credentials: "include" });
|
|
if (!response.ok) throw new Error(`표준 표 읽기 실패 (${response.status})`);
|
|
return (await response.json()) as CfStandards;
|
|
}
|
|
|
|
let machineNames: Promise<Record<string, string>> | null = null;
|
|
|
|
/** 기계 원문번호 → 「이름 규격」 — 한 번 받아 둠(못 받으면 빈 표 · 다음에 다시) */
|
|
export function cfMachineNames(): Promise<Record<string, string>> {
|
|
machineNames ??= fetch(`${API_BASE_URL}/m02/df/machine-names`, { credentials: "include" })
|
|
.then((r) => (r.ok ? (r.json() as Promise<Record<string, string>>) : Promise.reject()))
|
|
.catch(() => ((machineNames = null), {}));
|
|
return machineNames;
|
|
}
|