fix(495-2 M02 파일 업로드): 도면 상세 · 도면 양식 [파일 업로드] 지움 — DWG = CAD [삽입 → DWG 불러오기] 한 길

- M02_MasterTemplete_Drawing.ts — importDrawingFile · noImport · [파일 업로드] 덩이 지움
- DrawingCard · AreaDrawing — noImport 곁값 지움 · CardHelp 글 = CAD [삽입] DWG 불러오기
- 서버 /api/m02/drawing-import = 부르는 곳 0 · 남김
- 시험 test_m02_card_shell 두 개 고쳐 씀 · ui_checks 47-1 기대 detailImport = 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 19:41:35 +09:00
co-authored by Claude Opus 5.5
parent 5392680ec1
commit 08a9bc2e46
7 changed files with 25 additions and 87 deletions
@@ -39,7 +39,7 @@ export interface DrawingTemplateOptions {
projectId?: string | null;
/** 저장 안 한 고침이 생기면 true — CAD 편집 · 작도 영역 값 바꿈. */
onChanged?: (dirty: boolean) => void;
/** 페이지 제목 줄 안의 빈 칸 — 있으면 작도 영역 칸 · [파일 업로드]를 거기 한 줄로 놓는다. */
/** 페이지 제목 줄 안의 빈 칸 — 있으면 작도 영역 칸을 거기 한 줄로 놓는다. */
headerSlot?: HTMLElement;
/** CAD 좌측 패널(특성 · 도면층)을 접힌 채로 연다 — 누르면 펼침(구조물 도면 미리보기). */
panelsCollapsed?: boolean;
@@ -51,8 +51,6 @@ export interface DrawingTemplateOptions {
noArea?: boolean;
/** B07 도각을 외곽 좌하단 (0,0) 에 얹음 — 잠금 층 · 보여주기만(돌려줄 때 뺌 · 저장 안 됨). */
frame?: boolean;
/** [파일 업로드] 단추를 안 둠 — 집계표 카드 미리보기(불러오기는 도면 상세에서만). */
noImport?: boolean;
/** 장id(82-1) — 자동백업 칸을 장마다 나눔(1장 = 빈 값 · 옛 칸 그대로) */
sheet?: string;
/** 장 도번(82-2) — 얹은 도각 `{{도면번호}}` 자리 */
@@ -142,25 +140,6 @@ function withoutFrame(drawing: DrawingTemplateDoc): DrawingTemplateDoc {
};
}
async function importDrawingFile(
file: File,
): Promise<{ drawing: DrawingTemplateDoc; entity_count: number }> {
const form = new FormData();
form.append("file", file);
const response = await fetch(`${API_BASE_URL}/m02/drawing-import`, {
method: "POST",
credentials: "include",
body: form,
});
const payload = (await response.json()) as {
drawing: DrawingTemplateDoc;
entity_count: number;
message?: string;
};
if (!response.ok) throw new Error(payload.message ?? `HTTP ${response.status}`);
return payload;
}
export function mountDrawingTemplate(
container: HTMLElement,
doc: DrawingTemplateDoc,
@@ -292,45 +271,6 @@ export function mountDrawingTemplate(
after?.();
};
const actions = document.createElement("div");
actions.className = "m02-drawing__actions";
const canImport = !readOnly && options.noImport !== true;
if (canImport) {
const fileInput = document.createElement("input");
fileInput.type = "file";
fileInput.accept = ".dxf,.dwg";
fileInput.hidden = true;
fileInput.addEventListener("change", () => {
const file = fileInput.files?.[0];
fileInput.value = "";
if (!file) return;
importButton.disabled = true;
importDrawingFile(file)
.then((response) => {
// 불러온 도각은 아직 저장하지 않는다 — 자리표를 놓고 [저장]을 눌러야 양식이 된다.
void load(response.drawing);
options.onChanged?.(true); // 불러온 것은 아직 저장 전 — 떠날 때 묻게 함
showToast(`도형 ${response.entity_count}개를 불러왔습니다.`, "success");
})
.catch((error) =>
showToast(
error instanceof Error ? error.message : "도각 파일을 불러오지 못했습니다.",
"error",
),
)
.finally(() => (importButton.disabled = false));
});
const importButton = createButton({
label: "파일 업로드",
variant: "filled",
onClick: () => fileInput.click(),
});
// 구조물 조합 층 단추([마스터])와 같은 꼴 — 실무자료 [파일 업로드]와 같은 종류(362-2)
importButton.classList.add("m02-layers__btn");
importButton.title = importButton.ariaLabel = "파일 업로드 (DXF · DWG)";
actions.append(importButton, fileInput);
}
const getDoc = async (): Promise<DrawingTemplateDoc> => {
const { drawing: saved } = await cad.requestSave();
const drawing = options.frame ? withoutFrame(saved) : saved;
@@ -345,13 +285,14 @@ export function mountDrawingTemplate(
};
// 한 줄 — 페이지가 머리 칸(headerSlot)을 주면 거기, 아니면 그림 칸 위에 작게.
toolbar.append(...(noArea ? [] : [areaButton]), actions);
// DWG · DXF 불러오기 = CAD 리본 [삽입 → DWG 불러오기] · 끌어다 놓기 한 길(495-2)
toolbar.append(...(noArea ? [] : [areaButton]));
const tabs = options.tabs ? [options.tabs] : [];
if (options.headerSlot) {
toolbar.classList.add("m02-drawing__toolbar--slot");
options.headerSlot.append(toolbar);
root.append(...tabs, cad.element);
} else root.append(...(noArea && !canImport ? [] : [toolbar]), ...tabs, cad.element);
} else root.append(...(noArea ? [] : [toolbar]), ...tabs, cad.element);
container.append(root);
void load(doc);