From fd096f9d846f27999ba92ac7bef92946d020ca13 Mon Sep 17 00:00:00 2001 From: jsyang Date: Sat, 1 Nov 2025 01:41:32 +0900 Subject: [PATCH] =?UTF-8?q?1.=EC=9C=A0=EB=9F=89=ED=98=84=ED=99=A9,=20?= =?UTF-8?q?=EC=88=98=EC=A7=88=ED=98=84=ED=99=A9,=20rdii,=20=EA=B3=84?= =?UTF-8?q?=ED=9A=8D=ED=95=98=EC=88=98=EB=9F=89=20=EC=84=9C=EC=9A=B8?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80=202.?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=EA=B5=AC=EC=97=AD=EC=A0=95=EB=B3=B4=20api?= =?UTF-8?q?=EC=8B=A0=EA=B7=9C=EC=B6=94=EA=B0=80=20(=ED=95=9C=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=8B=9C=EC=84=A4=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A1=9C=20api=20=ED=98=B8=EC=B6=9C?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(with-layout)/facilityWaterQlty/page.tsx | 42 +++++++-------- .../app/pages/(with-layout)/flowRate/page.tsx | 42 +++++++++------ .../pages/(with-layout)/planSewage/page.tsx | 49 +++++++++++------- apps/fo/app/pages/(with-layout)/rdi/page.tsx | 34 +++++++------ apps/fo/app/store/flowRate/index.tsx | 1 - apps/fo/app/store/planSewage/index.tsx | 1 - apps/fo/app/store/processArea/index.tsx | 51 ++++++++++++------- .../src/ui/search_base_form/index.tsx | 18 +++++-- .../src/ui/search_form_left/index.tsx | 22 +++++--- 9 files changed, 160 insertions(+), 100 deletions(-) diff --git a/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx b/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx index a107dfd2a..cb4861971 100644 --- a/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx +++ b/apps/fo/app/pages/(with-layout)/facilityWaterQlty/page.tsx @@ -48,7 +48,8 @@ export default function ProcessFacilitySearch() { } = FacilityWaterQltyMain; const mainList: FacilityWaterQltyProps[] = facilityWaterQltyList || []; - + const [initTrigger, setInitTrigger] = useState(false); + const [excelTrigger, setExcelTrigger] = useState(false); // 그리드 관련 const [resetPage, setResetPage] = useState(false); const searchInputRef = useRef(null); @@ -77,16 +78,15 @@ export default function ProcessFacilitySearch() { partStr = partValue break; default: - if(sidoValue !== '0') nameCd = sidoValue; + if(sidoValue !== '0') nameCd = ref.current.sidoValue!="0"?ref.current.sidoValue:sidoValue; if(sigunValue !== '0') nameCd = sigunValue; partStr = envPartValue !== '0' ? envPartValue:partValue; break; } - - if (partStr.length > 1 || fcltCpct !== '0' || operationValue!== '0' ||nameCd ||(fcltyName.trim() !== "" && fcltyName.trim() !== null)) { - searchFacilityWaterQltyList(pageNo, pageCnt, searchYearValue, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); - } else { + if(partStr ==='G'){ searchFacilityWaterQltyList(pageNo, pageCnt, searchYearValue); + }else{ + searchFacilityWaterQltyList(pageNo, pageCnt, searchYearValue, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); } }, [operationValue, fcltyName, searchFacilityWaterQltyList, searchYearValue, fcltCpct]); @@ -105,7 +105,8 @@ export default function ProcessFacilitySearch() { input.value = ""; } } - searchFacilityWaterQltyList(1, 10, selectSearchYear[0]?.val || "0"); + ref.current.sidoValue = "11"; + searchFcltyQltyList(ref.current, 1, 10); } // 셀 클릭 시 모달 표시 @@ -125,7 +126,7 @@ export default function ProcessFacilitySearch() { } const ref = useRef({ partValue: '', - sidoValue: '', + sidoValue: '11', sigunValue: '', regionValue: '', unitWaterShedValue: '', @@ -137,12 +138,17 @@ export default function ProcessFacilitySearch() { useEffect(() => { if (!isInit) { - initializeCommonData(); - searchFacilityWaterQltyList(1, 10, selectSearchYear[0]?.val || "0"); + if(!initTrigger){ + initializeCommonData(); + searchFcltyQltyList(ref.current, 1, 10); + setInitTrigger(true); + } } - }, [isInit, initializeCommonData, searchFacilityWaterQltyList, selectSearchYear]); + }, [isInit, initializeCommonData, searchFacilityWaterQltyList, searchFcltyQltyList, initTrigger]); useEffect(() => { + if(!excelTrigger) return; + if (excelList && excelList.length > 0) { downloadExcelFormat( { @@ -154,15 +160,8 @@ export default function ProcessFacilitySearch() { decimalArray3:[13,14,18,19] } ); - - /* downloadExcel({ - data: excelList as unknown as JSON[], - fileName: '시설별 수질현황', - sheetNameArray: ['시설별 수질현황'], - headerRange: 'A1:T1' - }); */ } - }, [excelList]); + }, [excelList, excelTrigger]); const chkVal = useCallback((returntype:ReturnType) => { setWidthSize(returntype.partValue=='A' ?"w-[120%]":"w-[130%]") @@ -171,6 +170,7 @@ export default function ProcessFacilitySearch() { }, [upHeadList1, upHeadList2, upHeadList3]); const excelDownload = useCallback(() => { + setExcelTrigger(true); searchFcltyQltyList(ref.current, 1, 10000); }, [searchFcltyQltyList]); @@ -202,12 +202,12 @@ export default function ProcessFacilitySearch() { queryClick={chkVal} excelClick={excelDownload} initClick={resetVal} - ref={ref} isAdmin={false} /> + ref={ref} isAdmin={false} initSidoValue={"11"}/>
- index !== undefined && cellClick(index)} headName={"시설별 수질현황"} tableData={mainList} headlist={upheadList} pageSize={10} total={total<10?facilityWaterQltyList.length:total} resetPageNo={resetPage} onPageChange={handlePageChange} widthFixed={true} /> + index !== undefined && cellClick(index)} headName={"시설별 수질현황"} tableData={mainList} headlist={upheadList} pageSize={10} total={total} resetPageNo={resetPage} onPageChange={handlePageChange} widthFixed={true} />
diff --git a/apps/fo/app/pages/(with-layout)/flowRate/page.tsx b/apps/fo/app/pages/(with-layout)/flowRate/page.tsx index 5b53f51a2..a7e0933eb 100644 --- a/apps/fo/app/pages/(with-layout)/flowRate/page.tsx +++ b/apps/fo/app/pages/(with-layout)/flowRate/page.tsx @@ -67,9 +67,12 @@ export default function ProcessFacilitySearch() { const [selectedRow, setSelectedRow] = useState(null); const [fcltyNm, setFcltyNm] = useState(""); const [fcltyCd, setFcltyCd] = useState(""); - + const [excelTrigger, setExcelTrigger] = useState(false); + const [initTrigger, setInitTrigger] = useState(false); + const searchFlowRate = useCallback(({ partValue, regionValue, unitWaterShedValue, middleRegionValue, envPartValue, sidoValue, sigunValue }: ReturnType, pageNo: number, pageCnt:number=20) => { - let nameCd, partStr + let nameCd, partStr; + switch (partValue) { case 'R': if (regionValue !== '0') { @@ -77,20 +80,20 @@ export default function ProcessFacilitySearch() { else if (middleRegionValue==='0') nameCd = unitWaterShedValue; else nameCd = middleRegionValue; } - partStr = partValue + partStr = partValue; break; default: - if(sidoValue !== '0') nameCd = sidoValue; + if(sidoValue !== '0') nameCd = ref.current.sidoValue!="0"?ref.current.sidoValue:sidoValue; if(sigunValue !== '0') nameCd = sigunValue; partStr = envPartValue !== '0' ? envPartValue:partValue; break; } - if (partStr.length > 1 || fcltCpct !== '0' || operationValue!== '0' ||nameCd ||(fcltyName.trim() !== "" && fcltyName.trim() !== null)) { - searchFlowRateList(pageNo, pageCnt, searchYearValue, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); - } else { + if(partStr==='G'){ searchFlowRateList(pageNo, pageCnt, searchYearValue); + }else{ + searchFlowRateList(pageNo, pageCnt, searchYearValue, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); } - }, [operationValue, fcltyName, searchFlowRateList, searchYearValue, fcltCpct]); + }, [searchFlowRateList, searchYearValue, fcltCpct, operationValue, fcltyName]); const resetVal = () => { setWidthSize("w-[120%]"); @@ -107,7 +110,8 @@ export default function ProcessFacilitySearch() { input.value = ""; } } - searchFlowRateList(1, 10, selectSearchYear[0]?.val || "0"); + ref.current.sidoValue = '11'; + searchFlowRate(ref.current,1, 10); } // 셀 클릭 시 모달 표시 @@ -133,23 +137,29 @@ export default function ProcessFacilitySearch() { // 시도 데이터 초기화 useEffect(() => { if(!isInit) { - initializeCommonData(); - searchFlowRateList(1, 10, selectSearchYear[0]?.val || "0"); + if(!initTrigger){ + initializeCommonData(); + searchFlowRate(ref.current, 1, 10); + setInitTrigger(true); + } + //searchFlowRateList(1, 10, selectSearchYear[0]?.val || "0"); } - }, [isInit, initializeCommonData, searchFlowRateList, selectSearchYear]); + }, [isInit, initializeCommonData, searchFlowRateList, selectSearchYear, searchFlowRate, initTrigger]); useEffect(() => { + if(!excelTrigger) 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 if (prevExcelListRef.current && prevExcelListRef.current.length > 0) { alert('다운받을 데이터가 없습니다.'); } prevExcelListRef.current = excelList; - }, [excelList]); + }, [excelList, excelTrigger]); const ref = useRef({ partValue: '', - sidoValue: '', + sidoValue: '11', sigunValue: '', regionValue: '', unitWaterShedValue: '', @@ -167,10 +177,10 @@ export default function ProcessFacilitySearch() { const excelDownload = useCallback(() => { searchFlowRate(ref.current, 1, 10000); + setExcelTrigger(true); }, [searchFlowRate]); const total = flowRateCount; - return ( @@ -193,7 +203,7 @@ export default function ProcessFacilitySearch() { queryClick={chkVal} excelClick={excelDownload} initClick={resetVal} - ref={ref} isAdmin={false}/> + ref={ref} isAdmin={false} initSidoValue={'11'}/> <ListDiv> <LoadingOverlay isLoading={isLoading} /> <div className="h-full w-full overflow-x-scroll"> diff --git a/apps/fo/app/pages/(with-layout)/planSewage/page.tsx b/apps/fo/app/pages/(with-layout)/planSewage/page.tsx index 1f1768af5..fa993715e 100644 --- a/apps/fo/app/pages/(with-layout)/planSewage/page.tsx +++ b/apps/fo/app/pages/(with-layout)/planSewage/page.tsx @@ -57,7 +57,7 @@ export default function PlanSewage() { const ref = useRef<ReturnType>({ partValue: '', - sidoValue: '', + sidoValue: '11', sigunValue: '', regionValue: '', unitWaterShedValue: '', @@ -86,7 +86,10 @@ export default function PlanSewage() { const [operationValue, setOperationValue] = useState<string>("0"); // 조회기간 const [searchYear, setSearchYear] = useState<string>(selectSearchYear[0]?.val || "0"); - + + const [initTrigger, setInitTrigger] = useState<boolean>(false); + + const [excelTrigger, setExcelTrigger] = useState<boolean>(false); /** * 페이지 함수 */ @@ -106,20 +109,13 @@ export default function PlanSewage() { input.value = ""; } } - searchPlanSewageList(1, 10, selectSearchYear[0]?.val || "0", ref.current.partValue); + ref.current.sidoValue='11'; + searchPlanSewage(ref.current, 1, 10); } - /** - * useEffect - */ useEffect(() => { - if (!isInit) { - initializeCommonData(); - searchPlanSewageList(1, 10, selectSearchYear[0]?.val || "0", ref.current.partValue); - } - }, [isInit, initializeCommonData, searchPlanSewageList, selectSearchYear]); + if(!excelTrigger) return; - useEffect(() => { if (excelList && excelList.length > 0) { downloadExcel({ data: excelList as unknown as JSON[], @@ -128,7 +124,7 @@ export default function PlanSewage() { headerRange: 'A1:M1' }); } - }, [excelList]); + }, [excelList, excelTrigger]); /** * 콜백함수 @@ -146,20 +142,34 @@ export default function PlanSewage() { partStr = partValue break; default: - if(sidoValue !== '0') nameCd = sidoValue; + if(sidoValue !== '0') nameCd = ref.current.sidoValue!="0"?ref.current.sidoValue:sidoValue; if(sigunValue !== '0') nameCd = sigunValue; partStr = envPartValue !== '0' ? envPartValue:partValue; break; } - if (partStr.length > 1 || fcltCpct !== '0' || operationValue!== '0' ||nameCd ||(fcltyName.trim() !== "" && fcltyName.trim() !== null)) { - searchPlanSewageList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); - } else { - // G로 넘기면 데이터가 안떠서 환경청 전체로 넘기면 전체를 추출하기위해서... + + if(partStr === 'G'){ partValue = partValue==='G'?'A':partValue; searchPlanSewageList(pageNo, pageCnt, searchYear, partValue); } + else{ + searchPlanSewageList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); + } }, [operationValue, fcltyName, searchPlanSewageList, searchYear, fcltCpct]); + /** + * useEffect + */ + useEffect(() => { + if (!isInit) { + if(!initTrigger){ + initializeCommonData(); + searchPlanSewage(ref.current, 1, 10); + setInitTrigger(true); + } + } + }, [isInit, initializeCommonData, searchPlanSewageList, selectSearchYear, initTrigger, searchPlanSewage]); + const chkVal = useCallback((returntype:ReturnType) => { setWidthSize(returntype.partValue=='A' ?"w-[120%]":"w-[130%]") setUpheadList(returntype.partValue == 'R' ? upHeadList2 : returntype.partValue == 'G'?upHeadList3:upHeadList1); @@ -169,6 +179,7 @@ export default function PlanSewage() { // 엑셀다운로드 const excelDownload = useCallback((searchReturn: ReturnType) => { searchPlanSewage(searchReturn, 1, 10000); + setExcelTrigger(true); }, [searchPlanSewage]); // 페이지 변경 @@ -201,7 +212,7 @@ export default function PlanSewage() { queryClick={chkVal} excelClick={excelDownload} initClick={resetVal} - ref={ref} isAdmin={false}/> + ref={ref} isAdmin={false} initSidoValue={"11"}/> <ListDiv> <LoadingOverlay isLoading={isLoading} /> <div className="h-full w-full overflow-x-scroll"> diff --git a/apps/fo/app/pages/(with-layout)/rdi/page.tsx b/apps/fo/app/pages/(with-layout)/rdi/page.tsx index 72373f60f..2657dc647 100644 --- a/apps/fo/app/pages/(with-layout)/rdi/page.tsx +++ b/apps/fo/app/pages/(with-layout)/rdi/page.tsx @@ -87,6 +87,7 @@ export default function Rdi() { // 엑셀 다운로드 트리거 const [isInitExcelDownload, setIsInitExcelDownload] = useState<boolean>(false); + const [initTrigger, setInitTrigger] = useState<boolean>(false); /** * 페이지 함수 */ @@ -107,19 +108,10 @@ export default function Rdi() { input.value = ""; } } - searchRdiList(1, 10, selectSearchYear[0]?.val || "0"); + ref.current.sidoValue = "11"; + searchRdi(ref.current, 1, 10); } - /** - * useEffect - */ - useEffect(() => { - if (!isInit) { - initializeCommonData(); - searchRdiList(1, 10, selectSearchYear[0]?.val || "0"); - } - }, [isInit, initializeCommonData, searchRdiList, selectSearchYear]); - useEffect(() => { if(!isInitExcelDownload) return ; if (excelList && excelList.length > 0) { @@ -153,13 +145,25 @@ export default function Rdi() { partStr = envPartValue !== '0' ? envPartValue:partValue; break; } - if (partStr.length > 1 || fcltCpct !== '0' || operationValue!== '0' ||nameCd ||(fcltyName.trim() !== "" && fcltyName.trim() !== null)) { - searchRdiList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); - } else { + + if(partStr === 'G'){ searchRdiList(pageNo, pageCnt, searchYear); + }else{ + searchRdiList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined); + } }, [operationValue, fcltyName, searchRdiList, searchYear, fcltCpct]); + /** + * useEffect + */ + useEffect(() => { + if (!isInit) { + initializeCommonData(); + searchRdi(ref.current, 1, 10); + } + }, [isInit, initializeCommonData, searchRdiList, selectSearchYear, searchRdi]); + const chkVal = useCallback((returntype:ReturnType) => { setWidthSize(returntype.partValue=='A' ?"w-[130%]":"w-[150%]") setUpheadList(returntype.partValue == 'R' ? upHeadList2 : returntype.partValue == 'G'?upHeadList3:upHeadList1); @@ -203,7 +207,7 @@ export default function Rdi() { queryClick={chkVal} excelClick={excelDownload} initClick={resetVal} - ref={ref} isAdmin={false} /> + ref={ref} isAdmin={false} initSidoValue={"11"}/> <ListDiv> <LoadingOverlay isLoading={isLoading} /> <div className="h-full w-full overflow-x-scroll"> diff --git a/apps/fo/app/store/flowRate/index.tsx b/apps/fo/app/store/flowRate/index.tsx index ff406f7d4..66d639fb8 100644 --- a/apps/fo/app/store/flowRate/index.tsx +++ b/apps/fo/app/store/flowRate/index.tsx @@ -174,7 +174,6 @@ const fetchFlowRateList = async (pageNo: number, pageSize: number, searchYear: s try { const tailStr = partCd ? '/'+ partCd + '/' + nameCd + '/' + fcltCpct + '/' + operationValue + (fcltyNm && fcltyNm !== '' ? '/' + fcltyNm : '') : ''; const url = '/fclt/flow/' + pageNo + '/' + pageSize + '/' + searchYear + tailStr; - console.log(url); const res = await getFetch('fo', url); return { data: res.data, count: res.count } } catch (error) { diff --git a/apps/fo/app/store/planSewage/index.tsx b/apps/fo/app/store/planSewage/index.tsx index 80a4d66e7..44ab12440 100644 --- a/apps/fo/app/store/planSewage/index.tsx +++ b/apps/fo/app/store/planSewage/index.tsx @@ -96,7 +96,6 @@ const planSewageList:PlanSewageProps[] = [ const fetchPlanSewageList = async (pageNo: number, pageSize: number, searchYear: string, partCd?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => { const tailStr = partCd ? '/'+ partCd + '/' + (nameCd || '0') + '/' + (fcltCpct || '0') + '/' + (operationValue || '0') +'/0'+ (fcltyNm && fcltyNm !== '' ? '/' + fcltyNm : '') : ''; const url = '/prcsFclt/info/plan/' + pageNo + '/' + pageSize + '/' + searchYear + tailStr; - console.log(url); const res = await getFetch('fo', url); return { data: res.data, count: res.count } } diff --git a/apps/fo/app/store/processArea/index.tsx b/apps/fo/app/store/processArea/index.tsx index f108e263e..8a8b3075e 100644 --- a/apps/fo/app/store/processArea/index.tsx +++ b/apps/fo/app/store/processArea/index.tsx @@ -2,7 +2,6 @@ import { postFetch } from "@/app/components/api"; import DataForm from "@/app/components/common/DataForm"; import { fetchPlanInfo } from "../common"; import type { TableUpperProps } from "../dashboard"; -import { fetchFacilityListArea } from "../processFacility"; export type { TableUpperProps }; /**==================================== * Store - 타입 @@ -14,11 +13,12 @@ export type { TableUpperProps }; // 처리구역 리스트 export type ProcessAreaProps = { swtrmtFcltCd : string, - sido : string, - gugun : string, + ctpvNm?: string, + sggNm?: string, swtrmtFcltNm : string, location : string, fctCpc : number | '', + fcltCpctSum : number | '', ruse : boolean, planYrDt4 : string, planYr : string, @@ -130,8 +130,8 @@ const ProcessFacilityLabelArray:string[] = ['구분', '시도', '시군구','용 // 리스트 헤더(행정별) const upHeadList1:TableUpperProps[] = [ { id: "A", title: "행정구역", colSpan:2, rowSpan:2, row:0 }, - { id: "sido", title: "시도", upName:"upChangeRe", row:2, widthPercent:4 }, - { id: "sigungo", title: "시군구", upName:"upChangeRe", row:2, widthPercent:4 }, + { id: "ctpvNm", title: "시도", upName:"upChangeRe", row:2, widthPercent:4 }, + { id: "sggNm", title: "시군구", upName:"upChangeRe", row:2, widthPercent:4 }, { id: "swtrmtFcltNm", title: "시설명", rowSpan:3, row:0, widthPercent: 8 }, { id: "location", title: "주소", rowSpan:3, row:0 }, { id: "fctCpc", title: "시설용량(m³/일)", align:"right", rowSpan:3, row:0, widthPercent: 5 }, @@ -216,7 +216,7 @@ const gridListProcessAreaPlan:ProcessAreaPlanProps[] = [ * Store - API =====================================*/ // 시설 상세 정보 조회 API -const fetchFacilityDetailInfo = async (swtrmtFcltCd: string) => { +/* const fetchFacilityDetailInfo = async (swtrmtFcltCd: string) => { try { const tailUrl = '/1/5/A/0/0/0/SW'; const res = await postFetch('fo', '/prcsFclt/ruseInfo'+tailUrl, [swtrmtFcltCd]); @@ -225,10 +225,20 @@ const fetchFacilityDetailInfo = async (swtrmtFcltCd: string) => { console.error('시설정보 데이터를 가져오는데 실패했습니다:', error); return {data: [], count: 0}; } +}; */ + +const fetchFacilityDetailInfo = async (pageNo:number, pageSize:number, swtrmtFcltCd: string[]) : Promise<{data:any[], count:number}> => { + try { + const res = await postFetch('fo', '/prcsFclt/ruseInfo/'+pageNo+'/'+pageSize, swtrmtFcltCd); + return {data: res.data, count:res.count}; + } catch (error) { + console.error('시설정보 데이터를 가져오는데 실패했습니다:', error); + return {data:[], count:0}; + } }; // 시설정보 리스트 데이터 호출(구분 선택 후 시설명 있을 경우) -const fetchProcessAreaList = async (pageNo : number, pageSize : number, ctpvNm : string | undefined, sggNm : string | undefined, targetYear : string | undefined, set : (fn: (state: ProcessAreaType) => ProcessAreaType) => void): Promise<{data:ProcessAreaProps[], count:number}> => { +const fetchProcessAreaList = async (pageNo : number, pageSize : number, ctpvNm : string | undefined, sggNm : string | undefined, targetYear : string | undefined, set : (fn: (state: ProcessAreaType) => ProcessAreaType) => void): Promise<{data:any[], count:number}> => { try { const res = await fetchPlanInfo(targetYear, ctpvNm, sggNm, undefined); if(res && res.length > 0){ @@ -262,21 +272,27 @@ const fetchProcessAreaList = async (pageNo : number, pageSize : number, ctpvNm : head.title = '기승인\n4단계'; } }); - const res = await fetchFacilityDetailInfo(item.swtrmtFcltCd); - const detailInfo = res.data.filter((item:ProcessAreaProps) => item.ruse === true); - return { - ...item, - sido: detailInfo.length > 0 ? detailInfo[0].sido||'' : '', - sigungo: detailInfo.length > 0 ? detailInfo[0].gugun||'' : '', - location: detailInfo.length > 0 ? detailInfo[0].addr||'' : '', - fctCpc: detailInfo.length > 0 ? detailInfo[0].fctCpc||'' : 0, - trtDstr: detailInfo.length > 0 ? detailInfo[0].trtDstr||'' : '', - }; + return item; }) ); + const startIndex = (pageNo - 1) * pageSize; const endIndex = startIndex + pageSize; const paginatedData = enrichedData.slice(startIndex, endIndex); + + const fcltyCdList : string[]= []; + paginatedData.forEach(item => { + fcltyCdList.push(item.swtrmtFcltCd); + }) + + const detailFcltylist = await fetchFacilityDetailInfo(1, pageSize, fcltyCdList); + paginatedData.forEach(item => { + const filterdData = detailFcltylist.data.filter(fItem=>fItem.bscFctCd === item.swtrmtFcltCd)[0] || null; + item.fcltCpctSum = filterdData ? filterdData.fctCpc : ''; + item.location = filterdData ? filterdData.addr : ''; + item.ctpvNm = filterdData ? filterdData.sido : ''; + item.sggNm = filterdData ? filterdData.gugun : ''; + }); return {data: paginatedData, count: enrichedData.length}; }else{ return {data: [], count: 0}; @@ -376,6 +392,7 @@ export const processAreaReducer:(set:SetStateFunction)=>ProcessAreaActions=(set: })); const res = await fetchProcessAreaList(pageNo, pageSize, ctpvNm, sggNm, targetYear, set); res.data.forEach((item:ProcessAreaProps) => { + item.fctCpc = item.fcltCpctSum; DataForm({ type: 'float1', column: 'fctCpc', item:item as unknown as Record<string, unknown>}); }) const excelDownList: ExcelType[] = []; diff --git a/packages/common/business_components/src/ui/search_base_form/index.tsx b/packages/common/business_components/src/ui/search_base_form/index.tsx index f99963f14..82798db0b 100644 --- a/packages/common/business_components/src/ui/search_base_form/index.tsx +++ b/packages/common/business_components/src/ui/search_base_form/index.tsx @@ -25,6 +25,7 @@ type SearchBaseType = { leftClassName?: string; leftSelectClassName?: string; buttonOrder?: ("query" | "init" | "excel")[]; + initSidoValue?: string | ''; } export type ReturnType = { partValue: string; @@ -57,10 +58,11 @@ function SearchBaseForm ({ rightClassName, leftClassName, leftSelectClassName, - buttonOrder + buttonOrder, + initSidoValue='', }: SearchBaseType) { const [partValue, setPartValue] = useState<string>("A"); - const [sidoValue, setSidoValue] = useState<string>("0"); + const [sidoValue, setSidoValue] = useState<string>(initSidoValue?initSidoValue:"0"); const [sigunValue, setSigunValue] = useState<string>("0"); const [sidoText, setSidoText] = useState<string>(""); const [sigunText, setSigunText] = useState<string>(""); @@ -94,7 +96,7 @@ function SearchBaseForm ({ } }; const queryVal = () => { - console.log("조회버튼 클릭"); + console.log("조회버튼 클릭",); queryClick({ partValue: partValue, sidoValue: sidoValue, @@ -108,11 +110,18 @@ function SearchBaseForm ({ }); } const initVal = useCallback(() => { + if(initSidoValue){ + setSidoValue(initSidoValue); + } setResetTrigger(true); initClick(); - }, [setResetTrigger, initClick]); + }, [initSidoValue, setResetTrigger, initClick]); useEffect(() => { if (resetTrigger) { + if(initSidoValue!=""){ + setSidoValue(initSidoValue); + } + setResetTrigger(false); } }, [resetTrigger]); @@ -167,6 +176,7 @@ function SearchBaseForm ({ isAdmin={isAdmin} leftClassName={leftClassName} leftSelectClassName={leftSelectClassName} + initSidoValue={initSidoValue} > {leftChildren} </SearchFormLeft> diff --git a/packages/common/business_components/src/ui/search_form_left/index.tsx b/packages/common/business_components/src/ui/search_form_left/index.tsx index a989995ed..cfd12c5c4 100644 --- a/packages/common/business_components/src/ui/search_form_left/index.tsx +++ b/packages/common/business_components/src/ui/search_form_left/index.tsx @@ -3,6 +3,7 @@ import React, { useEffect, useState } from 'react'; import type { SelectDataType } from '../search_input_select'; import { SelectBox } from '../select'; +import { text } from 'stream/consumers'; /** * 검색 폼 왼쪽 컴포넌트 타입 @@ -46,6 +47,7 @@ type SearchFormLeftProps = { isAdmin?: boolean; leftClassName?: string; leftSelectClassName?: string; + initSidoValue?: string; } export type EnvPartSelectDataType = SelectDataType & { @@ -58,11 +60,11 @@ const selectPartData:SelectDataType[] = [ { text: "환경청별", val: 'G' }, ]; -function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], selectSigunData = [], selectRegionData = [], selectUnitWaterShedData = [], selectMiddleRegionData = [], selectEnvPartData = [], setRtnPartValue, setRtnSidoValue, setRtnSidoText, setRtnSigunValue, setRtnSigunText, setRtnRegionValue, setRtnUnitWaterShedValue, setRtnMiddleRegionValue, setRtnEnvPartValue, setRtnEnvPartSidoValue, setRtnEnvPartSigunValue, resetTrigger = false, isAdmin = false, leftClassName, leftSelectClassName }: SearchFormLeftProps) { +function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], selectSigunData = [], selectRegionData = [], selectUnitWaterShedData = [], selectMiddleRegionData = [], selectEnvPartData = [], setRtnPartValue, setRtnSidoValue, setRtnSidoText, setRtnSigunValue, setRtnSigunText, setRtnRegionValue, setRtnUnitWaterShedValue, setRtnMiddleRegionValue, setRtnEnvPartValue, setRtnEnvPartSidoValue, setRtnEnvPartSigunValue, resetTrigger = false, isAdmin = false, leftClassName, leftSelectClassName, initSidoValue }: SearchFormLeftProps) { /******************선택된 데이터******************/ const [partValue, setPartValue] = useState<string>('A'); //행정별 시도 시군구 - const [sidoValue, setSidoValue] = useState<string>('0'); + const [sidoValue, setSidoValue] = useState<string>(initSidoValue?initSidoValue : '0'); const [sigunValue, setSigunValue] = useState<string>('0'); const [sidoText, setSidoText] = useState<string>(''); const [sigunText, setSigunText] = useState<string>(''); @@ -85,6 +87,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel const [filteredEnvPartSidoData, setFilteredEnvPartSidoData] = useState<EnvPartSelectDataType[]>([{ text: "전체", val: '0', adstDliStrCd:'' }]); const [filteredEnvPartSigunData, setFilteredEnvPartSigunData] = useState<SelectDataType[]>([{ text: "전체", val: '0' }]); + const [initTrigger, setInitTrigger] = useState<boolean>(false); // 시군구 세팅 const initializeSigunData = (sidoCd: string) => { if (sidoCd === '0') { @@ -99,7 +102,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel setFilteredSigunData(newFilteredData); } } - + // 단위유역 세팅 const initializeUnitWaterShedData = (regionCd: string) => { if(regionCd === '0') { @@ -159,6 +162,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel } const onSelectValue = (val: string, type: string) => { + setInitTrigger(true); let selectedSido; let selectedSigun; let selectedEnvPartSido; @@ -272,7 +276,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel // 리셋 함수 const resetAllValues = () => { setPartValue('A'); - setSidoValue('0'); + setSidoValue(initSidoValue?initSidoValue:'0'); setSigunValue('0'); setRegionValue('0'); setUnitWaterShedValue('0'); @@ -287,7 +291,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel setFilteredEnvPartSigunData([{ text: "전체", val: '0' }]); if (setRtnPartValue) setRtnPartValue('A'); - if (setRtnSidoValue) setRtnSidoValue('0'); + if (setRtnSidoValue) setRtnSidoValue(initSidoValue?initSidoValue:'0'); if (setRtnSigunValue) setRtnSigunValue('0'); if (setRtnRegionValue) setRtnRegionValue('0'); if (setRtnUnitWaterShedValue) setRtnUnitWaterShedValue('0'); @@ -304,6 +308,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel // 리셋 후 트리거를 false로 설정 if (setRtnPartValue) { setRtnPartValue('A'); + setInitTrigger(false); } } }, [resetTrigger]); @@ -327,7 +332,12 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel ) : ( <> <SelectBox className={leftSelectClassName?leftSelectClassName:`col-span-3`} label={'시도'} selectArray={selectSidoData} onSelectValue={(val) => onSelectValue(val.toString(), 'sido')} value={sidoValue} selectClass={undefined}/> - <SelectBox className={leftSelectClassName?leftSelectClassName:`col-span-3`} label={'시군구'} selectArray={filteredSigunData} onSelectValue={(val) => onSelectValue(val.toString(), 'sigun')} value={sigunValue} selectClass={undefined}/> + <SelectBox className={leftSelectClassName?leftSelectClassName:`col-span-3`} label={'시군구'} selectArray={initSidoValue&&!initTrigger?[ + { text: '전체', val: '0' }, + ...selectSigunData.filter( + (item) => String(item.val).slice(0, 2) === String(initSidoValue) + ), + ]:filteredSigunData} onSelectValue={(val) => onSelectValue(val.toString(), 'sigun')} value={sigunValue} selectClass={undefined}/> </> )} {children}