@@ -39,10 +39,10 @@ import {
|
||||
import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel";
|
||||
|
||||
export default function prfmncPrfmncReg() {
|
||||
const { code, prfmnc, prfmncHasuInit, prfmnRegData } = useWrStore(
|
||||
const { code, prfmnc, prfmncHasuInit, prfmnRegData,prfmncHasuNmSearch } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { pbnstPrfmncHeadList, monthHeadList, prfmncRes } = prfmnc;
|
||||
const { pbnstPrfmncHeadList, monthHeadList, prfmncRes,prfmncResCount } = prfmnc;
|
||||
const [bdstTable, setbdstTable] = useState<FcPrfType[]>();
|
||||
const [searchTxt, setSearchTxt] = useState<string>();
|
||||
const [isExcelOpen, setIsExcelOPen] = useState<{
|
||||
@@ -164,7 +164,8 @@ export default function prfmncPrfmncReg() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!prfmnc.isInit) {
|
||||
prfmncHasuInit(1, "41");
|
||||
const year = new Date().getFullYear()
|
||||
prfmncHasuInit(1, "41",String(year));
|
||||
}
|
||||
}, [prfmnc.isInit, prfmncHasuInit]);
|
||||
useEffect(() => {
|
||||
@@ -221,7 +222,17 @@ export default function prfmncPrfmncReg() {
|
||||
<SearchFormRight className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 ">
|
||||
<div className="space-y">
|
||||
<div className="flex flex-row space-x-2">
|
||||
<Button size={"sm"} onClick={(e) => {}}>
|
||||
<Button size={"sm"} onClick={(e) => {
|
||||
|
||||
if(searchTxt&&searchTxt?.length>0){
|
||||
prfmncHasuNmSearch(1,'41',searchYear,searchTxt)
|
||||
setPageNation(1)
|
||||
}else{
|
||||
prfmncHasuInit(1,'41',searchYear)
|
||||
setPageNation(1)
|
||||
}
|
||||
|
||||
}}>
|
||||
조회
|
||||
</Button>
|
||||
<Button
|
||||
@@ -264,13 +275,17 @@ export default function prfmncPrfmncReg() {
|
||||
tableData={bdstTable || []}
|
||||
headlist={pbnstPrfmncHeadList}
|
||||
pageSize={10}
|
||||
total={10000}
|
||||
total={prfmncResCount}
|
||||
headName={"하수재이용시설 목록"}
|
||||
cellClick={(index: number | undefined, headId: string) => {
|
||||
cellClick(index);
|
||||
setCellNum(index ?? 0);
|
||||
}}
|
||||
onPageChange={setPageNation}
|
||||
onPageChange={
|
||||
(page) =>{
|
||||
prfmncHasuInit(page, "41",searchYear);
|
||||
setPageNation(page)
|
||||
}}
|
||||
children={undefined}
|
||||
/>
|
||||
</ScrollArea>
|
||||
@@ -303,11 +318,11 @@ export default function prfmncPrfmncReg() {
|
||||
data={isExcelOpen.data}
|
||||
setIsExcelOPen={(open) => {
|
||||
setIsExcelOPen({ ...isExcelOpen, isModal: open })
|
||||
|
||||
}}
|
||||
setModalExcelData={ async(excelData ) =>{
|
||||
await prfmnRegData(pageNation,'41',
|
||||
excelData,
|
||||
searchYear
|
||||
);
|
||||
// 데이터 저장 후 UI 업데이트는 useEffect가 감지하여 처리하므로 여기서는 호출하지 않습니다.
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export type pbnstPrfmncState = {
|
||||
pbnstPrfmncHeadList: TableUpperProps[];
|
||||
monthHeadList: TableUpperProps[];
|
||||
prfmncRes: FcPrfType[];
|
||||
prfmncResCount:number;
|
||||
excelList: Number[];
|
||||
pageKey:number
|
||||
};
|
||||
@@ -26,6 +27,7 @@ export const pbnstPrfmncStateExport: pbnstPrfmncState = {
|
||||
pbnstPrfmncHeadList: pbnstPrfmncHeadList,
|
||||
monthHeadList: monthHeadList,
|
||||
prfmncRes: [],
|
||||
prfmncResCount:1,
|
||||
excelList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
pageKey:1
|
||||
},
|
||||
@@ -34,16 +36,23 @@ export const pbnstPrfmncStateExport: pbnstPrfmncState = {
|
||||
export type pbnstPrfmncType = pbnstPrfmncState & pbnstPrfmncActions;
|
||||
|
||||
type pbnstPrfmncActions = {
|
||||
prfmncHasuInit: (page: number, sggOrCity: string) => void;
|
||||
prfmnRegData: (page:number,sggOrCity:string, data: PrfType) => void;
|
||||
prfmncHasuInit: (page: number, sggOrCity: string ,year:string) => void;
|
||||
prfmncHasuNmSearch: (page: number, sggOrCity: string , txt:string ,year:string) => void;
|
||||
prfmnRegData: (page:number,sggOrCity:string, data: PrfType,year:string) => void;
|
||||
};
|
||||
|
||||
const checkWrRegList = async () => {
|
||||
const wrRegList = await getFetch("wr", `/reuseFc/pubDetailList`);
|
||||
const checkWrRegList = async (year:string) => {
|
||||
|
||||
let url =`/reuseFc/pubDetailList`
|
||||
|
||||
if(year&& year.length>0){
|
||||
// url+=`/${year}`
|
||||
}
|
||||
const wrRegList = await getFetch("wr", url);
|
||||
return wrRegList;
|
||||
};
|
||||
const hasuListFetch = async (page: number, sggOrCity: string) => {
|
||||
const checkWrRegListRes = await checkWrRegList();
|
||||
const hasuListFetch = async (page: number, sggOrCity: string , year:string,searchNm?:string ) => {
|
||||
const checkWrRegListRes = await checkWrRegList(year);
|
||||
const rainRes = await postFectch(
|
||||
`/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`,
|
||||
checkWrRegListRes?.fcltCds,
|
||||
@@ -51,7 +60,7 @@ const hasuListFetch = async (page: number, sggOrCity: string) => {
|
||||
);
|
||||
|
||||
|
||||
const findData = rainRes.data.map((item: pubHasuType) => {
|
||||
let findData = rainRes.data.map((item: pubHasuType) => {
|
||||
const data = checkWrRegListRes?.fcPrfList.find(
|
||||
(fclt: FcPrfType) =>
|
||||
fclt.pbnstRuseFcltPk.substring(0, 11) === item?.bscFctCd
|
||||
@@ -70,20 +79,26 @@ const hasuListFetch = async (page: number, sggOrCity: string) => {
|
||||
}
|
||||
}).filter(Boolean); // undefined 값을 제거합니다.
|
||||
|
||||
return findData;
|
||||
if(searchNm){
|
||||
|
||||
findData= findData.filter((ruse:any) => ruse.ruseUtztnFcltNm.includes(searchNm))
|
||||
}
|
||||
|
||||
return {data:findData, count:findData.length};
|
||||
};
|
||||
export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (
|
||||
set: any
|
||||
) => {
|
||||
return {
|
||||
prfmncHasuInit: async (page: number, sggOrCity: string) => {
|
||||
prfmncHasuInit: async (page: number, sggOrCity: string,year:string) => {
|
||||
try {
|
||||
const prfmncRes = await hasuListFetch(page, sggOrCity);
|
||||
const prfmncRes = await hasuListFetch(page, sggOrCity, year);
|
||||
return set((state: pbnstPrfmncState) => ({
|
||||
...state,
|
||||
prfmnc: {
|
||||
...state.prfmnc,
|
||||
prfmncRes: prfmncRes,
|
||||
prfmncRes: prfmncRes.data,
|
||||
prfmncResCount: prfmncRes.count,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
@@ -91,7 +106,23 @@ export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (
|
||||
console.log(errorHasu);
|
||||
}
|
||||
},
|
||||
prfmnRegData: async (page:number,sggOrCity:string,data: PrfType) => {
|
||||
prfmncHasuNmSearch: async (page: number, sggOrCity: string,fcltNm:string ,year:string)=> {
|
||||
try {
|
||||
const prfmncRes = await hasuListFetch(page, sggOrCity,fcltNm ,year);
|
||||
return set((state: pbnstPrfmncState) => ({
|
||||
...state,
|
||||
prfmnc: {
|
||||
...state.prfmnc,
|
||||
prfmncRes: prfmncRes.data,
|
||||
prfmncResCount: prfmncRes.count,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
} catch (errorHasu) {
|
||||
console.log(errorHasu);
|
||||
}
|
||||
},
|
||||
prfmnRegData: async (page:number,sggOrCity:string,data: PrfType,year:string) => {
|
||||
try {
|
||||
const ressponse = await postFectch(
|
||||
"/reuseFc/pubFcPrf",
|
||||
@@ -102,12 +133,15 @@ export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (
|
||||
|
||||
if (ressponse.status === 200) {
|
||||
toast.success("하수재이용 시설 실적 등록이 완료되었습니다.");
|
||||
const prfmncRes = await hasuListFetch(page, sggOrCity);
|
||||
const prfmncRes = await hasuListFetch(page, sggOrCity,year) ;
|
||||
|
||||
|
||||
return set((state: pbnstPrfmncState) => ({
|
||||
...state,
|
||||
prfmnc: {
|
||||
...state.prfmnc,
|
||||
prfmncRes: prfmncRes,
|
||||
prfmncRes: prfmncRes.data,
|
||||
prfmncResCount: prfmncRes.count,
|
||||
isInit: false,
|
||||
pageKey: state.prfmnc.pageKey + 1
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user