diff --git a/apps/dm/components/ui/sdmInfoInsertForm/component.tsx b/apps/dm/components/ui/sdmInfoInsertForm/component.tsx index 7c6c13b32..5cfa526b8 100644 --- a/apps/dm/components/ui/sdmInfoInsertForm/component.tsx +++ b/apps/dm/components/ui/sdmInfoInsertForm/component.tsx @@ -637,7 +637,7 @@ export function SdmInfoRegForm({ }} />
- +
- +
-
+
- @@ -137,7 +139,9 @@ export default function Home() { total={htdflResCount} headName={"시설물 목록"} cellClick={(val, headId) => { - cellClick(val || undefined, headId); + if (val !== null && val !== undefined) { + cellClick(val, headId); + } }} onPageChange={setPageNation} > 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/fcltReg/rainReg/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/rainReg/page.tsx index f2d121887..629263c31 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/rainReg/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/fcltReg/rainReg/page.tsx @@ -1,7 +1,10 @@ "use client"; import { useWrStore } from "@/app/store"; -import { rainRegSize, type customRainBdst } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { formatArchArea, tableData } from "@/components/lib/func/commom"; +import { + rainRegSize, + type customRainBdst, +} from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { formatArchArea, tableData } from "@/components/lib/func/commom"; import RainRegForm from "@/components/ui/form/fcltReg/rainReg/rainRegForm"; import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; import { @@ -16,33 +19,43 @@ import { } from "@common/business_components"; import ListDiv from "@common/business_components/ui/list_div"; import { Button } from "@common/components"; -import { useEffect, useState } from "react"; -import { Toaster } from "react-hot-toast"; +import { useEffect, useRef, useState } from "react"; +import { Toaster } from "react-hot-toast"; export default function Home() { - const { auth, rain, code, initRain, rainSearch, getRainData } = useWrStore( - (state) => { - return state; - } - ); - - const { regAuthrtYn, mdfcnAuthrtYn } = auth; - + const { + auth, + rain, + code, + initRain, + rainSearch, + getRainData, + getLaeSeCdCheck, + } = useWrStore((state) => { + return state; + }); + const { regAuthrtYn, mdfcnAuthrtYn, laeSeCd } = auth; const { rainRes, rainResCount } = rain; + const useInitRef = useRef(false); const [rainForm, setRainForm] = useState(); const [issNewReg, setIsNewReg] = useState(false); const [pageNation, setPageNation] = useState(1); const [bdstTable, setbdstTable] = useState(); const [searchTxt, setSearchTxt] = useState(); + useEffect(() => { + getLaeSeCdCheck(); + useInitRef.current = true; + }, []); + useEffect(() => { setIsNewReg(false); - if (!rain.isInit) { - initRain("41"); + if (useInitRef.current == true && laeSeCd !== undefined) { + initRain(laeSeCd); } - }, [rain.isInit, initRain]); + }, [useInitRef.current, laeSeCd]); useEffect(() => { if (code.sggCd.length > 0) { @@ -51,9 +64,9 @@ export default function Home() { (item: customRainBdst) => { return { ...item, - archArea: formatArchArea(item?.archArea,1), + archArea: formatArchArea(item?.archArea, 1), bdstChgYn: item.chgBuilding[0]?.bdstChgNm != null ? "Y" : "N", - frstArchPrmsnDt:item?.frstArchPrmsnDt||'확인불가' + frstArchPrmsnDt: item?.frstArchPrmsnDt || "확인불가", }; } ); @@ -71,7 +84,7 @@ export default function Home() { }; useEffect(() => { - getRainData(pageNation, "41"); + getRainData(pageNation, laeSeCd); }, [pageNation]); return ( @@ -95,7 +108,7 @@ export default function Home() { className="" size={"sm"} onClick={() => { - rainSearch(searchTxt || "", 1, "41"); + rainSearch(searchTxt || "", 1, laeSeCd); //rainSearch(searchTxt || "", pageNation, "41"); }} > @@ -105,7 +118,7 @@ export default function Home() { size={"sm"} className="" onClick={() => { - setIsNewReg(!issNewReg); + setIsNewReg(!issNewReg); }} disabled={regAuthrtYn === "N"} > @@ -138,7 +151,7 @@ export default function Home() {
- + state - ); - const { regAuthrtYn, mdfcnAuthrtYn } = auth; + const { + auth, + code, + rswt, + initRswt, + rswtBdstSearch, + getRswtBdstData, + getLaeSeCdCheck, + } = useWrStore((state) => state); + const { regAuthrtYn, mdfcnAuthrtYn, laeSeCd } = auth; const [rswtForm, setRswtForm] = useState(); const [searchTxt, setSearchTxt] = useState(); @@ -32,14 +41,22 @@ export default function Home() { const [selectVal, setSelect] = useState(); const [bdstTable, setbdstTable] = useState(); const { rswtRes, rswtResCount } = rswt; + const useInitRef = useRef(false); + useEffect(() => { - if (!rswt.isInit) { - initRswt("41"); + getLaeSeCdCheck(); + useInitRef.current = true; + }, []); + + useEffect(() => { + setIsNewReg(false); + if (useInitRef.current == true && laeSeCd !== undefined) { + initRswt(laeSeCd); } - }, [rswt.isInit, initRswt]); + }, [useInitRef.current, laeSeCd]); + useEffect(() => { if (code.sggCd.length > 0) { - if (rswtRes?.length > 0) { const rswtData = tableData(rswtRes, { code })?.map( (item: customRswtBdst) => { @@ -63,7 +80,6 @@ export default function Home() { } } // }, [code, rswtRes, selectVal]); - }, [code, rswtRes]); useEffect(() => { if (rswtRes && rswtRes.length > 0) { @@ -79,11 +95,10 @@ export default function Home() { setSelect(val); } } - }; useEffect(() => { - getRswtBdstData(pageNation, "41"); + getRswtBdstData(pageNation,laeSeCd); }, [pageNation]); return ( @@ -107,7 +122,7 @@ export default function Home() { size={"sm"} className="" onClick={() => { - rswtBdstSearch(searchTxt || "", pageNation, "41"); + rswtBdstSearch(searchTxt || "", pageNation,laeSeCd); }} > 조회 diff --git a/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/rainSttn/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/rainSttn/page.tsx index 8055a2917..f5ec6e8c8 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/rainSttn/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/rainSttn/page.tsx @@ -92,7 +92,7 @@ export default function RainSttn() { useEffect(() => { if (!rainSttn.isInit) { - rainSttnInit(false, 1, rainSttnSize, "0", fcltNm, code.cityCd, code.sggCd); + rainSttnInit(false, 1, rainSttnSize, "0", fcltNm, code as unknown as Record); } }, [rainSttn.isInit, rainSttnInit]); @@ -146,8 +146,7 @@ export default function RainSttn() { rainSttnSize, String(getConValue()), fcltNm, - code.cityCd, - code.sggCd + code as unknown as Record ); isResetPage(false); }, [pageNation]); @@ -177,8 +176,7 @@ export default function RainSttn() { rainSttnResCount, String(getConValue()), fcltNm, - code.cityCd, - code.sggCd + code as unknown as Record ); }, [ rainSttnSearch, @@ -237,8 +235,7 @@ export default function RainSttn() { rainSttnSize, String(getConValue()), fcltNm, - code.cityCd, - code.sggCd + code as unknown as Record ); isResetPage(true); }} diff --git a/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/rswtSttn/page.tsx b/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/rswtSttn/page.tsx index b917a4105..7cb81d209 100644 --- a/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/rswtSttn/page.tsx +++ b/apps/wr/app/(with-layout)/ruseFcltMng/fcltSttn/rswtSttn/page.tsx @@ -34,6 +34,7 @@ export default function RswtSttn() { const { code, rswtSttn, rswtSttnSearch, rswtSttnInit } = useWrStore( (state) => state ); + const [pageNation, setPageNation] = useState(1); const { rswtSttnRes, rswtSttnResCount } = rswtSttn; @@ -83,8 +84,8 @@ export default function RswtSttn() { }; useEffect(() => { - if (!rswtSttn.isInit) { - rswtSttnInit(false, 1, rswtSttnSize, "0", fcltNm, code.cityCd, code.sggCd); + if (!rswtSttn.isInit&&code) { + rswtSttnInit(false, 1, rswtSttnSize, code.userSiSggCd, fcltNm, code as unknown as Record); } }, [rswtSttn.isInit, rswtSttnInit]); @@ -93,6 +94,8 @@ export default function RswtSttn() { const chData = data .map((item: customRswtBdst) => { const isOrgwtKndCd = item.reuseBuilding[0]?.rswtrObj.orgwtKndCd + + return { ...item, ...item.reuseBuilding[0], @@ -101,7 +104,7 @@ export default function RswtSttn() { chBuildingYn: item?.chgBuilding[0]?.bdstChgNm !== null && item?.chgBuilding.length > 0 ? 'Y' : 'N', instlCst: item.reuseBuilding[0]?.instlCst === -1 ? "확인불가" : item.reuseBuilding[0]?.instlCst, instlCstSprtAmt: item.reuseBuilding[0]?.instlCstSprtAmt === -1 ? "확인불가" : item.reuseBuilding[0]?.instlCstSprtAmt, - archArea: item?.archArea.split('.')[0] !== '-1' ? item?.archArea.split('.')[0] : '확인불가' + archArea: item?.archArea.split('.')[0] !== '-1' ? item?.archArea.split('.')[0] : '확인불가', } }) .filter( @@ -131,11 +134,11 @@ export default function RswtSttn() { const excelClick = useCallback(() => { isDownloadTriggered.current = true; - rswtSttnSearch(true, 1, rswtSttnResCount, String(getConValue()), fcltNm, code.cityCd, code.sggCd); + rswtSttnSearch(true, 1, rswtSttnResCount, String(getConValue()), fcltNm, code as unknown as Record); }, [rswtSttnSearch, objSearch, code.cityCd, code.sggCd, fcltNm, rswtSttnResCount]); useEffect(() => { - rswtSttnSearch(false, pageNation, rswtSttnSize, String(getConValue()), fcltNm, code.cityCd, code.sggCd); + rswtSttnSearch(false, pageNation, rswtSttnSize, String(getConValue()), fcltNm, code as unknown as Record); isResetPage(false) }, [pageNation]); @@ -186,7 +189,7 @@ export default function RswtSttn() { @@ -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/(with-layout)/stats/rswtStat/page.tsx b/apps/wr/app/(with-layout)/stats/rswtStat/page.tsx index 21ca5112a..de9bc86cf 100644 --- a/apps/wr/app/(with-layout)/stats/rswtStat/page.tsx +++ b/apps/wr/app/(with-layout)/stats/rswtStat/page.tsx @@ -27,7 +27,7 @@ export default function RswtStat() { const { t } = useTranslation('base'); useEffect(() => { - searchRswtStatList(searchYear, code.cityCd) + searchRswtStatList(searchYear, code.cityCd,code.rswtBdstType) }, [searchRswtStatList, code.cityCd]) const excelClick = () => { @@ -251,7 +251,7 @@ export default function RswtStat() { className="" size="sm" onClick={() => { - searchRswtStatList(searchYear, code.cityCd) + searchRswtStatList(searchYear, code.cityCd,code.rswtBdstType) }} > 조회 diff --git a/apps/wr/app/layout.tsx b/apps/wr/app/layout.tsx index 17945be51..f728f5de0 100644 --- a/apps/wr/app/layout.tsx +++ b/apps/wr/app/layout.tsx @@ -7,33 +7,38 @@ import { StoreProvider } from "./store"; import { LoginApi } from "@/src/entities/auth"; import { useEffect } from "react"; +const i18n = i18next.createInstance(); +i18n.init({ + lng: "ko", + fallbackLng: "ko", + resources: { + ko: { + base: koBase, + }, + }, +}); + export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { - i18next.init({ - lng: "ko", - fallbackLng: "ko", - resources: { - ko: { - base: koBase, - }, - }, - }); useEffect(() => { // 렌더 중이 아니라 클라이언트에서만 실행 + 에러 캐치 void LoginApi.login({ userId: "CLEANWATER", password: "gktneh12!@" }) + .finally(()=>{ + // getCommonUpCd() + } ) .catch((e) => { console.error("Auto login failed:", e); }); }, []); return ( - + - + {children} diff --git a/apps/wr/app/store/common/auth/index.tsx b/apps/wr/app/store/common/auth/index.tsx index 21be6e01c..5e65f3b6a 100644 --- a/apps/wr/app/store/common/auth/index.tsx +++ b/apps/wr/app/store/common/auth/index.tsx @@ -1,4 +1,5 @@ -import { getFetchWithCount } from "@/components/lib/api"; +import { fetchType, getFetchWithCount } from "@/components/lib/api"; +import { getUserInfo } from "@common/components/api"; import toast from "react-hot-toast"; export type authState = { @@ -8,6 +9,7 @@ export type authState = { regAuthrtYn: string; mdfcnAuthrtYn: string; delAuthrtYn: string; + laeSeCd: string; }; }; @@ -20,26 +22,32 @@ export const authStateExport: authState = { regAuthrtYn: "Y", mdfcnAuthrtYn: "Y", delAuthrtYn: "Y", + laeSeCd: "", }, }; export type authActions = { getMenuAuthrts: (menuCd: number) => void; + getLaeSeCdCheck: () => Promise; }; -export const authActionsExport: (set: any) => authActions = (set: any) => { +export const authActionsExport: (set: any, get: any) => authActions = ( + set: any, + get: any +) => { return { getMenuAuthrts: async (menuCd: number) => { - try{ + try { + const response = await getFetchWithCount( + fetchType.LOCAL, - const response = await getFetchWithCount( 'LOCAL', - `/cms-service/api/v1/menu-authrts/pageinfo/${menuCd}` ); set((state: authState) => { return { ...state, auth: { + ...state.auth, mngAuthrtYn: response[0].mngAuthrtYn, inqAuthrtYn: response[0].mngAuthrtYn, regAuthrtYn: response[0].mngAuthrtYn, @@ -48,12 +56,32 @@ export const authActionsExport: (set: any) => authActions = (set: any) => { }, }; }); - - }catch(e){ - - toast.error('권한 정보를 가져오는 중 오류가 발생했습니다. 관리자에게 문의하세요.'); - console.error('Error fetching menu authorities:', e); + } catch (e) { + toast.error( + "권한 정보를 가져오는 중 오류가 발생했습니다. 관리자에게 문의하세요." + ); + console.error("Error fetching menu authorities:", e); + } + }, + getLaeSeCdCheck: async () => { + try { + const current = get().auth.laeSeCd; + if (current && current !== "") { + return; + } + const infoMe = await getUserInfo(); + const isLaeSeCd = + infoMe.laeSeCd.slice(0, 2) === "G3" ? infoMe.laeSeCd.slice(2) : "0"; + set((state: authState) => ({ + ...state, + auth: { + ...state.auth, + laeSeCd: isLaeSeCd, + }, + })); + } catch (e) { + console.error("laeSeCd check error", e); } }, }; diff --git a/apps/wr/app/store/common/code/basicCode.tsx b/apps/wr/app/store/common/code/basicCode.tsx index 5fc13c16d..5f6981288 100644 --- a/apps/wr/app/store/common/code/basicCode.tsx +++ b/apps/wr/app/store/common/code/basicCode.tsx @@ -3,6 +3,7 @@ import type { SelectDataType } from "@common/business_components"; export const numSize = 12; export const txtSize = 20; +//export const lwCds: Record = {}; export const yn: SelectDataType[] = [ { val: "Y", text: "Y" }, { val: "N", text: "N" }, @@ -14,29 +15,35 @@ export const bdstFilterYn: SelectDataType[] = [ { val: "F", text: "미가동" }, ]; // 최우수(그린1)/우수(그린2), 우량(그린3), 일반(그린4), 확인불가 체크 -export const bdstGrntchClass: SelectDataType[] = [ - { val: "최우수(그린1)", text: "최우수(그린1)" }, - { val: "우수(그린2)", text: "우수(그린2)" }, - { val: "우량(그린3)", text: "우량(그린3)" }, - { val: "일반(그린4)", text: "일반(그린4)" }, - { val: "확인불가", text: "확인불가" }, -]; +//export const bdstGrntchClass: SelectDataType[] = lwCds['bdstGrntchClass']??[] + +// [ +// { val: "최우수(그린1)", text: "최우수(그린1)" }, +// { val: "우수(그린2)", text: "우수(그린2)" }, +// { val: "우량(그린3)", text: "우량(그린3)" }, +// { val: "일반(그린4)", text: "일반(그린4)" }, +// { val: "확인불가", text: "확인불가" }, +// ]; export const bdstIncenYn: SelectDataType[] = [ { val: "Y", text: "Y" }, { val: "N", text: "N" }, { val: "D", text: "확인불가" }, ]; //처리장연계/자체+연계/자체처리 -export const erctUswtrPrcsMeth: SelectDataType[] = [ - { val: "처리장연계", text: "처리장연계" }, - { val: "자체+연계", text: "자체+연계" }, - { val: "자체처리", text: "자체처리" }, -]; +//export const erctUswtrPrcsMeth: SelectDataType[] = lwCds['erctUswtrPrcsMeth']??[] -export const rusePrcsMthdCd: SelectDataType[] = [ - { val: "물리학적처리", text: "물리학적처리" }, - { val: "생물학적처리", text: "생물학적처리" }, -]; +// [ +// { val: "처리장연계", text: "처리장연계" }, +// { val: "자체+연계", text: "자체+연계" }, +// { val: "자체처리", text: "자체처리" }, +// ]; + +// export const rusePrcsMthdCd: SelectDataType[] = lwCds['rusePrcsMthdCd']??[] + +// [ +// { val: "물리학적처리", text: "물리학적처리" }, +// { val: "생물학적처리", text: "생물학적처리" }, +// ]; export const ruseSeCd: SelectDataType[] = [ { val: "신규", text: "신규" }, @@ -53,94 +60,100 @@ export const ruseBizMthdCd: SelectDataType[] = [ ]; // 공통 건축물 용도 -export const bdstUsgCd: SelectDataType[] = [ - { val: "-1", text: "확인불가" }, - { val: "1", text: "운동장" }, - { val: "2", text: "체육관" }, - { val: "3", text: "공공업무시설" }, - { val: "4", text: "공공기관의청사" }, - { val: "5", text: "아파트" }, - { val: "6", text: "연립주택" }, - { val: "7", text: "다세대주택" }, - { val: "8", text: "기숙사" }, - { val: "9", text: "초등학교" }, - { val: "10", text: "중학교" }, - { val: "11", text: "고등학교" }, - { val: "12", text: "전문대학" }, - { val: "13", text: "대학및대학교" }, - { val: "14", text: "골프장" }, - { val: "15", text: "대규모점포" }, - { val: "16", text: "기타" }, - { val: "17", text: "숙박업" }, - { val: "18", text: "목욕장업" }, - { val: "19", text: "공장" }, - { val: "20", text: "발전시설" }, - { val: "21", text: "관광단지개발사업" }, - { val: "22", text: "도시개발사업" }, - { val: "23", text: "산업단지개발사업" }, - { val: "24", text: "택지개발사업" }, - { val: "25", text: "대규모점포(대형마트)" }, - { val: "26", text: "대규모점포(전문점)" }, - { val: "27", text: "대규모점포(백화점)" }, - { val: "28", text: "대규모점포(쇼핑센터)" }, - { val: "29", text: "대규모점포(복합쇼핑몰)" }, - { val: "30", text: "물류시설" }, - { val: "31", text: "운수시설(여객자동차터미널)" }, - { val: "32", text: "운수시설(철도시설)" }, - { val: "33", text: "운수시설(공항시설)" }, - { val: "34", text: "운수시설(항만시설)" }, - { val: "35", text: "업무시설(공공업무시설)" }, - { val: "36", text: "업무시설(금융업소)" }, - { val: "37", text: "업무시설(사무소)" }, - { val: "38", text: "업무시설(결혼상담소 등 소개업소)" }, - { val: "39", text: "업무시설(출판사)" }, - { val: "40", text: "업무시설(신문사)" }, - { val: "41", text: "업무시설(오피스텔)" }, - { val: "42", text: "교정시설" }, - { val: "43", text: "방송국" }, - { val: "44", text: "전신전화국" }, - { val: "45", text: "기타" }, -]; +//export const bdstUsgCd: SelectDataType[] =lwCds?.bdstUsgCd?.concat(lwCds?.rswtBdstType??[])??[] -export const rswtBdstType: SelectDataType[] = [ - { val: "17", text: "숙박업" }, - { val: "18", text: "목욕장업" }, - { val: "19", text: "공장" }, - { val: "20", text: "발전시설" }, - { val: "21", text: "관광단지개발사업" }, - { val: "22", text: "도시개발사업" }, - { val: "23", text: "산업단지개발사업" }, - { val: "24", text: "택지개발사업" }, - { val: "25", text: "대규모점포(대형마트)" }, - { val: "26", text: "대규모점포(전문점)" }, - { val: "27", text: "대규모점포(백화점)" }, - { val: "28", text: "대규모점포(쇼핑센터)" }, - { val: "29", text: "대규모점포(복합쇼핑몰)" }, - { val: "30", text: "물류시설" }, - { val: "31", text: "운수시설(여객자동차터미널)" }, - { val: "32", text: "운수시설(철도시설)" }, - { val: "33", text: "운수시설(공항시설)" }, - { val: "34", text: "운수시설(항만시설)" }, - { val: "35", text: "업무시설(공공업무시설)" }, - { val: "36", text: "업무시설(금융업소)" }, - { val: "37", text: "업무시설(사무소)" }, - { val: "38", text: "업무시설(결혼상담소 등 소개업소)" }, - { val: "39", text: "업무시설(출판사)" }, - { val: "40", text: "업무시설(신문사)" }, - { val: "41", text: "업무시설(오피스텔)" }, - { val: "42", text: "교정시설" }, - { val: "43", text: "방송국" }, - { val: "44", text: "전신전화국" }, - { val: "45", text: "기타" }, -]; +// [ +// { val: "-1", text: "확인불가" }, +// { val: "1", text: "운동장" }, +// { val: "2", text: "체육관" }, +// { val: "3", text: "공공업무시설" }, +// { val: "4", text: "공공기관의청사" }, +// { val: "5", text: "아파트" }, +// { val: "6", text: "연립주택" }, +// { val: "7", text: "다세대주택" }, +// { val: "8", text: "기숙사" }, +// { val: "9", text: "초등학교" }, +// { val: "10", text: "중학교" }, +// { val: "11", text: "고등학교" }, +// { val: "12", text: "전문대학" }, +// { val: "13", text: "대학및대학교" }, +// { val: "14", text: "골프장" }, +// { val: "15", text: "대규모점포" }, +// { val: "16", text: "기타" }, +// { val: "17", text: "숙박업" }, +// { val: "18", text: "목욕장업" }, +// { val: "19", text: "공장" }, +// { val: "20", text: "발전시설" }, +// { val: "21", text: "관광단지개발사업" }, +// { val: "22", text: "도시개발사업" }, +// { val: "23", text: "산업단지개발사업" }, +// { val: "24", text: "택지개발사업" }, +// { val: "25", text: "대규모점포(대형마트)" }, +// { val: "26", text: "대규모점포(전문점)" }, +// { val: "27", text: "대규모점포(백화점)" }, +// { val: "28", text: "대규모점포(쇼핑센터)" }, +// { val: "29", text: "대규모점포(복합쇼핑몰)" }, +// { val: "30", text: "물류시설" }, +// { val: "31", text: "운수시설(여객자동차터미널)" }, +// { val: "32", text: "운수시설(철도시설)" }, +// { val: "33", text: "운수시설(공항시설)" }, +// { val: "34", text: "운수시설(항만시설)" }, +// { val: "35", text: "업무시설(공공업무시설)" }, +// { val: "36", text: "업무시설(금융업소)" }, +// { val: "37", text: "업무시설(사무소)" }, +// { val: "38", text: "업무시설(결혼상담소 등 소개업소)" }, +// { val: "39", text: "업무시설(출판사)" }, +// { val: "40", text: "업무시설(신문사)" }, +// { val: "41", text: "업무시설(오피스텔)" }, +// { val: "42", text: "교정시설" }, +// { val: "43", text: "방송국" }, +// { val: "44", text: "전신전화국" }, +// { val: "45", text: "기타" }, +// ]; -export const orgwtKndCd = [ - { text: "오수(변기 오수 제외)", val: "01" }, - { text: "오수", val: "02" }, - { text: "폐수", val: "03" }, - { text: "오수 및 폐수", val: "04" }, - { text: "기타", val: "05" }, -]; +// export const rswtBdstType: SelectDataType[] = lwCds?.rswtBdstType??[] +//[ +// { val: "17", text: "숙박업" }, +// { val: "18", text: "목욕장업" }, +// { val: "19", text: "공장" }, +// { val: "20", text: "발전시설" }, +// { val: "21", text: "관광단지개발사업" }, +// { val: "22", text: "도시개발사업" }, +// { val: "23", text: "산업단지개발사업" }, +// { val: "24", text: "택지개발사업" }, +// { val: "25", text: "대규모점포(대형마트)" }, +// { val: "26", text: "대규모점포(전문점)" }, +// { val: "27", text: "대규모점포(백화점)" }, +// { val: "28", text: "대규모점포(쇼핑센터)" }, +// { val: "29", text: "대규모점포(복합쇼핑몰)" }, +// { val: "30", text: "물류시설" }, +// { val: "31", text: "운수시설(여객자동차터미널)" }, +// { val: "32", text: "운수시설(철도시설)" }, +// { val: "33", text: "운수시설(공항시설)" }, +// { val: "34", text: "운수시설(항만시설)" }, +// { val: "35", text: "업무시설(공공업무시설)" }, +// { val: "36", text: "업무시설(금융업소)" }, +// { val: "37", text: "업무시설(사무소)" }, +// { val: "38", text: "업무시설(결혼상담소 등 소개업소)" }, +// { val: "39", text: "업무시설(출판사)" }, +// { val: "40", text: "업무시설(신문사)" }, +// { val: "41", text: "업무시설(오피스텔)" }, +// { val: "42", text: "교정시설" }, +// { val: "43", text: "방송국" }, +// { val: "44", text: "전신전화국" }, +// { val: "45", text: "기타" }, +// ]; + +//export const orgwtKndCd =lwCds['orgwtKndCd']??[] + + +// [ +// { text: "오수(변기 오수 제외)", val: "01" }, +// { text: "오수", val: "02" }, +// { text: "폐수", val: "03" }, +// { text: "오수 및 폐수", val: "04" }, +// { text: "기타", val: "05" }, +// ]; export const chBuCd = [ { val: "증축", text: "증축" }, @@ -148,97 +161,104 @@ export const chBuCd = [ { val: "재축", text: "재축" }, ]; -export const dmdUszCd = [ - { val: "조경용수", text: "조경용수" }, - { val: "청소화장실용수", text: "청소화장실용수" }, - { val: "농업용수", text: "농업용수" }, - { val: "공업용수", text: "공업용수" }, - { val: "친수용수", text: "친수용수" }, - { val: "기타", text: "기타" }, -]; +// export const dmdUszCd = [ +// { val: "조경용수", text: "조경용수" }, +// { val: "청소화장실용수", text: "청소화장실용수" }, +// { val: "농업용수", text: "농업용수" }, +// { val: "공업용수", text: "공업용수" }, +// { val: "친수용수", text: "친수용수" }, +// { val: "기타", text: "기타" }, +// ]; -export const ruseMngMtd = [ - { val: "자체운영", text: "자체운영" }, - { val: "공기업", text: "공기업" }, - { val: "민간(대행)", text: "민간(대행)" }, -]; -export const pplQulity = [ - { val: "도복장강관", text: "도복장강관" }, - { val: "PE관", text: "PE관" }, - { val: "스테인레스관", text: "스테인레스관" }, - { val: "덕타일주철관", text: "덕타일주철관" }, - { val: "유리섬유복합관", text: "유리섬유복합관" }, - { val: "기타", text: "기타" }, -]; -export const pplLenght = [ - { val: "D100", text: "D100" }, - { val: "D200", text: "D200" }, - { val: "D250", text: "D250" }, - { val: "D300", text: "D300" }, - { val: "D350", text: "D350" }, - { val: "D400", text: "D400" }, - { val: "D450", text: "D450" }, - { val: "D500", text: "D500" }, - { val: "D700", text: "D700" }, - { val: "D900", text: "D900" }, - { val: "D1000​", text: "D1000​" }, -]; -export const rainFcltCd = [ - { val: "10", text: "확인불가" }, - { val: "01", text: "지붕" }, - { val: "02", text: "건물옥상" }, - { val: "03", text: "골프장 연못" }, - { val: "04", text: "운동장 바닥" }, - { val: "05", text: "운동장 지붕" }, - { val: "06", text: "주차장" }, - { val: "07", text: "태양광패널" }, - { val: "08", text: "연못" }, - { val: "09", text: "기타" }, -]; +// export const ruseMngMtd = lwCds['ruseMngMtd'] +// [ +// { val: "자체운영", text: "자체운영" }, +// { val: "공기업", text: "공기업" }, +// { val: "민간(대행)", text: "민간(대행)" }, +// ]; + +// export const pplQulity = +// [ +// { val: "도복장강관", text: "도복장강관" }, +// { val: "PE관", text: "PE관" }, +// { val: "스테인레스관", text: "스테인레스관" }, +// { val: "덕타일주철관", text: "덕타일주철관" }, +// { val: "유리섬유복합관", text: "유리섬유복합관" }, +// { val: "기타", text: "기타" }, +// ]; +// export const pplLenght = [ +// { val: "D100", text: "D100" }, +// { val: "D200", text: "D200" }, +// { val: "D250", text: "D250" }, +// { val: "D300", text: "D300" }, +// { val: "D350", text: "D350" }, +// { val: "D400", text: "D400" }, +// { val: "D450", text: "D450" }, +// { val: "D500", text: "D500" }, +// { val: "D700", text: "D700" }, +// { val: "D900", text: "D900" }, +// { val: "D1000​", text: "D1000​" }, +// ]; + +// export const rainFcltCd = lwCds?.rainFcltCd??[] + + +// [ +// { val: "10", text: "확인불가" }, +// { val: "01", text: "지붕" }, +// { val: "02", text: "건물옥상" }, +// { val: "03", text: "골프장 연못" }, +// { val: "04", text: "운동장 바닥" }, +// { val: "05", text: "운동장 지붕" }, +// { val: "06", text: "주차장" }, +// { val: "07", text: "태양광패널" }, +// { val: "08", text: "연못" }, +// { val: "09", text: "기타" }, +// ]; //물리화학적처리(스크린, 응집, 침전)/생물학적처리(활성슬러지법 등)/소독(염소, UV 등)/기타 -export const rswtPrscCdMthdCd = [ - { - val: "물리화학적처리(스크린,응집,침전)", - text: "물리화학적처리(스크린,응집,침전)", - }, - { - val: "생물학적처리(활성슬러지법 등)", - text: "생물학적처리(활성슬러지법 등)", - }, - { val: "소독(염소, UV 등)", text: "소독(염소, UV 등)" }, - { val: "기타", text: "기타" }, - { val: "확인불가", text: "확인불가" }, -]; +//export const rswtPrscCdMthdCd = lwCds['rswtPrscCdMthdCd']??[] +// { +// val: "물리화학적처리(스크린,응집,침전)", +// text: "물리화학적처리(스크린,응집,침전)", +// }, +// { +// val: "생물학적처리(활성슬러지법 등)", +// text: "생물학적처리(활성슬러지법 등)", +// }, +// { val: "소독(염소, UV 등)", text: "소독(염소, UV 등)" }, +// { val: "기타", text: "기타" }, +// { val: "확인불가", text: "확인불가" }, +// ]; -export const htdPowerMthdCd= [ - { - val: "해당없음", - text: "해당없음", - }, - { - val: "석탄화력발전", - text: "석탄화력발전", - }, - { - val: "화력발전", - text: "화력발전", - }, - { - val: "수력발전", - text: "수력발전", - }, - { - val: "태양관발전", - text: "태양관발전", - }, -]; +// export const htdPowerMthdCd = [ +// { +// val: "해당없음", +// text: "해당없음", +// }, +// { +// val: "석탄화력발전", +// text: "석탄화력발전", +// }, +// { +// val: "화력발전", +// text: "화력발전", +// }, +// { +// val: "수력발전", +// text: "수력발전", +// }, +// { +// val: "태양관발전", +// text: "태양관발전", +// }, +// ]; //(공업용수/양식장/농업용수) -export const htdUtztnUsgCd= [ +export const htdUtztnUsgCd = [ { val: "공업용수", text: "공업용수", @@ -252,3 +272,171 @@ export const htdUtztnUsgCd= [ text: "농업용수", }, ]; + +export const ruseFcltSpot = [] +//(공업용수/양식장/농업용수) +export const rainRswtMng = [ + { + val: "위탁", + text: "01", + }, + { + val: "자체", + text: "02", + }, +]; + +export const rainFcltFlowRate = [ + { + val: "01", + text: "유량계", + }, + { + val: "02", + text: "수위계", + }, + { + val: "03", + text: "펌프적산전력계", + }, + { + val: "04", + text: "기타", + }, +]; +export const rainRswtUse = [ + { + val: "01", + text: "유량계", + }, + { + val: "02", + text: "수위계", + }, + { + val: "03", + text: "펌프적산전력계", + }, + { + val: "04", + text: "기타", + }, +]; + +export const sewageInFcltUse = [ + { + val: "01", + text: "세척수", + }, + { + val: "02", + text: "냉각수", + }, + { + val: "03", + text: "청소수", + }, + { + val: "04", + text: "삭수대", + }, + { + val: "05", + text: "희석용수", + }, + { + val: "06", + text: "중수도", + }, + { + val: "07", + text: "기타", + }, +]; + +export const sewageOutFclttUse = [ + { + val: "01", + text: "청소화장실용수", + }, + { + val: "02", + text: "세척살수용수", + }, + { + val: "03", + text: "조경용수", + }, + { + val: "04", + text: "친수용수", + }, + { + val: "05", + text: "지하수충전", + }, + { + val: "06", + text: "농업용수", + }, + { + val: "07", + text: "하천등유지용수", + }, + { + val: "08", + text: "공업용수", + }, +]; +// const codeMApping = { +// WR001: "bdstUsgCd", +// WR002: "rswtBdstType", +// WR003: "rainFcltCd", +// WR004: "bdstGrntchClass", +// WR005: "rswtPrscCdMthdCd", // 아직 디 못바꿈 +// WR006: "orgwtKndCd", //작업 완ㅛ +// WR007: "ruseMngMtd", // 작업완료 +// WR008: "rusePrcsMthdCd", //w작업완료 +// WR009: "erctUswtrPrcsMeth",//w작업완료 +// WR010: "ruseFcltSpot",// inout은 yn 만 사용해야 함으로 해당 코드는 사용안함. +// WR011: "pplQulity", +// WR012: "pplLenght", +// WR013: "bdstFilterYn", // 사용 불가 yn만 사용해야함으로 해당코드 사용 안함 +// WR014: "rainRswtMng", // 지도점검 등록 시변경 +// WR015: "rainFcltFlowRate", //지도점검 등록 시변경 +// WR016: "dmdUszCd", // 지도점검 등록 시변경 +// WR017: "sewageInFcltUse", //하수재이용 장내 +// WR018: "sewageOutFclttUse", // 하수재이용 장외 +// WR019: "htdPowerMthdCd", +// WR020: "htdUtztnUsgCd", +// }; +// export const getCommonUpCd = async () => { +// const upCd = await getFetchWithCount( +// fetchType.LOCAL, +// "/cms-service/api/v1/up-codes?keyword=&upCd=&cdSe=&useYn=Y&siteId=WR&page=0&size=100&sort=string" +// ); + +// const upWrCode: string[] = upCd.content +// .filter((item: any) => item.upCd.slice(0, 2) === "WR") +// .map((cd: any) => cd.upCd); + +// await Promise.all( +// upWrCode.map(async (cd) => { +// const mapping = codeMApping[cd as keyof typeof codeMApping]; +// if (!mapping) return; + +// const lwCd = await getFetchWithCount( +// fetchType.LOCAL, +// `/cms-service/api/v1/lwpo-cds/up-cd/${cd}` +// ); + +// const list = Array.isArray(lwCd) ? lwCd : lwCd.content ?? []; + +// lwCds[mapping] = list.map((it: any) => ({ +// text: it.lwpoCdNm, +// val: it.lwpoCd, +// })); +// }) +// ); +// console.log('lwCds ', lwCds) +// }; \ No newline at end of file diff --git a/apps/wr/app/store/common/code/index.ts b/apps/wr/app/store/common/code/index.ts index 72e910aad..0601c5e41 100644 --- a/apps/wr/app/store/common/code/index.ts +++ b/apps/wr/app/store/common/code/index.ts @@ -1,32 +1,97 @@ -import { getFetch } from "@/components/lib/api"; +import { fetchType, getFetch, getFetchWithCount } from "@/components/lib/api"; import type { EnvPartSelectDataType, SelectDataType, } from "@common/business_components/ui"; import { bdstFilterYn, - bdstGrntchClass, bdstIncenYn, - bdstUsgCd, chBuCd, - dmdUszCd, - erctUswtrPrcsMeth, - htdPowerMthdCd, - htdUtztnUsgCd, - orgwtKndCd, - pplLenght, - pplQulity, - rainFcltCd, - rswtPrscCdMthdCd, ruseBizMthdCd, - ruseMngMtd, - rusePrcsMthdCd, ruseSeCd, yn, } from "./basicCode"; export const btnClass = "p-4 m-2 text-white rounded-sm text-lg font-medium "; const laeSecd = "41"; +export const lwCds: Record = {}; + +const codeMApping = { + WR001: "bdstUsgCd", + WR002: "rswtBdstType", + WR003: "rainFcltCd", + WR004: "bdstGrntchClass", + WR005: "rswtPrscCdMthdCd", // 아직 디 못바꿈 + WR006: "orgwtKndCd", //작업 완ㅛ + WR007: "ruseMngMtd", // 작업완료 + WR008: "rusePrcsMthdCd", //w작업완료 + WR009: "erctUswtrPrcsMeth", //w작업완료 + WR010: "ruseFcltSpot", // inout은 yn 만 사용해야 함으로 해당 코드는 사용안함. + WR011: "pplQulity", + WR012: "pplLenght", + WR013: "bdstFilterYn", // 사용 불가 yn만 사용해야함으로 해당코드 사용 안함 + WR014: "rainRswtMng", // 지도점검 등록 시변경 + WR015: "rainFcltFlowRate", //지도점검 등록 시변경 + WR016: "dmdUszCd", // 지도점검 등록 시변경 + WR017: "sewageInFcltUse", //하수재이용 장내 + WR018: "sewageOutFclttUse", // 하수재이용 장외 + WR019: "htdPowerMthdCd", + WR020: "htdUtztnUsgCd", +}; +export const getCommonUpCd = async (set: any) => { + try { + let lwCdCode: Record = {}; + const upCd = await getFetchWithCount( + fetchType.LOCAL, + "/cms-service/api/v1/up-codes?keyword=&upCd=&cdSe=&useYn=Y&siteId=WR&page=0&size=100&sort=string" + ); + + const upWrCode: string[] = upCd.content + .filter((item: any) => item.upCd.slice(0, 2) === "WR") + .map((cd: any) => cd.upCd); + + await Promise.all( + upWrCode.map(async (cd) => { + const mapping = codeMApping[cd as keyof typeof codeMApping]; + if (!mapping) return; + + const lwCd = await getFetchWithCount( + fetchType.LOCAL, + `/cms-service/api/v1/lwpo-cds/up-cd/${cd}` + ); + + const list = Array.isArray(lwCd) ? lwCd : (lwCd.content ?? []); + lwCds[mapping] = list.map((it: any) => ({ + text: it.lwpoCdNm, + val: it.lwpoCd, + })); + }) + ); + lwCdCode = lwCds; + set((state: comCodeState) => ({ + code: { + ...state.code, + rainFcltCd: lwCdCode["rainFcltCd"] ?? [], + bdstUsgCd: lwCdCode["bdstUsgCd"] ?? [], + orgwtKndCd: lwCdCode["orgwtKndCd"] ?? [], + pplQulity: lwCdCode["pplQulity"] ?? [], + pplLenght: lwCdCode["pplLenght"] ?? [], + dmdUszCd: lwCdCode["dmdUszCd"] ?? [], + ruseMngMtd: lwCdCode["ruseMngMtd"] ?? [], + rusePrcsMthdCd: lwCdCode["rusePrcsMthdCd"] ?? [], + erctUswtrPrcsMeth: lwCdCode["erctUswtrPrcsMeth"] ?? [], + bdstGrntchClass: lwCdCode["bdstGrntchClass"] ?? [], + htdPowerMthdCd: lwCdCode["htdPowerMthdCd"] ?? [], + htdUtztnUsgCd: lwCdCode["htdUtztnUsgCd"] ?? [], + rswtBdstType: lwCdCode["rswtBdstType"] ?? [], + bdstTotalUsgType: + lwCdCode["bdstUsgCd"]?.concat(lwCdCode["rswtBdstType"] || []) ?? [], + }, + })); + } catch (e) { + console.log("com code error ", e); + } +}; //물재이용 주소 코드: devU01TX0FVVEgyMDI1MDgyNTEwMzkwNDExNjEwNTM= export const buildingType = { RST: "RST", @@ -181,9 +246,11 @@ export type comCodeState = { bdstFilterYn: SelectDataType[]; bdstIncenYn: SelectDataType[]; bdstGrntchClass: SelectDataType[]; - rswtPrscCdMthdCd: SelectDataType[]; + // rswtPrscCdMthdCd: SelectDataType[]; htdPowerMthdCd: SelectDataType[]; htdUtztnUsgCd: SelectDataType[]; + rswtBdstType: SelectDataType[]; + bdstTotalUsgType: SelectDataType[]; userSiSggCd: string; }; }; @@ -193,50 +260,56 @@ export type comCodeType = comCodeState & comCodeActions; export const comCodeStateExport: comCodeState = { code: { isInit: false, - rainFcltCd: rainFcltCd, - bdstUsgCd: bdstUsgCd, + rainFcltCd: lwCds["rainFcltCd"] ?? [], + bdstUsgCd: lwCds["bdstUsgCd"] ?? [], chBuCd: chBuCd, - orgwtKndCd: orgwtKndCd, + orgwtKndCd: lwCds["orgwtKndCd"] ?? [], cityCd: [], sggCd: [], rvbsnCd: [], mdmbsnCd: [], lgbsnCd: [], lclgvrnmntCd: [], - pplQulity: pplQulity, - pplLenght: pplLenght, + pplQulity: lwCds["pplQulity"] ?? [], + pplLenght: lwCds["pplLenght"] ?? [], yn: yn, - dmdUszCd: dmdUszCd, + dmdUszCd: lwCds["dmdUszCd"] ?? [], buildingType: buildingType, - ruseMngMtd: ruseMngMtd, + ruseMngMtd: lwCds["ruseMngMtd"] ?? [], ruseSeCd: ruseSeCd, ruseBizMthdCd: ruseBizMthdCd, - rusePrcsMthdCd: rusePrcsMthdCd, - erctUswtrPrcsMeth: erctUswtrPrcsMeth, + rusePrcsMthdCd: lwCds["rusePrcsMthdCd"] ?? [], + erctUswtrPrcsMeth: lwCds["erctUswtrPrcsMeth"] ?? [], bdstFilterYn: bdstFilterYn, bdstIncenYn: bdstIncenYn, - bdstGrntchClass: bdstGrntchClass, - rswtPrscCdMthdCd: rswtPrscCdMthdCd, - htdPowerMthdCd: htdPowerMthdCd, - htdUtztnUsgCd: htdUtztnUsgCd, + bdstGrntchClass: lwCds["bdstGrntchClass"] ?? [], + // rswtPrscCdMthdCd: rswtPrscCdMthdCd, // 공단연락오면 바꿔야함 + htdPowerMthdCd: lwCds["htdPowerMthdCd"] ?? [], + htdUtztnUsgCd: lwCds["htdUtztnUsgCd"] ?? [], userSiSggCd: laeSecd, + rswtBdstType: lwCds["rswtBdstType"] ?? [], + bdstTotalUsgType: lwCds["bdstTotalUsgType"] ?? [], }, }; export type comCodeActions = { returnCodeText: (val: string, codeName: string) => string; + returnTextCode: (text: string, codeName: string) => string; }; -export const codeActionExport: (set: any) => comCodeActions = (set: any) => { +export const codeActionExport: (set: any, get:any) => comCodeActions = (set: any, get:any) => { return { returnCodeText: (val: string, codeName: string) => { - console.log('val', val, 'codeName', codeName); - return set((state: comCodeState) => { - const codeList = state.code[codeName] || []; - const found = codeList.find((item) => item.val === val); - return found ? found.text : val; - } - ); + + const codeList = get().code[codeName] || []; + const found = codeList.find((item) => item.val === val); + + return found ? found.text : val; + }, + returnTextCode: (text: string, codeName: string) => { + const codeList = get().code[codeName] || []; + const found = codeList.find((item) => item.text === text); + return found ? found.val : text; }, }; }; diff --git a/apps/wr/app/store/common/code/type.ts b/apps/wr/app/store/common/code/type.ts new file mode 100644 index 000000000..55f684f55 --- /dev/null +++ b/apps/wr/app/store/common/code/type.ts @@ -0,0 +1,31 @@ + +export type LwCdType= { + lwpoCd: string, + upCd: string, + lwpoCdNm:string, + lwpoCdExpln:string, + unit: string, + prntLwpoCd: string, + useYn: string, + sortSeq: number, + regDt: Date, + rgtr: string, + mdfcnDt: Date, + mdfr: string +} + + +export type UPCdType= { + upCd: string, + upCdNm: string, + upCdExpln: string, + cdSe: string, + useYn: string, + delYn: string, + siteId: string, + regDt:Date, + rgtr: string + mdfcnDt: Date, + mdfr: string + +} diff --git a/apps/wr/app/store/map/rainMap/index.tsx b/apps/wr/app/store/map/rainMap/index.tsx index 1d23e7991..050639096 100644 --- a/apps/wr/app/store/map/rainMap/index.tsx +++ b/apps/wr/app/store/map/rainMap/index.tsx @@ -23,9 +23,7 @@ export type rainMapState = { type rainMapActions = { rainMapInit: (page: number, total: number, cityOrSgg:string) => void; - rainMapSearch: (isExcel: boolean, page: number, total: string, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => void; + rainMapSearch: (isExcel: boolean, page: number, total: string, con: string, txt: string,code:Record) => void; rainMapDetile:(featureCd:string) => Promise; }; @@ -72,8 +70,7 @@ export const rainMapActionsExport: (set: any) => rainMapActions = ( } }, rainMapSearch: async (isExcel: boolean, page: number, total: string, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => { + code :Record) => { try { const rainMapRes = await getFetchWithCount( fetchType.WR, @@ -84,7 +81,7 @@ export const rainMapActionsExport: (set: any) => rainMapActions = ( (txt ? `/${txt}` : "") ); if (isExcel) { - const rainMapExcelList = excelRainSttnParsing(rainMapRes, sidoCode, sggCode); + const rainMapExcelList = excelRainSttnParsing(rainMapRes, code); set((state: rainMapState) => { return { diff --git a/apps/wr/app/store/map/rswtMap/index.tsx b/apps/wr/app/store/map/rswtMap/index.tsx index 4acc0e321..1c98a4dd2 100644 --- a/apps/wr/app/store/map/rswtMap/index.tsx +++ b/apps/wr/app/store/map/rswtMap/index.tsx @@ -23,9 +23,7 @@ export type rswtMapState = { type rswtMapActions = { rswtMapInit: (page: number, total: number, cityOrSgg: string) => void; rswtMapSearch: ( - isExcel: boolean, page: number, total: string, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[] + isExcel: boolean, page: number, total: string, con: string, txt: string, code:Record ) => void; rswtMapDetile: (featureCd: string) => Promise; }; @@ -72,9 +70,7 @@ export const rswtMapActionsExport: (set: any) => rswtMapActions = ( console.log(e); } }, - rswtMapSearch: async (isExcel: boolean, page: number, total: string, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[] + rswtMapSearch: async (isExcel: boolean, page: number, total: string, con: string, txt: string,code:Record ) => { try { const rswtMapRes = await getFetchWithCount( @@ -86,7 +82,7 @@ export const rswtMapActionsExport: (set: any) => rswtMapActions = ( (txt ? `/${txt}` : "") ); if (isExcel) { - const rswtMapExcelList = excelRSwtSttnParsing(rswtMapRes, sidoCode, sggCode); + const rswtMapExcelList = excelRSwtSttnParsing(rswtMapRes, code); set((state: rswtMapState) => { return { ...state, diff --git a/apps/wr/app/store/matDmd/ruseCaseMng/headList.tsx b/apps/wr/app/store/matDmd/ruseCaseMng/headList.tsx index 024f40fe7..8ed65ee7d 100644 --- a/apps/wr/app/store/matDmd/ruseCaseMng/headList.tsx +++ b/apps/wr/app/store/matDmd/ruseCaseMng/headList.tsx @@ -167,7 +167,7 @@ export const ruseCaseHeadListExport: TableUpperProps[] = [ }, { id: "grnteWqPh", - title: "수소이온농도(ph)​", + title: "수소이온농도(pH)​", visible: true, row: 1, }, @@ -313,7 +313,7 @@ export const ruseCaseHeadListExport: TableUpperProps[] = [ }, { id: "prcmPlanEcqrRt", - title: "국고비율", + title: "국고비율(%)", visible: true, row: 1, }, @@ -350,7 +350,7 @@ export const ruseCaseHeadListExport: TableUpperProps[] = [ }, { id: "clclnEcqrRt", - title: "국고비율", + title: "국고비율(%)", visible: true, row: 1, }, diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx index 38e2cab7f..21636860a 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx @@ -7,6 +7,7 @@ import { parseRawValue, } from "@/components/lib/func/excelFunc"; import toast from "react-hot-toast"; +import { codeToText, textToCode } from "@/components/lib/func/commom"; export const useTypes = [ "조경용수", "청소화장실용수", @@ -17,17 +18,13 @@ export const useTypes = [ "기타", ]; - -export const chkMngType =[ - '위탁', - '자체' -] -export const chkSpwtPositnType = [ - '유량계', - '수위계', - '펌프적산전력계', - '기타' -] +export const chkMngType = { "01": "위탁", "02": "자체" }; +export const rainFcltFlowRateType = { + "01": "유량계", + "02": "수위계", + "03": "펌프적산전력계", + "04": "기타", +}; export type Buildingtype = { bdstInfoSn: number; @@ -118,7 +115,7 @@ export const excelToRainChkData = (excelData: any, year: string) => { const ruseData = parseRawValue(item[`빗물_${month}월`]); if (month.length < 2) month = "0" + month; return { - utztnUsgCd: item["이용용도"], + utztnUsgCd: textToCode(item["이용용도"], "dmdUszCd") ?? undefined, ym: year + month, chckYmd: checkYmd, splyUswtrUtztnQnt: splyData, @@ -133,14 +130,14 @@ export const excelToRainChkData = (excelData: any, year: string) => { bdstRuseFcltSn: Number(item["NO"]), chckYmd: checkYmd, rgtr: TEST_UUID, - operMngCd: item["운영관리형태"] ?? "", + operMngCd: textToCode(item["운영관리형태"], "rainRswtMng") ??item["운영관리형태"], anlOperCst: parseRawValue(item["연간운영비(원/년)"]), - oilqMeasMthd: item["유량측정방법"] ?? "", + oilqMeasMthd: textToCode( item["유량측정방법"],"rainFcltFlowRate",)??item["유량측정방법"], guideDetails: makeGuidDetail, rainyDetails: [ { ph: item["PH"], - utztnUsgCd: item["이용용도"], + utztnUsgCd: textToCode(item["이용용도"], "dmdUszCd")??item["이용용도"], trbt: parseRawValue(item["탁도"]), grssClfg: parseRawValue(item["총대장균군수"]), etc: item["기타"] || "", // 필드 누락 방지 @@ -156,10 +153,10 @@ export const excelToRainChkData = (excelData: any, year: string) => { }) .filter((el: any) => el !== undefined); -console.log("rainChkgdData", rainChkgdData); + console.log('rainChkgdData ', rainChkgdData) if (rainChkgdData.length > 0) { rainChkgdData.forEach((rain: any) => { - const defaultMessage = `[시설명: ${rain.bdstNm}, 점검일: ${rain.chckYmd}, 이용용도: ${rain.guideDetails[0]?.utztnUsgCd}] 항목에서 `; + const defaultMessage = `[시설명: ${rain.bdstNm}, 점검일: ${rain.chckYmd}, 이용용도: ${codeToText(rain.guideDetails[0]?.utztnUsgCd, "dmdUszCd") ??rain.guideDetails[0]?.utztnUsgCd}] 항목에서 `; if (rain.chckYmd && isInvalidDate(rain.chckYmd)) { issues.push( @@ -173,28 +170,36 @@ console.log("rainChkgdData", rainChkgdData); ); } - if (rain.operMngCd.length > 1 && !chkMngType.includes(rain.operMngCd)) { + if (rain.operMngCd.length > 1 && !chkMngType[rain.operMngCd]) { issues.push( - defaultMessage + `운영관리 형태: 위탁 혹은 자체 만 허용) /입력값:${rain.oilqMeasMthd}` + defaultMessage + + `운영관리 형태: 위탁 혹은 자체 만 허용) /입력값:${rain.operMngCd}` ); } - if (rain.oilqMeasMthd.length > 1 && !chkSpwtPositnType.includes(rain.oilqMeasMthd)) { + if ( + rain.oilqMeasMthd.length > 1 && + !rainFcltFlowRateType[rain.oilqMeasMthd] + ) { issues.push( - defaultMessage + `유량측정방법: 유량계, 수위계, 펌프적산전력계, 기타) /입력값:${rain.oilqMeasMthd}` + defaultMessage + + `유량측정방법: 유량계, 수위계, 펌프적산전력계, 기타) /입력값:${rain.oilqMeasMthd}` ); } rain.rainyDetails?.forEach((key) => { if (key.ph?.length > 1 && isInvalidNumber(key.ph)) { - issues.push(defaultMessage + `PH: 숫자 형식 아님 /입력값:${key.ph}`); + issues.push(defaultMessage + `pH: 숫자 형식 아님 /입력값:${key.ph}`); } if (key.trbt?.length > 1 && isInvalidNumber(key.trbt)) { - issues.push(defaultMessage + `탁도: 숫자 형식 아님 /입력값:${key.trbt}`); + issues.push( + defaultMessage + `탁도: 숫자 형식 아님 /입력값:${key.trbt}` + ); } if (key.grssClfg?.length > 1 && isInvalidNumber(key.grssClfg)) { issues.push( - defaultMessage + `총대장균군수: 숫자 형식 아님 /입력값:${key.grssClfg}` + defaultMessage + + `총대장균군수: 숫자 형식 아님 /입력값:${key.grssClfg}` ); } if (key.levyAmt?.length > 1 && isInvalidNumber(key.levyAmt)) { @@ -226,7 +231,7 @@ console.log("rainChkgdData", rainChkgdData); } }); }); - }else{ + } else { toast.error("데이터가 없습니다. 점검 데이터를 확인해주세요."); } diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx index 2b03d86df..b615b6532 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx @@ -87,6 +87,7 @@ export type chHeadType = { export type splRuseWaterType = { utztnUsgCd: string; + utztnUsgCdText: string; splTotal: number; spl01: number; spl02: number; @@ -141,17 +142,17 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [ { id: "cityText", title: "시도", mergeCell: true }, { id: "sggText", title: "시군구", mergeCell: true }, { id: "bdstNm", title: "시설명", mergeCell: true }, - { id: "operMngCd", title: "운영관리형태", mergeCell: true }, - { id: "oilqMeasMthd", title: "유량측정방법", mergeCell: true }, + { id: "operMngCdText", title: "운영관리형태", mergeCell: true }, + { id: "oilqMeasMthdText", title: "유량측정방법", mergeCell: true }, { id: "anlOperCst", title: "연간운영비(원/년)", mergeCell: true }, { id: "dtfcltCpct", title: "빗물저류조용량(m³)", mergeCell: true }, { id: "chckYmd", title: "점검일", mergeCell: true }, - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "totalSplyUswtrUtztnQnt", title: "연간대체수이용량(m³)" }, { id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" }, { id: "ph", - title: "수소이온농도(ph)", + title: "수소이온농도(pH)", upName: "useQuilty", upSequnce: 1, type: "number", @@ -201,7 +202,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [ ]; export const ruseHeadListExport: TableUpperProps[] = [ - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 }, { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 , edit: true }, { id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 , edit: true }, @@ -218,7 +219,7 @@ export const ruseHeadListExport: TableUpperProps[] = [ ]; export const splHeadListExport: TableUpperProps[] = [ - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1}, { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2, edit: true }, { id: "spl02", title: "2월", upName: "splWater", upSequnce: 3, edit: true }, 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/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx index a3372639b..5edba24b5 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx @@ -11,6 +11,7 @@ import { useTypes, type Buildingtype } from "../rainChkgdn/excel"; +import { codeToText, textToCode } from "@/components/lib/func/commom"; export const rswtMakeExcelSample = ( buildings: Buildingtype[], @@ -158,12 +159,12 @@ export const excelToRswtGuideData = ( if (checkYmd.length > 7) { return { bdstRuseFcltSn: Number(item["NO"]), - operMngCd: item["운영관리형태"], + operMngCd: textToCode(item["운영관리형태"], "rainRswtMng") ??item["운영관리형태"], anlOperCst: parseCommaRawValue(item["연간운영비(원/년)"]), prcsCpct: parseRawValue(item[`처리용량(m³)`]), spwtPositn: item["채수지점"], chckYmd: checkYmd, - utztnUsgCd: item["이용용도"], + utztnUsgCd: textToCode(item["이용용도"], "dmdUszCd")??item["이용용도"], guideDetails: makeGuidDetail, rgtr: TEST_UUID, mdfr: TEST_UUID, @@ -226,7 +227,7 @@ export const excelToRswtPolution = (excelData: any) => { return { bdstRuseFcltSn: Number(item["NO"]), chckYmd: checkYmd, - utztnUsgCd: item["이용용도"], + utztnUsgCd: textToCode(item["이용용도"], "dmdUszCd")??item["이용용도"], operMngCd: item["운영관리형태"], anlOperCst: parseCommaRawValue(item["연간운영비(원/년)"]), prcsCpct: parseRawValue(item["처리용량(m³)"]), @@ -236,7 +237,7 @@ export const excelToRswtPolution = (excelData: any) => { mdfr: TEST_UUID, rswtrDetails: [ { - utztnUsgCd: item["이용용도"], + utztnUsgCd: textToCode(item["이용용도"], "dmdUszCd")??item["이용용도"], vltnDt: vltnDt, vltnMttr: item["위반사항"], levyAmt: Number(item["과태료 부과금액(천원)"]) ?? 0, @@ -248,13 +249,6 @@ export const excelToRswtPolution = (excelData: any) => { } }) .filter((el: any) => el !== undefined); - // if (rswtChkgdData.length > 0) { - // rswtExcelDataCheck(rswtChkgdData, issues); - // } - - // if (issues.length > 0) { - // return { data: [], issues }; - // } return rswtChkgdData }; @@ -265,7 +259,7 @@ export const rswtExcelDataCheck = ( ) => { rswtChkgdData.forEach((rswt: any) => { - const defaultMessage = `*중수도 수질 [NO: ${rswt.bdstRuseFcltSn}, 점검일: ${rswt.chckYmd}, 이용용도: ${rswt.utztnUsgCd}] 항목에서 `; + const defaultMessage = `*중수도 수질 [NO: ${rswt.bdstRuseFcltSn}, 점검일: ${rswt.chckYmd}, 이용용도: ${codeToText(rswt.utztnUsgCd ,"dmdUszCd")??rswt.utztnUsgCd}] 항목에서 `; if (rswt.chckYmd && isInvalidDate(rswt.chckYmd)) { issues.push(defaultMessage + `점검일: 날짜 형식 아님 (${rswt.chckYmd})`); @@ -284,7 +278,7 @@ export const rswtExcelDataCheck = ( } // if ( // rswt.spwtPositn.length > 1 && - // !chkSpwtPositnType.includes(rswt.spwtPositn) + // !rainFcltFlowRateType[rswt.spwtPositn] // ) { // issues.push( // defaultMessage + diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx index 56ee59197..6e94ec4e6 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx @@ -53,6 +53,7 @@ const buildingZod = z.object({ }); export const rswtrPolutionsZode = z.object({ + utztnUsgCdText:z.string().nullish(), chkgdnDtlFk: z.string().nullish(), utztnUsgCd: z.string().nullish(), node: z.string().nullish(), @@ -143,7 +144,7 @@ export const rswtChkHeadListExport: TableUpperProps[] = [ { id: "prcsCpct", title: "처리용량(m³)" ,mergeCell: true}, { id: "spwtPositn", title: "채수지점" ,mergeCell: true}, { id: "chckYmd", title: "점검일" ,mergeCell: true}, - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "splyUswtrUtztnQnt", title: "연간대체수이용량(m³)" ,type: "number"}, { id: "ruseFcltUtztnQnt", title: "연간중수도이용량(m³)",type: "number"}, @@ -167,7 +168,7 @@ export const rswtChkHeadListExport: TableUpperProps[] = [ { id: "crmty", title: "색도(도)", upName: "useQuilty", upSequnce: 6 ,type: "number"}, { id: "tn", title: "총질소(T-N)(mg/L)", upName: "useQuilty", upSequnce: 7 ,type: "number"}, { id: "tph", title: "총인(T-P)(mg/L)", upName: "useQuilty", upSequnce: 8 ,type: "number"}, - { id: "ph", title: "수소이온농도(ph)", upName: "useQuilty", upSequnce: 9,type: "text" }, + { id: "ph", title: "수소이온농도(pH)", upName: "useQuilty", upSequnce: 9,type: "text" }, { id: "clIonQnt", title: "염화물(mg/L)", upName: "useQuilty", upSequnce: 10 ,type: "number"}, { @@ -197,7 +198,7 @@ export const rswtChkHeadListExport: TableUpperProps[] = [ export const rswtDetailHeadListExport: TableUpperProps[] = [ - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "grssClfgUswtr", @@ -237,7 +238,7 @@ export const rswtChkHeadListExport: TableUpperProps[] = [ }, { id: "tn", title: "T-N", upName: "detailQulity", upSequnce: 8, edit: true }, { id: "tph", title: "T-P", upName: "detailQulity", upSequnce: 9, edit: true }, - { id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10, edit: true }, + { id: "ph", title: "pH", upName: "detailQulity", upSequnce: 10, edit: true }, { id: "clIonQnt", title: "염화물", diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx index afba2f813..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; @@ -84,6 +85,7 @@ type rswtChkgdnActions = { rswtChkPolInit: () => void; rwstPolAndGuideUpdate: (rswtChk: rswtChkZodType[]) => void; rswtChkHeadChange: (rswtChkgdn: rswtChkgdnState, isEdit: boolean) => void; + setRswtChkLoading:(status:boolean) =>void }; export type rswtChkgdnType = rswtChkgdnState & rswtChkgdnActions; @@ -153,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); @@ -394,6 +397,15 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = ( } catch (e) { console.error(e); } - }, + },setRswtChkLoading:(status:boolean) =>{ + set((state: rswtChkgdnState) => ({ + ...state, + rswtChkgdn: { + ...state.rswtChkgdn, + isLoading: status, + }, + })); + } + }; }; diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx index bfd2838d0..51b9634d3 100644 --- a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx +++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx @@ -5,17 +5,17 @@ export const rainChkgdnHeadSttnExport: TableUpperProps[] = [ { id: "cityText", title: "시도", mergeCell: true }, { id: "sggText", title: "시군구", mergeCell: true }, { id: "bdstNm", title: "시설명", mergeCell: true }, - { id: "operMngCd", title: "운영관리형태", mergeCell: true }, - { id: "oilqMeasMthd", title: "유량측정방법", mergeCell: true }, + { id: "operMngCdText", title: "운영관리형태", mergeCell: true }, + { id: "oilqMeasMthdText", title: "유량측정방법", mergeCell: true }, { id: "anlOperCst", title: "연간운영비(원/년)", mergeCell: true }, { id: "dtfcltCpct", title: "빗물저류조용량(m³)", mergeCell: true }, { id: "chckYmd", title: "점검일", mergeCell: true }, - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "totalSplyUswtrUtztnQnt", title: "연간대체수이용량(m³)" }, { id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" }, { id: "ph", - title: "수소이온농도(ph)", + title: "수소이온농도(pH)", upName: "useQuilty", upSequnce: 1, type: "number", @@ -59,7 +59,7 @@ export const rainChkgdnHeadSttnExport: TableUpperProps[] = [ ]; export const ruseSttnHeadListExport: TableUpperProps[] = [ - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 }, { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 }, { id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 }, @@ -76,7 +76,7 @@ export const ruseSttnHeadListExport: TableUpperProps[] = [ ]; export const splSttnHeadListExport: TableUpperProps[] = [ - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1 }, { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2 }, { id: "spl02", title: "2월", upName: "splWater", upSequnce: 3 }, @@ -108,7 +108,7 @@ export const splSttnHeadListExport: TableUpperProps[] = [ ]; export const rswtDetailHeadListExport: TableUpperProps[] = [ - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "grssClfgUswtr", @@ -153,7 +153,7 @@ export const rswtDetailHeadListExport: TableUpperProps[] = [ upName: "detailQulity", upSequnce: 9, }, - { id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10 }, + { id: "ph", title: "pH", upName: "detailQulity", upSequnce: 10 }, { id: "clIonQnt", title: "염화물", diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx index 382396566..831266e36 100644 --- a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx +++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx @@ -10,7 +10,7 @@ export const rswtChkSttnHeadListExport: TableUpperProps[] = [ { id: "prcsCpct", title: "처리용량(m³)", mergeCell: true }, { id: "spwtPositn", title: "채수지점", mergeCell: true }, { id: "chckYmd", title: "점검일", mergeCell: true }, - { id: "utztnUsgCd", title: "이용용도" }, + { id: "utztnUsgCdText", title: "이용용도" }, { id: "splyUswtrUtztnQnt", title: "연간보급수이용량(m³)", type: "number" }, { id: "ruseFcltUtztnQnt", title: "연간중수도이용량(m³)", type: "number" }, @@ -64,7 +64,7 @@ export const rswtChkSttnHeadListExport: TableUpperProps[] = [ upSequnce: 8, type: "number", }, - { id: "ph", title: "수소이온농도(ph)", upName: "useQuilty", upSequnce: 9, type: "text" }, + { id: "ph", title: "수소이온농도(pH)", upName: "useQuilty", upSequnce: 9, type: "text" }, { id: "clIonQnt", title: "염화물(mg/L)", @@ -132,7 +132,7 @@ export const rswtDetailSttnHeadListExport: TableUpperProps[] = [ }, { id: "tn", title: "T-N", upName: "detailQulity", upSequnce: 8}, { id: "tph", title: "T-P", upName: "detailQulity", upSequnce: 9 }, - { id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10 }, + { id: "ph", title: "pH", upName: "detailQulity", upSequnce: 10 }, { id: "clIonQnt", title: "염화물", 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 ?? [], }, })); - } - + }, }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx index b44f5f700..ff263783a 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx @@ -1,5 +1,5 @@ import type { TableUpperProps } from "@/app/store/common/type/header"; -import { getFetchWithCount, postFectch, putFectch } from "@/components/lib/api"; +import { fetchType, getFetchWithCount, postFectch, putFectch } from "@/components/lib/api"; import toast from "react-hot-toast"; import { z } from "zod"; import { makeMdfr, makeRstr } from "../bdstReg"; @@ -71,7 +71,6 @@ export const selectClass = "w-full h-full !text-xl"; export type rainFacState = { rain: { - isInit: boolean; upHeadList: TableUpperProps[]; rainRes: customRainBdst[]; rainResCount: number; @@ -80,7 +79,7 @@ export type rainFacState = { type rainFacSActions = { initRain: (code: string | number) => void; getRainData: (pageNation: number, code: string | number) => void; - rainSearch: (txt: string, pageNation: number, code: string | number) => void; + rainSearch: (txt: string, pageNation: number, code: string ) => void; rainBdstReg: (data: customRainBdst, code: string | number) => void; rainBdstUpdate: (data: customRainBdst, code: string | number) => void; @@ -90,7 +89,6 @@ export type rainFacType = rainFacState & rainFacSActions; export const rainFacStateExport: rainFacState = { rain: { - isInit: false, rainRes: rainRes, rainResCount: 1, upHeadList: upHeadList, @@ -98,8 +96,7 @@ export const rainFacStateExport: rainFacState = { }; const initFetch = async (code: string | number) => { - // const rainRes =await getFetch("wr", `/reuseFc/rainyInfoList/1/10/${code}`); - const rainRes = await getFetchWithCount("wr", `/reuseFc/rainyInfoList/1/${rainRegSize}/${code}`); + const rainRes = await getFetchWithCount(fetchType.WR, `/reuseFc/rainyInfoList/1/${rainRegSize}/${code}`); return rainRes; }; export const rainFacActionsExport: (set: any) => rainFacSActions = ( @@ -108,7 +105,7 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = ( return { getRainData: async (pageNation: number, code: string | number) => { try { - const rainRes = await getFetchWithCount("wr", `/reuseFc/rainyInfoList/${pageNation}/${rainRegSize}/${code}`); + const rainRes = await getFetchWithCount(fetchType.WR, `/reuseFc/rainyInfoList/${pageNation}/${rainRegSize}/${code}`); // 여기서 상태 업데이트 return set((state: rainFacState) => ({ @@ -117,7 +114,6 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = ( ...state.rain, rainRes: rainRes.data, rainResCount: rainRes.count, - isInit: false, }, })); @@ -138,18 +134,17 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = ( ...state.rain, rainRes: rainRes.data, rainResCount: rainRes.count, - isInit: false, }, })); } catch (error) { console.log("error", error); } }, - rainSearch: async (txt: string, pageNation: number) => { + rainSearch: async (txt: string, pageNation: number ,code:string) => { try { // const rainRes = await getFetch('wr' , `/reuseFc/rainyInfoList/${pageNation}/20/41` +(txt? `/${txt}`:'')) - const rainRes = await getFetchWithCount('wr', `/reuseFc/rainyInfoList/${pageNation}/${rainRegSize}/41` + (txt ? `/${txt}` : '')) + const rainRes = await getFetchWithCount(fetchType.WR, `/reuseFc/rainyInfoList/${pageNation}/${rainRegSize}/${code}` + (txt ? `/${txt}` : '')) console.log("rainRes", rainRes) set((state: rainFacState) => { return { @@ -157,7 +152,6 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = ( ...state.rain, rainRes: rainRes.data, rainResCount: rainRes.count, - isInit: false, }, }; }) @@ -201,7 +195,6 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = ( ...state.rain, rainRes: rainRes.data, rainResCount: rainRes.count, - isInit: false, }, })); } catch (e) { @@ -253,7 +246,6 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = ( ...state.rain, rainRes: rainRes.data, rainResCount: rainRes.count, - isInit: false, }, })); } catch (e) { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx index 42e771292..d324f3332 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx @@ -11,15 +11,11 @@ import { baseReuseBuildingSchema, chgBuildingSchema, validationMessages } from " export const rswtRegSize =15; const rswtrObjSchema = z.object({ bdstRuseFcltSn: z.number().nullish(), - //wtrUsqty: z.number({ required_error: validationMessages.required("물사용량(m³)") }).positive({ message: validationMessages.required("물사용량(m³)") }), - //oblgTrgtWtrUsqty: z.number().nullish().default(0), orgwtKndCd: z.string({ required_error: validationMessages.requiredSelect("원수 종류") }).min(1, { message: validationMessages.requiredSelect("원수 종류") }), filtrTrtmfctCpct: z.number().nullish(), filtrTrtmfctProcs: z.string({ required_error: validationMessages.required("주요처리공정") }).min(1, { message: validationMessages.required("주요처리공정") }), filtrTrtmfctUsgCd: z.string().default("").nullish(), rswtrUsqty: z.number().default(0), - //altUswtrUtztnYn: z.enum(["Y", "N"]).nullish(), //안쓰는값 -// altUswtrKndCd: z.string().default("").nullish(), //안쓰는값 altUswtrUtztnQnt: z.number().default(0), //안쓰는값 altUswtrIdntyMthdCd: z.string().default("").nullish(), //안쓰는값 rgtr: z.string().nullish().default(null), @@ -56,7 +52,6 @@ const rswtRes: customRswtBdst[] = []; export type rswtFacState = { rswt: { - isInit: boolean; upHeadList: TableUpperProps[]; rswtRes: customRswtBdst[]; rswtResCount: number; @@ -78,7 +73,6 @@ export type rswtFacType = rswtFacState & rswtFacSActions; export const rswtFacStateExport: rswtFacState = { rswt: { - isInit: false, upHeadList: upHeadList, rswtRes: rswtRes, rswtResCount: 1, @@ -111,7 +105,6 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( ...state.rswt, rswtRes: rswtRes.data, rswtResCount: rswtRes.count, - isInit: false, }, }; }); @@ -133,7 +126,6 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( ...state.rswt, rswtRes: rswtRes.data, rswtResCount: rswtRes.count, - isInit: false, }, })); } catch (e) { @@ -149,7 +141,6 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( ...state.rswt, rswtRes: rswtRes.data, rswtResCount: rswtRes.count, - isInit: false, }, })); } catch (error) { @@ -189,7 +180,6 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( ...state.rswt, rswtRes: rswtRes.data, rswtResCount: rswtRes.count, - isInit: false, }, })); @@ -235,7 +225,6 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( ...state.rswt, rswtRes: rswtRes.data, rswtResCount: rswtRes.count, - isInit: false, }, })); } catch (e) { diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx index 60b726e2b..a1d1193b2 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx @@ -461,7 +461,7 @@ export const ruseGuranteeHeadListExport: TableUpperProps[] = [ { id: "crmty", title: "색도(도)", visible: true }, { id: "tn", title: "총질소(mg/L)", visible: true }, { id: "tph", title: "총인(mg/L)", visible: true }, - { id: "ph", title: "수소이온농도(ph)", visible: true }, + { id: "ph", title: "수소이온농도(pH)", visible: true }, { id: "clIonQnt", title: "염화물(mg/L)", visible: true }, { id: "cdtnv", title: "전기전도도(μs/cm)​", visible: true }, ]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx index 65f02e26b..989a73071 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx @@ -1,22 +1,18 @@ import type { SelectDataType } from "@common/business_components/ui"; import type { customRainBdst } from "../../fcltReg/rainReg"; -import { bdstUsgCd } from "@/app/store/common/code/basicCode"; -//TODO: 공통코드시 삭제되니 수정 해야됨 export const excelRainSttnParsing = ( excel: { data: customRainBdst[] }, - sidoCode: SelectDataType[], - sggCode: SelectDataType[] + code: Record ): string[][] => { const excelExportData: string[][] = []; excel.data.forEach((item) => { - console.log("item", item) excelExportData.push([ - sidoCode.find((sido) => sido.val === item.ctpvCd?.toString())?.text ?? "", - sggCode.find((sgg) => sgg.val === item.sggCd?.toString())?.text ?? "", + code?.cityCd?.find((sido) => sido.val === item.ctpvCd?.toString())?.text ?? "", + code?.sggCd?.find((sgg) => sgg.val === item.sggCd?.toString())?.text ?? "", item.bdstNm ?? "", item.daddr ?? "", - bdstUsgCd.find((cd) => cd.val === item.reuseBuilding?.[0]?.bdstUsgCd.toString())?.text ?? "", //건축물용도 + code?.bdstUsgCd?.find((cd) => cd.val === item.reuseBuilding?.[0]?.bdstUsgCd.toString())?.text ?? "", //건축물용도 String(item.frstArchPrmsnDt ?? ""), String(item.archArea.split('.')[0] === '-1' ? '확인불가' : item.archArea.split('.')[0]), String(item.chgBuilding.length > 0 ? "Y" : "N"), diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx index e78183cc5..9ed008ac5 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx @@ -126,7 +126,7 @@ export const rainSttHeadListExport: z.infer = [ visible: true, }, { - id: "grntchBdstCertGrd", + id: "grntchBdstCertGrdText", title: "녹색건축물인증등급", visible: true, }, @@ -405,7 +405,7 @@ export const rainSttNodeListExport: CommonTableProps[] = [ colSpan: 1, }, { - id: "grntchBdstCertGrd", + id: "grntchBdstCertGrdText", title: "인증등급", upName: "grntchBdstCert", visible: true, @@ -445,7 +445,7 @@ export const rainSttnDetailNodeListExport:CommonTableProps[] = [ rowSpan: 1, colSpan: 4 }, - { id: "ph", title: "PH", + { id: "ph", title: "pH", visible: true, row: 2, rowSpan: 1, @@ -524,7 +524,7 @@ export const rainSttnDetailHeadListExport:CommonTableProps[] = [ colSpan: 1 }, - { id: "ph", title: "PH", + { id: "ph", title: "pH", visible: true, row: 1, rowSpan: 1, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx index 34629f259..e57603fe3 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx @@ -102,12 +102,8 @@ export type rainSttnState = { }; }; type rainSttnActions = { - rainSttnInit: (isExcel: boolean, page: number, total: number, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => void - rainSttnSearch: (isExcel: boolean, page: number, total: number, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => void; + rainSttnInit: (isExcel: boolean, page: number, total: number, con: string, txt: string,code: Record ) => void + rainSttnSearch: (isExcel: boolean, page: number, total: number, con: string, txt: string,code: Record) => void; rainChSttnHead: ( headList: z.infer, ) => void; @@ -134,9 +130,7 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = ( set: any ) => { return { - rainSttnInit: async (isExcel: boolean, page: number, total: number, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => { + rainSttnInit: async (isExcel: boolean, page: number, total: number, con: string, txt: string, code: Record) => { try { const rainSttnRes = await getFetchWithCount( @@ -148,7 +142,7 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = ( (txt ? `/${txt}` : "") ); if (isExcel) { - const rainExcel = excelRainSttnParsing(rainSttnRes, sidoCode, sggCode); + const rainExcel = excelRainSttnParsing(rainSttnRes, code); set((state: rainSttnState) => { return { ...state, @@ -174,9 +168,7 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = ( console.log(e) } }, - rainSttnSearch: async (isExcel: boolean, page: number, total: number, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => { + rainSttnSearch: async (isExcel: boolean, page: number, total: number, con: string, txt: string,code: Record) => { try { const rainSttnRes = await getFetchWithCount( fetchType.WR, @@ -187,7 +179,7 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = ( (txt ? `/${txt}` : "") ); if (isExcel) { - const rainExcel = excelRainSttnParsing(rainSttnRes, sidoCode, sggCode); + const rainExcel = excelRainSttnParsing(rainSttnRes,code); set((state: rainSttnState) => { return { ...state, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx index b3d3835c2..46a2f0e61 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx @@ -1,21 +1,20 @@ -import { bdstUsgCd } from "@/app/store/common/code/basicCode"; import type { SelectDataType } from "@common/business_components/ui"; import type { customRswtBdst } from "../../fcltReg/rswtReg"; + export const excelRSwtSttnParsing = ( excel: { data: customRswtBdst[] }, - sidoCode: SelectDataType[], - sggCode: SelectDataType[] + code: Record ): string[][] => { + const excelExportData: string[][] = []; excel.data.forEach((item) => { - console.log("item", item) excelExportData.push([ - sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "", - sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "", + code.cityCd?.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "", + code.sggCd?.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "", item.bdstNm ?? "", item.daddr ?? "", - bdstUsgCd.find((cd)=> cd.val === item.reuseBuilding?.[0]?.bdstUsgCd.toString())?.text ?? "", //건축물용도 + code?.bdstUsgCd?.find((cd)=> cd.val === item.reuseBuilding?.[0]?.bdstUsgCd.toString())?.text ?? "", //건축물용도 String(item.frstArchPrmsnDt ?? ""), String(item.archArea.split('.')[0] === '-1' ? '확인불가' : item.archArea.split('.')[0]), // String(item.reuseBuilding?.[0]?.rswtrObj.wtrUsqty ?? "0"), //물사용량 diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx index e4bcce08a..ec772610d 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx @@ -119,7 +119,7 @@ export const rswtSttHeadListExport: z.infer = [ visible: true, }, { - id: "grntchBdstCertGrd", + id: "grntchBdstCertGrdText", title: "녹색건축물인증등급", visible: true, }, @@ -379,7 +379,7 @@ export const rswtSttNodeListExport: CommonTableProps[] = [ colSpan: 1, }, { - id: "grntchBdstCertGrd", + id: "grntchBdstCertGrdText", title: "인증등급", upName: "grntchBdstCert", visible: true, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx index 1d4617442..47444ce32 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx @@ -30,12 +30,8 @@ export type rswtSttnState = { }; type rswtSttnActions = { - rswtSttnInit: (isExcel: boolean, page: number, total: number, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => void; - rswtSttnSearch: (isExcel: boolean, page: number, total: number, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => void; + rswtSttnInit: (isExcel: boolean, page: number, total: number, con: string, txt: string, code: Record) => void; + rswtSttnSearch: (isExcel: boolean, page: number, total: number, con: string, txt: string, code: Record) => void; rswtChSttnHead: ( headList: z.infer, ) => void; @@ -60,9 +56,7 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = ( set: any ) => { return { - rswtSttnInit: async (isExcel: boolean, page: number, total: number, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => { + rswtSttnInit: async (isExcel: boolean, page: number, total: number, con: string, txt: string, code: Record) => { try { const rswtSttnRes = await getFetchWithCount( fetchType.WR, @@ -73,17 +67,17 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = ( (txt ? `/${txt}` : "") ); if (isExcel) { - const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, sidoCode, sggCode); - set((state: rswtSttnState) => { - return { - ...state, - rswtSttn: { - ...state.rswtSttn, - excelList: rswtExcel, - }, - }; - }); - } else + const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, code); + set((state: rswtSttnState) => { + return { + ...state, + rswtSttn: { + ...state.rswtSttn, + excelList: rswtExcel, + }, + }; + }); + } set((state: rswtSttnState) => { return { @@ -100,9 +94,7 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = ( console.log(e) } }, - rswtSttnSearch: async (isExcel: boolean, page: number, total: number, con: string, txt: string, - sidoCode: SelectDataType[], - sggCode: SelectDataType[]) => { + rswtSttnSearch: async (isExcel: boolean, page: number, total: number, con: string, txt: string,code: Record) => { try { const rswtSttnRes = await getFetchWithCount( fetchType.WR, @@ -113,7 +105,7 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = ( (txt ? `/${txt}` : "") ); if (isExcel) { - const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, sidoCode, sggCode); + const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, code); set((state: rswtSttnState) => { return { ...state, diff --git a/apps/wr/app/store/stats/rswtStat/excel.tsx b/apps/wr/app/store/stats/rswtStat/excel.tsx index 00935b8fb..4bd698ad0 100644 --- a/apps/wr/app/store/stats/rswtStat/excel.tsx +++ b/apps/wr/app/store/stats/rswtStat/excel.tsx @@ -1,7 +1,10 @@ -import type { RswtStatProps } from "."; -import { bdstUsgCd } from "../../common/code/basicCode"; +import type { SelectDataType } from "@common/business_components/ui"; +import type { RswtStatProps } from "."; -export const excelRswtStat = (excelList:RswtStatProps[]) : (string | number)[][] => { +export const excelRswtStat = (excelList: RswtStatProps[], rswtBdstType : SelectDataType[] ) : (string | number)[][] => { + + + console.log('bdstUsgCd ', rswtBdstType) const excelData: (string | number)[][] = []; excelList.forEach((item) => { excelData.push([ @@ -15,7 +18,7 @@ export const excelRswtStat = (excelList:RswtStatProps[]) : (string | number)[][] String(item.bdstNm) ?? "", //건축물용도코드(빈칸) //String(item.bdstUsgCd) ?? "", - bdstUsgCd.find((cd)=> cd.val === item.bdstUsgCd.toString())?.text ?? "", //건축물용도 + rswtBdstType?.find((cd)=> cd.val === item.bdstUsgCd.toString())?.text ?? "", //건축물용도 //주소 String(item.daddr) ?? "", //법적의무대상여부 diff --git a/apps/wr/app/store/stats/rswtStat/index.tsx b/apps/wr/app/store/stats/rswtStat/index.tsx index 89c4089c0..bd9a9c8e0 100644 --- a/apps/wr/app/store/stats/rswtStat/index.tsx +++ b/apps/wr/app/store/stats/rswtStat/index.tsx @@ -2,6 +2,7 @@ import { fetchType, getFetch } from "@/components/lib/api"; import type { TableUpperProps } from "../../common/type/header"; import { rswtStatHeadListExport } from "./headList"; import { excelRswtStat } from "./excel"; +import type { SelectDataType } from "@common/business_components/ui"; export type RswtStatProps = { cityText: string //시도명 @@ -38,7 +39,7 @@ export type GuideStatProps = { } type rswtStatActions = { - searchRswtStatList: (year: string, city: { val: string; text: string }[]) => void; + searchRswtStatList: (year: string, city: SelectDataType[],bdstUsgCd: SelectDataType[] ) => void; } export type ExcelType = { @@ -72,7 +73,7 @@ export const rswtStatActionsExport: (set: any) => rswtStatActions = ( set: any ) => { return { - searchRswtStatList: async (year: string, city: { val: string; text: string }[]) => { + searchRswtStatList: async (year: string, city: SelectDataType[] , rswtBdstType:SelectDataType[]) => { const res = await getFetch(fetchType.WR, `/reuseChk/reuseWater/stat/${year}`) const data = res.filter(item => { const code = item.ctpvCd.trim(); @@ -198,7 +199,7 @@ export const rswtStatActionsExport: (set: any) => rswtStatActions = ( utztnUsgCd: utztnUsgArray.join(', '), }) }); - const excelDetailData = excelRswtStat(rswtDetailList); + const excelDetailData = excelRswtStat(rswtDetailList,rswtBdstType); set((state: rswtStatState) => ({ rswtStat: { ...state.rswtStat, diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index e19ec2216..fbb3434d9 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -3,6 +3,7 @@ import { codeActionExport, comCodeStateExport, getCityCd, + getCommonUpCd, getEnvPartCd, getMiddleRegionCd, getRegionCd, @@ -334,13 +335,14 @@ export const StoreZus = ( ...dmMapState, } ) => { - return createStore()((set) => { + return createStore()((set ,get) => { getSggCd(set); getCityCd(set); getRegionCd(set); getMiddleRegionCd(set); getUnitWaterShedCd(set); getEnvPartCd(set); + getCommonUpCd(set) return { ...initState, ...comFcltSearchAction(set), @@ -349,7 +351,7 @@ export const StoreZus = ( ...rswtFacActionsExport(set), ...matDmdActionsExport(set), ...htdflFacActionsExport(set), - ...codeActionExport(set), + ...codeActionExport(set,get), ...bdstActionsExport(set), ...rainChkgdnActionsExport(set), ...rswtChkgdnActionsExport(set), @@ -369,7 +371,7 @@ export const StoreZus = ( ...ruseCaseActionsExport(set), ...rainStatActionsExport(set), ...rswtStatActionsExport(set), - ...authActionsExport(set), + ...authActionsExport(set,get), ...commonMapActionsExport(set), ...pbnMapActionsExport(set), ...rainMapActionsExport(set), diff --git a/apps/wr/components/lib/func/TableData.tsx b/apps/wr/components/lib/func/TableData.tsx index bee5e093d..1a66802f5 100644 --- a/apps/wr/components/lib/func/TableData.tsx +++ b/apps/wr/components/lib/func/TableData.tsx @@ -10,6 +10,7 @@ import { } from "@common/components/ui"; import moment from "moment"; import { + codeToText, formatCommaNumber, formatYyyymmdd, handleCommaNumberChange @@ -73,23 +74,23 @@ export const rswtChkTableData = (chkData: rswtChkZodType[]) => { let flatRswtChk = {}; const findGuide = root.guideDetails.find( (guide) => guide.utztnUsgCd === detail.utztnUsgCd - ); + ) const findPoluttion = root.rswtrPollutions.find( (polution) => polution.utztnUsgCd === detail.utztnUsgCd ); - const operMngCd = root?.reuseBuilding.operMngCd; flatRswtChk = { ...root, ...detail, ...findGuide, ...findPoluttion, ...flatRswtChk, - operMngCd: operMngCd, + utztnUsgCdText: codeToText(detail.utztnUsgCd, 'dmdUszCd'), }; makeRswtData.push(flatRswtChk); }); }); } + return makeRswtData; }; diff --git a/apps/wr/components/lib/func/commom.tsx b/apps/wr/components/lib/func/commom.tsx index 042e74aa6..1e15fae1c 100644 --- a/apps/wr/components/lib/func/commom.tsx +++ b/apps/wr/components/lib/func/commom.tsx @@ -1,4 +1,4 @@ -import type { comCodeState } from "@/app/store/common/code"; +import { lwCds, type comCodeState } from "@/app/store/common/code"; import { filePickedBlob, filePickedBlobArray, @@ -33,12 +33,11 @@ export const getCity = (val: string, sggCd: SelectDataType[]) => { // cd text 넣기 export const tableData = (data: any, code: comCodeState) => { const chCode = code.code; - return data?.map( (item: { sggCd: string; ctpvCd: string; - reuseBuilding: { lawTrgtYn: any; bdstUsgCd: any }[]; + reuseBuilding: { lawTrgtYn: string; bdstUsgCd: string ,grntchBdstCertGrd:string}[]; }) => { let returnData = {}; const sggText = chCode.sggCd.find( @@ -48,16 +47,25 @@ export const tableData = (data: any, code: comCodeState) => { (cd) => cd.val === String(item.ctpvCd).trim() )?.text; if (item?.reuseBuilding?.length > 0) { - const bdsgUsgText = chCode.bdstUsgCd.find( - (cd) => Number(cd.val) === item?.reuseBuilding[0]?.bdstUsgCd + + const bdsgUsgText = chCode?.bdstTotalUsgType?.find( + (cd) => cd.val === item?.reuseBuilding[0]?.bdstUsgCd )?.text; + const lawTrgtYn = item?.reuseBuilding[0]?.lawTrgtYn; + + + const grntchBdstCertGrdText =chCode?.bdstGrntchClass?.find( + (cd) => cd.val === item?.reuseBuilding[0]?.grntchBdstCertGrd + )?.text; + returnData = { ...item, sggText: sggText ?? "없음", cityText: cityText ?? "없음", bdsgUsgText: bdsgUsgText, lawTrgtYn: lawTrgtYn, + grntchBdstCertGrdText:grntchBdstCertGrdText }; } else { returnData = { @@ -296,4 +304,23 @@ export const formatArchArea =(value: string, digits: number=0 ) => { // 다시 천 단위 콤마 찍어서 반환 return Number(rounded).toLocaleString(); +} + + +export const codeToText = ( val:string, codeName:string ) =>{ + + if(val===''|| val===undefined){ + return '' + } + + return lwCds[codeName]?.find((cd) => cd.val ===val)?.text +} + +export const textToCode = (text:string, codeName:string) =>{ + if(text===''|| text===undefined){ + return '' + } + + return lwCds[codeName]?.find((cd) => cd.text ===text)?.val + } \ No newline at end of file diff --git a/apps/wr/components/lib/func/mapUtil.ts b/apps/wr/components/lib/func/mapUtil.ts index 13ce5b82a..a39bf17d7 100644 --- a/apps/wr/components/lib/func/mapUtil.ts +++ b/apps/wr/components/lib/func/mapUtil.ts @@ -197,7 +197,7 @@ export const getOverLayObj = (fclType: string, data: any,code?:any) => { newObj = { 건물용도: code?.bdstUsgCd.find((item) => item.val===String(data?.reuseBuilding[0].bdstUsgCd) )?.text ?? '확인불가', 설치완료일: data?.reuseBuilding[0]?.instlCmptnDt ?? '확인불가', - "주요 처리공정": code?.rswtPrscCdMthdCd.find((item) => item.val===data?.reuseBuilding[0]?.rswtrObj.filtrTrtmfctProcs)?.text ?? '확인불가', + "주요 처리공정": data?.reuseBuilding[0]?.rswtrObj.filtrTrtmfctProcs ?? '확인불가', 원수종류: code?.orgwtKndCd.find((item) => item.val === data?.reuseBuilding[0]?.rswtrObj.orgwtKndCd)?.text ?? '확인불가', //이용용도: isCode.filtrTrtmfctUsgCd data?.reuseBuilding[0]?.rswtrObj.altUswtrKndCd ?? '확인불가', }; diff --git a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx index 0b7be34fa..91a2c5379 100644 --- a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx +++ b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx @@ -9,19 +9,16 @@ import { SelectBox, type SelectDataType, } from "@common/business_components"; -import SearchInputAddress from "@common/business_components/ui/search_input_address"; -import type { addressType } from "@common/business_components/ui/search_input_address/findAddress"; import { Input } from "@common/components"; import { useEffect, useState } from "react"; export default function BdstReg({ form, type }: { form: any; type?: string }) { - const { code } = useWrStore((state) => { + const { code, returnCodeText } = useWrStore((state) => { return state; }); const { userSiSggCd } = code; const [useCityCd, setUserCityCd] = useState([]); const [useSggCd, setUserSggCd] = useState([]); - const [initDaddr, setInitDaddr] = useState(); useEffect(() => { if (userSiSggCd.length === 2 && code.cityCd.length > 0) { @@ -56,10 +53,8 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { form.setValue("ctpvCd", Number(city[0]?.val)); form.setValue("sggCd", Number(sgg[0]?.val)); } - }, [form, userSiSggCd, code.cityCd, code.sggCd]); - useEffect(() => { const subscription = form.form?.watch((value: any) => { console.log("vale", value); @@ -72,12 +67,40 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { // console.log("form ", form.watch()); // }, [form.formState]); + useEffect(() => { + const bdstInfoSn = form.getValues("bdstInfoSn"); + if (bdstInfoSn && bdstInfoSn > 0) form.setValue("daddr", bdstInfoSn); + }, [form.getValues("bdstInfoSn")]); + + const userCtpvCd = form.watch("ctpvCd"); + const userSggCd = form.watch("sggCd"); useEffect(() => { - const bdstInfoSn = form.getValues("bdstInfoSn"); - if(bdstInfoSn&&bdstInfoSn>0) - setInitDaddr(form.getValues("daddr")); - }, [form.getValues("bdstInfoSn")]); + const strCtpvCd = String(userCtpvCd); + + if (strCtpvCd && strCtpvCd !== "0") { + const city = returnCodeText(strCtpvCd, "cityCd"); + form?.setValue("daddr", city); + } else if (strCtpvCd === "0") { + form?.setValue("daddr", ""); + } + }, [userCtpvCd]); + + useEffect(() => { + const strSggCd = String(userSggCd); + if (strSggCd && strSggCd !== "0") { + const city = returnCodeText(strSggCd.slice(0, 2), "cityCd"); + const sgg = returnCodeText(strSggCd, "sggCd"); + + form?.setValue("daddr", city + " " + sgg); + } else if (strSggCd === "0") { + const ctpvCdText = returnCodeText( + String(form.getValues("ctpvCd")), + "cityCd" + ); + form?.setValue("daddr", ctpvCdText); + } + }, [userSggCd]); return ( <> @@ -162,24 +185,17 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { name="daddr" render={({ field }) => ( - {/* { - field.onChange(e.target.value) - }} - value={field.value || ''} - maxLength={50} - /> */}
- { - console.log("rtnData", rtnData); - field.onChange(rtnData.roadAddrPart1); + { + field.onChange(e.target.value); }} - > + value={field.value || ""} + maxLength={50} + />
)} @@ -222,9 +238,9 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { className={""} selectClass={selectClass} label={""} - selectArray={code.bdstUsgCd} + selectArray={ type ==='RNB'?code.bdstUsgCd:code.rswtBdstType} onSelectValue={(val) => { - field.onChange(Number(val)); + field.onChange(val); }} value={field.value ?? code.bdstUsgCd[0]?.val} /> diff --git a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx index c17dfda04..192a65397 100644 --- a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx @@ -34,7 +34,7 @@ export default function HtdflRegForm({ isModal, readonly = false, setIsModal, - isMap + isMap, }: { htdflForm: customHtdflBdst; isModal: boolean; @@ -79,9 +79,29 @@ export default function HtdflRegForm({ const cleanHtdflData = (raw: any): z.infer => { const buildings = - raw?.reuseBuilding && raw.reuseBuilding.length > 0 - ? raw.reuseBuilding - : [{}]; + raw?.reuseBuilding && raw.reuseBuilding.length > 0 + ? raw.reuseBuilding + : [{}]; + + if (htdflForm.reuseBuilding && htdflForm.reuseBuilding[0]?.htdflObj.ph) { + const htdflPH = htdflForm.reuseBuilding[0]?.htdflObj.ph; + if (htdflPH && String(htdflPH).includes("~")) { + const [frontPH, backPH] = htdflPH.split("~"); + if (frontPH) { + setFrontPHdata(frontPH); + } + if (backPH) { + setBackPHdata(backPH); + } + } else { + setFrontPHdata(""); + setBackPHdata(""); + } + } else { + setFrontPHdata(""); + setBackPHdata(""); + } + return { ...raw, frstArchPrmsnDt: new Date(raw?.frstArchPrmsnDt || null), @@ -96,7 +116,7 @@ export default function HtdflRegForm({ : new Date(item?.archChgPrmsnDt), bdstChgNm: item?.bdstChgNm ?? "", // null → "" })), - reuseBuilding:buildings.map((item: any) => ({ + reuseBuilding: buildings.map((item: any) => ({ ...item, instlCmptnDt: new Date(item?.instlCmptnDt), htdflObj: { @@ -146,16 +166,16 @@ export default function HtdflRegForm({ const [divStyle, setDivStyle] = useState("h-[53vh]"); useEffect(() => { - if(isMap){ - setDivStyle("h-[100vh]") - }else if (isModal === true) { - setDivStyle("h-[53vh] max-h-[37vh]") + if (isMap) { + setDivStyle("h-[100vh]"); + } else if (isModal === true) { + setDivStyle("h-[53vh] max-h-[37vh]"); } else if (readonly === true) { - setDivStyle("h-[62vh]") + setDivStyle("h-[62vh]"); } else { - setDivStyle("h-[57vh]") + setDivStyle("h-[57vh]"); } - }, [isModal, readonly ,isMap]); + }, [isModal, readonly, isMap]); useEffect(() => { console.log("form errors:", form.formState.errors); @@ -164,25 +184,9 @@ export default function HtdflRegForm({ // form.reset은 비동기로 동작할 수 있어, useEffect 하나로 관리하여 의도치 않은 초기화를 방지합니다. useEffect(() => { // Case 1: 수정 또는 '복사하여 등록' 등 데이터가 주입되는 경우 - if (htdflForm && Object.keys(htdflForm).length > 0) { - - const htdflPH = htdflForm.reuseBuilding[0]?.htdflObj.ph - if(htdflPH && String(htdflPH).includes("~")){ - const [frontPH, backPH] = htdflPH.split("~"); - if (frontPH) { - setFrontPHdata(frontPH); - } - if (backPH) { - setBackPHdata(backPH); - } - } else { - setFrontPHdata(""); - setBackPHdata(""); - } - - + if (htdflForm) { form.reset(cleanHtdflData(htdflForm)); - }else{ + } else { form.reset(); } // Case 2: 데이터가 없는 순수 신규 등록 모드인 경우 @@ -227,37 +231,12 @@ export default function HtdflRegForm({ if (!isPowerPlant) { form.setValue( "reuseBuilding.0.htdflObj.etgtType", - "해당없음", // 빈 문자열로 초기화 + "01", // 빈 문자열로 초기화 { shouldDirty: true } // dirty 상태로 남길지 여부는 취사선택 ); } }, [isPowerPlant, form]); - -// useEffect(() => { -// const watchPH = form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.ph`); -// const checkPkAndCycle = -// form.getValues(`items.${indexMng}.pbnstRuseFcltId`) + -// String(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cycl`)); - -// console.log("checkPkAndCycle ", checkPkAndCycle); -// if (chekcPk !== checkPkAndCycle) { -// if (watchPH && watchPH !== undefined) { -// const [frontPH, backPH] = watchPH.split("~"); -// if (frontPH) { -// setFrontPHdata(frontPH); -// } -// if (backPH) { -// setBackPHdata(backPH); -// } -// } else { -// setFrontPHdata("0"); -// setBackPHdata("0"); -// } -// setCheakPk(checkPkAndCycle); -// } -// }, [form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.ph`), chekcPk]); - return (
@@ -310,12 +289,8 @@ export default function HtdflRegForm({ selectArray={code.htdPowerMthdCd} onSelectValue={readonly ? () => {} : field.onChange} // value={field.value ?? ""} - value={ - field.value || - (code?.htdPowerMthdCd[0] && - code?.htdPowerMthdCd[0].val) - } - readOnly={readonly || !isPowerPlant} + value={field.value} + readOnly={readonly} /> )} @@ -885,7 +860,7 @@ export default function HtdflRegForm({
- +
} > diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/buseWaterQulity/buseWaterQulity.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/buseWaterQulity/buseWaterQulity.tsx index fd9ed6126..dd43658d1 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/buseWaterQulity/buseWaterQulity.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/buseWaterQulity/buseWaterQulity.tsx @@ -460,7 +460,7 @@ export function BuseWaterQulity({ />
- +
void; readonly?: boolean; isMap?: boolean; - }) { - const { code, rswtBdstUpdate, rswtBdstReg } = useWrStore( - (state) => state - ); + const { code, rswtBdstUpdate, rswtBdstReg } = useWrStore((state) => state); // const [divStyle, setDivStyle] = useState("h-[53vh]"); useEffect(() => { - if(isMap){ + if (isMap) { } }, [isMap]); // const defaultValues: z.infer = rswtZod.parse({}); @@ -64,29 +61,27 @@ export default function RswtrRegForm({ "reuseBuilding.0.rswtrObj.filtrTrtmfctProcs", ]); - const { t } = useTranslation('base'); + const { t } = useTranslation("base"); const onSubmit = (values: z.infer) => { if (isModal) { const handleConfirm = async () => { rswtBdstReg(values, "41"); if (setIsModal) setIsModal(false); }; - confirmToast(t('isInsertMsg'), handleConfirm); - + confirmToast(t("isInsertMsg"), handleConfirm); } else { const handleConfirm = async () => { rswtBdstUpdate(values, "41"); }; - confirmToast(t('isUpdateMsg'), handleConfirm); + confirmToast(t("isUpdateMsg"), handleConfirm); } }; - const filtrTrtmfctCpct = form.watch('reuseBuilding.0.rswtrObj.filtrTrtmfctCpct') const cleanRswtData = (raw: any): z.infer => { const buildings = - raw?.reuseBuilding && raw.reuseBuilding.length > 0 - ? raw.reuseBuilding - : [{}]; + raw?.reuseBuilding && raw.reuseBuilding.length > 0 + ? raw.reuseBuilding + : [{}]; return { ...raw, frstArchPrmsnDt: raw?.frstArchPrmsnDt @@ -95,31 +90,26 @@ export default function RswtrRegForm({ archChgPrmsnDt: raw?.archChgPrmsnDt ? new Date(raw?.archChgPrmsnDt) : null, - reuseBuilding:buildings.map((item: any) => ({ + reuseBuilding: buildings.map((item: any) => ({ ...item, instlCmptnDt: item?.instlCmptnDt ? new Date(item.instlCmptnDt) : new Date(), // item?.instlCmptnDt가 유효하지 않으면 현재 날짜로 초기화 operMngCd: item?.operMngCd || "", // null → "" - instlCstSprtYn: item?.instlCstSprtYn || 'N', // null → "Y" - grntchBdstCertYn: item?.grntchBdstCertYn ||'N', + instlCstSprtYn: item?.instlCstSprtYn || "N", // null → "Y" + grntchBdstCertYn: item?.grntchBdstCertYn || "N", bdstUsgCd: item?.bdstUsgCd ?? Number("-1"), // null → "-1" rswtrObj: { ...item?.rswtrObj, filtrTrtmfctYn: item?.rainyObj?.filtrTrtmfctYn || code.yn[0]?.val, filtrTrtmfctCpct: item?.rswtrObj?.filtrTrtmfctCpct ?? null, - filtrTrtmfctProcs: item?.rswtrObj?.filtrTrtmfctProcs || code.rswtPrscCdMthdCd[0]?.val, + filtrTrtmfctProcs: + item?.rswtrObj?.filtrTrtmfctProcs||'', orgwtKndCd: item?.rswtrObj?.orgwtKndCd || code.orgwtKndCd[0]?.val, }, })), }; }; - // useEffect(() =>{ - // console.log(' formform ', form.watch()) - // },[form.formState]) - useEffect(() => { - console.log(' filtrTrtmfctCpct ', filtrTrtmfctCpct) - }, [filtrTrtmfctCpct]) useEffect(() => { console.log("form errors:", form.formState.errors); @@ -133,7 +123,6 @@ export default function RswtrRegForm({ form.setValue("reuseBuilding.0.instlCstSprtAmt", 0); } - if (grntchBdstCertYn === "D") { form.setValue("reuseBuilding.0.grntchBdstCertYr", "0000"); form.setValue("reuseBuilding.0.grntchBdstCertNo", "확인불가"); @@ -141,7 +130,6 @@ export default function RswtrRegForm({ } else if (instlCstSprtYn === "D") { form.setValue("reuseBuilding.0.instlCstSprtAmt", -1); } - }, [grntchBdstCertYn, instlCstSprtYn, filtrTrtmfctProcs, form]); useEffect(() => { @@ -149,8 +137,6 @@ export default function RswtrRegForm({ }, [rswtForm, form]); - - return (
@@ -176,335 +162,342 @@ export default function RswtrRegForm({
{/* */} - {isModal && rswtForm != undefined ? : <>} - {isModal ? ( -

- 중수도 시설 정보{" "} -

- ) : ( - <> - )} -

기본정보

-
-
- ( - - field.onChange(date), + {isModal && rswtForm != undefined ? : <>} + {isModal ? ( +

+ 중수도 시설 정보{" "} +

+ ) : ( + <> + )} +

기본정보

+
+
+ ( + + field.onChange(date), + }} + selectClass={"w-full"} + readOnly={readonly} + /> + + )} + /> +
+
+ { + const value = field.value; + const isUnknown = value === null || value === -1; // 또는 Number(value) === -1 + return ( + + { + // 입력 시 자동으로 확인불가 해제 + if (isUnknown && !readonly) { + field.onChange(""); // 초기화 + } + }} + onChange={(e) => { + if (readonly) return; + handleMinusNumberChange(e, field.onChange); }} - selectClass={"w-full"} readOnly={readonly} + maxLength={numSize} /> - )} - /> -
-
- { - const value = field.value; - const isUnknown = value === null || value === -1; // 또는 Number(value) === -1 - return ( - - +
+
+
+

중수도 시설 정보

+
+ +
+
+ { + const value = field.value; + const isUnknown = value === null || value === -1; // 또는 Number(value) === -1 + + return ( + + { + // 입력 시 자동으로 확인불가 해제 + if (isUnknown && !readonly) { + field.onChange(""); // 초기화 } - onFocus={() => { - // 입력 시 자동으로 확인불가 해제 - if (isUnknown && !readonly) { - field.onChange(""); // 초기화 - } - }} - onChange={(e) => { - if (readonly) return; - handleMinusNumberChange(e, field.onChange); - }} - readOnly={readonly} - maxLength={numSize} - /> - - ); - }} - /> -
+ }} + onChange={(e) => { + if (readonly) return; + handleMinusNumberChange(e, field.onChange); + }} + readOnly={readonly} + maxLength={numSize} + /> + + ); + }} + />
-
-

중수도 시설 정보

+
+ ( + + {} : field.onChange} + value={field.value ?? code.orgwtKndCd[0]?.val} + readOnly={readonly} + /> + + )} + />
+
+ ( + + { + if (readonly) return; -
-
- { - const value = field.value; - const isUnknown = value === null || value === -1; // 또는 Number(value) === -1 + field.onChange(e.target.value); + }} + maxLength={txtSize} + /> + + )} + /> +
+
- return ( - - +

인센티브 정보

+
+
+

설치비(원) 지원

+
+
+
+ ( + + {} : field.onChange} + value={field.value || code.bdstIncenYn[0]?.val} + readOnly={readonly} + /> + + )} + /> +
+
+ { + const value = field.value; + const isUnknown = value === null || value === -1; // 또는 Number(value) === -1 + return ( + + { + // 입력 시 자동으로 확인불가 해제 + if (isUnknown && !readonly) { + field.onChange(""); // 초기화 } - onFocus={() => { - // 입력 시 자동으로 확인불가 해제 - if (isUnknown && !readonly) { + }} + onChange={(e) => { + if (readonly) return; + handleMinusNumberChange(e, field.onChange); + }} + disabled={ + instlCstSprtYn === "N" || instlCstSprtYn === "D" + } + maxLength={numSize} + /> + + ); + }} + /> +
+
- console.log('value') - field.onChange(""); // 초기화 - } - }} - onChange={(e) => { - if (readonly) return; - handleMinusNumberChange(e, field.onChange); - }} - readOnly={readonly} - maxLength={numSize} - /> - - ); - }} - /> -
-
- ( - - { } : field.onChange} - value={field.value ?? code.orgwtKndCd[0]?.val} - readOnly={readonly} - /> - - )} - /> -
-
- ( - - { } : field.onChange} - value={field.value || code.rswtPrscCdMthdCd[0]?.val} - readOnly={readonly} - /> - - )} - /> -
+
+

녹색건축물 인증

+
+
+
+ ( + + {} : field.onChange} + value={field.value || code.yn[0]?.val} + readOnly={readonly} + /> + + )} + />
- -
-

인센티브 정보

-
-
-

설치비(원) 지원

-
-
-
- ( - - { } : field.onChange} - value={field.value || code.bdstIncenYn[0]?.val} - readOnly={readonly} - /> - - )} - /> -
-
- { - const value = field.value; - const isUnknown = value === null || value === -1; // 또는 Number(value) === -1 - return ( - - + { + const isUnknown = + field.value === null || field.value === "0000"; // 또는 Number(value) === -1 + return ( + + { + // 입력 시 자동으로 확인불가 해제 + if (isUnknown && !readonly) { + field.onChange(""); // 초기화 } - onFocus={() => { - // 입력 시 자동으로 확인불가 해제 - if (isUnknown && !readonly) { - field.onChange(""); // 초기화 - } - }} - onChange={(e) => { - if (readonly) return; - handleMinusNumberChange(e, field.onChange); - }} - disabled={instlCstSprtYn === "N" || instlCstSprtYn === "D"} - maxLength={numSize} - /> - - ); - }} - /> -
-
- -
-

녹색건축물 인증

-
-
-
- ( - - { } : field.onChange} - value={field.value || code.yn[0]?.val} - readOnly={readonly} + }} + value={isUnknown ? "확인불가" : (field.value ?? "")} + onChange={(e) => { + if (readonly) return; + if (e.target.value === "확인불가") { + field.onChange("0000"); + } else { + field.onChange(e.target.value); + } + }} + disabled={ + grntchBdstCertYn == "N" || grntchBdstCertYn == "D" + } + max={4} /> - )} - /> -
-
- { - const isUnknown = field.value === null || field.value === "0000"; // 또는 Number(value) === -1 - return ( - - { - // 입력 시 자동으로 확인불가 해제 - if (isUnknown && !readonly) { - field.onChange(""); // 초기화 - } - }} - value={ - isUnknown ? '확인불가' : field.value ?? ""} - onChange={(e) => { - if (readonly) return - if (e.target.value === '확인불가') { - field.onChange('0000'); - } else { - field.onChange(e.target.value); - } - }} - disabled={grntchBdstCertYn == "N" || grntchBdstCertYn == "D"} - max={4} - /> - - ) - }} - /> -
-
- { - const isUnknown = field.value === null || field.value === "0000"; // 또는 Number(value) === -1 - return ( - - { - // 입력 시 자동으로 확인불가 해제 - if (isUnknown && !readonly) { - field.onChange(""); // 초기화 - } - }} - value={ - isUnknown ? '확인불가' : field.value ?? ""} - onChange={(e) => { - if (readonly) return + ); + }} + /> +
+
+ { + const isUnknown = + field.value === null || field.value === "0000"; // 또는 Number(value) === -1 + return ( + + { + // 입력 시 자동으로 확인불가 해제 + if (isUnknown && !readonly) { + field.onChange(""); // 초기화 + } + }} + value={isUnknown ? "확인불가" : (field.value ?? "")} + onChange={(e) => { + if (readonly) return; - if (e.target.value === '확인불가') { - field.onChange(''); - } else { - field.onChange(e.target.value); - } - }} - disabled={grntchBdstCertYn == "N" || grntchBdstCertYn == "D"} - maxLength={txtSize} - /> - - ) - }} - /> -
-
- ( - - { } : field.onChange} - value={field.value || code.bdstGrntchClass[0]?.val} - readOnly={readonly} + if (e.target.value === "확인불가") { + field.onChange(""); + } else { + field.onChange(e.target.value); + } + }} + disabled={ + grntchBdstCertYn == "N" || grntchBdstCertYn == "D" + } + maxLength={txtSize} /> - )} - /> -
+ ); + }} + />
- +
+ ( + + {} : field.onChange} + value={field.value || code.bdstGrntchClass[0]?.val} + readOnly={readonly} + /> + + )} + /> +
+
+ {/* */} diff --git a/apps/wr/components/ui/map/LayerPopUp/RainFacility/RainFacility.tsx b/apps/wr/components/ui/map/LayerPopUp/RainFacility/RainFacility.tsx index 80bb8d7ec..96ecadcc9 100644 --- a/apps/wr/components/ui/map/LayerPopUp/RainFacility/RainFacility.tsx +++ b/apps/wr/components/ui/map/LayerPopUp/RainFacility/RainFacility.tsx @@ -191,8 +191,7 @@ export function RainFacility({ "1000000", String(con), seartchTxt ?? "", - code.cityCd, - code.sggCd + code as unknown as Record ); } }} @@ -249,8 +248,7 @@ export function RainFacility({ String(rainMapSize), String(con), seartchTxt ?? "", - code.cityCd, - code.sggCd + code as unknown as Record ); setIsReset(false); diff --git a/apps/wr/components/ui/map/LayerPopUp/RswtFacilty/RswtFacilty.tsx b/apps/wr/components/ui/map/LayerPopUp/RswtFacilty/RswtFacilty.tsx index becd76872..5c3c238d6 100644 --- a/apps/wr/components/ui/map/LayerPopUp/RswtFacilty/RswtFacilty.tsx +++ b/apps/wr/components/ui/map/LayerPopUp/RswtFacilty/RswtFacilty.tsx @@ -187,8 +187,7 @@ export function RswtFacility({ "1000000", String(con), seartchTxt ?? "", - code.cityCd, - code.sggCd + code as unknown as Record ); } }} @@ -236,8 +235,7 @@ export function RswtFacility({ String(rainMapSize), String(con), seartchTxt ?? "", - code.cityCd, - code.sggCd + code as unknown as Record ); setIsReset(false); diff --git a/apps/wr/components/ui/map/LayerPopUp/RuseFacilty/RuseFacility.tsx b/apps/wr/components/ui/map/LayerPopUp/RuseFacilty/RuseFacility.tsx index 2c7a5295c..231667898 100644 --- a/apps/wr/components/ui/map/LayerPopUp/RuseFacilty/RuseFacility.tsx +++ b/apps/wr/components/ui/map/LayerPopUp/RuseFacilty/RuseFacility.tsx @@ -18,16 +18,17 @@ import toast from "react-hot-toast"; import { useTranslation } from "react-i18next"; export function RuseFacility({ - rtnFeature, - }: { - rtnFeature: (feature: any) => void; - }) { - const { code, ruseMap, ruseMapInit, getMapFlcts,ruseMapSearch } = useWrStore( + rtnFeature, +}: { + rtnFeature: (feature: any) => void; +}) { + const { code, ruseMap, ruseMapInit, getMapFlcts, ruseMapSearch } = useWrStore( (state) => state ); const { t } = useTranslation("base"); - const { ruseMapCount, ruseExcelList,fclts, ruseMapRes,ruseMapHeadList } = ruseMap; + const { ruseMapCount, ruseExcelList, fclts, ruseMapRes, ruseMapHeadList } = + ruseMap; const [ruseTable, setRuseTable] = useState(); const [isReset, setIsReset] = useState(false); @@ -38,10 +39,7 @@ export function RuseFacility({ const [pbnRuseNm, setPbnRuseNm] = useState(""); const ruseCellClick = (index: number | undefined) => { - if ( - index !== undefined && - ruseTable !== undefined - ) { + if (index !== undefined && ruseTable !== undefined) { rtnFeature(ruseTable[index]); } }; @@ -51,12 +49,11 @@ export function RuseFacility({ } }, [ruseMap.isInit]); useEffect(() => { - ruseMapInit(1,ruseMapSize, ref.current, searchYear, fclts); + ruseMapInit(1, ruseMapSize, ref.current, searchYear, fclts); }, [fclts]); - - useEffect(()=>{ - if(ruseExcelList&&ruseExcelList.length>0){ + useEffect(() => { + if (ruseExcelList && ruseExcelList.length > 0) { if (ruseExcelList.length > 0) { excelDownload( ruseExcelList, @@ -66,20 +63,18 @@ export function RuseFacility({ 3 ); } else { - toast.error(t('excelDownErrMsg')); + toast.error(t("excelDownErrMsg")); } } - - },[ruseExcelList]) + }, [ruseExcelList]); useEffect(() => { if (ruseMapRes && ruseMapRes.length > 0) { - setRuseTable(ruseMapRes); + setRuseTable(ruseMapRes); } else { - setRuseTable([]); + setRuseTable([]); } }, [ruseMapRes]); - return ( <> @@ -94,34 +89,35 @@ export function RuseFacility({ selectMiddleRegionData={code.mdmbsnCd} selectEnvPartData={code.lclgvrnmntCd} buttonOrder={["query", "init", "excel"]} - rightClassName="ml-auto mr-6 flex items-center space-x-1" + rightClassName="ml-auto mr-6 flex items-center space-x-1 " leftClassName="flex gap-5 w-9/12 m-4" leftSelectClassName="w-1/4" rightChildren={<>} leftChildren={
- - setSearchYear(String(val)) - } - /> - - { - setPbnRuseNm(e || ""); - }} - /> -
+ + setSearchYear(String(val)) + } + className={""} + selectContentClass={''} + /> + + { + setPbnRuseNm(e || ""); + }} + /> +
} queryClick={() => { setIsReset(true); @@ -133,7 +129,15 @@ export function RuseFacility({ ref={ref} isAdmin={false} excelClick={function (returnType: ReturnType): void { - ruseMapSearch(true,1,1000000 , returnType, searchYear, fclts,pbnRuseNm??'') + ruseMapSearch( + true, + 1, + 1000000, + returnType, + searchYear, + fclts, + pbnRuseNm ?? "" + ); }} />
@@ -147,10 +151,24 @@ export function RuseFacility({ headName={""} cellClick={ruseCellClick} onPageChange={(page) => { - if(pbnRuseNm&&pbnRuseNm.length>0){ - ruseMapSearch(false,page,ruseMapSize , ref.current, searchYear, fclts,pbnRuseNm) - }else{ - ruseMapInit(page,ruseMapSize , ref.current, searchYear, fclts); + if (pbnRuseNm && pbnRuseNm.length > 0) { + ruseMapSearch( + false, + page, + ruseMapSize, + ref.current, + searchYear, + fclts, + pbnRuseNm + ); + } else { + ruseMapInit( + page, + ruseMapSize, + ref.current, + searchYear, + fclts + ); } setIsReset(false); diff --git a/apps/wr/components/ui/map/detailPopup/coSttnDetailPopup/coSttnDetailPopup.tsx b/apps/wr/components/ui/map/detailPopup/coSttnDetailPopup/coSttnDetailPopup.tsx index 26c586561..9f8db7409 100644 --- a/apps/wr/components/ui/map/detailPopup/coSttnDetailPopup/coSttnDetailPopup.tsx +++ b/apps/wr/components/ui/map/detailPopup/coSttnDetailPopup/coSttnDetailPopup.tsx @@ -23,6 +23,7 @@ export default function CoSttnDetailPopup({isDetail} :{isDetail:DemandCompType}) bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"} updateList={isDetail} readOnly={true} + openNetwork={false} >
diff --git a/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx b/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx index 84dd7d8e3..24a983dce 100644 --- a/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx +++ b/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx @@ -18,6 +18,7 @@ import { SelectBox, Title, } from "@common/business_components/ui"; +import LoadingOverlay from "@common/business_components/ui/loadingBar"; import { Button, Input } from "@common/components/ui"; import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect, useRef, useState } from "react"; @@ -35,9 +36,12 @@ export default function ChkgdExcel({ setYearChange: (year: string) => void; }) { const { + rswtChkgdn, + rainChkgdn, rainChkExcelDataUPload, rswtChkExceDataUpload, setRainChkLoading, + setRswtChkLoading, } = useWrStore((state) => { return state; }); @@ -110,43 +114,38 @@ export default function ChkgdExcel({ setRainChkLoading(false); }); } else if (type === "RST") { - filePickedArray(file, 0).then((res) => { - + setRswtChkLoading(true); + filePickedArray(file, 0) + .then((res) => { + if (res && res?.length > 1) { + const guideData = excelToRswtGuideData( + res[0], + form.getValues("chckYr") + ); + const polutionData = excelToRswtPolution(res[1]); - if (res && res?.length > 1) { - const guideData = excelToRswtGuideData( - res[0], - form.getValues("chckYr"), - ); - const polutionData = excelToRswtPolution(res[1]); - - - - const keyGenerator = (item: rswtChkZodType) => `${item.bdstRuseFcltSn}|${item.chckYmd}|${item.utztnUsgCd}`; - const totalData: rswtChkZodType[] = guideData.map( - (guide) => { - const fusion = polutionData.find( - (polution) => - guide.bdstRuseFcltSn === polution.bdstRuseFcltSn && - guide.chckYmd === polution.chckYmd && - guide.utztnUsgCd === polution.utztnUsgCd - ); + const totalData: rswtChkZodType[] = guideData.map((guide) => { + const fusion = polutionData.find( + (polution) => + guide.bdstRuseFcltSn === polution.bdstRuseFcltSn && + guide.chckYmd === polution.chckYmd && + guide.utztnUsgCd === polution.utztnUsgCd + ); - if (fusion) { - return { - ...guide, - rswtrPollutions: fusion?.rswtrPollutions, - rswtrDetails: fusion?.rswtrDetails, - }; - } else { - return { - ...guide, - }; - } + if (fusion) { + return { + ...guide, + rswtrPollutions: fusion?.rswtrPollutions, + rswtrDetails: fusion?.rswtrDetails, + }; + } else { + return { + ...guide, + }; } - ); + }); const guideKey = new Set(guideData.map(keyGenerator)); const onlypolution = polutionData.filter( (item) => !guideKey.has(keyGenerator(item)) @@ -158,7 +157,7 @@ export default function ChkgdExcel({ ]; const issues: string[] = []; - rswtExcelDataCheck(listTotalData,issues) + rswtExcelDataCheck(listTotalData, issues); if (issues && issues.length > 0) { issues.some((err, index) => { @@ -169,8 +168,9 @@ export default function ChkgdExcel({ } else { setExcelRswtData(listTotalData); } - } - }); + } + }) + .finally(() => setRswtChkLoading(false)); } } }, [file]); @@ -222,6 +222,11 @@ export default function ChkgdExcel({ return ( <> + +
diff --git a/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx b/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx index c528f5add..d6f0e3a26 100644 --- a/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx +++ b/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx @@ -2,13 +2,24 @@ import { useWrStore } from "@/app/store"; import type { TableUpperProps } from "@/app/store/common/type/header"; import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import type { rswtrPolutionsZode } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList"; +import { codeToText } from "@/components/lib/func/commom"; import { GuideDetailsTable } from "@/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable"; import { ScrollArea, Title } from "@common/business_components/ui"; import { Button } from "@common/components/ui"; -import React, { useEffect, useState } from "react"; +import React, { useEffect, useState } from "react"; import type { z } from "zod"; -export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: string; obj: any, setIsModal: (open: boolean) => void, readonly: boolean }) { +export default function ChkgdModal({ + type, + obj, + setIsModal, + readonly, +}: { + type: string; + obj: any; + setIsModal: (open: boolean) => void; + readonly: boolean; +}) { const { rainChkgdn, rswtChkgdn, @@ -58,14 +69,14 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: setHeadList({ splHeadList: rainChkSttn.splHeadList, ruseHeadList: rainChkSttn.ruseHeadList, - rswtDetailHeadList: type === "RNB" ? [] : rswtChkSttn.rswtDetailSttnHeadList, + rswtDetailHeadList: + type === "RNB" ? [] : rswtChkSttn.rswtDetailSttnHeadList, }); } else { setHeadList({ splHeadList: rainChkgdn.splHeadList, ruseHeadList: rainChkgdn.ruseHeadList, - rswtDetailHeadList: - type === "RNB" ? [] : rswtChkgdn.rswtDetailHeadList, + rswtDetailHeadList: type === "RNB" ? [] : rswtChkgdn.rswtDetailHeadList, }); } }, [ @@ -73,12 +84,13 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: rainChkgdn.splHeadList, rainChkSttn.splHeadList, rswtChkgdn.rswtDetailHeadList, - rswtChkSttn.rswtDetailSttnHeadList + rswtChkSttn.rswtDetailSttnHeadList, ]); useEffect(() => { const result = obj.guideDetails?.reduce((acc: any, cur: any) => { const code = cur.utztnUsgCd; + const codeText = codeToText(cur.utztnUsgCd, "dmdUszCd"); const month = cur.ym?.slice(4); // "MM" const ruseMonthKey = `ruse${month}`; const splMonthKey = `spl${month}`; @@ -91,7 +103,12 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: (it: { utztnUsgCd: string }) => it?.utztnUsgCd === code ); if (!target) { - target = { utztnUsgCd: code, ruseTotal: 0, splTotal: 0 }; + target = { + utztnUsgCdText: codeText, + utztnUsgCd: code, + ruseTotal: 0, + splTotal: 0, + }; acc.push(target); } // 월별 값 누적 @@ -106,12 +123,11 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: if (result) { // '기타' 항목을 배열의 맨 뒤로 정렬합니다. result.sort((a: splRuseWaterType, b: splRuseWaterType) => { - if (a.utztnUsgCd === "기타") return 1; // a를 b 뒤로 보냅니다. - if (b.utztnUsgCd === "기타") return -1; // b를 a 뒤로 보냅니다. + if (a.utztnUsgCd === "07") return 1; // a를 b 뒤로 보냅니다. + if (b.utztnUsgCd === "07") return -1; // b를 a 뒤로 보냅니다. return 0; // 순서를 유지합니다. }); } - setGuidData(result as splRuseWaterType[]); if (obj.rswtrPollutions) { @@ -124,6 +140,10 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: obj.rswtrPollutions.forEach( (item: z.infer) => { const nodeKey = String(item.node); + item["utztnUsgCdText"] = codeToText( + item.utztnUsgCd ?? "", + "dmdUszCd" + ); resultPolution[nodeKey]?.push(item); } ); @@ -132,8 +152,8 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: Object.entries(resultPolution).forEach(([nodeKey, items]) => { const onlyData = items as z.infer[]; if (onlyData.length === 0) return; - const total = initStats(); + onlyData.forEach((item) => { total.grssClfgUswtr += item.grssClfgUswtr; total.combResdch += item.combResdch; @@ -148,7 +168,7 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: }); const average = { - utztnUsgCd: "평균", + utztnUsgCdText: "평균", edit: false, grssClfgUswtr: (total.grssClfgUswtr / onlyData.length).toFixed(1), combResdch: (total.combResdch / onlyData.length).toFixed(1), @@ -168,8 +188,8 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: // '기타' 항목을 배열의 맨 뒤로 정렬합니다. resultPolution[nodeKey].sort((a: any, b: any) => { - if (a.utztnUsgCd === "기타") return 1; // a를 b 뒤로 보냅니다. - if (b.utztnUsgCd === "기타") return -1; // b를 a 뒤로 보냅니다. + if (a.utztnUsgCd === "07") return 1; // a를 b 뒤로 보냅니다. + if (b.utztnUsgCd === "07") return -1; // b를 a 뒤로 보냅니다. return 0; // 순서를 유지합니다. }); @@ -213,16 +233,15 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: }); obj.guideDetails = realGuideDetail; if (type === "RNB") { - rainChkGuidUpdate(obj); - setIsModal(false) + setIsModal(false); } else { const polution = Object.values(upPolutionData) .flat() .filter((item) => item.utztnUsgCd !== "평균"); obj.rswtrPollutions = polution; rwstPolAndGuideUpdate([obj]); - setIsModal(false) + setIsModal(false); } }; @@ -247,7 +266,11 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: } > {!rainChkSttn.isSttn ? ( - ) : ( @@ -256,7 +279,8 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type:

{type === "RNB" - ? `시설명 : (${obj.bdstNm})` : `시설명 : (${obj.building.bdstNm})`} + ? `시설명 : (${obj.bdstNm})` + : `시설명 : (${obj.building.bdstNm})`}

@@ -269,7 +293,11 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: { setChGuidData(data); @@ -284,7 +312,11 @@ export default function ChkgdModal({ type, obj, setIsModal, readonly }: { type: { setChGuidData(data); diff --git a/apps/wr/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable.tsx b/apps/wr/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable.tsx index 6fc2c0632..4717e8346 100644 --- a/apps/wr/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable.tsx +++ b/apps/wr/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable.tsx @@ -4,12 +4,11 @@ import { useWrStore } from "@/app/store"; import type { TableUpperProps } from "@/app/store/common/type/header"; import { rainPageSize, type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; -import { tableData } from "@/components/lib/func/commom"; +import { codeToText, tableData } from "@/components/lib/func/commom"; import { chRowspanTable, rainChkTableData } from "@/components/lib/func/TableData"; -import LoadingOverlay from "@common/business_components/ui/loadingBar"; import UiPageNations from "@common/business_components/ui/table/uiPageNations"; import { Table, @@ -89,15 +88,18 @@ export default function RainChkgdTable({ } ) }) + return { ...item, ...bud[0], + utztnUsgCdText: codeToText(item.guideDetails[0].utztnUsgCd, 'dmdUszCd'), + oilqMeasMthdText:codeToText(item.oilqMeasMthd, 'rainFcltFlowRate'), + operMngCdText:codeToText(item.operMngCd.trim(), 'rainRswtMng'), rainyDetails:rainyDetails, rowspan: item.rainyDetails?.length, }; }); - console.log('rainChg ', rainChg) setMakeTableData(rainChkTableData(rainChg)); } else { setMakeTableData([]); @@ -188,7 +190,6 @@ export default function RainChkgdTable({ return ( <> - {headMakeprfmnc( diff --git a/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx b/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx index aa74ad2c2..e931cf706 100644 --- a/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx +++ b/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx @@ -13,7 +13,6 @@ import { chRowspanTable, rswtChkTableData, } from "@/components/lib/func/TableData"; -import LoadingOverlay from "@common/business_components/ui/loadingBar"; import UiPageNations from "@common/business_components/ui/table/uiPageNations"; import { Table, TableBody, TableHeader } from "@common/components/ui"; import { useCallback, useEffect, useState } from "react"; @@ -138,7 +137,6 @@ export default function RswtChkgdTable({ return ( <> -
{headMakeprfmnc(headList?.headList, headList?.upHeadList)} diff --git a/apps/wr/public/sample_rswtSttn.xlsx b/apps/wr/public/sample_rswtSttn.xlsx index cec85971d..1085c6cfc 100644 Binary files a/apps/wr/public/sample_rswtSttn.xlsx and b/apps/wr/public/sample_rswtSttn.xlsx differ