From 858a2c0bacf92ce98b25a9ad83d4d9ed51225273 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 16 Sep 2025 17:22:33 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=BC=EC=9E=AC=EC=9D=B4=EC=9A=A9=20?= =?UTF-8?q?=EC=95=84=EC=9D=B4=EB=94=94=EB=B3=84=20=EC=A7=80=EC=9E=90?= =?UTF-8?q?=EC=B2=B4=20=EC=BD=94=EB=93=9C=20=EC=A0=81=EC=9A=A9=20=EC=8B=A4?= =?UTF-8?q?=EC=A0=81=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/page.tsx | 38 +-- .../ruseFcltMng/prfmncReg/chkgdnReg/page.tsx | 52 ++-- .../prfmncReg/pbnstPrfmncReg/page.tsx | 225 ++++++++++-------- .../prfmncReg/chkgdnReg/rainChkgdn/index.tsx | 8 +- .../prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx | 8 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 200 ++++++---------- 6 files changed, 261 insertions(+), 270 deletions(-) diff --git a/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 219d5cfbe..b5b3f37f9 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -12,7 +12,7 @@ import { import { Button } from "@common/components"; import { useWrStore } from "../../../../store"; import { Tabs, TabsList, TabsTrigger, TabsContent } from "@common/components"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import ListDiv from "@common/business_components/ui/list_div"; import { confirmToast, tableData } from "@/components/lib/func/commom"; import type { @@ -47,21 +47,22 @@ export default function PublicReuseFaciltyInsert() { pbnstRuseFcltUpdate, pubHasuSearch, pbnstRuseBizUpdate, + getLaeSeCdCheck, } = useWrStore((state) => state); const { t } = useTranslation("base"); const { pubFacHeadList, pbnstHasuResCount, pbnstHasuRes, pbnstRes } = pbnst; - const { regAuthrtYn, mdfcnAuthrtYn } = auth; + const { regAuthrtYn, mdfcnAuthrtYn, laeSeCd } = auth; const [, setCurrentTab] = useState("mng"); const [isRuseReg, setIsRuseReg] = useState<{ isModal: boolean; }>({ isModal: false }); - const [resetPage, isResetPage] = useState(false); const [indexMng, setIndexMng] = useState(0); const [indexBiz, setIndexBiz] = useState(0); const [searchTxt, setSearchTxt] = useState(); const [bdstTable, setbdstTable] = useState(); const [selectRow, setSelectRow] = useState(); + const [resetPage, isResetPage] = useState(false); const [pageNation, setPageNation] = useState(1); const form = useForm<{ @@ -83,17 +84,20 @@ export default function PublicReuseFaciltyInsert() { }); const formWatch = form.watch("items"); + const useInitRef = useRef(false); + useEffect(() => { - if (!pbnst.isInit) { - pubHasuInit("1", "41"); + getLaeSeCdCheck(); + useInitRef.current = true; + }, []); + + useEffect(() => { + if (useInitRef.current == true && laeSeCd !== undefined) { + pubHasuInit("1", laeSeCd); } - }, [pbnst.isInit, pubHasuInit]); + }, [useInitRef.current, laeSeCd]); const onSubmit = async (valuse: { items: PbnstRegArrrayType }) => { - // if (!isDirty) { - // toast.error("변경사항이 없습니다."); // 변경사항이 없으면 메시지 표시 - // return; - // } const data = writeRgtrAndMdfr(valuse.items); let bizs = [] as fcBizType[]; data.forEach((fclt) => { @@ -133,7 +137,7 @@ export default function PublicReuseFaciltyInsert() { message += "하수재이용 시설 사업 "; } toast.error(message + "오류 입니다 "); - pubHasuInit("1", "41"); + pubHasuInit("1", laeSeCd); } }); }; @@ -220,7 +224,7 @@ export default function PublicReuseFaciltyInsert() { setSelectRow(pbnstHasuRes?.[val]); if (selectRow) { pbnstRegClick(selectRow); - setIndexMng(0) + setIndexMng(0); } else { console.error("선택된 행이 없습니다."); } @@ -237,7 +241,6 @@ export default function PublicReuseFaciltyInsert() { }, [indexMng]); useEffect(() => { - if (pbnst.pbnstRes && pbnst.pbnstRes?.length > 0) { form.reset({ items: pbnst.pbnstRes }); } else { @@ -263,7 +266,7 @@ export default function PublicReuseFaciltyInsert() { }, [pbnstRes, append, selectRow]); useEffect(() => { - pubHasuInit(String(pageNation), "41"); + pubHasuInit(String(pageNation), laeSeCd); isResetPage(false); }, [pageNation, pubHasuInit]); @@ -289,13 +292,12 @@ export default function PublicReuseFaciltyInsert() { size={"sm"} onClick={() => { if (searchTxt && searchTxt?.length > 0) { - pubHasuSearch(String(pageNation), "41", searchTxt); + pubHasuSearch(String(pageNation), laeSeCd, searchTxt); } else { - pubHasuInit(String(pageNation), "41"); + pubHasuInit(String(pageNation), laeSeCd); } isResetPage(true); }} - > 조회 @@ -428,7 +430,7 @@ export default function PublicReuseFaciltyInsert() { } }} onInvalid={onInvalid} - newIndexMng={(formWatch?.length -1)} + newIndexMng={formWatch?.length - 1} > } bodyClass="w-[68vw] max-w-none h-[90vh]" diff --git a/apps/wr/app/(with-layout)/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx index 97d80a7a8..06003462f 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx @@ -2,7 +2,6 @@ import { useWrStore } from "@/app/store"; import { - commonCd, rainPageSize, type rainChkZodType, } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; @@ -38,7 +37,7 @@ import { TooltipProvider, TooltipTrigger, } from "@common/components/ui/tooltip"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import toast, { Toaster } from "react-hot-toast"; import { useTranslation } from "react-i18next"; @@ -62,10 +61,11 @@ export default function Page() { rswtChkDelete, rswtrChkExcelDownload, rswtChkHeadChange, + getLaeSeCdCheck } = useWrStore((state) => { return state; }); - const { regAuthrtYn, mdfcnAuthrtYn, delAuthrtYn } = auth; + const { regAuthrtYn, mdfcnAuthrtYn, delAuthrtYn,laeSeCd } = auth; const [isRegExcel, setIsRegExcel] = useState(false); const [updateRainDetail, setUpdateRainDetail] = useState( [] @@ -85,6 +85,17 @@ export default function Page() { const [searchYear, setSearchYear] = useState( String(new Date().getFullYear()) ); + + const useInitRef = useRef(false); + + + useEffect(() => { + getLaeSeCdCheck(); + useInitRef.current = true; + }, []); + + + const cellClick = () => { if (searchYear) if (selFcltDiv === "RNB") { @@ -93,12 +104,12 @@ export default function Page() { rainPageNation, rainPageSize, searchYear, - commonCd, + laeSeCd, fcltNm ); setRainPageNation(1); } else { - rainChkInit(rainPageNation, rainPageSize, searchYear, commonCd); + rainChkInit(rainPageNation, rainPageSize, searchYear, laeSeCd); } } else { if (fcltNm) { @@ -106,12 +117,12 @@ export default function Page() { rainPageNation, rainPageSize, searchYear, - commonCd, + laeSeCd, fcltNm ); setRswtPageNation(1); } else { - rswtChkgdnInit(rswtPageNation, rswtPageSize, searchYear, commonCd); + rswtChkgdnInit(rswtPageNation, rswtPageSize, searchYear, laeSeCd); } } }; @@ -123,11 +134,11 @@ export default function Page() { pageNo, rainPageSize, searchYear, - commonCd, + laeSeCd, fcltNm ); } else { - rainChkInit(pageNo, rainPageSize, searchYear, commonCd); + rainChkInit(pageNo, rainPageSize, searchYear, laeSeCd); } } }; @@ -139,41 +150,43 @@ export default function Page() { pageNo, rainPageSize, searchYear, - commonCd, + laeSeCd, fcltNm ); } else { - rswtChkgdnInit(pageNo, rswtPageSize, searchYear, commonCd); + rswtChkgdnInit(pageNo, rswtPageSize, searchYear, laeSeCd); } } }; + + useEffect(() => { - if (!rainChkgdn.isInit) { + if (useInitRef.current == true && laeSeCd !== undefined&& !rainChkgdn.isInit) { rainChkInit( 1, rainPageSize, new Date().getFullYear().toString(), - commonCd + laeSeCd ); isRainSttn(false); setIsModal({ data: {}, open: false }); setIsRegExcel(false); } - }, [rainChkgdn.isInit, rainChkInit, rainPageSize]); + }, [rainChkgdn.isInit, rainChkInit, rainPageSize,laeSeCd]); useEffect(() => { - if (!rswtChkgdn.isInit) { + if (useInitRef.current == true && laeSeCd !== undefined&&!rswtChkgdn.isInit) { rswtChkgdnInit( 1, rswtPageSize, new Date().getFullYear().toString(), - commonCd + laeSeCd ); setIsModal({ data: {}, open: false }); setIsRegExcel(false); } - }, [rswtChkgdn.isInit, rswtChkgdnInit, rswtPageSize]); + }, [rswtChkgdn.isInit, rswtChkgdnInit, rswtPageSize,laeSeCd]); useEffect(() => { if (rswtChkgdn.excelList[0] && rswtChkgdn.excelList[0]?.data.length > 1) { @@ -197,9 +210,9 @@ export default function Page() { const excelClick = useCallback(() => { if (selFcltDiv === "RNB") { - rainChkExcelDownload(code.cityCd, code.sggCd); + rainChkExcelDownload(code.cityCd, code.sggCd,laeSeCd); } else { - rswtrChkExcelDownload(code.cityCd, code.sggCd); + rswtrChkExcelDownload(code.cityCd, code.sggCd,laeSeCd); } }, [ rainChkExcelDownload, @@ -207,6 +220,7 @@ export default function Page() { code.cityCd, code.sggCd, selFcltDiv, + laeSeCd ]); const handleClick = useCallback( diff --git a/apps/wr/app/(with-layout)/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index 4fd866d75..bedb71815 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -9,7 +9,11 @@ import { type FcPrfType, type PrfType, } from "@/app/store/prfmncReg/pbnstPrfmncReg/type"; -import { confirmToast, excelDownload, yearOptions } from "@/components/lib/func/commom"; +import { + confirmToast, + excelDownload, + yearOptions, +} from "@/components/lib/func/commom"; import { InputTableBody } from "@/components/lib/func/TableData"; import PbnPrfExcelModal from "@/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal"; import { @@ -32,17 +36,29 @@ import { TableBody, TableHeader, } from "@common/components/ui"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import toast, { Toaster } from "react-hot-toast"; import { useTranslation } from "react-i18next"; import { headMakeprfmnc } from "../chkgdnReg/TableHead"; export default function PrfmncPrfmncReg() { - const { auth, prfmnc, prfmncHasuInit, prfmnRegData, prfmncHasuNmSearch,getPrfFmcRes } = useWrStore( - (state) => state - ); - const { prfPbnFclts, pbnstPrfmncHeadList, monthHeadList, prfmncRes, prfmncResCount } = prfmnc; - const { regAuthrtYn, mdfcnAuthrtYn } = auth; + const { + auth, + prfmnc, + prfmncHasuInit, + prfmnRegData, + prfmncHasuNmSearch, + getPrfFmcRes, + getLaeSeCdCheck, + } = useWrStore((state) => state); + const { + prfPbnFclts, + pbnstPrfmncHeadList, + monthHeadList, + prfmncRes, + prfmncResCount, + } = prfmnc; + const { regAuthrtYn, mdfcnAuthrtYn, laeSeCd } = auth; const [isReset, setIsReset] = useState(false); const [bdstTable, setbdstTable] = useState(); const [searchTxt, setSearchTxt] = useState(); @@ -57,6 +73,8 @@ export default function PrfmncPrfmncReg() { String(new Date().getFullYear()) ); + const useInitRef = useRef(false); + const excelClick = useCallback(() => { excelDownload( [[]], @@ -66,26 +84,26 @@ export default function PrfmncPrfmncReg() { ); }, [prfmnc.excelList]); - const { t } = useTranslation('base'); + const { t } = useTranslation("base"); const onSave = useCallback(() => { const handleConfirm = async () => { if (!pbnstRuseFcltId) return; prfmnRegData( 1, - '41', + laeSeCd, excelToPbnPrfData( inputData as unknown as JSON[], searchYear, pbnstRuseFcltId - ) as unknown as PrfType - , searchYear, + ) as unknown as PrfType, + searchYear, prfPbnFclts ); }; - confirmToast(t('isUpdateMsg'), handleConfirm); - }, [inputData, searchYear, pbnstRuseFcltId, cellNum,prfPbnFclts]); + confirmToast(t("isUpdateMsg"), handleConfirm); + }, [inputData, searchYear, pbnstRuseFcltId, cellNum, prfPbnFclts]); const cellClick = useCallback( (index: number | undefined) => { @@ -112,89 +130,90 @@ export default function PrfmncPrfmncReg() { }; if (prfmncRes[index]?.prfList) { prfmncRes[index].prfList?.forEach((prfItem) => { - const yr = Number(prfItem.ym?.slice(0, 4)); // "YYYY" + const yr = Number(prfItem.ym?.slice(0, 4)); // "YYYY" - if(yr === Number(searchYear)) { - const month = Number(prfItem?.ym?.slice(4)); // "MM" - const monthKey = `${month}월`; + if (yr === Number(searchYear)) { + const month = Number(prfItem?.ym?.slice(4)); // "MM" + const monthKey = `${month}월`; - inUsageData.forEach((inData: any) => { - const usageKey = inData.usage; - const value = (prfItem as any)[usageKey] ?? 0; + inUsageData.forEach((inData: any) => { + const usageKey = inData.usage; + const value = (prfItem as any)[usageKey] ?? 0; - inData[monthKey] = value; - inData.total += value; + inData[monthKey] = value; + inData.total += value; - if (inSubtotal && usageKey !== "subtotal") { - (inSubtotal as any)[monthKey] = - ((inSubtotal as any)[monthKey] ?? 0) + value; - inSubtotal.total += value; - } - }); + if (inSubtotal && usageKey !== "subtotal") { + (inSubtotal as any)[monthKey] = + ((inSubtotal as any)[monthKey] ?? 0) + value; + inSubtotal.total += value; + } + }); - outUsageData.forEach((outData: any) => { - const usageKey = outData.usage; - const value = (prfItem as any)[usageKey] ?? 0; + outUsageData.forEach((outData: any) => { + const usageKey = outData.usage; + const value = (prfItem as any)[usageKey] ?? 0; - outData[monthKey] = value; - outData.total += value; + outData[monthKey] = value; + outData.total += value; - if (usageKey !== "subtotal") { - (outSubtotal as any)[monthKey] = - ((outSubtotal as any)[monthKey] ?? 0) + value; - outSubtotal.total += value; - } - }); - } + if (usageKey !== "subtotal") { + (outSubtotal as any)[monthKey] = + ((outSubtotal as any)[monthKey] ?? 0) + value; + outSubtotal.total += value; + } + }); + } }); - if(inSubtotal.total!==0 && outSubtotal.total!==0) { + if (inSubtotal.total !== 0 && outSubtotal.total !== 0) { + inUsageData.push(inSubtotal); + outUsageData.push(outSubtotal); + const usageTotalObj: { [key: string]: any } = { + ...structuredClone(totalObj), + 구분: "총합계", + 용수명: "", + }; + for (const key in usageTotalObj) { + if (["usage", "gubun", "edit"].includes(key)) continue; + const val = + (Number((inSubtotal as any)[key]) || 0) + + (Number((outSubtotal as any)[key]) || 0); - inUsageData.push(inSubtotal); - outUsageData.push(outSubtotal); - const usageTotalObj: { [key: string]: any } = { - ...structuredClone(totalObj), - 구분: "총합계", - 용수명: "", - }; - for (const key in usageTotalObj) { - if (["usage", "gubun", "edit"].includes(key)) continue; - const val = - (Number((inSubtotal as any)[key]) || 0) + - (Number((outSubtotal as any)[key]) || 0); - - (usageTotalObj as any)[key] = val; + (usageTotalObj as any)[key] = val; + } + const tableData = [...inUsageData, ...outUsageData, usageTotalObj]; + setpbnstRuseFcltId(prfmncRes[index].pbnstRuseFcltId); + setInputData(tableData); + } else { + setInputData([]); } - const tableData = [...inUsageData, ...outUsageData, usageTotalObj]; - setpbnstRuseFcltId(prfmncRes[index].pbnstRuseFcltId); - setInputData(tableData); - }else{ - setInputData([]); - } } else { setInputData([]); } } }, - [prfmncRes,searchYear] + [prfmncRes, searchYear] ); - useEffect(() => { - if (!prfmnc.isInit) { - getPrfFmcRes() + getLaeSeCdCheck(); + useInitRef.current = true; + }, []); + useEffect(() => { + if (useInitRef.current == true && laeSeCd !== undefined) { + getPrfFmcRes(); + useInitRef.current = true; } - }, [prfmnc.isInit, getPrfFmcRes]); + }, [useInitRef.current, laeSeCd]); - - useEffect(() =>{ - const year = new Date().getFullYear() - prfmncHasuInit(1, '41',String(year) ,prfPbnFclts); - },[prfPbnFclts]) useEffect(() => { + const year = new Date().getFullYear(); + prfmncHasuInit(1, laeSeCd, String(year), prfPbnFclts); + }, [prfPbnFclts]); + useEffect(() => { if (prfmncRes && prfmncRes.length > 0) { - setbdstTable(prfmncRes); } @@ -244,11 +263,12 @@ export default function PrfmncPrfmncReg() {
- @@ -270,7 +290,7 @@ export default function PrfmncPrfmncReg() { setIsExcelOPen({ ...isExcelOpen, isModal: true }); } }} - disabled={regAuthrtYn === 'N'} + disabled={regAuthrtYn === "N"} > 파일등록 @@ -289,7 +309,7 @@ export default function PrfmncPrfmncReg() { { - if (searchTxt && searchTxt?.length > 0) { - prfmncHasuNmSearch(page, '41', searchYear, searchTxt,prfPbnFclts) - } else { - prfmncHasuInit(page, '41', searchYear,prfPbnFclts) - } - setIsReset(false); - }} - resetPageNo={isReset} + onPageChange={(page: number) => { + if (searchTxt && searchTxt?.length > 0) { + prfmncHasuNmSearch( + page, + laeSeCd, + searchYear, + searchTxt, + prfPbnFclts + ); + } else { + prfmncHasuInit(page, laeSeCd, searchYear, prfPbnFclts); + } + setIsReset(false); + }} + resetPageNo={isReset} /> @@ -324,8 +349,13 @@ export default function PrfmncPrfmncReg() { {headMakeprfmnc(monthHeadList, [])} - - {InputTableBody(inputData ?? [], monthHeadList, setInputData, mdfcnAuthrtYn === 'N' ? false : true)} + + {InputTableBody( + inputData ?? [], + monthHeadList, + setInputData, + mdfcnAuthrtYn === "N" ? false : true + )} @@ -338,17 +368,12 @@ export default function PrfmncPrfmncReg() { { - setIsExcelOPen({ ...isExcelOpen, isModal: open }) + setIsExcelOPen({ ...isExcelOpen, isModal: open }); }} setModalExcelData={async (excelData) => { - await prfmnRegData(1, '41', - excelData, - searchYear - ,prfPbnFclts - ); + await prfmnRegData(1, laeSeCd, excelData, searchYear, prfPbnFclts); // 데이터 저장 후 UI 업데이트는 useEffect가 감지하여 처리하므로 여기서는 호출하지 않습니다. - } - } + }} > } open={isExcelOpen.isModal} diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx index d2c8e18e1..e30606651 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx @@ -72,7 +72,8 @@ type rainChkgdnActions = { rainChkGuidUpdate(rainChk: rainChkZodType): Promise; rainChkExcelDownload( sidoCode: SelectDataType[], - sggCode: SelectDataType[] + sggCode: SelectDataType[], + sggCd:string ): Promise; rainChkExcelDataUPload(excelData: rainChkZodType[] ,year :string) : Promise; rainChkDelete(chkgdnSns: number[] ,year :string): Promise; @@ -151,12 +152,13 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( return { rainChkExcelDownload: async ( sidoCode: SelectDataType[], - sggCode: SelectDataType[] + sggCode: SelectDataType[], + sggCd: string, ) => { // 로그인한 아이디의 시도 or 시군구로 들어가야하는데 현재는 그냥 0으로 하드코딩 const data = await getFetch( fetchType.WR, - `/reuseFc/buildingFlg/${buildingType.RNB}/41` + `/reuseFc/buildingFlg/${buildingType.RNB}/${sggCd}` ); const excelList = buildingToExcelType(data, sidoCode, sggCode); set((state: rainChkgdnState) => ({ diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx index 23591ae42..e9ebdab8d 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx @@ -75,7 +75,8 @@ type rswtChkgdnActions = { ) => void; rswtrChkExcelDownload( sidoCode: SelectDataType[], - sggCode: SelectDataType[] + sggCode: SelectDataType[], + sggCd: string, ): Promise; rswtChkExceDataUpload: (excelData: rswtChkZodType[]) => void; rswtChkDelete: (chkgdnSns: number[] ,year:string) => void; @@ -154,11 +155,12 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = ( return { rswtrChkExcelDownload: async ( sidoCode: SelectDataType[], - sggCode: SelectDataType[] + sggCode: SelectDataType[], + sggCd: string, ) => { const data = await getFetch( fetchType.WR, - `/reuseFc/buildingFlg/${buildingType.RST}/41` + `/reuseFc/buildingFlg/${buildingType.RST}/${sggCd}` ); const excelList: any = []; const exceldata = rswtMakeExcelSample(data, sidoCode, sggCode); diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 423c3c113..e5a1f7da2 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -37,7 +37,6 @@ const fcOrgwtsHeadList = fcOrgwtsHeadListExport; export type pubFacState = { pbnst: { - isInit: boolean; pubFacHeadList: TableUpperProps[]; pbnstMngUpHeadList: TableUpperProps[]; pbnstMngNm: chHeadType[]; @@ -52,10 +51,10 @@ export type pubFacState = { fcOrgwtsHeadList: TableUpperProps[]; pbnstMngRegData: customPbnst[]; pbnsUpdateIndex: pbnstInsertIndex; - fcOrgwtsNmList:pubHasuType[]; + fcOrgwtsNmList: pubHasuType[]; dmdComList: any[]; - apiMessage:string; - pbnstHasuResCount:number + apiMessage: string; + pbnstHasuResCount: number; }; }; type pubFacActions = { @@ -63,19 +62,17 @@ type pubFacActions = { pbnstRegClick: (pubHasuRes: pubHasuType) => void; //pbnstReg: (txt: string | undefined) => void; pbnstInsert(pbnstRes: customPbnst): Promise; - appendRuseFclt(array: customPbnst[]): void; fileDelete: (atflCd: string) => void; fileDownLoad: (atflCd: string) => void; pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void; pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void; - pubHasuSearch :(page: string, sggOrCity: string , searchTxt:string) => void - getFcOrgwts: (fcltPkList: string[], size:number) => void; + pubHasuSearch: (page: string, sggOrCity: string, searchTxt: string) => void; + getFcOrgwts: (fcltPkList: string[], size: number) => void; }; export type pubFacType = pubFacState & pubFacActions; export const pubFacStateExport: pubFacState = { pbnst: { - isInit: false, pubFacHeadList: pubFacHeadList, pbnstMngUpHeadList: pbnstMngUpHeadList, pbnstMngNm: pbnstMngNm, @@ -90,10 +87,10 @@ export const pubFacStateExport: pubFacState = { pbnstBizCycle: [{ text: "없음", val: "1" }], pbnstMngRegData: [], pbnsUpdateIndex: {} as pbnstInsertIndex, - fcOrgwtsNmList:[], + fcOrgwtsNmList: [], dmdComList: [], - apiMessage:'', - pbnstHasuResCount:1 + apiMessage: "", + pbnstHasuResCount: 1, }, }; @@ -102,22 +99,20 @@ export const checkWrRegList = async () => { return wrRegList; }; -const hasuListFetch = async (page: string, sggOrCity: string, searchTxt?:string) => { +const hasuListFetch = async ( + page: string, + sggOrCity: string, + searchTxt?: string +) => { const checkWrRegListRes = await checkWrRegList(); -let url = `/prcsFclt/ruseInfo/${page ? page : 1}/11/A/${sggOrCity? sggOrCity : "11"}/0/1/SW`; + let url = `/prcsFclt/ruseInfo/${page ? page : 1}/11/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`; - -const data = checkWrRegListRes.filter((item:string) => item !== "") -if(searchTxt){ - url= url +`/${searchTxt}` - -} - const rainRes = await postFectch( - url, - data, - fetchType.COMMON - ); + const data = checkWrRegListRes.filter((item: string) => item !== ""); + if (searchTxt) { + url = url + `/${searchTxt}`; + } + const rainRes = await postFectch(url, data, fetchType.COMMON); const hasuList = rainRes.data.map((item: any) => { return { @@ -127,49 +122,46 @@ if(searchTxt){ }; }); - return {data: hasuList, count:rainRes.count}; + return { data: hasuList, count: rainRes.count }; }; -const initFetch = async (ruseFcltPk: string | undefined) => { +const initFetch = async (ruseFcltPk: string | undefined) => { const pbnstRes = await getFetch("wr", `/reuseFc/pubFc/${ruseFcltPk}`); return pbnstRes; }; export const writeRgtrAndMdfr = (data: customPbnst[]) => { - data.forEach((pbnst) => { pbnst.rgtr = TEST_UUID; pbnst.mdfr = TEST_UUID; - pbnst.fcBizs = pbnst.fcBizs?.map((item) => { - item.rgtr = TEST_UUID; - item.mdfr = TEST_UUID; - item.fcOrgwts = item.fcOrgwts?.map((orgwt) => { - orgwt.mdfr = TEST_UUID; - orgwt.rgtr = TEST_UUID; - return orgwt; - }); + pbnst.fcBizs = pbnst.fcBizs?.map((item) => { + item.rgtr = TEST_UUID; + item.mdfr = TEST_UUID; + item.fcOrgwts = item.fcOrgwts?.map((orgwt) => { + orgwt.mdfr = TEST_UUID; + orgwt.rgtr = TEST_UUID; + return orgwt; + }); - item.fcDemands = item.fcDemands?.map((dmd) => { - dmd.mdfr = TEST_UUID; - dmd.rgtr = TEST_UUID; - return dmd; + item.fcDemands = item.fcDemands?.map((dmd) => { + dmd.mdfr = TEST_UUID; + dmd.rgtr = TEST_UUID; + return dmd; + }); + return item; + }); + pbnst.fcOpers = pbnst?.fcOpers?.map((oper) => { + oper.rgtr = TEST_UUID; + oper.mdfr = TEST_UUID; + return oper; + }); + pbnst.fcFiles = pbnst.fcFiles?.map((file) => { + file.rgtr = TEST_UUID; + file.mdfr = TEST_UUID; + return file; }); - return item; }); - pbnst.fcOpers = pbnst?.fcOpers?.map((oper) => { - oper.rgtr = TEST_UUID; - oper.mdfr = TEST_UUID; - return oper; - }); - pbnst.fcFiles = pbnst.fcFiles?.map((file) => { - file.rgtr = TEST_UUID; - file.mdfr = TEST_UUID; - return file; - }); -}); - - return data; }; @@ -183,24 +175,26 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { pbnst: { ...state.pbnst, pbnstHasuRes: pbnstHasuRes.data, - pbnstHasuResCount:pbnstHasuRes.count, - isInit: false, + pbnstHasuResCount: pbnstHasuRes.count, }, })); } catch (errorHasu) { console.log(errorHasu); } - },pubHasuSearch : async(page: string, sggOrCity: string , searchTxt:string)=> { - - try{ - const pbnstHasuRes = await hasuListFetch(page, sggOrCity,searchTxt); + }, + pubHasuSearch: async ( + page: string, + sggOrCity: string, + searchTxt: string + ) => { + try { + const pbnstHasuRes = await hasuListFetch(page, sggOrCity, searchTxt); return set((state: pubFacState) => ({ ...state, pbnst: { ...state.pbnst, pbnstHasuRes: pbnstHasuRes.data, - pbnstHasuResCount:pbnstHasuRes.count, - isInit: false, + pbnstHasuResCount: pbnstHasuRes.count, }, })); } catch (errorHasu) { @@ -215,7 +209,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { pbnst: { ...state.pbnst, pbnstRes: pbnstRes, - isInit: false, }, })); } catch (errorHasu) { @@ -224,69 +217,40 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { }, pbnstInsert: async (pbnstRes: customPbnst) => { try { - - const response = await postFectch( - `/reuseFc/pubFc`, - pbnstRes - ); - if( response.status === 200) { - toast.success(`${pbnstRes.ruseUtztnFcltNm} 하수재이용 시설이 등록되었습니다.`); + const response = await postFectch(`/reuseFc/pubFc`, pbnstRes); + if (response.status === 200) { + toast.success( + `${pbnstRes.ruseUtztnFcltNm} 하수재이용 시설이 등록되었습니다.` + ); } - const newPbnstRes = await initFetch(pbnstRes.pbnstRuseFcltId.slice(0, 11)); + const newPbnstRes = await initFetch( + pbnstRes.pbnstRuseFcltId.slice(0, 11) + ); return set((state: pubFacState) => ({ ...state, pbnst: { ...state.pbnst, pbnstRes: newPbnstRes, - // isInit: false, }, })); - - } catch (error) { console.error("Error updating pbnst:", error); } - },pbnstRuseFcltUpdate : async(ruseRes:customPbnst[])=>{ + }, + pbnstRuseFcltUpdate: async (ruseRes: customPbnst[]) => { try { - - await putFectch( - `/reuseFc/pubFc`, - ruseRes - ); - + await putFectch(`/reuseFc/pubFc`, ruseRes); } catch (error) { console.error("Error pbnstRuseFcltUpdate:", error); } - } ,pbnstRuseBizUpdate : async(ruseRes:fcBizType[])=>{ + }, + pbnstRuseBizUpdate: async (ruseRes: fcBizType[]) => { try { - - await putFectch( - `/reuseFc/pubFcBiz`, - ruseRes - ); - + await putFectch(`/reuseFc/pubFcBiz`, ruseRes); } catch (error) { console.error("Error pbnstRuseFcltUpdate:", error); } - } , - getBizCycle: async (pbnstObj: customPbnst) => { - const pbnstBizCycle = pbnstObj.fcBizs.map((item) => { - return { - text: `${item.cycl}차`, - val: item.cycl, - }; - }); - - return set((state: pubFacState) => ({ - ...state, - pbnst: { - ...state.pbnst, - pbnstBizCycle: pbnstBizCycle, - pbnstResObj: pbnstObj, - isInit: false, - }, - })); }, fileDelete: async (atflCd: string) => { try { @@ -301,7 +265,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { ...state, pbnst: { ...state.pbnst, - isInit: false, }, })); } catch (error) { @@ -310,32 +273,16 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { }, fileDownLoad: async (atflCd: string) => { try { - await getFetch( + await getFetch( fetchType.CS, `/attach-service/api/v1/atflcd/download/${atflCd}` ); } catch (error) { console.error("Error downloading file:", error); throw new Error(`Error downloading file: ${error}`); - } }, - - appendRuseFclt: async (array: customPbnst[]) => { - try { - return set((state: pubFacState) => ({ - ...state, - pbnst: { - ...state.pbnst, - pbnstRes: array, - isInit: false, - }, - })); - } catch (e) { - console.log(e); - } - },getFcOrgwts : async (fcltPkList: string[] ,size:number) => { - + getFcOrgwts: async (fcltPkList: string[], size: number) => { const fcOrgwtsNmList = await postFectch( `/prcsFclt/ruseInfo/1/${size}/A/0/0/1/SW`, fcltPkList, @@ -346,10 +293,9 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { ...state, pbnst: { ...state.pbnst, - fcOrgwtsNmList:fcOrgwtsNmList.data??[] + fcOrgwtsNmList: fcOrgwtsNmList.data ?? [], }, })); - } - + }, }; };