Merge commit 'bca13cad659343bfd578a115af2f282039bcf411' into iipbs/wr/sttn

This commit is contained in:
unknown
2025-05-13 11:09:48 +09:00
2 changed files with 90 additions and 28 deletions
@@ -1,25 +1,37 @@
'use client'
"use client";
import { useWrStore } from "@/app/store";
import { btnClass } from "@/app/store/common/code";
import type { chgBuilding, customRainBdst } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { getCityOrSgg } from "@/components/lib/func/commom";
import { ContentsDiv, SearchBaseForm, Title ,UiTable,type ReturnType, } from "@common/business_components/ui"
import type {
chgBuilding,
customRainBdst,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { getCityOrSgg, tableData } from "@/components/lib/func/commom";
import {
ContentsDiv,
SearchBaseForm,
Title,
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 { Button } from "@common/components/ui";
import { useCallback, useRef, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
export default function HtdflSttn(){
const { code,htdflSttn } = useWrStore(
(state) => state
);
const ref = useRef<ReturnType>({} as ReturnType);
export default function HtdflSttn() {
const { code, htdflSttn ,initHtdfl} = useWrStore((state) => state);
const { htdflSttnRes } = htdflSttn;
const ref = useRef<ReturnType>({} as ReturnType);
const [pageNation, setPageNation] = useState(1);
const [isChHead, setIsChHead] = useState(false);
const [bdstTable, setBdstTable] = useState<customRainBdst[]>();
const [detailModal, setDetailModal] = useState<{isOpen:boolean,data:customRainBdst|undefined}>({data:undefined,isOpen:false })
const [detailModal, setDetailModal] = useState<{
isOpen: boolean;
data: customRainBdst | undefined;
}>({ data: undefined, isOpen: false });
const [bdstChgProps, setBdstChgProps] = useState<{
isOpen: boolean;
chBuilding: chgBuilding[];
@@ -27,18 +39,38 @@ const ref = useRef<ReturnType>({} as ReturnType);
const codeData = getCityOrSgg(ref);
const excelClick = useCallback(() => {
const excelClick = useCallback(() => {
// if (codeData) rainSttnSearch(1, "10000", codeData);
}, []);
const cellClick=(index:number|undefined, headId: string)=>{
}
return(
<>
<ContentsDiv>
}, []);
const cellClick = (index: number | undefined, headId: string) => {};
useEffect(() => {
if (!htdflSttn.isInit) {
initHtdfl(codeData ?? "0");
}
}, [htdflSttn.isInit, initHtdfl]);
useEffect(() => {
if (htdflSttnRes.length > 0 && code.cityCd.length > 0) {
const data = tableData(htdflSttnRes, { code });
const chData = data
.map((item: any) => ({
...item,
...item.reuseBuilding[0],
...item.reuseBuilding[0].htdflObj,
chBuildingYn: item.chgBuilding[0]?.bdstChgNm !== null ? "Y" : "N",
}))
.filter((item: any) => item.htdflObj !== undefined);
setBdstTable(chData);
}
}, [code, htdflSttnRes, htdflSttn.htdflSttHeadList]);
return (
<>
<ContentsDiv>
<div className="grid grid-cols-4 gap-4 ">
<div className="col-span-4">
<Title title={"온배수 시설 현황"} />
@@ -68,7 +100,7 @@ const ref = useRef<ReturnType>({} as ReturnType);
} else {
con = returnType.sidoValue;
}
// rainSttnSearch(1, "20", con);
// rainSttnSearch(1, "20", con);
}}
excelClick={excelClick}
initClick={function (): void {}}
@@ -89,13 +121,15 @@ const ref = useRef<ReturnType>({} as ReturnType);
headlist={htdflSttn.htdflSttHeadList}
pageSize={20}
total={100000}
cellClick={(index: number | undefined,headId:string)=>{cellClick(index ?? undefined,headId)} }
cellClick={(index: number | undefined, headId: string) => {
cellClick(index ?? undefined, headId);
}}
onPageChange={setPageNation}
></UiTable>
</ListDiv>
</div>
</div>
</ContentsDiv>
</>
)
}
</ContentsDiv>
</>
);
}
@@ -2,6 +2,8 @@ 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 type { customHtdflBdst } from "../../fcltReg/htdflReg";
import { getFetch } from "@/components/lib/api";
const htdflSttHeadList = htdflSttHeadListExport;
const htdflSttNodeList = htdflSttNodeListExport;
@@ -11,6 +13,7 @@ export type htdflSttnState = {
isInit: boolean;
htdflSttHeadList: z.infer<typeof sttnHeadListType>;
htdflSttNodeList: CommonTableProps[];
htdflSttnRes:customHtdflBdst[]
};
};
type htdflSttnActions = {};
@@ -21,13 +24,38 @@ export const htdflSttnStateExport: htdflSttnState = {
htdflSttn: {
htdflSttHeadList: htdflSttHeadList,
htdflSttNodeList: htdflSttNodeList,
htdflSttnRes:[],
isInit: false,
},
};
const initFetch = async (code:string|number) => {
const rswtRes = await getFetch(
"wr",
`/drain/facilityList/1/20/${code}`)
return rswtRes;
};
export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
set: any
) => {
return {
initHtdfl: async (code: string | number) => {
try {
const htdflSttnRes = await initFetch(code);
set((state: htdflSttnState) => {
return {
...state,
htdflSttn: {
...state.htdflSttn,
htdflSttnRes: htdflSttnRes,
isInit: false,
},
};
});
} catch (error) {
console.log(error);
}
},
}
}