재이용실적현황 엑셀 다운로드 완료
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { btnClass } from "@/app/store/common/code";
|
||||
import { initValInUsage, initValOutUsage, subTotalObj, totalObj, type FcPrfType, type PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
|
||||
import { excelPrfmncSttnParsing } from "@/app/store/prfmncSttn/pbnstPrfmncSttn/excel";
|
||||
import { excelDownload, yearOptions } from "@/components/lib/func/commom";
|
||||
import SearchInputText from "@/components/ui/searchInput/searchInput";
|
||||
import { CHART_FORM, ContentsDiv, MainChart, ScrollArea, SearchBaseForm, SearchInput, SelectBox, Title, UiTable, type ChartConfig, type ReturnType } from "@common/business_components";
|
||||
@@ -23,7 +24,7 @@ export default function PbnstPrfmncSttn() {
|
||||
pbnNmSearch
|
||||
} = useWrStore((state) => state);
|
||||
const { monthHeadList } = prfmnc
|
||||
const { pbnstPrfHeadList, pbnstPrfmncRes, prfmncRes, rawData, selectYearList } = pbnstPrfmncSttn;
|
||||
const { pbnstPrfHeadList, prfmncRes, rawData, selectYearList } = pbnstPrfmncSttn;
|
||||
const [isChHead, setIsChHead] = useState(false);
|
||||
const [fromDate, setFromDate] = useState<string>(String(new Date().getFullYear()));
|
||||
const [toDate, setToDate] = useState<string>(String(new Date().getFullYear()));
|
||||
@@ -32,14 +33,16 @@ export default function PbnstPrfmncSttn() {
|
||||
const ref = useRef<ReturnType>({} as ReturnType);
|
||||
const [swtrmtFcltNm, setSwtrmtFcltNm] = useState<string>();
|
||||
const [pbnRuseNm, setPbnRuseNm] = useState<string>("");
|
||||
const [excelData, setExcelData] = useState<any[]>([]);
|
||||
const excelClick = useCallback(() => {
|
||||
excelDownload(
|
||||
[[]],
|
||||
"하수재이용실적 현황",
|
||||
"sample_pbnstPrfmncReg.xlsx",
|
||||
"A1:O1"
|
||||
excelData,
|
||||
"하수재이용실적 현황",
|
||||
"sample_pbnstPrfmncSttn.xlsx",
|
||||
"A1:N1",
|
||||
2
|
||||
);
|
||||
}, [prfmnc.excelList]);
|
||||
}, [excelData]);
|
||||
|
||||
const [chartConfig, setChartConfig] = useState<ChartConfig>({});
|
||||
const [chartData, setChartData] = useState<dnChartForm[]>([]);
|
||||
@@ -72,13 +75,11 @@ export default function PbnstPrfmncSttn() {
|
||||
chartData6: lineChartDataProps[];
|
||||
}>();
|
||||
|
||||
|
||||
|
||||
type dnChartForm = { label: string, val: number, fill?: string };
|
||||
type barChartForm = { label: string, "장내용수": number, "장외용수": number };
|
||||
type lineChartDataProps = { label: string, val: number, color: string };
|
||||
|
||||
const prfTableData = (prfList: PrfType[], year:string) => {
|
||||
const prfTableData = (prfList: PrfType[], year: string) => {
|
||||
const inUsageData = structuredClone(initValInUsage);
|
||||
const outUsageData = structuredClone(initValOutUsage);
|
||||
|
||||
@@ -132,7 +133,7 @@ export default function PbnstPrfmncSttn() {
|
||||
}
|
||||
const tableData = [...inUsageData, ...outUsageData, usageTotalObj];
|
||||
setPrfData(tableData);
|
||||
|
||||
setExcelData(excelPrfmncSttnParsing(prfData ?? []))
|
||||
} else {
|
||||
setPrfData([]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
export const excelPrfmncSttnParsing = (
|
||||
data: any[]
|
||||
): string[][] => {
|
||||
const excelExportData: string[][] = [];
|
||||
data.forEach((item) => {
|
||||
excelExportData.push([
|
||||
item.용수명,
|
||||
item.total,
|
||||
item["1월"],
|
||||
item["2월"],
|
||||
item["3월"],
|
||||
item["4월"],
|
||||
item["5월"],
|
||||
item["6월"],
|
||||
item["7월"],
|
||||
item["8월"],
|
||||
item["9월"],
|
||||
item["10월"],
|
||||
item["11월"],
|
||||
item["12월"],
|
||||
]);
|
||||
});
|
||||
return excelExportData;
|
||||
};
|
||||
@@ -49,7 +49,6 @@ const hasuListFetch = async (page: string, sggOrCity: string) => {
|
||||
checkWrRegListRes?.fcltCds,
|
||||
fetchType.COMMON
|
||||
);
|
||||
console.log("api 호출", rainRes)
|
||||
const data = checkWrRegListRes.fcPrfList.map((item: FcPrfType) => {
|
||||
const findData = rainRes.data.find(
|
||||
(fclt: pubHasuType) =>
|
||||
@@ -87,7 +86,7 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
|
||||
yearHead[0].title = i + "년도"
|
||||
}
|
||||
yearHeader = [...yearHeader, ...yearHead]
|
||||
selectList.push({text: i + "년도", val: String(i)} )
|
||||
selectList.push({ text: i + "년도", val: String(i) })
|
||||
}
|
||||
set((state: pbnstPrfmncSttnState) => {
|
||||
return {
|
||||
@@ -143,7 +142,6 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
|
||||
bscFctCdList,
|
||||
`wr`,
|
||||
)
|
||||
console.log("res", res)
|
||||
let inUsageSum = 0;
|
||||
let outUsageSum = 0;
|
||||
let usageSum = 0;
|
||||
@@ -177,9 +175,6 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
|
||||
resData.push({ ...data, ...acc })
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
return set((state: pbnstPrfmncSttnState) => ({
|
||||
...state,
|
||||
pbnstPrfmncSttn: {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user