온배수 완료, 엑셀 해야됨

This commit is contained in:
jyha00
2025-05-14 14:35:11 +09:00
parent 52f154b53c
commit 2ce2d2eca3
6 changed files with 358 additions and 32 deletions
+5
View File
@@ -48,6 +48,11 @@ export default function Home() {
</Link>
</Button>
</div>
<div className="col-span-2">
<Button className="w-full">
<Link href="ruseFcltMng/prfmncSttn/chkgdnSttn">지도점검 결과 현황</Link>
</Button>
</div>
</div>
</div>
@@ -7,20 +7,24 @@ import type {
customRainBdst,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { getCityOrSgg, tableData } from "@/components/lib/func/commom";
import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal";
import {
ContentsDiv,
SearchBaseForm,
Title,
UiModal,
UiTable,
type ReturnType,
} from "@common/business_components/ui";
import ListDiv from "@common/business_components/ui/list_div";
import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
import SttnDetailModal from "@/components/ui/modal/sttn/sttnDetailModal/sttnDetailModal";
import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal";
import { Button } from "@common/components/ui";
import { useCallback, useEffect, useRef, useState } from "react";
export default function HtdflSttn() {
const { code, htdflSttn ,initHtdfl} = useWrStore((state) => state);
const { code, htdflSttn, htdflSttnSearch, initHtdfl} = useWrStore((state) => state);
const { htdflSttnRes } = htdflSttn;
const ref = useRef<ReturnType>({} as ReturnType);
@@ -40,11 +44,26 @@ export default function HtdflSttn() {
const codeData = getCityOrSgg(ref);
const excelClick = useCallback(() => {
// if (codeData) rainSttnSearch(1, "10000", codeData);
if (codeData) htdflSttnSearch(1, "10000", codeData);
}, []);
const cellClick = (index: number | undefined, headId: string) => {};
useEffect(() => {
if (codeData != null) htdflSttnSearch(pageNation, "20", codeData);
}, [pageNation]);
const cellClick = (index: number | undefined, headId: string) => {
if(headId!=='chBuildingYn' && index!==undefined && bdstTable!==undefined){
setDetailModal({isOpen:true ,data:bdstTable[index] })
}else if( headId==='chBuildingYn' && index!==undefined && bdstTable!==undefined){
if (
bdstTable[index] &&
bdstTable[index]?.chgBuilding[0]?.bdstChgNm!==null
) {
setBdstChgProps({ isOpen:true , chBuilding: bdstTable[index].chgBuilding});
}
}
};
useEffect(() => {
if (!htdflSttn.isInit) {
@@ -129,6 +148,39 @@ export default function HtdflSttn() {
</ListDiv>
</div>
</div>
<UiModal
open={isChHead}
onOpenChange={() => {
setIsChHead(!isChHead);
}}
bodyClass={""}
body={
<HeadChModal
type={"HTB"}
headList={htdflSttn.htdflSttHeadList.map((item) => ({
...item,
visible: item.visible ?? false,
}))}
/>
}
/>
<UiModal
open={detailModal.isOpen}
onOpenChange={()=>{
setDetailModal({...detailModal, isOpen:!detailModal.isOpen})
}}
bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"}
body={<SttnDetailModal type={"HTB"} formObj={detailModal.data}/>}/>
<UiModal
bodyClass={""}
open={bdstChgProps.isOpen}
body={
<BdstChgModal chgBuilding={bdstChgProps.chBuilding}></BdstChgModal>
}
onOpenChange={(open) => {
setBdstChgProps({ ...bdstChgProps, isOpen: open });
}}
/>
</ContentsDiv>
</>
);
@@ -0,0 +1,206 @@
"use client";
import { useWrStore } from "@/app/store";
import { type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
import {
excelArrayDownload,
excelDownload,
} from "@/components/lib/func/commom";
import ChkgdExcel from "@/components/ui/modal/chkgd/chkgdExcel/chkgdExcel";
import ChkgdModal from "@/components/ui/modal/chkgd/chkgdModal/chkgdModal";
import RainChkgdTable from "@/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable";
import RswtChkgdTable from "@/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable";
import {
ContentsDiv,
SearchDiv,
SearchFormLeft,
SearchFormRight,
SearchInput,
SelectBox,
Title,
UiModal,
} from "@common/business_components/ui";
import ListDiv from "@common/business_components/ui/list_div";
import { Button } from "@common/components/ui";
import { useCallback, useEffect, useState } from "react";
import { Toaster } from "react-hot-toast";
//-----------------------
export default function Page() {
const {
code,
rainChkgdn,
rswtChkgdn,
rainChkInit,
rainChkDetilUpdate,
rainChkDelete,
rainChkExcelDownload,
rswtrChkExcelDownload,
rswtChkgdnInit
} = useWrStore((state) => {
return state;
});
const [isRegExcel, setIsRegExcel] = useState(false);
const [searchTxt, setSearchTxt] = useState<string>();
const [updateRainDetail, setUpdateRainDetail] = useState<rainChkZodType[]>(
[]
);
const [deleteIdx, setDeleteIdx] = useState<number[]>([]);
const [selFcltDiv, setSelFcltDiv] = useState("RNB");
const [isModal, setIsModal] = useState({
open: false,
data: {},
});
const cellClick = () => {
if (searchTxt) rainChkInit(searchTxt, "0");
};
useEffect(() => {
if (!rainChkgdn.isInit) {
rainChkInit("2024", "0");
setIsModal({ data: {}, open: rainChkgdn.isModalClose });
setIsRegExcel(false);
}
if (!rswtChkgdn.isInit) {
rswtChkgdnInit("2024", "0");
setIsModal({ data: {}, open: rainChkgdn.isModalClose });
setIsRegExcel(false);
}
}, [rainChkgdn.isInit, rainChkInit]);
useEffect(() => {
console.log("rswtChkgdn.excelList ", rswtChkgdn.excelList);
if (rswtChkgdn.excelList[0]?.data.length > 1)
excelArrayDownload(
"중수도_점검결과_이용량현황",
"sample_rs_chk.xlsx",
rswtChkgdn.excelList
);
}, [rswtChkgdn.excelList]);
useEffect(() => {
excelDownload(
rainChkgdn.excelList,
"빗물이용시설 지도점검",
"sample_rainy.xlsx",
"A1:AN1"
);
}, [rainChkgdn.excelList]);
const excelClick = useCallback(() => {
console.log("selFcltDiv ", selFcltDiv);
if (selFcltDiv === "RNB") {
rainChkExcelDownload(code.cityCd, code.sggCd);
} else {
rswtrChkExcelDownload(code.cityCd, code.sggCd);
}
}, [
rainChkExcelDownload,
rswtrChkExcelDownload,
code.cityCd,
code.sggCd,
selFcltDiv,
]);
const handleClick = useCallback(
(data: any) => {
if (data) setIsModal({ open: true, data: data });
},
[isModal]
);
const clickDelete = (data: number[]) => {
if (data.length > 0) {
rainChkDelete(data);
}
};
return (
<ContentsDiv>
<div className="grid grid-cols-4 gap-4 ">
<div className="col-span-4">
<Title title={"지도점검 결과 현황"} />
<SearchDiv>
<SearchFormLeft>
<SearchInput
className="col-span-3 my-7 !text-xl"
label=" 지도점검년도"
textValue={searchTxt ?? ""}
setText={(e) => {
setSearchTxt(e);
}}
/>
<SelectBox
className={"col-span-3 w-full h-full text-2xl"}
label={"시설구분"}
selectClass={""}
selectArray={rainChkgdn.fcltDiv}
onSelectValue={(val: string | number) =>
setSelFcltDiv(String(val))
}
value={selFcltDiv ?? rainChkgdn.fcltDiv[0]?.val}
/>
</SearchFormLeft>
<SearchFormRight>
<div className="space-y">
<div className="flex flex-row space-x-2">
<Button
size={"sm"}
onClick={(e) => {
cellClick();
}}
>
조회
</Button>
</div>
<div className="flex flex-row space-x-2 pt-3">
<Button color="green" size={"sm"} onClick={excelClick}>
양식받기
</Button>
</div>
</div>
</SearchFormRight>
</SearchDiv>
</div>
</div>
<div className="grid grid-cols-6 gap-4 ">
<div className="col-span-6">
<ListDiv>
{selFcltDiv === "RNB" ? (
<RainChkgdTable
deleteData={setDeleteIdx}
detailUp={setUpdateRainDetail}
handleClick={handleClick}
/>
) : (
<RswtChkgdTable detaiRswtlUpdate={function (data: rswtChkZodType[]): void {
throw new Error("Function not implemented.");
} } deleteRswtData={function (selectedIds: number[]): void {
throw new Error("Function not implemented.");
} } />
)}
</ListDiv>
</div>
</div>
<UiModal
open={isModal.open}
onOpenChange={() => {
setIsModal({ open: !open, data: {} });
}}
bodyClass={"w-[80vw] max-w-none"}
body={<ChkgdModal type={"RNB"} obj={isModal.data} />}
></UiModal>
<UiModal
open={isRegExcel}
onOpenChange={setIsRegExcel}
bodyClass={"w-[40vw] max-w-none"}
body={<ChkgdExcel type={selFcltDiv}></ChkgdExcel>}
/>
<Toaster position="top-center" />
</ContentsDiv>
);
}
@@ -2,8 +2,9 @@ import type { CommonTableProps } from "@/app/store/common/type/headder";
import { htdflSttHeadListExport, htdflSttNodeListExport } from "./headList";
import type { sttnHeadListType } from "../rainSttn/headList";
import type { z } from "zod";
import { controlHeadView } from "../rainSttn";
import type { customHtdflBdst } from "../../fcltReg/htdflReg";
import { getFetch } from "@/components/lib/api";
import { fetchType, getFetch } from "@/components/lib/api";
const htdflSttHeadList = htdflSttHeadListExport;
const htdflSttNodeList = htdflSttNodeListExport;
@@ -16,7 +17,13 @@ export type htdflSttnState = {
htdflSttnRes:customHtdflBdst[]
};
};
type htdflSttnActions = {};
type htdflSttnActions = {
initHtdfl:(con:string) => void;
htdflSttnSearch: (page: number, total: string, con: string) => void;
htdflChSttnHead: (
headList: z.infer<typeof sttnHeadListType>,
) => void;
};
export type htdflSttnType = htdflSttnState & htdflSttnActions;
@@ -29,11 +36,11 @@ export const htdflSttnStateExport: htdflSttnState = {
},
};
const initFetch = async (code:string|number) => {
const rswtRes = await getFetch(
const htdflRes = await getFetch(
"wr",
`/drain/facilityList/1/20/${code}`)
return rswtRes;
return htdflRes;
};
export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
@@ -57,5 +64,52 @@ export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
console.log(error);
}
},
htdflSttnSearch: async (page: number, total: string, con: string) => {
try {
const htdflSttnRes = await getFetch(
fetchType.WR,
`/drain/facilityList/${page}/${total}/${con}`
);
if (Number(total) > 9000) {
// const htdflExcel = excelHtdflSttnParsing(htdflSttnRes);
set((state: htdflSttnState) => {
return {
...state,
htdflSttn: {
...state.htdflSttn,
// excelList: htdflExcel,
},
};
});
} else
set((state: htdflSttnState) => {
return {
...state,
htdflSttn: {
...state.htdflSttn,
htdflSttnRes: htdflSttnRes,
isInit: false,
},
};
});
} catch (erTxt) {
console.log("error", erTxt);
}
},
htdflChSttnHead: async (
headList: z.infer<typeof sttnHeadListType>
): Promise<void> => {
console.log('head ', headList)
const changeNodeList= controlHeadView(headList,htdflSttNodeList)
return set((state: htdflSttnState) => ({
htdflSttn: {
...state.htdflSttn,
htdflSttHeadList: headList,
htdflSttNodeList: changeNodeList,
},
}));
},
}
}
@@ -8,7 +8,7 @@ import { useForm } from "react-hook-form";
import { z } from "zod";
export default function HeadChModal({headList, type }:{headList : z.infer<typeof sttnHeadListType> ,type:string }) {
const { rainChSttnHead , rswtChSttnHead} = useWrStore((state) => state);
const { rainChSttnHead , rswtChSttnHead, htdflChSttnHead} = useWrStore((state) => state);
let items = headList.map(item => ({id:item.id, title:item.title, val:item.visible }));
@@ -32,6 +32,8 @@ export default function HeadChModal({headList, type }:{headList : z.infer<typeo
rainChSttnHead(valueList)
}else if(type=== 'RST'){
rswtChSttnHead(valueList)
}else if(type === 'HTB'){
htdflChSttnHead(valueList)
}
}
@@ -2,8 +2,10 @@
import { ScrollArea, Title, UiTable } from "@common/business_components/ui";
import RainRegForm from "../../../form/fcltReg/rainReg/rainRegForm";
import RswtrRegForm from "../../../form/fcltReg/rswtrReg/rswtrRegForm";
import HtdflRegForm from "../../../form/fcltReg/htdflReg/htdflRegForm";
import type { customRainBdst } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg";
import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
import { useWrStore } from "@/app/store";
import { useEffect, useState } from "react";
import type { CommonTableProps } from "@/app/store/common/type/headder";
@@ -72,31 +74,36 @@ export default function SttnDetailModal({
return (
<div>
<Title title={type === "RNB" ?"빗물이용시설 상세정보":"중수도시설 상세정보"}></Title>
<ScrollArea className={detailData.data.length>0?"h-[80vh]":"h-[70vh]"} >
{type === "RNB" ? (
<RainRegForm rainForm={formObj as customRainBdst} isModal={false} />
) : (
<RswtrRegForm rswtForm={formObj as customRswtBdst} isModal={false} />
)}
<Title title={ type === "RNB" ? "빗물이용시설 상세정보"
: type === "RST" ? "중수도시설 상세정보"
: "온배수시설 상세정보"}></Title>
<ScrollArea className={detailData.data.length>0?"h-[80vh]":"h-[70vh]"} >
{type === "RNB" ? (
<RainRegForm rainForm={formObj as customRainBdst} isModal={false} />
) : type === "RST" ? (
<RswtrRegForm rswtForm={formObj as customRswtBdst} isModal={false} />
) : (<HtdflRegForm htdflForm={formObj as customHtdflBdst} isModal={false} />)}
{detailData.data.length>0?
<UiTable
headName={
type === "RNB" ? "빗물이용시설 상세정보" : "중수도시설 상세정보"
}
tableData={detailData.data || []}
headlist={detailData.head || []}
children={ <HeadMakeColSpan upHeadList={detailData.node} />}
pageSize={0}
total={0}
cellClick={undefined}
onPageChange={function (page: number): void {
throw new Error("Function not implemented.");
}}
></UiTable>:<></>}
</ScrollArea>
{detailData.data.length>0?
<UiTable
headName={
type === "RNB" ? "빗물이용시설 상세정보"
: type === "RST" ? "중수도시설 상세정보"
: "온배수시설 상세정보"
}
tableData={detailData.data || []}
headlist={detailData.head || []}
children={ <HeadMakeColSpan upHeadList={detailData.node} />}
pageSize={0}
total={0}
cellClick={undefined}
onPageChange={function (page: number): void {
throw new Error("Function not implemented.");
}}
></UiTable>:<></>}
</ScrollArea>
</div>
);
}