From 39fb1d974abbdb57fffbfd92695b0ff00b98184d Mon Sep 17 00:00:00 2001 From: ljpark Date: Fri, 30 Jan 2026 10:39:41 +0900 Subject: [PATCH] =?UTF-8?q?fo:=20excel=20=EC=A1=B0=ED=9A=8C=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../facilityPrecipitation/page.tsx | 39 +++++++++------ .../(with-layout)/facilityWaterQlty/page.tsx | 48 +++++++++++-------- .../app/pages/(with-layout)/flowRate/page.tsx | 29 +++++++---- .../pages/(with-layout)/planSewage/page.tsx | 40 +++++++++------- .../pages/(with-layout)/processArea/page.tsx | 39 +++++++++------ .../(with-layout)/processFacility/page.tsx | 33 ++++++++----- apps/fo/app/pages/(with-layout)/rdi/page.tsx | 38 +++++++++------ .../pages/(with-layout)/sewageOccur/page.tsx | 41 +++++++++------- .../(with-layout)/underWaterInput/page.tsx | 42 +++++++++------- apps/fo/app/store/processFacility/index.tsx | 4 +- 10 files changed, 217 insertions(+), 136 deletions(-) diff --git a/apps/fo/app/pages/(with-layout)/facilityPrecipitation/page.tsx b/apps/fo/app/pages/(with-layout)/facilityPrecipitation/page.tsx index 4df912186..42dbb1be1 100644 --- a/apps/fo/app/pages/(with-layout)/facilityPrecipitation/page.tsx +++ b/apps/fo/app/pages/(with-layout)/facilityPrecipitation/page.tsx @@ -98,6 +98,7 @@ export default function FacilityPrecipitation() { const [searchYear, setSearchYear] = useState(defaultSearchYear); // 엑셀다운로드 트리거 const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); /** * 페이지 함수 */ @@ -147,21 +148,28 @@ export default function FacilityPrecipitation() { useEffect(() => { if (!isExcelDownClick) return; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '시설별 강수현황', - sheetNameArray: ['시설별 강수현황'], - headerRange: 'A1:N1' - }); - } else { - alert("조회된 결과가 없습니다."); - } - setIsExcelDownClick(false); - }, 500); - return () => clearTimeout(timer); - }, [excelList]); + if (isLoading) { + excelWaitRef.current = true; + return; + } + + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcel({ + data: excelList as unknown as JSON[], + fileName: '시설별 강수현황', + sheetNameArray: ['시설별 강수현황'], + headerRange: 'A1:N1' + }); + } else { + alert("조회된 결과가 없습니다."); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); useEffect(() => { if (facilityPrecipitation.length > 0) { @@ -221,6 +229,7 @@ export default function FacilityPrecipitation() { // return; // } // } + excelWaitRef.current = false; searchFacilityPrecipitation(searchReturn, 1, 10000); setIsExcelDownClick(true); }, [searchFacilityPrecipitation]); diff --git a/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx b/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx index 1df3be0cd..316ea78a1 100644 --- a/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx +++ b/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx @@ -56,6 +56,7 @@ export default function ProcessFacilitySearch() { const [initTrigger, setInitTrigger] = useState(false); // 엑셀다운로드 트리거 const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); // 그리드 관련 const [resetPage, setResetPage] = useState(false); const searchInputRef = useRef(null); @@ -155,26 +156,32 @@ export default function ProcessFacilitySearch() { useEffect(() => { if (!isExcelDownClick) return; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcelFormat( - { - data: excelList as unknown as JSON[], - fileName: '시설별 수질현황', - sheetNameArray: ['시설별 수질현황'], - headerRange: 'A1:T1', - decimalArray1: [10, 11, 12, 15, 16, 17], - decimalArray3: [13, 14, 18, 19] - } - ); - } else { - alert("조회된 결과가 없습니다."); - } - setIsExcelDownClick(false); - }, 500); + if (isLoading) { + excelWaitRef.current = true; + return; + } - return () => clearTimeout(timer); - }, [excelList, isExcelDownClick]); + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcelFormat( + { + data: excelList as unknown as JSON[], + fileName: '시설별 수질현황', + sheetNameArray: ['시설별 수질현황'], + headerRange: 'A1:T1', + decimalArray1: [10, 11, 12, 15, 16, 17], + decimalArray3: [13, 14, 18, 19] + } + ); + } else { + alert("조회된 결과가 없습니다."); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); const chkVal = useCallback((returntype: ReturnType) => { // setWidthSize(returntype.partValue=='A' ?"w-[120%]":"w-[130%]") @@ -200,8 +207,9 @@ export default function ProcessFacilitySearch() { } } - setIsExcelDownClick(true); + excelWaitRef.current = false; searchFcltyQltyList(ref.current, 1, 10000); + setIsExcelDownClick(true); }, [searchFcltyQltyList]); const handlePageChange = useCallback((page: number) => { diff --git a/apps/fo/app/pages/(with-layout)/flowRate/page.tsx b/apps/fo/app/pages/(with-layout)/flowRate/page.tsx index 66b8c990d..527c8d45e 100644 --- a/apps/fo/app/pages/(with-layout)/flowRate/page.tsx +++ b/apps/fo/app/pages/(with-layout)/flowRate/page.tsx @@ -73,6 +73,7 @@ export default function ProcessFacilitySearch() { const [fcltyNm, setFcltyNm] = useState(""); const [fcltyCd, setFcltyCd] = useState(""); const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); const [initTrigger, setInitTrigger] = useState(false); const searchFlowRate = useCallback(({ partValue, regionValue, unitWaterShedValue, middleRegionValue, envPartValue, sidoValue, sigunValue }: ReturnType, pageNo: number, pageCnt:number=20) => { @@ -154,16 +155,23 @@ export default function ProcessFacilitySearch() { useEffect(() => { if(!isExcelDownClick) return; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcelFormat({ data: JSON.parse(JSON.stringify(excelList)), fileName: '시설별 유량현황', sheetNameArray: ['시설별 유량현황'], headerRange: 'A1:O1', decimalArray0: [9,10,11,12,13,14] }); - } else { - alert('조회된 결과가 없습니다.'); - } - setIsExcelDownClick(false); - }, 1000); // 약간의 지연을 두고 다운로드 실행 - return () => clearTimeout(timer); - }, [excelList, isExcelDownClick]); + if (isLoading) { + excelWaitRef.current = true; + return; + } + + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcelFormat({ data: JSON.parse(JSON.stringify(excelList)), fileName: '시설별 유량현황', sheetNameArray: ['시설별 유량현황'], headerRange: 'A1:O1', decimalArray0: [9,10,11,12,13,14] }); + } else { + alert('조회된 결과가 없습니다.'); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); const ref = useRef({ partValue: '', @@ -201,6 +209,7 @@ export default function ProcessFacilitySearch() { } } + excelWaitRef.current = false; searchFlowRate(ref.current, 1, 10000); setIsExcelDownClick(true); }, [searchFlowRate]); diff --git a/apps/fo/app/pages/(with-layout)/planSewage/page.tsx b/apps/fo/app/pages/(with-layout)/planSewage/page.tsx index fca74757c..3ad19c1bb 100644 --- a/apps/fo/app/pages/(with-layout)/planSewage/page.tsx +++ b/apps/fo/app/pages/(with-layout)/planSewage/page.tsx @@ -95,6 +95,7 @@ export default function PlanSewage() { const [initTrigger, setInitTrigger] = useState(false); // 엑셀다운로드 트리거 const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); /** * 페이지 함수 @@ -122,22 +123,28 @@ export default function PlanSewage() { useEffect(() => { if (!isExcelDownClick) return; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '계획하수량 산정지표 현황', - sheetNameArray: ['계획하수량 산정지표 현황'], - headerRange: 'A1:M1' - }); - } else { - alert("조회된 결과가 없습니다."); - } - setIsExcelDownClick(false); - }, 500); - - return () => clearTimeout(timer); - }, [excelList, isExcelDownClick]); + if (isLoading) { + excelWaitRef.current = true; + return; + } + + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcel({ + data: excelList as unknown as JSON[], + fileName: '계획하수량 산정지표 현황', + sheetNameArray: ['계획하수량 산정지표 현황'], + headerRange: 'A1:M1' + }); + } else { + alert("조회된 결과가 없습니다."); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); /** * 콜백함수 @@ -208,6 +215,7 @@ export default function PlanSewage() { } } + excelWaitRef.current = false; searchPlanSewage(searchReturn, 1, 10000); setIsExcelDownClick(true); }, [searchPlanSewage]); diff --git a/apps/fo/app/pages/(with-layout)/processArea/page.tsx b/apps/fo/app/pages/(with-layout)/processArea/page.tsx index 00ce67077..d4fb0e973 100644 --- a/apps/fo/app/pages/(with-layout)/processArea/page.tsx +++ b/apps/fo/app/pages/(with-layout)/processArea/page.tsx @@ -72,6 +72,7 @@ export default function ProcessArea() { const [searchYearValue, setSearchYearValue] = useState(defaultSearchYear); const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); const ref = useRef({ partValue: '', @@ -130,21 +131,28 @@ export default function ProcessArea() { useEffect(() => { if(!isExcelDownClick) return; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '처리구역정보', - sheetNameArray: ['처리구역정보'], - headerRange: 'A1:W1' - }); - } else { - alert('조회된 결과가 없습니다.'); - } - setIsExcelDownClick(false); - }, 500); // 약간의 지연을 두고 다운로드 실행 - return () => clearTimeout(timer); - }, [excelList, isExcelDownClick]); + if (isLoading) { + excelWaitRef.current = true; + return; + } + + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcel({ + data: excelList as unknown as JSON[], + fileName: '처리구역정보', + sheetNameArray: ['처리구역정보'], + headerRange: 'A1:W1' + }); + } else { + alert('조회된 결과가 없습니다.'); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); const excelDownload = useCallback(() => { // if (ref.current.partValue === 'A') { // 행정별 @@ -164,6 +172,7 @@ export default function ProcessArea() { // } // } + excelWaitRef.current = false; searchProcessArea(ref.current, 1, 10000); setIsExcelDownClick(true); }, [searchProcessArea]); diff --git a/apps/fo/app/pages/(with-layout)/processFacility/page.tsx b/apps/fo/app/pages/(with-layout)/processFacility/page.tsx index fdc70433e..995f2e8e9 100644 --- a/apps/fo/app/pages/(with-layout)/processFacility/page.tsx +++ b/apps/fo/app/pages/(with-layout)/processFacility/page.tsx @@ -90,6 +90,7 @@ export default function ProcessFacilitySearch() { // const [widthSize, setWidthSize] = useState("w-[120%]"); const [upHeadList, setUpheadList] = useState(upHeadList1); const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); /** * 모달 상태 변수 @@ -151,18 +152,25 @@ export default function ProcessFacilitySearch() { }, [partValue, upHeadList1, upHeadList2, upHeadList3]); useEffect(() => { - if(!isExcelDownClick) return; + if (!isExcelDownClick) return; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ data: excelList as unknown as JSON[], fileName: '처리시설 시설정보', sheetNameArray: ['처리시설 시설정보'], headerRange: 'A1:P1' }); - } else { - alert('조회된 결과가 없습니다.'); - } - setIsExcelDownClick(false); - }, 500); // 약간의 지연을 두고 다운로드 실행 - return () => clearTimeout(timer); - }, [excelList, isExcelDownClick]); + if (isLoading) { + excelWaitRef.current = true; + return; + } + + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcel({ data: excelList as unknown as JSON[], fileName: '처리시설 시설정보', sheetNameArray: ['처리시설 시설정보'], headerRange: 'A1:P1' }); + } else { + alert('조회된 결과가 없습니다.'); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); const searchFcltyList = useCallback(({ partValue, regionValue, unitWaterShedValue, middleRegionValue, envPartValue, sidoValue, sigunValue }: ReturnType, pageNo: number, pageCnt:number=10) => { let nameCd, partStr @@ -262,6 +270,7 @@ export default function ProcessFacilitySearch() { // } // } + excelWaitRef.current = false; searchFcltyList(ref.current, 1, 10000); setIsExcelDownClick(true); }, [searchFcltyList]); @@ -326,4 +335,4 @@ export default function ProcessFacilitySearch() { )} ); -} \ No newline at end of file +} diff --git a/apps/fo/app/pages/(with-layout)/rdi/page.tsx b/apps/fo/app/pages/(with-layout)/rdi/page.tsx index 03d4017bc..8f601c299 100644 --- a/apps/fo/app/pages/(with-layout)/rdi/page.tsx +++ b/apps/fo/app/pages/(with-layout)/rdi/page.tsx @@ -91,6 +91,7 @@ export default function Rdi() { const [searchYear, setSearchYear] = useState(defaultSearchYear); // 엑셀 다운로드 트리거 const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); const [initTrigger, setInitTrigger] = useState(false); @@ -121,22 +122,28 @@ export default function Rdi() { useEffect(() => { if(!isExcelDownClick) return ; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: 'RDII추정', - sheetNameArray: ['RDII추정'], - headerRange: 'A1:R1' - }); - } else { - alert("조회된 결과가 없습니다."); - } - setIsExcelDownClick(false); - }, 500); // 약간의 지연을 두고 다운로드 실행 + if (isLoading) { + excelWaitRef.current = true; + return; + } - return () => clearTimeout(timer); - }, [excelList, isExcelDownClick]); + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcel({ + data: excelList as unknown as JSON[], + fileName: 'RDII추정', + sheetNameArray: ['RDII추정'], + headerRange: 'A1:R1' + }); + } else { + alert("조회된 결과가 없습니다."); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); /** * 콜백함수 @@ -206,6 +213,7 @@ export default function Rdi() { // } // } + excelWaitRef.current = false; searchRdi(ref.current, 1, 5000); setIsExcelDownClick(true); }, [searchRdi]); diff --git a/apps/fo/app/pages/(with-layout)/sewageOccur/page.tsx b/apps/fo/app/pages/(with-layout)/sewageOccur/page.tsx index 4d3578314..a9e990e82 100644 --- a/apps/fo/app/pages/(with-layout)/sewageOccur/page.tsx +++ b/apps/fo/app/pages/(with-layout)/sewageOccur/page.tsx @@ -101,6 +101,7 @@ export default function PlanSewage() { const [searchYear, setSearchYear] = useState(defaultSearchYear); // 엑셀다운로드 트리거 const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); /** * 페이지 함수 @@ -151,22 +152,28 @@ export default function PlanSewage() { useEffect(() => { if(!isExcelDownClick) return ; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '오수발생량 추정', - sheetNameArray: ['오수발생량 추정'], - headerRange: 'A1:O1' - }); - } else { - alert("조회된 결과가 없습니다."); - } - setIsExcelDownClick(false); - }, 500); // 약간의 지연을 두고 다운로드 실행 + if (isLoading) { + excelWaitRef.current = true; + return; + } - return () => clearTimeout(timer); - }, [excelList, isInit, isExcelDownClick]); + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcel({ + data: excelList as unknown as JSON[], + fileName: '오수발생량 추정', + sheetNameArray: ['오수발생량 추정'], + headerRange: 'A1:O1' + }); + } else { + alert("조회된 결과가 없습니다."); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); /** * 콜백함수 @@ -190,7 +197,8 @@ export default function PlanSewage() { break; } if (partStr.length > 1 || fcltCpct !== '0' || operationValue!== '0' ||nameCd ||(fcltyName.trim() !== "" && fcltyName.trim() !== null)) { - searchSewageOccurList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); + searchSewageOccurList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue + , fcltyName.trim() !== ""? fcltyName : undefined); } else { searchSewageOccurList(pageNo, pageCnt, searchYear); } @@ -220,6 +228,7 @@ export default function PlanSewage() { return; } } + excelWaitRef.current = false; searchFacilityPrecipitation(ref.current, 1, 5000); setIsExcelDownClick(true); }, [searchFacilityPrecipitation]); diff --git a/apps/fo/app/pages/(with-layout)/underWaterInput/page.tsx b/apps/fo/app/pages/(with-layout)/underWaterInput/page.tsx index d03053520..1b90b4584 100644 --- a/apps/fo/app/pages/(with-layout)/underWaterInput/page.tsx +++ b/apps/fo/app/pages/(with-layout)/underWaterInput/page.tsx @@ -106,6 +106,7 @@ export default function UnderWaterInput() { const [searchYear, setSearchYear] = useState(defaultSearchYear); // 엑셀다운로드 트리거 const [isExcelDownClick, setIsExcelDownClick] = useState(false); + const excelWaitRef = useRef(false); /** * 페이지 함수 @@ -156,21 +157,28 @@ export default function UnderWaterInput() { useEffect(() => { if(!isExcelDownClick) return ; - const timer = setTimeout(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '지하수유입량 추정', - sheetNameArray: ['지하수유입량 추정'], - headerRange: 'A1:O1' - }); - } else { - alert("조회된 결과가 없습니다."); - } - setIsExcelDownClick(false); - }, 1000); // 약간의 지연을 두고 다운로드 실행 - return () => clearTimeout(timer); - }, [excelList, isExcelDownClick]); + if (isLoading) { + excelWaitRef.current = true; + return; + } + + if (!excelWaitRef.current) { + return; + } + + if (excelList && excelList.length > 0) { + downloadExcel({ + data: excelList as unknown as JSON[], + fileName: '지하수유입량 추정', + sheetNameArray: ['지하수유입량 추정'], + headerRange: 'A1:O1' + }); + } else { + alert("조회된 결과가 없습니다."); + } + setIsExcelDownClick(false); + excelWaitRef.current = false; + }, [excelList, isExcelDownClick, isLoading]); /** * 콜백함수 @@ -194,7 +202,8 @@ export default function UnderWaterInput() { break; } if (partStr.length > 1 || fcltCpct !== '0' || operationValue!== '0' ||nameCd ||(fcltyName.trim() !== "" && fcltyName.trim() !== null)) { - searchUnderWaterList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); + searchUnderWaterList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue + , fcltyName.trim() !== ""? fcltyName : undefined); } else { searchUnderWaterList(pageNo, pageCnt, searchYear); } @@ -224,6 +233,7 @@ export default function UnderWaterInput() { return; } } + excelWaitRef.current = false; searchFacilityPrecipitation(ref.current, 1, 5000); setIsExcelDownClick(true); }, [searchFacilityPrecipitation]); diff --git a/apps/fo/app/store/processFacility/index.tsx b/apps/fo/app/store/processFacility/index.tsx index 8fa38e5bc..240ad2d4d 100644 --- a/apps/fo/app/store/processFacility/index.tsx +++ b/apps/fo/app/store/processFacility/index.tsx @@ -418,7 +418,9 @@ const gridListFcltyWaterQltyInfo: fcltyWaterQltyInfoProps[] = [ */ export const fetchFacilityListInit = async (pageNo: number, pageSize: number, partValue?: string, nameCd?: string, fcltCpct?: string, oprtngSttsCd?: string, facilityPartValue?: string, facilityName?: string): Promise<{ data: facilityListProps[], count: number }> => { try { - const tailStr = partValue ? '/' + (partValue === 'G' ? 'A' : partValue) + '/' + nameCd + '/' + fcltCpct + '/' + oprtngSttsCd + '/' + facilityPartValue + (facilityName && facilityName !== '' ? '/' + facilityName : '') : ''; + const tailStr = partValue ? '/' + (partValue === 'G' ? 'A' : partValue) + '/' + nameCd + '/' + fcltCpct + '/' + oprtngSttsCd + + (facilityPartValue && facilityPartValue !== ''? '/' + facilityPartValue : '') + + (facilityName && facilityName !== ''? '/' + facilityName : '') : ''; const url = '/prcsFclt/info/' + pageNo + '/' + pageSize + tailStr; const res = await getFetch('fo', url); res.data.forEach((item: Record) => {