조사결과 관로·맨홀 지도 레이어와 보고서 조회 연동

This commit is contained in:
kiminchan
2026-08-03 10:11:48 +09:00
parent bcf5d3caec
commit c9d85a8ce4
22 changed files with 1538 additions and 56 deletions
@@ -11,7 +11,7 @@ export const windowPopupDefinitions = {
key: "exmnResultRegister",
title: "조사 결과 업로드",
width: 1000,
height: 500,
height: 650,
requiredParams: ["exmnBizId"],
},
exmnSurveyDetail: {
@@ -21,6 +21,13 @@ export const windowPopupDefinitions = {
height: 720,
requiredParams: ["exmnBizId", "trtdstId", "trtdstNm", "jobType"],
},
exmnPipeReport: {
key: "exmnPipeReport",
title: "관로 조사보고서",
width: 1200,
height: 850,
requiredParams: ["exmnBizId", "pipeNumber"],
},
oldPpUpload: {
key: "oldPpUpload",
title: "노후 하수관로 정비사업 등록",
@@ -3,6 +3,7 @@ import type { WindowPopupRegistryItem } from "./model/types";
import AgedPipePopupContent from "./ui/AgedPipePopupContent";
import AgedPipeStatusByCtpvPopupContent from "./ui/AgedPipeStatusByCtpvPopupContent";
import ExmnBusinessRegisterPopupContent from "./ui/ExmnBusinessRegisterPopupContent";
import ExmnPipeReportPopupContent from "./ui/ExmnPipeReportPopupContent";
import ExmnResultRegisterPopupContent from "./ui/ExmnResultRegisterPopupContent";
import ExmnSurveyDetailPopupContent from "./ui/ExmnSurveyDetailPopupContent";
import FloodPreTablePopupContent from "./ui/FloodPreTablePopupContent";
@@ -50,6 +51,10 @@ export const windowPopupRegistry = {
...windowPopupDefinitions.exmnSurveyDetail,
component: ExmnSurveyDetailPopupContent,
},
exmnPipeReport: {
...windowPopupDefinitions.exmnPipeReport,
component: ExmnPipeReportPopupContent,
},
oldPpUpload: {
...windowPopupDefinitions.oldPpUpload,
component: OldPpUploadPopupContent,
@@ -0,0 +1,97 @@
"use client";
import { useEffect, useState } from "react";
import { downloadExmnPipeReport } from "@/features/exmn/api/exmn-business-api";
import type { WindowPopupContentProps } from "../model/types";
const getParam = (value: string | string[] | undefined) =>
Array.isArray(value) ? value[0] ?? "" : value ?? "";
/** 공통 Blob API 오류 문자열에서 백엔드의 사용자 안내 메시지만 추출한다. */
const getReportErrorMessage = (error: unknown) => {
if (!(error instanceof Error)) {
return "관로 조사보고서를 불러오지 못했습니다.";
}
const backendMessage = error.message.match(/"message":"((?:\\.|[^"\\])*)"/)?.[1];
if (!backendMessage) return error.message;
try {
return JSON.parse(`"${backendMessage}"`) as string;
} catch {
return backendMessage;
}
};
/** 저장된 관로별 PDF 구간을 공통 WindowPopup 안에서 표시한다. */
export default function ExmnPipeReportPopupContent({
searchParams,
}: WindowPopupContentProps) {
const exmnBizId = getParam(searchParams.exmnBizId);
const pipeNumber = getParam(searchParams.pipeNumber);
const reportNo = getParam(searchParams.reportNo);
const [reportUrl, setReportUrl] = useState("");
const [errorMessage, setErrorMessage] = useState("");
useEffect(() => {
let active = true;
let objectUrl = "";
setReportUrl("");
setErrorMessage("");
void downloadExmnPipeReport(exmnBizId, pipeNumber)
.then((blob) => {
if (!active) return;
const pdfBlob =
blob.type === "application/pdf"
? blob
: new Blob([blob], { type: "application/pdf" });
objectUrl = URL.createObjectURL(pdfBlob);
setReportUrl(objectUrl);
})
.catch((error) => {
if (!active) return;
console.warn("관로 조사보고서 조회 실패:", error);
setErrorMessage(getReportErrorMessage(error));
});
return () => {
active = false;
if (objectUrl) URL.revokeObjectURL(objectUrl);
};
}, [exmnBizId, pipeNumber]);
return (
<main className="sn-popup-page">
<header className="sn-popup-header">
<h1 className="sn-popup-title">관로 조사보고서</h1>
<span className="text-[1.05rem] text-white">
관로번호 {pipeNumber}
{reportNo ? ` · 보고서번호 ${reportNo}` : ""}
</span>
</header>
<section className="min-h-0 flex-1 bg-container p-3">
{errorMessage ? (
<div className="flex h-full items-center justify-center rounded-sm border border-red-200 bg-red-50 p-6 text-center text-[1.1rem] text-red-700">
{errorMessage}
</div>
) : reportUrl ? (
<iframe
title={`${pipeNumber} 관로 조사보고서`}
src={reportUrl}
className="h-full w-full border border-border bg-white"
/>
) : (
<div className="flex h-full items-center justify-center rounded-sm border border-border bg-white text-[1.1rem] text-muted-foreground">
조사보고서를 불러오는 중입니다.
</div>
)}
</section>
</main>
);
}