diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx index 978805d9d..130578654 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead.tsx @@ -10,6 +10,7 @@ export const headMakeprfmnc = ( <> {upHeadList + .filter((data) => data.visible != false) .map((head: TableUpperProps) => !head.upSequnce ? ( { if (!rainChkgdn.isInit) { rainChkInit("2024", "0"); - setIsModal({ data: {}, open: rainChkgdn.isModalClose }); + isRainSttn(false) + + setIsModal({ data: {}, open: false }); setIsRegExcel(false); } if (!rswtChkgdn.isInit) { rswtChkgdnInit("2024", "0"); - setIsModal({ data: {}, open: rainChkgdn.isModalClose }); + setIsModal({ data: {}, open: false }); setIsRegExcel(false); } }, [rainChkgdn.isInit, rainChkInit]); @@ -136,7 +139,6 @@ export default function Page() { const clickDelete = (data: number[],selFcltDiv:string) => { - if (data.length > 0) { if(selFcltDiv === "RNB"){ rainChkDelete(data); @@ -147,15 +149,17 @@ export default function Page() { }; const chkUpdateTable =(selFcltDiv:string) =>{ if(selFcltDiv === "RNB"){ + rainChkDetilUpdate(updateRainDetail) }else{ - console.log("updateRswtDetail ", updateRswtDetail) rswtChkDetilsUpdate(updateRswtDetail) } } + + return (
@@ -236,12 +240,14 @@ export default function Page() { deleteData={setDeleteIdx} detailUp={setUpdateRainDetail} handleClick={handleClick} + rainChkData={rainChkgdn.rainChk} /> ) : ( ) } diff --git a/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx b/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx index eb943ca2c..8716c5cbf 100644 --- a/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncSttn/chkgdnSttn/page.tsx @@ -30,17 +30,18 @@ import { Toaster } from "react-hot-toast"; export default function Page() { const { code, - rainChkgdn, - rswtChkgdn, + rainChkSttn, + rswtChkSttn, - rainChkInit, - rswtChkgdnInit, - rainChkHeadChange, - rswtChkHeadChange + + rainChkSttnInit, + rainChkSttnSearch, + rswtChkSttnInit, + isRainSttn, + isRswtSttn } = useWrStore((state) => { return state; }); - const [isRegExcel, setIsRegExcel] = useState(false); const [searchTxt, setSearchTxt] = useState(); const [selFcltDiv, setSelFcltDiv] = useState("RNB"); const [isModal, setIsModal] = useState({ @@ -48,33 +49,26 @@ export default function Page() { data: {}, }); const cellClick = () => { - if (searchTxt) rainChkInit(searchTxt, "0"); + if (searchTxt) rainChkSttnSearch(searchTxt, "0"); }; useEffect(() => { - if (!rainChkgdn.isInit) { - rainChkInit("2024", "0"); + if (!rainChkSttn.isInit) { + isRainSttn(true) + rainChkSttnInit( "0"); setIsModal({ data: {}, open: false }); } - }, [rainChkgdn.isInit, rainChkInit]); + }, [rainChkSttn.isInit, rainChkSttnInit]); useEffect(() => { - if (!rswtChkgdn.isInit) { - rswtChkgdnInit("2024", "0"); + if (!rswtChkSttn.isInit) { setIsModal({ data: {}, open: false }); + rswtChkSttnInit( "0"); + isRswtSttn(true) } - },[rswtChkgdn.isInit, rswtChkgdnInit]) + },[rswtChkSttn.isInit, rswtChkSttnInit]) - useEffect(() => { - rainChkgdn.isSttn=true - rswtChkgdn.isSttn=true - if (rainChkgdn.isSttn &&rswtChkgdn.isSttn) { - rainChkHeadChange({rainChkgdn}, false); - rswtChkHeadChange({rswtChkgdn}, false); - } - }, [rainChkgdn.isSttn ,rswtChkgdn.isSttn]); - @@ -84,8 +78,32 @@ export default function Page() { }, [isModal] ); +const excelDown=() =>{ + console.log("excelDown" , rainChkSttn.sttnExcelList) + if(rainChkSttn.sttnExcelList && selFcltDiv === "RNB"){ + excelDownload( + rainChkSttn.sttnExcelList, + "빗물이용시설 지도점검 현황", + "sample_rainChkSttn.xlsx", + "A1:Q1", + 3 + ); + + + }else if(rswtChkSttn.sttnExcelList && selFcltDiv === "RST"){ + console.log("rswtChkSttn " , rswtChkSttn.sttnExcelList) + excelDownload( + rswtChkSttn.sttnExcelList, + "중수도시설 지도점검 현황", + "sample_rswtChkSttn.xlsx", + "A1:Q1", + 3 + ); + } +} + return (
@@ -105,11 +123,11 @@ export default function Page() { className={"col-span-3 w-full h-full text-2xl"} label={"시설구분"} selectClass={""} - selectArray={rainChkgdn.fcltDiv} + selectArray={rainChkSttn.fcltDiv} onSelectValue={(val: string | number) => setSelFcltDiv(String(val)) } - value={selFcltDiv ?? rainChkgdn.fcltDiv[0]?.val} + value={selFcltDiv ?? rainChkSttn.fcltDiv[0]?.val} /> @@ -125,8 +143,8 @@ export default function Page() {
-
@@ -142,12 +160,14 @@ export default function Page() { deleteData={() => {}} detailUp={() => {}} handleClick={handleClick} + rainChkData={rainChkSttn.rainChkRes} /> ) : ( {}} deleteRswtData={() => {}} handleRswtClick={handleClick} + rswtChkData={rswtChkSttn.rswtChkRes} /> )} diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx index 6a60ec582..3729ab987 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList.tsx @@ -33,6 +33,8 @@ export const rainChkZod = z.object({ chkgdnPk: z.number().nullable(), bdstRuseFcltFk: z.number(), chckYmd: z.string(), + cityText:z.string().nullish(), + sggText:z.string().nullish(), prcsCpct: z.number().nullable(), spwtPositn: z.string().nullable(), regDt: z.string().nullable(), @@ -122,6 +124,7 @@ export const rainHeadNmExport: chHeadType[] = [ export const rainChkgdnHeadListExport: TableUpperProps[] = [ { id: "order", title: "순번", rowSpan: true }, + { id: "checkBox", title: "선택", rowSpan: true }, { id: "cityText", title: "시도", rowSpan: true }, { id: "sggText", title: "시군구", rowSpan: true }, { id: "bdstNm", title: "시설명", rowSpan: true }, diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx index e37708cc0..fe40fb441 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList.tsx @@ -116,6 +116,7 @@ export const rswtHeadNmExport: chHeadType[] = [ export const rswtChkHeadListExport: TableUpperProps[] = [ { id: "order", title: "순번", rowSpan: true }, + { id: "checkBox", title: "선택", rowSpan: true }, { id: "cityText", title: "시도" ,rowSpan: true }, { id: "sggText", title: "시군구",rowSpan: true }, { id: "bdstNm", title: "시설명" ,rowSpan: true}, diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/excel.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/excel.tsx new file mode 100644 index 000000000..78e0b878f --- /dev/null +++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/excel.tsx @@ -0,0 +1,41 @@ +import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; + +type rainSttnExcelType = { + bdstInfoPk: number; + ctpvCd: 1; + sggCd: 1001; + daddr: "string3"; + bdstNm: "string"; + frstArchPrmsnDt: "2025-03-25"; + archArea: 0; + regDt: "2025-04-16"; + rgtr: null; + mdfcnDt: "2025-04-16"; + mdfr: null; +}; +export const buildingExcelRainSttn = (excelList: any[]) => { + const excelData: string[][] = []; + excelList.forEach((item, index) => { + excelData.push([ + String(item.cityText) ?? "", + String(item.sggText) ?? "", + String(item.bdstNm) ?? "", + item.operMngCd || String(item.operMngCd)===null? String(item.operMngCd) : "", + String(item.oilqMeasMthd) ?? "", + String(item.anlOperCst) ?? "", + String(item.dtfcltCpct) ?? "", + String(item.chckYmd) ?? "", + String(item.utztnUsgCd) ?? "", + String(item.totalSplyUswtrUtztnQnt) ?? "", + String(item.totalRuseFcltUtztnQnt) ?? "", + String(item.ph) ?? "", + String(item.trbt) ?? "", + String(item.grssClfg) ?? "", + String(item.vltnDt) ?? "", + String(item.vltnMttr) ?? "", + String(item.levyAmt) ?? "", + ]); + }); + + return excelData; +}; diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx index 4cb16df01..768de0776 100644 --- a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx +++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/headList.tsx @@ -2,7 +2,6 @@ import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; export const rainChkgdnHeadSttnExport: TableUpperProps[] = [ { id: 'order', title: "순번", rowSpan: true }, - { id: "checkBox", title: "체크박스", rowSpan: true }, { id: "cityText", title: "시도", rowSpan: true }, { id: "sggText", title: "시군구", rowSpan: true }, { id: "bdstNm", title: "시설명", rowSpan: true }, @@ -59,7 +58,7 @@ export const rainChkgdnHeadSttnExport: TableUpperProps[] = [ }, ]; -export const ruseHeadListExport: TableUpperProps[] = [ +export const ruseSttnHeadListExport: TableUpperProps[] = [ { id: "utztnUsgCd", title: "이용용도" }, { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 }, { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 }, @@ -76,7 +75,7 @@ export const ruseHeadListExport: TableUpperProps[] = [ { id: "ruse12", title: "12월", upName: "ruseWater", upSequnce: 13 }, ]; -export const splHeadListExport: TableUpperProps[] = [ +export const splSttnHeadListExport: TableUpperProps[] = [ { id: "utztnUsgCd", title: "이용용도" }, { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1 }, { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2 }, diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/index.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/index.tsx index 714057be0..9fd948856 100644 --- a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/index.tsx +++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rainChkgdnSttn/index.tsx @@ -1,54 +1,66 @@ import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; -import { - rainHeadNmExport, - rainChkgdnHeadListExport, - type chHeadType, -} from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { getFetch } from "@/components/lib/api"; import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; import type { SelectDataType } from "@common/business_components/ui"; +import { rainChkgdnHeadSttnExport, ruseSttnHeadListExport, splSttnHeadListExport } from "./headList"; +import { rainHeadNmExport, type chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; +import { buildingExcelRainSttn } from "./excel"; const fcltDiv = [ { val: "RST", text: "중수도시설" }, { val: "RNB", text: "빗물이용시설" }, ]; -const rainHeadNm = rainHeadNmExport; -const rainChkgdnHeadList = rainChkgdnHeadListExport; + +const rainChkgdnHeadList = rainChkgdnHeadSttnExport; +const ruseHeadList = ruseSttnHeadListExport; +const splHeadList = splSttnHeadListExport; +const rainHeadNm = rainHeadNmExport const rainChk: rainChkZodType[] = []; export type rainChkSttnState = { rainChkSttn: { - rainChkgdnHeadList: TableUpperProps[]; - rainChkSttn: rainChkZodType[]; - rainHeadNm: chHeadType[]; + rainChkRes: rainChkZodType[]; fcltDiv: SelectDataType[]; + rainChkgdnHeadList: TableUpperProps[]; + rainHeadNm:chHeadType[]; + ruseHeadList: TableUpperProps[]; + splHeadList: TableUpperProps[]; + sttnExcelList:[] isInit: boolean; + isSttn:boolean; }; }; type rainChkSttnActions = { - rainChkSttnInit: (searchTxt: string, sggCd: string) => void; + rainChkSttnInit: ( sggCd: string) => void; + rainChkSttnSearch: (searchTxt: string, sggCd: string) => void; + isRainSttn:(isSttn:boolean) => void; + getRainSttnExcel:(excelList:rainChkZodType[]) => void; }; export type rainChkSttnType = rainChkSttnState & rainChkSttnActions; export const rainChkSttnStateExport: rainChkSttnState = { rainChkSttn: { - rainChkgdnHeadList: rainChkgdnHeadList, - rainHeadNm: rainHeadNm, - rainChkSttn: [], + rainChkRes: [], fcltDiv: fcltDiv, + rainChkgdnHeadList: rainChkgdnHeadList, + ruseHeadList: ruseHeadList, + splHeadList: splHeadList, + rainHeadNm:rainHeadNm, isInit: false, + sttnExcelList:[], + isSttn:false, }, }; const initFetch = async (txt: string | undefined, sgg: string | undefined) => { const rainRes = await getFetch( "wr", - `/reuseChk/rainy` + (txt ? `/${txt}` : "2024") + (sgg ? `/${sgg}` : "/0") + `/reuseChk/rainy/` + (txt ? `${txt}` : "2024") + (sgg ? `/${sgg}` : "/0") ); return rainRes; }; @@ -56,7 +68,22 @@ export const rainChkSttnActionsExport: (set: any) => rainChkSttnActions = ( set: any ) => { return { - rainChkSttnInit: async (searchTxt: string, sggCd: string) => { + rainChkSttnInit: async ( sggCd: string) => { + try { + const rainChkRes = await initFetch(undefined, sggCd); + + return set((state: rainChkSttnState) => ({ + ...state, + rainChkSttn: { + ...state.rainChkSttn, + rainChkRes:rainChkRes + }, + })); + } catch (error) { + console.log(error); + } + }, + rainChkSttnSearch: async (searchTxt: string, sggCd: string) => { try { const rainChkRes = await initFetch(searchTxt, sggCd); @@ -70,6 +97,33 @@ export const rainChkSttnActionsExport: (set: any) => rainChkSttnActions = ( } catch (error) { console.log(error); } - }, + },isRainSttn :(isSttn:boolean) =>{ + try { + return set((state: rainChkSttnState) => ({ + ...state, + rainChkSttn: { + ...state.rainChkSttn, + isSttn:isSttn + }, + })); + } catch (error) { + console.log(error); + } + },getRainSttnExcel: async (excelList:rainChkZodType[]) => { + try { + + const excelData = buildingExcelRainSttn(excelList) + + return set((state: rainChkSttnState) => ({ + ...state, + rainChkSttn: { + ...state.rainChkSttn, + sttnExcelList:excelData + }, + })); + } catch (error) { + console.log(error); + } + } }; }; diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/excel.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/excel.tsx new file mode 100644 index 000000000..ff104bc91 --- /dev/null +++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/excel.tsx @@ -0,0 +1,34 @@ + +export const buildingExcelRswtSttn = (excelList: any[]) => { + const excelData: string[][] = []; + excelList.forEach((item, index) => { + excelData.push([ + String(item.cityText) ?? "", + String(item.sggText) ?? "", + String(item.bdstNm) ?? "", + item.operMngCd===null ? "":item.operMngCd, + String(item.anlOperCst) ?? "", + String(item.prcsCpct) ?? "", + item.spwtPositn===null ? "":item.spwtPositn, + item.chckYmd ?? "", + String(item.utztnUsgCd) ?? "", + String(item.splyUswtrUtztnQnt) ?? "", + String(item.ruseFcltUtztnQnt) ?? "", + String(item.grssClfgUswtr) ?? "", + String(item.combResdch) ?? "", + String(item.trbt) ?? "", + String(item.bod) ?? "", + String(item.smll) ?? "", + String(item.tn) ?? "", + String(item.tph) ?? "", + String(item.ph) ?? "", + String(item.clIonQnt) ?? "", + String(item.vltnDt) ?? "", + String(item.vltnMttr) ?? "", + String(item.levyAmt) ?? "", + ]); + }); + + return excelData; + }; + \ No newline at end of file diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx new file mode 100644 index 000000000..f3b018d10 --- /dev/null +++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/headList.tsx @@ -0,0 +1,142 @@ +import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; + +export const rswtChkSttnHeadListExport: TableUpperProps[] = [ + { id: "order", title: "순번", rowSpan: true }, + { id: "cityText", title: "시도", rowSpan: true }, + { id: "sggText", title: "시군구", rowSpan: true }, + { id: "bdstNm", title: "시설명", rowSpan: true }, + { id: "operMngCd", title: "운영관리형태", rowSpan: true }, + { id: "anlOperCst", title: "연간운영비(원/년)", rowSpan: true }, + { id: "prcsCpct", title: "처리용량(m³)", rowSpan: true }, + { id: "spwtPositn", title: "채수지점", rowSpan: true }, + { id: "chckYmd", title: "점검일", rowSpan: true }, + { id: "utztnUsgCd", title: "이용용도" }, + { id: "splyUswtrUtztnQnt", title: "연간보급수이용량(m³)", type: "number" }, + { id: "ruseFcltUtztnQnt", title: "연간중수도이용량(m³)", type: "number" }, + + { + id: "grssClfgUswtr", + title: "총대장균군수", + upName: "useQuilty", + upSequnce: 1, + type: "number", + }, + { + id: "combResdch", + title: "결합잔류염소", + upName: "useQuilty", + upSequnce: 2, + type: "number", + }, + { + id: "trbt", + title: "탁도", + upName: "useQuilty", + upSequnce: 3, + type: "number", + }, + { + id: "bod", + title: "BOD", + upName: "useQuilty", + upSequnce: 4, + type: "number", + }, + { + id: "smll", + title: "냄새", + upName: "useQuilty", + upSequnce: 5, + type: "number", + }, + { + id: "crmty", + title: "색도", + upName: "useQuilty", + upSequnce: 6, + type: "number", + }, + { id: "tn", title: "T-N", upName: "useQuilty", upSequnce: 7, type: "number" }, + { + id: "tph", + title: "T-P", + upName: "useQuilty", + upSequnce: 8, + type: "number", + }, + { id: "ph", title: "PH", upName: "useQuilty", upSequnce: 9, type: "number" }, + { + id: "clIonQnt", + title: "염화물", + upName: "useQuilty", + upSequnce: 10, + type: "number", + }, + + { + id: "vltnDt", + title: "부과일(위반일)", + upName: "feeHist", + upSequnce: 1, + type: "text", + }, + { + id: "vltnMttr", + title: "위반사항", + upName: "feeHist", + upSequnce: 2, + type: "text", + }, + { + id: "levyAmt", + title: "부과금액(천원)", + upName: "feeHist", + upSequnce: 3, + type: "number", + }, +]; + +export const rswtDetailSttnHeadListExport: TableUpperProps[] = [ + { id: "utztnUsgCd", title: "이용용도" }, + + { + id: "grssClfgUswtr", + title: "총대장균군수", + upName: "detailQulity", + upSequnce: 2, + }, + { + id: "combResdch", + title: "결합잔류염소", + upName: "detailQulity", + upSequnce: 3, + }, + { + id: "trbt", + title: "탁도", + upName: "detailQulity", + upSequnce: 4, + }, + { id: "bod", title: "BOD", upName: "detailQulity", upSequnce: 5 }, + { + id: "smll", + title: "냄새", + upName: "detailQulity", + upSequnce: 6, + }, + { + id: "crmty", + title: "색도", + upName: "detailQulity", + upSequnce: 7, + }, + { 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: "clIonQnt", + title: "염화물", + upName: "detailQulity", + upSequnce: 11, + }, +]; diff --git a/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/index.tsx b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/index.tsx new file mode 100644 index 000000000..f1dbd6c6e --- /dev/null +++ b/apps/wr/app/store/prfmncSttn/chkgdnSttn/rswtChkgdnSttn/index.tsx @@ -0,0 +1,108 @@ +import { rswtHeadNmExport } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList"; +import { rswtChkSttnHeadListExport, rswtDetailSttnHeadListExport } from "./headList"; +import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; +import type { sheetParameter } from "@common/business_components/ui"; +import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn"; +import { getFetch } from "@/components/lib/api"; +import { buildingExcelRswtSttn } from "./excel"; + +const rswtChkHeadList = rswtChkSttnHeadListExport; +const rswtDetailHeadList = rswtDetailSttnHeadListExport; +const rswtHeadNm = rswtHeadNmExport; + + +export type rswtChkSttnState = { + rswtChkSttn: { + rswtChkSttnHeadList: TableUpperProps[]; + rswtDetailSttnHeadList: TableUpperProps[]; + rswtSttnHeadNm: chHeadType[]; + sttnExcelList: []; + rswtChkRes: rswtChkZodType[]; + isInit: boolean; + isSttn: boolean; + }; +}; + +type rswtChkSttnActions = { + rswtChkSttnInit: ( sggCd: string) => void; + isRswtSttn: (isSttn:boolean) => void; + getRswtSttnExcel:(excelList:rswtChkZodType[]) => void; + +}; + +export type rswtChkSttnType = rswtChkSttnState & rswtChkSttnActions; + +export const rswtChkStateExport: rswtChkSttnState = { + rswtChkSttn: { + rswtChkSttnHeadList: rswtChkHeadList, + rswtDetailSttnHeadList: rswtDetailHeadList, + rswtSttnHeadNm: rswtHeadNm, + sttnExcelList: [], + rswtChkRes: [], + isInit: false, + isSttn:false, + }, +}; + +const initFetch = async (year: string | undefined, sgg: string | undefined) => { + const rswtChkRes = await getFetch( + "wr", + `/reuseChk/reuseWater/` + + (year ? `${year}` : "2024") + + (sgg ? `/${sgg}` : "/0") + ); + return rswtChkRes; +}; + + +export const rswtChkSttnActionsExport: (set: any) => rswtChkSttnActions = ( + set: any +) => { + return { + rswtChkSttnInit: async ( sggCd: string) => { + try { + const rswtChkRes = await initFetch("2024", sggCd); + return set((state: rswtChkSttnState) => ({ + ...state, + rswtChkSttn: { + ...state.rswtChkSttn, + rswtChkRes: rswtChkRes, + isInit: false, + }, + })); + } catch (error) { + console.log(error); + } + },isRswtSttn :(isSttn:boolean) =>{ + try { + return set((state: rswtChkSttnState) => ({ + ...state, + rswtChkSttn: { + ...state.rswtChkSttn, + isSttn:isSttn + }, + })); + } catch (error) { + console.log(error); + } + },getRswtSttnExcel: async (excelList:rswtChkZodType []) => { + try { + + const excelData = buildingExcelRswtSttn(excelList) + + return set((state: rswtChkSttnState) => ({ + ...state, + rswtChkSttn: { + ...state.rswtChkSttn, + sttnExcelList:excelData + }, + })); + } catch (error) { + console.log(error); + } + } + + + }; +}; diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index ab2e78277..23cba135d 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -83,6 +83,7 @@ import { type rainChkSttnState, type rainChkSttnType, } from "./prfmncSttn/chkgdnSttn/rainChkgdnSttn"; +import { rswtChkStateExport, rswtChkSttnActionsExport, type rswtChkSttnState, type rswtChkSttnType } from "./prfmncSttn/chkgdnSttn/rswtChkgdnSttn"; export type WrStore = comCodeType & pubFacType & @@ -96,7 +97,8 @@ export type WrStore = comCodeType & rainSttnType & rswtSttnType & htdflSttnType & - rainChkSttnType; + rainChkSttnType& + rswtChkSttnType; export const StoreZus = ( initState: comCodeState & @@ -111,7 +113,8 @@ export const StoreZus = ( rainSttnState & rswtSttnState & htdflSttnState & - rainChkSttnState + rainChkSttnState& + rswtChkSttnState = { ...comCodeStateExport, ...pubFacStateExport, @@ -126,6 +129,7 @@ export const StoreZus = ( ...rswtSttnStateExport, ...htdflSttnStateExport, ...rainChkSttnStateExport, + ...rswtChkStateExport, } ) => { return createStore()((set) => { @@ -149,7 +153,8 @@ export const StoreZus = ( ...rainSttnActionsExport(set), ...rswtSttnActionsExport(set), ...htdflSttnActionsExport(set), - ...rainChkSttnActionsExport(set) + ...rainChkSttnActionsExport(set), + ...rswtChkSttnActionsExport(set) }; }); }; diff --git a/apps/wr/components/lib/func/TableData.tsx b/apps/wr/components/lib/func/TableData.tsx index e5f6c00db..250a431da 100644 --- a/apps/wr/components/lib/func/TableData.tsx +++ b/apps/wr/components/lib/func/TableData.tsx @@ -97,7 +97,10 @@ export const chRowspanTable = ( <> {makeTableData.map((row, rowIndex) => ( - {headList.map((head) => { + {headList + .map((head) => { + + const key = head.id; const isMerged = head.rowSpan; const value = row[key]; @@ -120,7 +123,7 @@ export const chRowspanTable = ( rowSpan={rowspan} className="align-middle text-center whitespace-nowrap" > - {key === "chekcBox" ? ( + {key === "checkBox" ? ( @@ -164,3 +167,16 @@ export const chRowspanTable = ( ); }; + + + +export const headVisibleChange= (headList: TableUpperProps[] , isEdit :boolean) => { + return headList.forEach(( head) => { + if(head.edit!== undefined) + head.edit=isEdit; + if(head.id==='checkBox' ){ + head.visible=false + } + + }); +} \ No newline at end of file diff --git a/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx b/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx index 13da8a8bd..90f78ab1a 100644 --- a/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx +++ b/apps/wr/components/ui/modal/chkgd/chkgdModal/chkgdModal.tsx @@ -8,11 +8,23 @@ import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgd import type { rswtrPolutionsZode } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList"; import type { z } from "zod"; import React from "react"; +import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { - const { rainChkgdn, rswtChkgdn, rainChkGuidUpdate, rwstPolAndGuideUpdate } = - useWrStore((state) => state); + const { + rainChkgdn, + rswtChkgdn, + rainChkSttn, + rswtChkSttn, + rainChkGuidUpdate, + rwstPolAndGuideUpdate, + } = useWrStore((state) => state); const [guidData, setGuidData] = useState(); + const [headList, setHeadList] = useState<{ + splHeadList: TableUpperProps[]; + ruseHeadList: TableUpperProps[]; + rswtDetailHeadList: TableUpperProps[]; + }>({ splHeadList: [], ruseHeadList: [], rswtDetailHeadList: [] }); const [polutionData, setPolutionData] = useState>({ "1": [] as z.infer[], @@ -43,6 +55,30 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { clIonQnt: 0, }); + ///현황일 경우 input 비활성화 한다. + useEffect(() => { + if (rainChkSttn.isSttn) { + setHeadList({ + splHeadList: rainChkSttn.splHeadList, + ruseHeadList: rainChkSttn.ruseHeadList, + rswtDetailHeadList: type === "RNB" ? [] : rswtChkSttn.rswtDetailSttnHeadList, + }); + } else { + setHeadList({ + splHeadList: rainChkgdn.splHeadList, + ruseHeadList: rainChkgdn.ruseHeadList, + rswtDetailHeadList: + type === "RNB" ? [] : rswtChkgdn.rswtDetailHeadList, + }); + } + }, [ + rainChkSttn.isSttn, + rainChkgdn.splHeadList, + rainChkSttn.splHeadList, + rswtChkgdn.rswtDetailHeadList, + rswtChkSttn.rswtDetailSttnHeadList + ]); + useEffect(() => { const result = obj.guideDetails?.reduce((acc: any, cur: any) => { const code = cur.utztnUsgCd; @@ -197,7 +233,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {

{"○" + "" + `(${obj.bdstNm})`}

- {!rainChkgdn.isSttn ? ( + {!rainChkSttn.isSttn ? ( @@ -214,7 +250,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { { setChGuidData(data); @@ -227,7 +263,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { { setChGuidData(data); @@ -248,7 +284,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) { { getPolutionData(data); diff --git a/apps/wr/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable.tsx b/apps/wr/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable.tsx index ed3f590b1..9c9bdbb24 100644 --- a/apps/wr/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable.tsx +++ b/apps/wr/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable.tsx @@ -2,9 +2,12 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import { useWrStore } from "@/app/store"; import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; +import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; +import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { tableData } from "@/components/lib/func/commom"; import { chRowspanTable, + headVisibleChange, rainChkTableData } from "@/components/lib/func/TableData"; import { @@ -16,16 +19,21 @@ import { useCallback, useEffect, useState } from "react"; export default function RainChkgdTable({ detailUp, handleClick=() => {}, - deleteData + deleteData, + rainChkData, }: { detailUp: (data: rainChkZodType[]) => void; handleClick?: (data:any) => void; deleteData:(selectedIds:number[])=>void + rainChkData?: rainChkZodType[]; }) { - const { code, rainChkgdn } = useWrStore((state) => state); + const { code, rainChkgdn ,rainChkSttn,getRainSttnExcel } = useWrStore((state) => state); const [makeTableData, setMakeTableData] = useState([]); const [selectedIds, setSelectedIds] = useState([]); const [upRaintDetail, setUpRaintDetail] = useState([]); + const [headList, setHeadList] = useState< {headList:TableUpperProps[],upHeadList:chHeadType[]}>({headList:[], upHeadList:[]}); + + const toggleSelection = (pk: number, checked: boolean) => { setSelectedIds((prev) => checked ? [...prev, pk] : prev.filter((item) => item !== pk) @@ -60,20 +68,24 @@ export default function RainChkgdTable({ useEffect(() => { setSelectedIds([])// 셀렉트 초기화를 위한 작업 - const rainChg = rainChkgdn.rainChk.map((item: any) => { - const bud = tableData([item.building], { code }); - return { - ...item, - ...bud[0], - rowspan: item.rainyDetails?.length, - }; - }); - const tableTotalData = rainChkTableData(rainChg) - setMakeTableData(tableTotalData); - }, [rainChkgdn.rainChk, code]); + if(rainChkData){ + const rainChg = rainChkData.map((item: any) => { + const bud = tableData([item.building], { code }); + return { + ...item, + ...bud[0], + rowspan: item.rainyDetails?.length, + }; + }); + setMakeTableData(rainChkTableData(rainChg)); + } + }, [rainChkData, code]); useEffect(() => { //데이터를 평탄화 한것중에 체크박스 선택한 테이블만 선택 + + //현황 페이지에서 필요한 엑셀 데이터를 바뀔때마다 넣기 위해서 + getRainSttnExcel(makeTableData); const selectedData = makeTableData.filter((item) =>selectedIds.includes(item.chkgdnPk)); if (selectedData.length > 0) { @@ -123,6 +135,7 @@ export default function RainChkgdTable({ useEffect(() => { detailUp(upRaintDetail); + }, [upRaintDetail]); useEffect(() =>{ @@ -133,19 +146,38 @@ export default function RainChkgdTable({ },[selectedIds]) + ///현황일 경우 input 비활성화 한다. + useEffect(() => { + if(rainChkSttn.isSttn){ + + setHeadList({ + headList: rainChkSttn.rainChkgdnHeadList, + upHeadList: rainChkSttn.rainHeadNm + }) + }else{ + setHeadList({ + headList: rainChkgdn.rainChkgdnHeadList, + upHeadList: rainChkgdn.rainHeadNm + }) + + } + + }, [rainChkSttn.isSttn, rainChkgdn.rainChkgdnHeadList , rainChkSttn.rainChkgdnHeadList]); + + return ( {headMakeprfmnc( - rainChkgdn?.rainChkgdnHeadList, - rainChkgdn?.rainHeadNm + headList?.headList, + headList?.upHeadList )} {chRowspanTable( makeTableData, - rainChkgdn.rainChkgdnHeadList, + headList.headList, handleChange, toggleSelection, selectedIds, diff --git a/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx b/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx index d9caa86fd..b4f0281ac 100644 --- a/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx +++ b/apps/wr/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable.tsx @@ -1,9 +1,12 @@ "use client"; import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import { useWrStore } from "@/app/store"; +import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import type { + rswtChkZodType, rswtrChkDetailsZodType, } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn"; +import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { tableData } from "@/components/lib/func/commom"; import { chRowspanTable, @@ -16,14 +19,17 @@ export default function RswtChkgdTable({ detaiRswtlUpdate, handleRswtClick = () => {}, deleteRswtData, + rswtChkData, }: { detaiRswtlUpdate: (data: rswtrChkDetailsZodType[]) => void; handleRswtClick?: (data: any) => void; deleteRswtData: (selectedIds: number[]) => void; + rswtChkData: rswtChkZodType[]; }) { - const { code, rswtChkgdn, rswtChkgdnInit, rswtChkPolAndGuide } = useWrStore( + const { code, rswtChkgdn,rswtChkSttn , rswtChkgdnInit, rswtChkPolAndGuide,getRswtSttnExcel } = useWrStore( (state) => state ); + const [headList, setHeadList] = useState< {headList:TableUpperProps[],upHeadList:chHeadType[]}>({headList:[], upHeadList:[]}); const [makeTableData, setMakeTableData] = useState([]); const [selectedIds, setSelectedIds] = useState([]); @@ -61,6 +67,8 @@ export default function RswtChkgdTable({ }, [rswtChkgdn.rswtChkPolGuide]); useEffect(() => { + console.log("makeTableData ", makeTableData) + getRswtSttnExcel(makeTableData) const selectedData = makeTableData .map((item) => { return { @@ -78,8 +86,9 @@ export default function RswtChkgdTable({ useEffect(() => { setSelectedIds([]); // 셀렉트 초기화를 위한 작업 - const tableTotalData = rswtChkTableData(rswtChkgdn.rswtChkRes); - const rswtChkData = tableTotalData.map((item: any) => { + + const tableTotalData = rswtChkTableData(rswtChkData); + const makeRswtChkData = tableTotalData.map((item: any) => { const bud = tableData([item.building], { code }); return { ...item, @@ -87,8 +96,8 @@ export default function RswtChkgdTable({ rowspan: item.rswtrDetails?.length, }; }); - setMakeTableData(rswtChkData); - }, [rswtChkgdn.rswtChkRes, code]); + setMakeTableData(makeRswtChkData); + }, [rswtChkData, code]); useEffect(() => { detaiRswtlUpdate(upRswttDetail); @@ -101,17 +110,35 @@ export default function RswtChkgdTable({ } }, [selectedIds]); + ///현황일 경우 input 비활성화 한다. + useEffect(() => { + if(rswtChkSttn.isSttn){ + setHeadList({ + headList: rswtChkSttn.rswtChkSttnHeadList, + upHeadList: rswtChkSttn.rswtSttnHeadNm + }) + }else{ + setHeadList({ + headList: rswtChkgdn.rswtChkHeadList, + upHeadList: rswtChkgdn.rswtHeadNm + }) + + } + + }, [rswtChkSttn.isSttn, rswtChkgdn.rswtChkHeadList , rswtChkSttn.rswtChkSttnHeadList]); + + return ( <>
- {headMakeprfmnc(rswtChkgdn?.rswtChkHeadList, rswtChkgdn?.rswtHeadNm)} + {headMakeprfmnc(headList?.headList, headList?.upHeadList)} {chRowspanTable( makeTableData, - rswtChkgdn.rswtChkHeadList, + headList.headList, handleChange, toggleSelection, selectedIds, diff --git a/apps/wr/public/sample_rainChkSttn.xlsx b/apps/wr/public/sample_rainChkSttn.xlsx new file mode 100644 index 000000000..dcab1be0c Binary files /dev/null and b/apps/wr/public/sample_rainChkSttn.xlsx differ diff --git a/apps/wr/public/sample_rswtChkSttn.xlsx b/apps/wr/public/sample_rswtChkSttn.xlsx new file mode 100644 index 000000000..a5b2e85a4 Binary files /dev/null and b/apps/wr/public/sample_rswtChkSttn.xlsx differ