diff --git a/apps/fo/app/pages/(with-layout)/facilityPrecipitation/page.tsx b/apps/fo/app/pages/(with-layout)/facilityPrecipitation/page.tsx index 14d16810d..4df912186 100644 --- a/apps/fo/app/pages/(with-layout)/facilityPrecipitation/page.tsx +++ b/apps/fo/app/pages/(with-layout)/facilityPrecipitation/page.tsx @@ -96,7 +96,8 @@ export default function FacilityPrecipitation() { const [operationValue, setOperationValue] = useState("0"); // 조회기간 const [searchYear, setSearchYear] = useState(defaultSearchYear); - + // 엑셀다운로드 트리거 + const [isExcelDownClick, setIsExcelDownClick] = useState(false); /** * 페이지 함수 */ @@ -144,14 +145,22 @@ export default function FacilityPrecipitation() { }, [isInit, initializeCommonData, searchFacilityPrecipitationList, defaultSearchYear]); useEffect(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '시설별 강수현황', - sheetNameArray: ['시설별 강수현황'], - headerRange: 'A1:N1' - }); - } + 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]); useEffect(() => { @@ -213,6 +222,7 @@ export default function FacilityPrecipitation() { // } // } 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 0f8427458..1df3be0cd 100644 --- a/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx +++ b/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx @@ -54,7 +54,8 @@ export default function ProcessFacilitySearch() { const mainList: FacilityWaterQltyProps[] = facilityWaterQltyList || []; const [initTrigger, setInitTrigger] = useState(false); - const [excelTrigger, setExcelTrigger] = useState(false); + // 엑셀다운로드 트리거 + const [isExcelDownClick, setIsExcelDownClick] = useState(false); // 그리드 관련 const [resetPage, setResetPage] = useState(false); const searchInputRef = useRef(null); @@ -152,21 +153,28 @@ export default function ProcessFacilitySearch() { }, [isInit, initializeCommonData, searchFacilityWaterQltyList, searchFcltyQltyList, initTrigger]); useEffect(() => { - if (!excelTrigger) return; + if (!isExcelDownClick) 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] - } - ); - } - }, [excelList, excelTrigger]); + 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); + + return () => clearTimeout(timer); + }, [excelList, isExcelDownClick]); const chkVal = useCallback((returntype: ReturnType) => { // setWidthSize(returntype.partValue=='A' ?"w-[120%]":"w-[130%]") @@ -192,7 +200,7 @@ export default function ProcessFacilitySearch() { } } - setExcelTrigger(true); + setIsExcelDownClick(true); searchFcltyQltyList(ref.current, 1, 10000); }, [searchFcltyQltyList]); diff --git a/apps/fo/app/pages/(with-layout)/flowRate/page.tsx b/apps/fo/app/pages/(with-layout)/flowRate/page.tsx index c80d46699..66b8c990d 100644 --- a/apps/fo/app/pages/(with-layout)/flowRate/page.tsx +++ b/apps/fo/app/pages/(with-layout)/flowRate/page.tsx @@ -160,6 +160,7 @@ export default function ProcessFacilitySearch() { } else { alert('조회된 결과가 없습니다.'); } + setIsExcelDownClick(false); }, 1000); // 약간의 지연을 두고 다운로드 실행 return () => clearTimeout(timer); }, [excelList, isExcelDownClick]); diff --git a/apps/fo/app/pages/(with-layout)/planSewage/page.tsx b/apps/fo/app/pages/(with-layout)/planSewage/page.tsx index 41b541ce9..fca74757c 100644 --- a/apps/fo/app/pages/(with-layout)/planSewage/page.tsx +++ b/apps/fo/app/pages/(with-layout)/planSewage/page.tsx @@ -93,8 +93,9 @@ export default function PlanSewage() { const [searchYear, setSearchYear] = useState(defaultSearchYear); const [initTrigger, setInitTrigger] = useState(false); + // 엑셀다운로드 트리거 + const [isExcelDownClick, setIsExcelDownClick] = useState(false); - const [excelTrigger, setExcelTrigger] = useState(false); /** * 페이지 함수 */ @@ -119,17 +120,24 @@ export default function PlanSewage() { } useEffect(() => { - if (!excelTrigger) return; + if (!isExcelDownClick) return; - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '계획하수량 산정지표 현황', - sheetNameArray: ['계획하수량 산정지표 현황'], - headerRange: 'A1:M1' - }); - } - }, [excelList, excelTrigger]); + 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]); /** * 콜백함수 @@ -201,7 +209,7 @@ export default function PlanSewage() { } searchPlanSewage(searchReturn, 1, 10000); - setExcelTrigger(true); + 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 371a1262d..00ce67077 100644 --- a/apps/fo/app/pages/(with-layout)/processArea/page.tsx +++ b/apps/fo/app/pages/(with-layout)/processArea/page.tsx @@ -70,6 +70,8 @@ export default function ProcessArea() { const [resetPage, setResetPage] = useState(false); const [searchYearValue, setSearchYearValue] = useState(defaultSearchYear); + + const [isExcelDownClick, setIsExcelDownClick] = useState(false); const ref = useRef({ partValue: '', @@ -126,15 +128,23 @@ export default function ProcessArea() { }, [isInit, initializeCommonData, searchProcessAreaList, defaultSearchYear]); useEffect(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '처리구역정보', - sheetNameArray: ['처리구역정보'], - headerRange: 'A1:W1' - }); - } - }, [excelList]); + 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]); const excelDownload = useCallback(() => { // if (ref.current.partValue === 'A') { // 행정별 @@ -155,6 +165,7 @@ export default function ProcessArea() { // } searchProcessArea(ref.current, 1, 10000); + setIsExcelDownClick(true); }, [searchProcessArea]); const handlePageChange = useCallback((pageNo: number) => { diff --git a/apps/fo/app/pages/(with-layout)/processFacility/page.tsx b/apps/fo/app/pages/(with-layout)/processFacility/page.tsx index 9a6535db1..fdc70433e 100644 --- a/apps/fo/app/pages/(with-layout)/processFacility/page.tsx +++ b/apps/fo/app/pages/(with-layout)/processFacility/page.tsx @@ -89,6 +89,7 @@ export default function ProcessFacilitySearch() { const [partValue, setPartValue] = useState("A"); // const [widthSize, setWidthSize] = useState("w-[120%]"); const [upHeadList, setUpheadList] = useState(upHeadList1); + const [isExcelDownClick, setIsExcelDownClick] = useState(false); /** * 모달 상태 변수 @@ -150,10 +151,18 @@ export default function ProcessFacilitySearch() { }, [partValue, upHeadList1, upHeadList2, upHeadList3]); useEffect(() => { - if (excelList && excelList.length > 0) { - downloadExcel({ data: excelList as unknown as JSON[], fileName: '처리시설 시설정보', sheetNameArray: ['처리시설 시설정보'], headerRange: 'A1:P1' }); - } - }, [excelList]); + 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]); const searchFcltyList = useCallback(({ partValue, regionValue, unitWaterShedValue, middleRegionValue, envPartValue, sidoValue, sigunValue }: ReturnType, pageNo: number, pageCnt:number=10) => { let nameCd, partStr @@ -254,6 +263,7 @@ export default function ProcessFacilitySearch() { // } searchFcltyList(ref.current, 1, 10000); + setIsExcelDownClick(true); }, [searchFcltyList]); // 모달 닫기 diff --git a/apps/fo/app/pages/(with-layout)/rdi/page.tsx b/apps/fo/app/pages/(with-layout)/rdi/page.tsx index 63df65e13..03d4017bc 100644 --- a/apps/fo/app/pages/(with-layout)/rdi/page.tsx +++ b/apps/fo/app/pages/(with-layout)/rdi/page.tsx @@ -120,16 +120,22 @@ export default function Rdi() { useEffect(() => { if(!isExcelDownClick) return ; - if (excelList && excelList.length > 0) { - downloadExcel({ - data: excelList as unknown as JSON[], - fileName: 'RDII추정', - sheetNameArray: ['RDII추정'], - headerRange: 'A1:R1' - }); - } else { - alert("조회된 결과가 없습니다."); - } + + 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); // 약간의 지연을 두고 다운로드 실행 + + return () => clearTimeout(timer); }, [excelList, isExcelDownClick]); /** diff --git a/apps/fo/app/pages/(with-layout)/sewageOccur/page.tsx b/apps/fo/app/pages/(with-layout)/sewageOccur/page.tsx index a7ff0df71..4d3578314 100644 --- a/apps/fo/app/pages/(with-layout)/sewageOccur/page.tsx +++ b/apps/fo/app/pages/(with-layout)/sewageOccur/page.tsx @@ -162,6 +162,7 @@ export default function PlanSewage() { } else { alert("조회된 결과가 없습니다."); } + setIsExcelDownClick(false); }, 500); // 약간의 지연을 두고 다운로드 실행 return () => clearTimeout(timer); diff --git a/apps/fo/app/pages/(with-layout)/underWaterInput/page.tsx b/apps/fo/app/pages/(with-layout)/underWaterInput/page.tsx index 849689312..d03053520 100644 --- a/apps/fo/app/pages/(with-layout)/underWaterInput/page.tsx +++ b/apps/fo/app/pages/(with-layout)/underWaterInput/page.tsx @@ -167,6 +167,7 @@ export default function UnderWaterInput() { } else { alert("조회된 결과가 없습니다."); } + setIsExcelDownClick(false); }, 1000); // 약간의 지연을 두고 다운로드 실행 return () => clearTimeout(timer); }, [excelList, isExcelDownClick]);