하수처리시설 팝업도 수정

This commit is contained in:
leedj312
2025-08-13 13:56:51 +09:00
parent c47167cc64
commit 5f559b4e2d
4 changed files with 104 additions and 6 deletions
+21
View File
@@ -0,0 +1,21 @@
export const excelHasuMapParsing = (
excel:{data:any[]}
): string[][] => {
const excelExportData: string[][] = [];
excel.data.forEach((item) => {
excelExportData.push([
item.sido??'',
item.gugun??'',
item.bscFctNm ?? "",
String(item.addr??""),
item.efflWqltStndrdNm ?? "",
String(item.fctCpc ?? ""),
String(item.ruse ?? ""),
String(item.rswtrYn ?? ""),
]);
});
return excelExportData;
};
+54 -2
View File
@@ -1,9 +1,10 @@
import { fetchType, postFectch } from "@/components/lib/api";
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
import { checkWrRegList } from "../../ruseFcltMng/fcltReg/pbnstReg";
import type { ReturnType } from "@common/business_components/ui";
import type { ReturnType} from "@common/business_components/ui";
import { pubFacHeadListExport } from "../../ruseFcltMng/fcltReg/pbnstReg/headList";
import type { TableUpperProps } from "../../common/type/header";
import { excelHasuMapParsing } from "./excel";
export const pbnMapTableSize = 20;
@@ -61,12 +62,23 @@ export type pbnMapState = {
pbnMapRes: pubHasuType[];
pbnMapCount: number;
pbnMapHeadList: TableUpperProps[];
hasuMapExcelList:[]
};
};
type pbnMapActions = {
pbnMapInit: (page: number, pageTotal: number, reurnValue: ReturnType) => void;
pbnMapDetaile: (featureCd: string, data: string) => Promise<pubHasuType | undefined>;
pbnMapSearch: (
isExcel: boolean,
page: number,
pageTotal: number,
reurnValue: ReturnType,
txt: string,
) => void;
pbnMapDetaile: (
featureCd: string,
data: string
) => Promise<pubHasuType | undefined>;
};
export type pbnMapType = pbnMapState & pbnMapActions;
@@ -77,6 +89,7 @@ export const pbnMapStateExport: pbnMapState = {
pbnMapRes: [],
pbnMapCount: 1,
pbnMapHeadList: pubFacHeadListExport,
hasuMapExcelList:[]
},
};
@@ -124,5 +137,44 @@ export const pbnMapActionsExport: (set: any) => pbnMapActions = (set: any) => {
throw error; // 호출부에서 catch 가능하도록
}
},
pbnMapSearch: async (
isExcel: boolean,
page: number,
pageTotal: number,
reurnValue: ReturnType,
txt: string,
) => {
try {
const hasuMapRes = await hasuListFetch(page, pageTotal, reurnValue, txt);
if (isExcel) {
const hasuMapExcelList = excelHasuMapParsing(
hasuMapRes
);
set((state: pbnMapState) => {
return {
...state,
pbnMap: {
...state.pbnMap,
hasuMapExcelList: hasuMapExcelList
},
};
});
} else {
set((state: pbnMapState) => {
return {
...state,
pbnMap: {
...state.pbnMap,
pbnMapRes: hasuMapRes.data,
pbnMapCount: hasuMapRes.count,
isInit: false,
},
};
});
}
} catch (e) {
console.log(e);
}
},
};
};
@@ -2,7 +2,7 @@ import { useWrStore } from "@/app/store";
import { btnClass } from "@/app/store/common/code";
import { pbnMapTableSize } from "@/app/store/map/pbnstMap";
import type { pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
import { tableData } from "@/components/lib/func/commom";
import { excelDownload, tableData } from "@/components/lib/func/commom";
import {
ContentsDiv,
SearchBaseForm,
@@ -13,14 +13,17 @@ import {
} from "@common/business_components/ui";
import { Label } from "@common/components/ui";
import { useEffect, useRef, useState } from "react";
import toast from "react-hot-toast";
import { useTranslation } from "react-i18next";
export function HasuFacility({rtnFeature}:{rtnFeature:(feature:any)=>void } ) {
const { code, pbnMap, pbnMapInit } = useWrStore((state) => state);
const { code, pbnMap, pbnMapInit ,pbnMapSearch} = useWrStore((state) => state);
const [hasuTable, setHasuTable] = useState<pubHasuType[]>();
const [isReset, setIsReset] = useState(false);
const [pbnRuseNm, setPbnRuseNm] = useState<string>("");
const ref = useRef<ReturnType>({} as ReturnType);
const { pbnMapHeadList, pbnMapRes, pbnMapCount } = pbnMap;
const { pbnMapHeadList, pbnMapRes, pbnMapCount ,hasuMapExcelList} = pbnMap;
const { t } = useTranslation("base");
useEffect(() => {
if (!pbnMap.isInit) {
@@ -39,6 +42,22 @@ export function HasuFacility({rtnFeature}:{rtnFeature:(feature:any)=>void } ) {
rtnFeature(pbnMapRes[index])
}
};
useEffect(() => {
if (hasuMapExcelList.length > 0) {
excelDownload(
hasuMapExcelList,
"하수처리시설 현황",
"sample_hasuMap.xlsx",
"A1:H1",
2
);
} else {
toast.error(t("excelDownErrMsg"));
}
}, [hasuMapExcelList]);
return (
<>
<ContentsDiv>
@@ -83,6 +102,10 @@ export function HasuFacility({rtnFeature}:{rtnFeature:(feature:any)=>void } ) {
isAdmin={false}
excelClick={function (returnType: ReturnType): void {
console.log("pbnstSttnSearch ", returnType);
pbnMapSearch(true,1, 100000, returnType,'' )
}}
/>
</div>
@@ -96,7 +119,9 @@ export function HasuFacility({rtnFeature}:{rtnFeature:(feature:any)=>void } ) {
headName={""}
cellClick={hasuCellClick}
onPageChange={(page) => {
pbnMapInit(page, pbnMapTableSize, ref.current);
//pbnMapInit(page, pbnMapTableSize, ref.current);
pbnMapSearch(false,page, pbnMapTableSize, ref.current,pbnRuseNm??'' )
setIsReset(false);
}}
resetPageNo={isReset}
Binary file not shown.