Merge commit '7f966c9d874be8231805f713e78f664583f3b155' into iipbs/wr/stats
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
"use client";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type { ExcelType, RswtStatProps } from "@/app/store/stats/rswtStat";
|
||||
import type { RswtStatProps } from "@/app/store/stats/rswtStat";
|
||||
import { tableData, yearOptions } from "@/components/lib/func/commom";
|
||||
import {
|
||||
ContentsDiv,
|
||||
downloadExcel,
|
||||
SearchDiv,
|
||||
SelectBox,
|
||||
Title,
|
||||
@@ -21,7 +22,20 @@ export default function RswtStat() {
|
||||
const [searchYear, setSearchYear] = useState<string>(
|
||||
String(new Date().getFullYear())
|
||||
);
|
||||
const [excelData, setExceData] = useState<ExcelType[]>();
|
||||
const [excelData, setExceData] = useState<any[]>();
|
||||
|
||||
useEffect(() => {
|
||||
searchRswtStatList(searchYear)
|
||||
}, [searchRswtStatList, searchYear])
|
||||
|
||||
const excelClick = () => {
|
||||
downloadExcel({
|
||||
data: (excelData as unknown as JSON[]) ?? [],
|
||||
fileName: "중수도재이용통계",
|
||||
sheetNameArray: ["Sheet1"],
|
||||
headerRange: "A1:O1"
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const transData = Array.isArray(rswtStatList) ? rswtStatList : [rswtStatList];
|
||||
@@ -40,7 +54,27 @@ export default function RswtStat() {
|
||||
useEffect(() => {
|
||||
const transExcel = Array.isArray(excelList) ? excelList : [excelList];
|
||||
const exData = tableData(transExcel, { code });
|
||||
const tbData = Array.isArray(excelData)
|
||||
const tbData = Array.isArray(exData) ?
|
||||
exData.map((item: RswtStatProps) => {
|
||||
return {
|
||||
"시도": item.cityText,
|
||||
"개소": item.ctpvCnt,
|
||||
"건축연면적(m³)": item.archArea,
|
||||
"처리용량(m³)": item.filtrTrtmfctCpct,
|
||||
"물사용량(m³/년)": item.wtrUsqty,
|
||||
"중수도+대체수이용량(m³/년)": item.rswtAltSum,
|
||||
"중수도이용량(m³/년)": item.rswtrUsqty,
|
||||
"대체수이용량(m³/년)": item.altUswtrUtztnQnt,
|
||||
"조경용수": item.lndwtr,
|
||||
"청소화장실용수": item.cleanToilUswtr,
|
||||
"농업용수": item.farmUswtr,
|
||||
"공업용수": item.indstUswtr,
|
||||
"친수용수": item.hydUswtr,
|
||||
"기타": item.ithlEtcUswtr,
|
||||
"연간운영비(백만원/년)": item.anlOperCst,
|
||||
};
|
||||
}) : [];
|
||||
setExceData(tbData);
|
||||
}, [excelList])
|
||||
|
||||
return (<>
|
||||
@@ -65,7 +99,6 @@ export default function RswtStat() {
|
||||
className=""
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
console.log("searchYear", searchYear)
|
||||
searchRswtStatList(searchYear)
|
||||
}}
|
||||
>
|
||||
@@ -74,7 +107,7 @@ export default function RswtStat() {
|
||||
<Button
|
||||
className=""
|
||||
size="sm"
|
||||
onClick={() => { }}
|
||||
onClick={() => excelClick()}
|
||||
>
|
||||
다운로드
|
||||
</Button>
|
||||
|
||||
@@ -62,8 +62,6 @@ export const rswtStatActionsExport: (set: any) => rswtStatActions = (
|
||||
return {
|
||||
searchRswtStatList: async (year: string) => {
|
||||
const res = await getFetch(fetchType.WR, `/reuseChk/reuseWater/stat/${year}`)
|
||||
|
||||
const rswtStatList: RswtStatProps[] = [];
|
||||
|
||||
let cityArr: any[] = [];
|
||||
res.forEach((item: RswtStatProps) => {
|
||||
|
||||
Reference in New Issue
Block a user