하수재이용 현황 엑셀 다운로드

This commit is contained in:
jyha00
2025-06-04 18:59:17 +09:00
parent f4687be765
commit 789b9d38ae
4 changed files with 93 additions and 23 deletions
@@ -15,20 +15,27 @@ import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal";
import { useCallback, useEffect, useRef, useState } from "react";
import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
import type { customPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
import { excelDownload, getCityOrSgg } from "@/components/lib/func/commom";
export default function PbnstSttn() {
const { code, pbnstSttn } = useWrStore(
(state) => state
);
const { code, pbnstSttn, pbnstSttnSearch } = useWrStore((state) => state);
const ref = useRef<ReturnType>({} as ReturnType);
const codeData = getCityOrSgg(ref);
const [pageNation, setPageNation] = useState(1);
const [isChHead, setIsChHead] = useState(false);
const [bdstTable, setBdstTable] = useState<customPbnst[]>();
const excelClick = useCallback(() => {
}, []);
// if (codeData) pbnstSttnSearch(1, "10000", codeData);
excelDownload(
[[]],
"하수재이용시설 현황",
"sample_pbnstSttn.xlsx",
"A1:U2"
);
}, [pbnstSttnSearch, codeData]);
return (
<>
@@ -65,7 +72,7 @@ export default function PbnstSttn() {
// pbnstSttnSearch(1, "20", con);
}}
excelClick={excelClick}
initClick={function (): void {}}
initClick={function (): void { }}
btnClass={btnClass}
ref={ref}
/>
@@ -83,7 +90,7 @@ export default function PbnstSttn() {
headlist={pbnstSttn.pbnstSttHeadList}
pageSize={20}
total={100000}
cellClick={(index: number | undefined,headId:string)=>{} }
cellClick={(index: number | undefined, headId: string) => { }}
onPageChange={setPageNation}
></UiTable>
</ListDiv>
@@ -0,0 +1,28 @@
import type { customPbnst } from "../../fcltReg/pbnstReg/type";
export const excelPbnstSttnParsing = (data: any[]): string[][] => {
const excelExportData: string[][] = [];
data.forEach((item) => {
excelExportData.push([
item.a,
String(item.aaa),
item.aaaa ?? "",
item.operMngCd ?? "",
String(item.cityText ?? ""),
String(item.sggText ?? ""),
String(item.bdnstNm ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
String(item.archArea ?? ""),
])
})
return excelExportData;
}
@@ -3,11 +3,12 @@ import type { z } from "zod";
import {
pbnSttHeadListExport,
pbnstSttNodeListExport
} from "./headList";
} from "./headList";
import { fetchType, getFetch } from "@/components/lib/api";
import { controlHeadView } from "../rainSttn";
import type { sttnHeadListType } from "../rainSttn/headList";
import type { customPbnst } from "../../fcltReg/pbnstReg/type";
import { excelPbnstSttnParsing } from "./excel";
const pbnstSttHeadList = pbnSttHeadListExport;
const pbnstSttNodeList = pbnstSttNodeListExport;
@@ -26,6 +27,7 @@ type pbnstSttnActions = {
pbnstChSttnHead: (
headList: z.infer<typeof sttnHeadListType>,
) => void;
pbnstSttnSearch: (page: number, total: string, con: string) => void;
};
export type pbnstSttnType = pbnstSttnState & pbnstSttnActions;
@@ -34,8 +36,8 @@ export const pbnstSttnStateExport: pbnstSttnState = {
pbnstSttn: {
pbnstSttHeadList: pbnstSttHeadList,
pbnstSttNodeList: pbnstSttNodeList,
pbnstSttnRes:[],
excelList:[],
pbnstSttnRes: [],
excelList: [],
isInit: false,
},
};
@@ -45,19 +47,52 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
) => {
return {
pbnstChSttnHead: async (
headList: z.infer<typeof sttnHeadListType>
): Promise<void> => {
console.log('head ', headList)
const changeNodeList= controlHeadView(headList,pbnstSttNodeList)
return set((state: pbnstSttnState) => ({
pbnstSttn: {
...state.pbnstSttn,
pbnstSttHeadList: headList,
pbnstSttNodeList: changeNodeList,
},
}));
headList: z.infer<typeof sttnHeadListType>
): Promise<void> => {
console.log('head ', headList)
const changeNodeList = controlHeadView(headList, pbnstSttNodeList)
return set((state: pbnstSttnState) => ({
pbnstSttn: {
...state.pbnstSttn,
pbnstSttHeadList: headList,
pbnstSttNodeList: changeNodeList,
},
}));
},
pbnstSttnSearch: async (page: number, total: string, con: string) => {
try {
const pbnstSttnRes = await getFetch(
fetchType.WR,
`/reuseFc/waterreuseFc/${page}/${total}/${con}`
);
if (Number(total) > 9000) {
const pbnstExcel = excelPbnstSttnParsing(pbnstSttnRes);
set((state: pbnstSttnState) => {
return {
...state,
pbnstSttn: {
...state.pbnstSttn,
excelList: pbnstExcel,
},
};
});
} else
set((state: pbnstSttnState) => {
return {
...state,
pbnstSttn: {
...state.pbnstSttn,
pbnstSttnRes: pbnstSttnRes,
isInit: false,
},
};
});
} catch (erTxt) {
console.log("error", erTxt);
}
},
}
}
Binary file not shown.