diff --git a/apps/wr/app/matMng/coMng/ldrmntCoSttn/page.tsx b/apps/wr/app/matMng/coMng/ldrmntCoSttn/page.tsx index eb43b29bf..5ce69d508 100644 --- a/apps/wr/app/matMng/coMng/ldrmntCoSttn/page.tsx +++ b/apps/wr/app/matMng/coMng/ldrmntCoSttn/page.tsx @@ -3,11 +3,10 @@ import { useWrStore } from "@/app/store"; import { btnClass } from "@/app/store/common/code"; import { type customLdrmnt } from "@/app/store/matDmd/ldrmntCoSttn"; -import { ldrmntHeadListExport, ldrmntNodeListExport } from "@/app/store/matDmd/ldrmntCoSttn/headList"; +import { ldrmntHeadListExport } from "@/app/store/matDmd/ldrmntCoSttn/headList"; import { excelDownload, getCity, - getCityOrSgg, tableData } from "@/components/lib/func/commom"; import CoRegExcel from "@/components/ui/modal/coReg/coRegExcel/coRegExcelModal"; @@ -24,54 +23,74 @@ import { Title, UiModal, UiTable, - type ReturnType, type SelectDataType } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button } from "@common/components/ui"; -import { useCallback, useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; +import { Toaster } from "react-hot-toast"; export default function LdrmntCoSttn() { const { code, ldrmnt, ldrmntInit, ldrmntSearch, } = useWrStore( (state) => state ); - const { ldrmntRes, excelList } = ldrmnt; + const { ldrmntRes, excelList, ldrmntResCount } = ldrmnt; const [detailModal, setDetailModal] = useState<{ isOpen: boolean, data: customLdrmnt | undefined }>({ data: undefined, isOpen: false }) const [pageNation, setPageNation] = useState(1); const [selectSgg, setSelectSgg] = useState() const [objSearch, setObjSearch] = useState({ sgg: "", city: "" }); const [bdstTable, setBdstTable] = useState(); const [searchTxt, setSearchTxt] = useState(); - const ref = useRef({} as ReturnType); const [excelData, setExcelData] = useState(); - const [isExcelDownload, setIsExcelDownload] = useState(false); + // const [isExcelDownload, setIsExcelDownload] = useState(false); const excelClick = useCallback(() => { excelDownload( [[]], - "잠재수요처 관리", + "잠재수요처 등록양식", "sample_ldrmntCoSttn.xlsx", "A1:AL1", 2 ); }, []); - const excelDownloadClick = () => { - ldrmntSearch(1, "10000", "0", ""); - setIsExcelDownload(true); - } + const computeCityNm = () => { + let cityTxt = ""; + let sggTxt = ""; + + if (objSearch.city) { + cityTxt = + code.cityCd.find((c) => c.val === objSearch.city)?.text || ""; + } + if (objSearch.sgg) { + sggTxt = + code.sggCd.find((s) => s.val === objSearch.sgg)?.text || ""; + } + + if (cityTxt === "" || cityTxt === "전체") cityTxt = "0"; + + return sggTxt && sggTxt !== "0" + ? `${cityTxt} ${sggTxt}` + : cityTxt; + }; + + const excelDownloadClick = useCallback(() => { + const cityNm = computeCityNm(); + ldrmntSearch(true, pageNation, String(ldrmntResCount), cityNm, searchTxt || ""); + // setIsExcelDownload(true); + }, [objSearch, pageNation, searchTxt, code, ldrmntSearch, computeCityNm, ldrmntResCount]); useEffect(() => { - if (isExcelDownload && excelData && excelData.length > 0) { + if (/*isExcelDownload &&*/ excelData && excelData.length > 0) { downloadExcel({ data: excelData, fileName: "잠재수요처 관리", sheetNameArray: ["Sheet1"], headerRange: "A1:F1" }); - setIsExcelDownload(false); + // setIsExcelDownload(false); } - }, [excelData, isExcelDownload]); + }, [excelData, /*isExcelDownload*/]); const [isExcelOpen, setIsExcelOpen] = useState<{ isModal: boolean; @@ -141,33 +160,8 @@ export default function LdrmntCoSttn() { }, [excelList]) useEffect(() => { - let cityTxt = '' - let sggTxt = '' - - if (objSearch?.city.toString().length > 0) { - cityTxt = code.cityCd.find((item) => item.val === objSearch?.city)?.text ?? ''; - } - - if (objSearch?.sgg.toString().length > 1) { - sggTxt = code.sggCd.find((item) => item.val === objSearch?.sgg)?.text ?? ''; - } - - if (cityTxt === '전체' || cityTxt === '') { - cityTxt = '0' - } - - let cityNm = "" - - if (sggTxt !== "0") { - cityNm = cityTxt + " " + sggTxt - } else { - cityNm = cityTxt - } - if (cityNm) { - ldrmntSearch(pageNation, '20', cityNm, searchTxt || ""); - } else { - ldrmntSearch(pageNation, '20', '0', searchTxt || ""); - } + const cityNm = computeCityNm(); + ldrmntSearch(false, pageNation, '20', cityNm, searchTxt || ""); }, [pageNation]); return ( @@ -210,32 +204,8 @@ export default function LdrmntCoSttn() { - + {formWatch && formWatch[0]?.pbnstRuseFcltPk ? ( + + + + 시설정보 + + + 차수별정보 + + + + - - ) : ( - <> + + + + ) : ( + <>
- 등록된 재이용시설 정보가 없습니다. + 등록된 재이용시설 정보가 없습니다.
-
-

- 신규등록 버튼을 클릭하여 재이용시설을 등록해주세요. -

- -
- + + - )} - + )} } bodyClass="w-[68vw] max-w-none h-[90vh]" diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx index b943e8b4f..344234af5 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/htdflSttn/page.tsx @@ -39,7 +39,7 @@ export default function HtdflSttn() { const { code, htdflSttn, htdflSttnSearch, initHtdfl } = useWrStore( (state) => state ); - const { htdflSttnRes } = htdflSttn; + const { htdflSttnRes, htdflSttnResCount } = htdflSttn; const ref = useRef({} as ReturnType); @@ -61,8 +61,8 @@ export default function HtdflSttn() { const excelClick = useCallback(() => { // 최신 검색 조건 반영 const con = getConValue(); - htdflSttnSearch(true, 1, "20", String(con), fcltNm, code.cityCd, code.sggCd); - }, [htdflSttnSearch, objSearch, code.cityCd, code.sggCd]); + htdflSttnSearch(true, pageNation, String(htdflSttnResCount), String(con), fcltNm, code.cityCd, code.sggCd); + }, [htdflSttnSearch, objSearch, code.cityCd, code.sggCd, pageNation, fcltNm, htdflSttnResCount]); useEffect(() => { htdflSttnSearch(false, pageNation, "20", String(getConValue()), fcltNm, code.cityCd, code.sggCd); @@ -120,7 +120,7 @@ export default function HtdflSttn() { useEffect(() => { if (!htdflSttn.isInit) { - initHtdfl(1, "20", "0", fcltNm, code.cityCd, code.sggCd); + initHtdfl(false, 1, "20", "0", fcltNm, code.cityCd, code.sggCd); } }, [htdflSttn.isInit, initHtdfl]); @@ -152,7 +152,10 @@ export default function HtdflSttn() { label="시도" selectClass={""} selectArray={code.cityCd} - onSelectValue={getSelCity} + onSelectValue={(val) => { + getSelCity(val) + setPageNation(1) + }} /> { + getSgg(val) + setPageNation(1) + }} />