diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index b7f47f0ca..6c865932e 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -17,10 +17,10 @@ import HeadChModal from "@/components/ui/modal/headChModal/headChModal"; import { useState } from "react"; export default function PbnstSttn() { - const { code, sttnCommon } = useWrStore((state) => state); + const { code, rainSttn } = useWrStore((state) => state); const [isChHead, setIsChHead] = useState(false); - const nodeList = headMakeprfmnc(sttnCommon.pbnSttHeadList, sttnCommon.pbnSttHeadNm); + const nodeList = headMakeprfmnc(rainSttn.pbnSttHeadList, rainSttn.pbnSttHeadNm); return ( <> @@ -113,7 +113,7 @@ export default function PbnstSttn() { state); - const { rainRes } = sttnCommon; - + const { rainSttnRes } = rainSttn; const [isChHead, setIsChHead] = useState(false); const ref = useRef({} as ReturnType); const [bdstTable, setBdstTable] = useState(); - const nodeList = headMakeTriple( - sttnCommon.rainSttHeadList, - sttnCommon.rainSttHeadNm - ); + // const nodeList = headMakeTriple( + // rainSttn.rainSttHeadList, + // rainSttn.rainSttHeadNm + // ); useEffect(() => { - if (!sttnCommon.isInit) { + if (!rainSttn.isInit) { let con if (ref.current.sigunValue != '0') { con = ref.current.sigunValue @@ -40,15 +39,12 @@ export default function RainSttn() { } rainSttnSearch('1', '20' ,con); } - }, [sttnCommon.isInit, rainSttnSearch]); - - + }, [rainSttn.isInit, rainSttnSearch]); useEffect(() => { - if (rainRes.length > 0) { - const data = tableData(rainRes, { code }); - // data 는 위 JSON 객체라고 가정 + if (rainSttnRes.length > 0) { + const data = tableData(rainSttnRes, { code }); const chData = data .map((item: any) => ({ @@ -60,15 +56,14 @@ export default function RainSttn() { setBdstTable(chData); } - }, [code, rainRes, sttnCommon.rainSttHeadList]); + }, [code, rainSttnRes, rainSttn.rainSttHeadList]); useEffect(() => { - if(sttnCommon.excelList.length>0){ - console.log('sttnCommon.excelList', sttnCommon.excelList); + if(rainSttn.excelList.length>0){ - if (sttnCommon.excelList.length === 0) return; - excelDownload(sttnCommon.excelList , '빗물재이용시설 현황','sample_rainSttn.xlsx') + if (rainSttn.excelList.length === 0) return; + excelDownload(rainSttn.excelList , '빗물재이용시설 현황','sample_rainSttn.xlsx') } - }, [sttnCommon.excelList]); + }, [rainSttn.excelList]); const excelClick = useCallback((returnType:ReturnType) => { @@ -127,7 +122,7 @@ export default function RainSttn() { - {nodeList} + {/* {nodeList} */} diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx index cd915e33b..220ff76f3 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx @@ -70,7 +70,7 @@ export default function Page() { {setSearchTxt(e);}} diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx index 24c8cdebc..d6c8d8345 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx @@ -97,16 +97,16 @@ export const excelToRainChkData = ( return { utztnUsgCd: item["이용용도"], ym: year + month, - chckYmd: excelSerialToDateString(item["점검일"]) , - splyUswtrUtztnQnt: splyData !== undefined ? splyData : 0, - ruseFcltUtztnQnt: ruseData !== undefined ? ruseData : 0, + chckYmd: item["점검일"] , + splyUswtrUtztnQnt: splyData !== "" ? splyData : 0, + ruseFcltUtztnQnt: ruseData !== "" ? ruseData : 0, flg: "RNB", }; }); return { bdstRuseFcltFk: Number(item["NO"]), - chckYmd: excelSerialToDateString(item["점검일"]) , + chckYmd: item["점검일"] , spwtPositn: item["유량측정방법"], rgtr: TEST_UUID, oilqMeasMthd: item["운영관리형태"], diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx index 5a74d104d..d80261d21 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx @@ -6,6 +6,8 @@ import { fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api import type { SelectDataType } from "@common/business_components/ui"; import { z } from "zod"; import { buildingToExcelType, excelToRainChkData } from "./excel"; +import toast from "react-hot-toast"; +import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; export const rainChkZod = z.object({ chkgdnPk: z.number().nullable(), @@ -307,7 +309,7 @@ type rainChkgdnActions = { rainChkDetilUpdate(rainChk: rainChkZodType[]): Promise; rainChkGuidUpdate(rainChk: rainChkZodType): Promise; rainChkExcelDownload(sidoCode: SelectDataType[],sggCode: SelectDataType[]): Promise - excelDataUPload(excelData:rainChkZodType[]) : Promise + rainChkExcelDataUPload(excelData:rainChkZodType[]) : Promise }; export type rainChkgdnType = rainChkgdnState & rainChkgdnActions; @@ -371,11 +373,11 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( }, })); }, - excelDataUPload: async(excelData:rainChkZodType[] ) =>{ + rainChkExcelDataUPload: async(excelData:rainChkZodType[] ) =>{ try{ const res = await postFectch("/reuseChk/rainyExcel", excelData); if (res.ok) { - alert(" 데이터 입력 완료"); + ToastFormUi({body:"엑셀 데이터 업로드가 성공하였습니다. " ,title:'엑셀등록'}) } const rainChkRes = await initFetch('2024', '0'); return set((state: rainChkgdnState) => ({ @@ -387,7 +389,7 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( })); }catch(error){ console.log(error); - alert("데이터 입력을 실패하였습니다."); + ToastFormUi({body:"엑셀 데이터 업로드를 실패하였습니다. " ,title:'엑셀등록'}) } }, rainChkInit: async (searchTxt: string, sggCd: string) => { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx index ccf0e2b32..855d05d71 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx @@ -133,7 +133,7 @@ export const upHeadList: TableUpperProps[] = [ const rainRes: customRainBdst[] = []; -export const selectClass = "w-full h-full text-2xl"; +export const selectClass = "w-full h-full !text-2xl"; const selectYN = [ { text: "Y", val: "1" }, { text: "N", val: "2" }, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx new file mode 100644 index 000000000..d4c4fed31 --- /dev/null +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx @@ -0,0 +1,169 @@ +import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; +import type { TableUpperProps } from "../../fcltReg/rainReg"; + +export const pbnSttHeadNmExport: chHeadType[] = [ + { headNm: "catchment", text: "유역", length: 3 }, + { headNm: "adminDiv", text: "행정구역", length: 2 }, + { headNm: "rusSup", text: "재이용수공급가능량", length: 3 }, + { headNm: "yearResult", text: "연간실적정보(m³)", length: 3 }, + { headNm: "mngInfo", text: "운영정보", length: 4 }, +]; + +// id는 다확인해야함 +export const pbnSttHeadListExport: TableUpperProps[] = [ + { id: "a", title: "권역", upName: "catchment", upSequnce: 1, visible: true }, + { + id: "aaa", + title: "단위유역", + upName: "catchment", + upSequnce: 2, + visible: true, + }, + { + id: "aaaa", + title: "중권역", + upName: "catchment", + upSequnce: 3, + visible: false, + }, + { id: "operMngCd", title: "환경청", visible: true }, + { + id: "cityText", + title: "시도", + upName: "adminDiv", + upSequnce: 1, + visible: false, + }, + { + id: "sggText", + title: "시군구", + upName: "adminDiv", + upSequnce: 2, + visible: true, + }, + { id: "bdnstNm", title: "시설명", visible: true }, + { id: "locDiv", title: "지역구분", visible: true }, + { id: "phone", title: "전화번호", visible: true }, + + { id: "fcltQuantity", title: "시설용량(톤/일)", visible: true }, + { id: "rusNm", title: "재이용시설명", visible: true }, + + { + id: "fcltCpct", + title: "시설용량(m³/일)", + upName: "rusSup", + upSequnce: 1, + visible: true, + }, + { + id: "trbt", + title: "하수처리량(m³/일)", + upName: "rusSup", + upSequnce: 2, + visible: true, + }, + { + id: "ruseCpct", + title: "재이용량(m³/일)", + upName: "rusSup", + upSequnce: 3, + visible: true, + }, + + { + id: "total", + title: "합계", + upName: "yearResult", + upSequnce: 1, + visible: true, + }, + { + id: "ithlWtr", + title: "장내용수", + upName: "yearResult", + upSequnce: 2, + visible: true, + }, + { + id: "othlWtr", + title: "장외용수", + upName: "yearResult", + upSequnce: 3, + visible: true, + }, + + { + id: "mngMeth", + title: "운영방식", + upName: "mngInfo", + upSequnce: 1, + visible: true, + }, + { + id: "rprtvBzenty", + title: "대행업체", + upName: "mngInfo", + upSequnce: 2, + visible: true, + }, + { + id: "firstDay", + title: "시작일", + upName: "mngInfo", + upSequnce: 3, + visible: true, + }, + { + id: "LastDay", + title: "종료일", + upName: "mngInfo", + upSequnce: 4, + visible: true, + }, +]; + + + + +// 참고용 지워야함. +// rainChSttnHead: async (checkList: string[], type: string) => { +// const headList = +// type === "pbn" +// ? pbnSttHeadList +// : type === "rain" +// ? rainSttHeadList +// : null; + +// let chNm = type === "pbn" ? pbnSttHeadNm : rainSttHeadNm; +// headList?.forEach((item) => { +// if (checkList.find((ch) => ch === item.id)) { +// item.visible = false; +// if (item.upName) { +// const upNames = Array.isArray(item.upName) +// ? item.upName +// : [item.upName]; +// upNames?.forEach((up) => { +// chNm.find((ch) => { +// if (ch.headNm === up) { +// ch.length = ch.length - 1; +// } +// }); +// }); +// } +// } +// }); +// set((state: rainSttnState) => ({ +// sttnCommon: { +// ...state.sttnCommon, +// pbnSttHeadList: +// type === "pbn" ? headList : state.sttnCommon.pbnSttHeadList, +// rainSttHeadList: +// type === "rain" ? headList : state.sttnCommon.rainSttHeadList, +// rainSttHeadNm: +// type === "rain" ? chNm : state.sttnCommon.rainSttHeadNm, +// pbnSttHeadNm: type === "rain" ? chNm : state.sttnCommon.pbnSttHeadNm, +// }, +// })); +// }, +// }; +// }; \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx similarity index 100% rename from apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/excel.tsx rename to apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx new file mode 100644 index 000000000..cf06687c4 --- /dev/null +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx @@ -0,0 +1,428 @@ +import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; +import type { TableTripleProps, TableUpperProps } from "../../fcltReg/rainReg"; + +export type TableUpperPropsTest = { + id: string; + title: string; + upName?: string; + upSequnce?: number; + row?: number; + rowSpan?: number; + colSpan?: number; + visible?: boolean; +}; + +// id는 다확인해야함 +export const rainSttHeadListExportTest: TableUpperPropsTest[] = [ + { + id: "bdnstInfo", + title: "1.건축물정보", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 9, + }, + { + id: "rainFcltInfo", + title: "2.빗물이용시설정보", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 6, + }, + { id: "insenInfo", + title: "3.인센티브 정보", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 7 + }, + + // 2번째 줄 + { id: "adminDiv", + title: "행정구역", + visible: true, + row: 2, + rowSpan: 1, + colSpan: 2 }, + + // 1번째 줄 건축물정보 아래의 행으로 만들 헤더 + { + id: "bdstNm", + title: "건축물명", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1 }, + { + id: "daddr", + title: "주소", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1 }, + { + id: "bdstUsgCd", + title: "건축물용도코드", + row: 2, + rowSpan: 2, + colSpan: 1 }, + { + id: "frstArchPrmsnDt", + title: "최초건축허가일시", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1 }, + { + id: "archArea", + title: "건축면적", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1 }, + { + id: "lawTrgtYn", + title: "법적의무대상여부", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1 }, + { + id: "instlCmptnDt", + title: "설치완료일시", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1 }, + + + { + id: "instlCst", + title: "설치비용", + visible: true, + row: 2, + rowSpan: 1, + colSpan: 2 + }, + + { id: "pntfCol", + title: "집수면", + visible: true, + row: 2, + rowSpan: 1, + colSpan: 2 + }, + { id: "filtrTrtmfct", + title: "여과등 처리시설", + visible: true, + row: 2, + rowSpan: 1, + colSpan: 3 + }, + { + id: "dtfcltCpct", + title: "저류조용량", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1 + }, + + + { id: "instlCstSprt", + title: "설치비지원", + visible: true, + row: 2, + rowSpan: 1, + colSpan: 2 + }, + { id: "grntchBdstCert", + title: "녹색건축물인증여부", + visible: true, + row: 2, + rowSpan: 1, + colSpan: 4 + }, + + // 3번째줄 시작 + { + id: "cityText", + title: "시도", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "sggText", + title: "시군구", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + + + + { + id: "pntfColKnd", + title: "집수지점종류", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "pntfColArea", + title: "집수지점면적", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "filtrTrtmfctYn", + title: "여과처리시설유무", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "filtrTrtmfctCpct", + title: "여과처리시설용량", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "filtrTrtmfctPrs", + title: "여과처리시설처리공정", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + + + { + id: "instlCstSprtYn", + title: "설치지원비용여부", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "instlCstSprtAmt", + title: "설치지원비용", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + + { + id: "grntchBdstCertYn", + title: "녹색건축물인증여부", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "grntchBdstCertYr", + title: "녹색건축물인증년도", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "grntchBdstCertNo", + title: "녹색건축물인증번호", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, + { + id: "grntchBdstCertGrd", + title: "녹색건축물인증등급", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1 + }, +]; + +export const rainSttHeadNmExport: chHeadType[] = [ + { headNm: "bdnstInfo", text: "1.건축물정보", length: 9 }, + { headNm: "rainFcltInfo", text: "2.빗물이용시설정보", length: 7 }, + { headNm: "insenInfo", text: "3.인센티브 정보", length: 9 }, + + +]; + +// id는 다확인해야함 +export const rainSttHeadListExport: TableTripleProps[] = [ + { + id: "cityText", + title: "시도", + visible: true, + upName: ["bdnstInfo", "adminDiv"], + upSequnce: [1, 1], + }, + { + id: "sggText", + title: "시군구", + visible: true, + upName: ["bdnstInfo", "adminDiv"], + upSequnce: [2, 2], + }, + { + id: "bdstNm", + title: "건축물명", + visible: true, + upName: ["bdnstInfo"], + upSequnce: [3], + }, + { + id: "daddr", + title: "주소", + visible: true, + upName: ["bdnstInfo"], + upSequnce: [4], + }, + { + id: "bdstUsgCd", + title: "건축물용도코드", + visible: true, + upName: ["bdnstInfo"], + upSequnce: [5], + }, + { + id: "frstArchPrmsnDt", + title: "최초건축허가일시", + visible: true, + upName: ["bdnstInfo"], + upSequnce: [6], + }, + { + id: "archArea", + title: "건축면적", + visible: true, + upName: ["bdnstInfo"], + upSequnce: [7], + }, + { + id: "lawTrgtYn", + title: "법적의무대상여부", + visible: true, + upName: ["bdnstInfo"], + upSequnce: [8], + }, + { + id: "instlCmptnDt", + title: "설치완료일시", + visible: true, + upName: ["bdnstInfo"], + upSequnce: [9], + }, + + { + id: "instlCst", + title: "설치비용", + visible: true, + upName: ["rainFcltInfo"], + upSequnce: [1], + }, + { + id: "pntfColKnd", + title: "집수지점종류", + visible: true, + upName: ["rainFcltInfo", "pntfCol"], + upSequnce: [2, 1], + }, + { + id: "pntfColArea", + title: "집수지점면적", + visible: true, + upName: ["rainFcltInfo", "pntfCol"], + upSequnce: [3, 2], + }, + { + id: "filtrTrtmfctYn", + title: "여과처리시설유무", + visible: true, + upName: ["rainFcltInfo", "filtrTrtmfct"], + upSequnce: [4, 1], + }, + { + id: "filtrTrtmfctCpct", + title: "여과처리시설용량", + visible: true, + upName: ["rainFcltInfo", "filtrTrtmfct"], + upSequnce: [5, 2], + }, + { + id: "filtrTrtmfctPrs", + title: "여과처리시설처리공정", + visible: true, + upName: ["rainFcltInfo", "filtrTrtmfct"], + upSequnce: [6, 3], + }, + { + id: "dtfcltCpct", + title: "저류조용량", + visible: true, + upName: ["rainFcltInfo"], + upSequnce: [7], + }, + + { + id: "instlCstSprtYn", + title: "설치지원비용여부", + visible: true, + upName: ["insenInfo", "instlCstSprt"], + upSequnce: [1, 1], + }, + { + id: "instlCstSprtAmt", + title: "설치지원비용", + visible: true, + upName: ["insenInfo", "instlCstSprt"], + upSequnce: [2, 2], + }, + + { + id: "grntchBdstCertYn", + title: "녹색건축물인증여부", + visible: true, + upName: ["insenInfo", "grntchBdstCert"], + upSequnce: [3, 1], + }, + { + id: "grntchBdstCertYr", + title: "녹색건축물인증년도", + visible: true, + upName: ["insenInfo", "grntchBdstCert"], + upSequnce: [4, 2], + }, + { + id: "grntchBdstCertNo", + title: "녹색건축물인증번호", + visible: true, + upName: ["insenInfo", "grntchBdstCert"], + upSequnce: [5, 3], + }, + { + id: "grntchBdstCertGrd", + title: "녹색건축물인증등급", + visible: true, + upName: ["insenInfo", "grntchBdstCert"], + upSequnce: [6, 4], + }, +]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx new file mode 100644 index 000000000..7ebc9b7aa --- /dev/null +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx @@ -0,0 +1,109 @@ +import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; +import { fetchType, getFetch } from "@/components/lib/api"; +import { + type customRainBdst, + type TableTripleProps, +} from "../../fcltReg/rainReg"; +import { excelSttnParsing } from "./excel"; +import { rainSttHeadListExport, rainSttHeadListExportTest, rainSttHeadNmExport, type TableUpperPropsTest } from "./headList"; + +// 테이블 헤드 리스트 +const rainSttHeadNm = rainSttHeadNmExport; + +//const rainSttHeadList = rainSttHeadListExport; +const rainSttHeadList = rainSttHeadListExportTest; +const rainSttnRes: customRainBdst[] = []; + +export type rainSttnState = { + rainSttn: { + rainSttnRes: customRainBdst[]; + // rainSttHeadList: TableTripleProps[]; + rainSttHeadList: TableUpperPropsTest[]; + rainSttHeadNm: chHeadType[]; + excelList: []; + isInit: boolean; + }; +}; +type rainSttnActions = { + rainSttnSearch: (page: string, total: string, con: string) => void; + rainChSttnHead: (checkList: string[]) => void; +}; + +export type rainSttnType = rainSttnState & rainSttnActions; + +export const rainSttnStateExport: rainSttnState = { + rainSttn: { + rainSttHeadList: rainSttHeadList, + rainSttHeadNm: rainSttHeadNm, + rainSttnRes: rainSttnRes, + excelList: [], + isInit: false, + }, +}; + +export const rainSttnActionsExport: (set: any) => rainSttnActions = ( + set: any +) => { + return { + rainSttnSearch: async (page: string, total: string, con: string) => { + try { + const rainSttnRes = await getFetch( + fetchType.WR, + `/reuseFc/rainyInfoList/${page}/${total}/${con}` + ); + if (Number(total) > 9000) { + const rainExcel = excelSttnParsing(rainSttnRes); + set((state: rainSttnState) => { + return { + ...state, + rainSttn: { + ...state.rainSttn, + excelList: rainExcel, + }, + }; + }); + } else + set((state: rainSttnState) => { + return { + ...state, + rainSttn: { + ...state.rainSttn, + rainSttnRes: rainSttnRes, + isInit: false, + }, + }; + }); + } catch (erTxt) { + console.log("error", erTxt); + } + }, + rainChSttnHead: async (checkList: string[]) => { + const headList = rainSttHeadList; + let chNm = rainSttHeadNm; + headList?.forEach((item) => { + if (checkList.find((ch) => ch === item.id)) { + item.visible = false; + if (item.upName) { + const upNames = Array.isArray(item.upName) + ? item.upName + : [item.upName]; + upNames?.forEach((up) => { + chNm.find((ch) => { + if (ch.headNm === up) { + ch.length = ch.length - 1; + } + }); + }); + } + } + }); + set((state: rainSttnState) => ({ + rainSttn: { + ...state.rainSttn, + rainSttHeadList: headList, + rainSttHeadNm: chNm, + }, + })); + }, + }; +}; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/index.tsx deleted file mode 100644 index d0dd648e7..000000000 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/sttn/index.tsx +++ /dev/null @@ -1,412 +0,0 @@ -import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; -import { fetchType, getFetch } from "@/components/lib/api"; -import { - type customRainBdst, - type TableTripleProps, - type TableUpperProps, -} from "../../fcltReg/rainReg"; -import { excelSttnParsing, } from "./excel"; - -const pbnSttHeadNm: chHeadType[] = [ - { headNm: "catchment", text: "유역", length: 3 }, - { headNm: "adminDiv", text: "행정구역", length: 2 }, - { headNm: "rusSup", text: "재이용수공급가능량", length: 3 }, - { headNm: "yearResult", text: "연간실적정보(m³)", length: 3 }, - { headNm: "mngInfo", text: "운영정보", length: 4 }, -]; - -// id는 다확인해야함 -const pbnSttHeadList: TableUpperProps[] = [ - { id: "a", title: "권역", upName: "catchment", upSequnce: 1, visible: true }, - { - id: "aaa", - title: "단위유역", - upName: "catchment", - upSequnce: 2, - visible: true, - }, - { - id: "aaaa", - title: "중권역", - upName: "catchment", - upSequnce: 3, - visible: false, - }, - { id: "operMngCd", title: "환경청", visible: true }, - { - id: "cityText", - title: "시도", - upName: "adminDiv", - upSequnce: 1, - visible: false, - }, - { - id: "sggText", - title: "시군구", - upName: "adminDiv", - upSequnce: 2, - visible: true, - }, - { id: "bdnstNm", title: "시설명", visible: true }, - { id: "locDiv", title: "지역구분", visible: true }, - { id: "phone", title: "전화번호", visible: true }, - - { id: "fcltQuantity", title: "시설용량(톤/일)", visible: true }, - { id: "rusNm", title: "재이용시설명", visible: true }, - - { - id: "fcltCpct", - title: "시설용량(m³/일)", - upName: "rusSup", - upSequnce: 1, - visible: true, - }, - { - id: "trbt", - title: "하수처리량(m³/일)", - upName: "rusSup", - upSequnce: 2, - visible: true, - }, - { - id: "ruseCpct", - title: "재이용량(m³/일)", - upName: "rusSup", - upSequnce: 3, - visible: true, - }, - - { - id: "total", - title: "합계", - upName: "yearResult", - upSequnce: 1, - visible: true, - }, - { - id: "ithlWtr", - title: "장내용수", - upName: "yearResult", - upSequnce: 2, - visible: true, - }, - { - id: "othlWtr", - title: "장외용수", - upName: "yearResult", - upSequnce: 3, - visible: true, - }, - - { - id: "mngMeth", - title: "운영방식", - upName: "mngInfo", - upSequnce: 1, - visible: true, - }, - { - id: "rprtvBzenty", - title: "대행업체", - upName: "mngInfo", - upSequnce: 2, - visible: true, - }, - { - id: "firstDay", - title: "시작일", - upName: "mngInfo", - upSequnce: 3, - visible: true, - }, - { - id: "LastDay", - title: "종료일", - upName: "mngInfo", - upSequnce: 4, - visible: true, - }, -]; -const rainSttHeadNm: chHeadType[] = [ - { headNm: "bdnstInfo", text: "1.건축물정보", length: 9 }, - { headNm: "rainFcltInfo", text: "2.빗물이용시설정보", length: 7 }, - { headNm: "insenInfo", text: "3.인센티브 정보", length: 9 }, - - { headNm: "adminDiv", text: "행정구역", length: 2 }, - { headNm: "pntfCol", text: "집수면", length: 2 }, - { headNm: "filtrTrtmfct", text: "여과등 처리시설", length: 3 }, - { headNm: "instlCstSprt", text: "설치비지원", length: 2 }, - - { headNm: "grntchBdstCert", text: "녹색건축물인증여부", length: 4 }, -]; - -// id는 다확인해야함 -const rainSttHeadList: TableTripleProps[] = [ - { - id: "cityText", - title: "시도", - visible: true, - upName: ["bdnstInfo", "adminDiv"], - upSequnce: [1, 1], - }, - { - id: "sggText", - title: "시군구", - visible: true, - upName: ["bdnstInfo", "adminDiv"], - upSequnce: [2, 2], - }, - { - id: "bdstNm", - title: "건축물명", - visible: true, - upName: ["bdnstInfo"], - upSequnce: [3], - }, - { - id: "daddr", - title: "주소", - visible: true, - upName: ["bdnstInfo"], - upSequnce: [4], - }, - { - id: "bdstUsgCd", - title: "건축물용도코드", - visible: true, - upName: ["bdnstInfo"], - upSequnce: [5], - }, - { - id: "frstArchPrmsnDt", - title: "최초건축허가일시", - visible: true, - upName: ["bdnstInfo"], - upSequnce: [6], - }, - { - id: "archArea", - title: "건축면적", - visible: true, - upName: ["bdnstInfo"], - upSequnce: [7], - }, - { - id: "lawTrgtYn", - title: "법적의무대상여부", - visible: true, - upName: ["bdnstInfo"], - upSequnce: [8], - }, - { - id: "instlCmptnDt", - title: "설치완료일시", - visible: true, - upName: ["bdnstInfo"], - upSequnce: [9], - }, - - { - id: "instlCst", - title: "설치비용", - visible: true, - upName: ["rainFcltInfo"], - upSequnce: [1], - }, - { - id: "pntfColKnd", - title: "집수지점종류", - visible: true, - upName: ["rainFcltInfo", "pntfCol"], - upSequnce: [2, 1], - }, - { - id: "pntfColArea", - title: "집수지점면적", - visible: true, - upName: ["rainFcltInfo", "pntfCol"], - upSequnce: [3, 2], - }, - { - id: "filtrTrtmfctYn", - title: "여과처리시설유무", - visible: true, - upName: ["rainFcltInfo", "filtrTrtmfct"], - upSequnce: [4, 1], - }, - { - id: "filtrTrtmfctCpct", - title: "여과처리시설용량", - visible: true, - upName: ["rainFcltInfo", "filtrTrtmfct"], - upSequnce: [5, 2], - }, - { - id: "filtrTrtmfctPrs", - title: "여과처리시설처리공정", - visible: true, - upName: ["rainFcltInfo", "filtrTrtmfct"], - upSequnce: [6, 3], - }, - { - id: "dtfcltCpct", - title: "저류조용량", - visible: true, - upName: ["rainFcltInfo"], - upSequnce: [7], - }, - - { - id: "instlCstSprtYn", - title: "설치지원비용여부", - visible: true, - upName: ["insenInfo", "instlCstSprt"], - upSequnce: [1, 1], - }, - { - id: "instlCstSprtAmt", - title: "설치지원비용", - visible: true, - upName: ["insenInfo", "instlCstSprt"], - upSequnce: [2, 2], - }, - - { - id: "grntchBdstCertYn", - title: "녹색건축물인증여부", - visible: true, - upName: ["insenInfo", "grntchBdstCert"], - upSequnce: [3, 1], - }, - { - id: "grntchBdstCertYr", - title: "녹색건축물인증년도", - visible: true, - upName: ["insenInfo", "grntchBdstCert"], - upSequnce: [4, 2], - }, - { - id: "grntchBdstCertNo", - title: "녹색건축물인증번호", - visible: true, - upName: ["insenInfo", "grntchBdstCert"], - upSequnce: [5, 3], - }, - { - id: "grntchBdstCertGrd", - title: "녹색건축물인증등급", - visible: true, - upName: ["insenInfo", "grntchBdstCert"], - upSequnce: [6, 4], - }, -]; -const rainRes: customRainBdst[] = []; - -export type sttnState = { - sttnCommon: { - rainRes: customRainBdst[]; - pbnSttHeadList: TableUpperProps[]; - pbnSttHeadNm: chHeadType[]; - rainSttHeadList: TableTripleProps[]; - rainSttHeadNm: chHeadType[]; - excelList:[]; - isInit:boolean - }; -}; -type sttnActions = { - rainSttnSearch: (page: string, total: string, con: string) => void; - chSttnHead: (checkList: string[], type: string) => void; -}; - -export type sttnType = sttnState & sttnActions; - -export const sttnStateExport: sttnState = { - sttnCommon: { - pbnSttHeadList: pbnSttHeadList, - pbnSttHeadNm: pbnSttHeadNm, - rainSttHeadList: rainSttHeadList, - rainSttHeadNm: rainSttHeadNm, - rainRes: rainRes, - excelList: [], - isInit:false - }, -}; - -export const sttnActionsExport: (set: any) => sttnActions = (set: any) => { - return { - rainSttnSearch: async (page: string, total: string, con: string) => { - try { - const rainRes = await getFetch( - fetchType.WR, - `/reuseFc/rainyInfoList/${page}/${total}/${con}` - ); - if(Number(total) > 9000){ - const rainExcel= excelSttnParsing(rainRes) - set((state: sttnState) => { - return { - ...state, - sttnCommon: { - ...state.sttnCommon, - excelList: rainExcel, - }, - }; - }); - } - else - set((state: sttnState) => { - return { - ...state, - sttnCommon: { - ...state.sttnCommon, - rainRes: rainRes, - isInit: false, - }, - }; - }); - } catch (erTxt) { - console.log("error", erTxt); - } - }, - chSttnHead: async (checkList: string[], type: string) => { - const headList = - type === "pbn" - ? pbnSttHeadList - : type === "rain" - ? rainSttHeadList - : null; - - let chNm = type === "pbn" ? pbnSttHeadNm : rainSttHeadNm; - headList?.forEach((item) => { - if (checkList.find((ch) => ch === item.id)) { - item.visible = false; - if (item.upName) { - const upNames = Array.isArray(item.upName) - ? item.upName - : [item.upName]; - upNames?.forEach((up) => { - chNm.find((ch) => { - if (ch.headNm === up) { - ch.length = ch.length - 1; - } - }); - }); - } - } - }); - set((state: sttnState) => ({ - sttnCommon: { - ...state.sttnCommon, - pbnSttHeadList: - type === "pbn" ? headList : state.sttnCommon.pbnSttHeadList, - rainSttHeadList: - type === "rain" ? headList : state.sttnCommon.rainSttHeadList, - rainSttHeadNm: - type === "rain" ? chNm : state.sttnCommon.rainSttHeadNm, - pbnSttHeadNm: type === "rain" ? chNm : state.sttnCommon.pbnSttHeadNm, - }, - })); - }, - }; -}; - - diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index f826689de..848ba0b03 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -33,7 +33,7 @@ import { type rswtFacState, type rswtFacType, } from "./ruseFcltMng/fcltReg/rswtReg"; -import { sttnActionsExport, sttnStateExport, type sttnState, type sttnType } from "./ruseFcltMng/fcltSttn/sttn"; +import { rainSttnActionsExport, rainSttnStateExport, type rainSttnState, type rainSttnType } from "./ruseFcltMng/fcltSttn/rainSttn"; export type WrStore = comCodeType& pubFacType & @@ -44,7 +44,7 @@ export type WrStore = comCodeType& bdstFulType& rainChkgdnType& rswtChkgdnType& - sttnType + rainSttnType ; export const StoreZus = ( @@ -57,7 +57,7 @@ export const StoreZus = ( bdstState & rainChkgdnState& rswtChkgdnState& - sttnState + rainSttnState = { ...comCodeStateExport, ...pubFacStateExport, @@ -68,7 +68,7 @@ export const StoreZus = ( ...bdstStateExport, ...rainChkgdnStateExport, ...rswtChkgdnStateExport, - ...sttnStateExport + ...rainSttnStateExport } ) => { return createStore()((set) => { @@ -89,7 +89,7 @@ export const StoreZus = ( ...bdstActionsExport(set), ...rainChkgdnActionsExport(set), ...rswtChkgdnActionsExport(set), - ...sttnActionsExport(set) + ...rainSttnActionsExport(set) }; }); }; diff --git a/apps/wr/components/lib/func/TableData.tsx b/apps/wr/components/lib/func/TableData.tsx index d6bc9f30e..b6718889a 100644 --- a/apps/wr/components/lib/func/TableData.tsx +++ b/apps/wr/components/lib/func/TableData.tsx @@ -126,7 +126,7 @@ export const chRowspanTable = ( `${value}` ) : ( { handleChange(rowIndex, head.id, e.target.value); diff --git a/apps/wr/components/lib/func/commom.tsx b/apps/wr/components/lib/func/commom.tsx index a25ea0278..57e885d38 100644 --- a/apps/wr/components/lib/func/commom.tsx +++ b/apps/wr/components/lib/func/commom.tsx @@ -74,6 +74,6 @@ export const excelSerialToDateString = (excelDate: number|undefined): string => }else{ date =new Date() } - return date.toISOString().split("T")[0] || ""; // "YYYY-MM-DD" + return date.toISOString().split("T")[0]?.replaceAll("-",'') || ""; // "YYYY-MM-DD" }; diff --git a/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx b/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx index 88d7638cf..416561b99 100644 --- a/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx @@ -101,7 +101,7 @@ useEffect(() =>{ - + const inputClass = '!text-lg' return (
@@ -109,7 +109,7 @@ useEffect(() =>{
-

+

{isModal ? "○건축물 운영정보" : "○ 빗물이용시설 정보"}

+ ); } diff --git a/apps/wr/components/ui/modal/headChModal/headChModal.tsx b/apps/wr/components/ui/modal/headChModal/headChModal.tsx index 979834dbb..d6b30c199 100644 --- a/apps/wr/components/ui/modal/headChModal/headChModal.tsx +++ b/apps/wr/components/ui/modal/headChModal/headChModal.tsx @@ -9,11 +9,12 @@ import { useForm } from "react-hook-form"; import { z } from "zod"; export default function HeadChModal({type }:{type: string }) { - const { sttnCommon ,chSttnHead} = useWrStore((state) => state); + const { rainSttn ,rainChSttnHead} = useWrStore((state) => state); - const { rainSttHeadList,pbnSttHeadList } =sttnCommon; - let items = rainSttHeadList.map(item => ({id:item.id, label:item.title})); + const { rainSttHeadList } =rainSttn; + let items = rainSttHeadList.map(item => ({id:item.id, label:item.title, val:item.visible })); + const FormSchema = z.object({ @@ -31,12 +32,17 @@ export default function HeadChModal({type }:{type: string }) { }) - + useEffect(() =>{ + form.reset({ data: items.map((el) => el.val!==undefined ? el.val.toString():undefined )}) + + + + },[rainSttHeadList]) const onSubmit = (val : z.infer) =>{ if(val?.data.length > 0) - chSttnHead(val?.data, 'rain') + rainChSttnHead(val?.data, ) } diff --git a/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx b/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx index 376ab7a95..b378167cc 100644 --- a/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx +++ b/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx @@ -1,6 +1,6 @@ 'use client' -import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/page"; +import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import { useWrStore } from "@/app/store"; import { UiTable } from "@common/business_components/ui"; diff --git a/apps/wr/components/ui/toast/toastFromUi.tsx b/apps/wr/components/ui/toast/toastFromUi.tsx index 465870c8b..5886c2e0b 100644 --- a/apps/wr/components/ui/toast/toastFromUi.tsx +++ b/apps/wr/components/ui/toast/toastFromUi.tsx @@ -1,55 +1,46 @@ - import { Button } from "@common/components/ui"; import Link from "next/link"; import toast from "react-hot-toast"; +interface toastFormType { + body: string; + title: string; + url?: string; + buttonName?: string; +} - -export function ToastFormUi(body:string,title:string,url:string,buttonName:string){ - +export function ToastFormUi({ body, title, url, buttonName }: toastFormType) { //const router = useRouter(); - return( - - toast.custom((t) => ( - -
-
-
-
- -
-
-

- {title} -

-

- {body} -

-
-
-
-
- -
-
- + return toast.custom((t) => ( +
+
+
+
+
+

{title}

+

{body}

- )) - ) -} \ No newline at end of file +
+
+ {url && buttonName ? ( + + ) : ( + <> + )} +
+
+ +
+
+ )); +}