[st] feat: IMR 데이터 엑셀 다운로드 기능
This commit is contained in:
@@ -90,6 +90,7 @@ const ImrVerificationHistory = () => {
|
||||
useState<StAnlsMstResponse | null>(null);
|
||||
const [selectedDetail, setSelectedDetail] =
|
||||
useState<StAnlsRsltResponse | null>(null);
|
||||
const [isDownloading, setIsDownloading] = useState<boolean>(false);
|
||||
|
||||
// Area B Grid State
|
||||
const [gridRowData, setGridRowData] = useState<
|
||||
@@ -230,6 +231,29 @@ const ImrVerificationHistory = () => {
|
||||
setDateRange(defaultRange);
|
||||
};
|
||||
|
||||
const handleDownload = async () => {
|
||||
if (!selectedHistory || isDownloading) return;
|
||||
setIsDownloading(true);
|
||||
|
||||
try {
|
||||
const blob = await stAnlsRsltApi.downloadExcelImr(
|
||||
selectedHistory.anlsSn,
|
||||
);
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = `IMR_분석결과.xlsx`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
} catch (error) {
|
||||
console.error("Failed to download IMR excel", error);
|
||||
} finally {
|
||||
setIsDownloading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const chartOptions: ChartOptions<"line"> = useMemo(
|
||||
() => ({
|
||||
responsive: true,
|
||||
@@ -442,16 +466,11 @@ const ImrVerificationHistory = () => {
|
||||
<Button
|
||||
color="green"
|
||||
disabled={
|
||||
!detailData || detailData.content.length === 0
|
||||
!detailData ||
|
||||
detailData.content.length === 0 ||
|
||||
isDownloading
|
||||
}
|
||||
onClick={() => {
|
||||
if (selectedHistory) {
|
||||
stAnlsRsltApi.downloadExcel(
|
||||
selectedHistory.anlsSn,
|
||||
0,
|
||||
);
|
||||
}
|
||||
}}
|
||||
onClick={handleDownload}
|
||||
>
|
||||
다운로드
|
||||
</Button>
|
||||
|
||||
@@ -14,11 +14,7 @@ export const useStAnlsSidoCombo = () => {
|
||||
|
||||
export const useStAnlsSigunguCombo = (sidoCd: string) => {
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
ENDPOINT.STATVERIFY_SERVICE.ST_ANLS_MST,
|
||||
"sigungu",
|
||||
sidoCd,
|
||||
],
|
||||
queryKey: [ENDPOINT.STATVERIFY_SERVICE.ST_ANLS_MST, "sigungu", sidoCd],
|
||||
queryFn: () => stAnlsMstApi.getSigunguCombo(sidoCd),
|
||||
enabled: Boolean(sidoCd),
|
||||
});
|
||||
@@ -40,7 +36,7 @@ export const useStAnlsRsltList = (
|
||||
anlsSn,
|
||||
vrfcTrgtSn: Number(vrfcTrgtSn),
|
||||
page: 0,
|
||||
size: 1000,
|
||||
size: 15000,
|
||||
sort: "admdstCd,asc",
|
||||
}),
|
||||
enabled: !!anlsSn && !!vrfcTrgtSn,
|
||||
|
||||
@@ -60,6 +60,17 @@ export class StAnlsRsltApiService {
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async downloadExcelImr(anlsSn: number): Promise<Blob> {
|
||||
const response = await client.get<Blob>(
|
||||
`${ENDPOINT.STATVERIFY_SERVICE.ST_ANLS_RSLT}/excel-down/imr/${anlsSn}`,
|
||||
{
|
||||
responseType: "blob",
|
||||
},
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const stAnlsRsltApi = new StAnlsRsltApiService();
|
||||
|
||||
Reference in New Issue
Block a user