온배수 현황 엑셀 다운로드 완료
iipbs_wr / build (push) Has been cancelled

This commit is contained in:
leedj312
2025-05-14 16:16:51 +09:00
parent 9c0c41b60d
commit 1466e04638
5 changed files with 94 additions and 26 deletions
@@ -6,7 +6,11 @@ import type {
chgBuilding,
customRainBdst,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { getCityOrSgg, tableData } from "@/components/lib/func/commom";
import {
excelDownload,
getCityOrSgg,
tableData,
} from "@/components/lib/func/commom";
import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal";
import {
ContentsDiv,
@@ -22,9 +26,12 @@ import SttnDetailModal from "@/components/ui/modal/sttn/sttnDetailModal/sttnDeta
import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal";
import { Button } from "@common/components/ui";
import { useCallback, useEffect, useRef, useState } from "react";
import { excelHtdflSttnParsing } from "@/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel";
export default function HtdflSttn() {
const { code, htdflSttn, htdflSttnSearch, initHtdfl} = useWrStore((state) => state);
const { code, htdflSttn, htdflSttnSearch, initHtdfl } = useWrStore(
(state) => state
);
const { htdflSttnRes } = htdflSttn;
const ref = useRef<ReturnType>({} as ReturnType);
@@ -44,26 +51,52 @@ export default function HtdflSttn() {
const codeData = getCityOrSgg(ref);
const excelClick = useCallback(() => {
if (codeData) htdflSttnSearch(1, "10000", codeData);
}, []);
if (codeData) htdflSttnSearch(1, "10000", codeData);
}, [htdflSttnSearch, codeData]);
useEffect(() => {
if (codeData != null) htdflSttnSearch(pageNation, "20", codeData);
}, [pageNation]);
const cellClick = (index: number | undefined, headId: string) => {
if(headId!=='chBuildingYn' && index!==undefined && bdstTable!==undefined){
setDetailModal({isOpen:true ,data:bdstTable[index] })
}else if( headId==='chBuildingYn' && index!==undefined && bdstTable!==undefined){
if (
headId !== "chBuildingYn" &&
index !== undefined &&
bdstTable !== undefined
) {
setDetailModal({ isOpen: true, data: bdstTable[index] });
} else if (
headId === "chBuildingYn" &&
index !== undefined &&
bdstTable !== undefined
) {
if (
bdstTable[index] &&
bdstTable[index]?.chgBuilding[0]?.bdstChgNm!==null
bdstTable[index]?.chgBuilding[0]?.bdstChgNm !== null
) {
setBdstChgProps({ isOpen:true , chBuilding: bdstTable[index].chgBuilding});
setBdstChgProps({
isOpen: true,
chBuilding: bdstTable[index].chgBuilding,
});
}
}
};
useEffect(() => {
const excelDown = async () => {
if (htdflSttn.excelList.length > 0) {
if (htdflSttn.excelList.length === 0) return;
const excelData = await tableData(htdflSttn.excelList, { code });
const htdflExcel = excelHtdflSttnParsing(excelData);
excelDownload(
htdflExcel as [[]],
"온배수시설 현황",
"sample_htdflSttn.xlsx",
"A1:S3"
);
}
};
excelDown();
}, [htdflSttn.excelList, code]);
useEffect(() => {
if (!htdflSttn.isInit) {
@@ -165,12 +198,13 @@ export default function HtdflSttn() {
}
/>
<UiModal
open={detailModal.isOpen}
onOpenChange={()=>{
setDetailModal({...detailModal, isOpen:!detailModal.isOpen})
}}
bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"}
body={<SttnDetailModal type={"HTB"} formObj={detailModal.data}/>}/>
open={detailModal.isOpen}
onOpenChange={() => {
setDetailModal({ ...detailModal, isOpen: !detailModal.isOpen });
}}
bodyClass={"w-[40vw] max-w-none max-h-[calc(100%-70px)]"}
body={<SttnDetailModal type={"HTB"} formObj={detailModal.data} />}
/>
<UiModal
bodyClass={""}
open={bdstChgProps.isOpen}
@@ -8,6 +8,8 @@ export const hdtflZod = z.object({
bdstInfoPk: z.number().nullish(),
ctpvCd: z.number().default(0),
sggCd: z.number().default(0),
cityText: z.string().nullish(),
sggText: z.string().nullish(),
daddr: z.string().default(" "),
bdstNm: z.string().default(" "),
frstArchPrmsnDt: z.date().default(() => new Date()),
@@ -27,16 +29,8 @@ export const hdtflZod = z.object({
anlOperCst: z.number().default(0),
instlCstSprtYn: z.enum(["Y", "N"]).nullish(),
instlCstSprtAmt: z.number().nullish().default(0),
// grntchBdstCertYn: z.enum(["Y", "N"]),
// grntchBdstCertYr: z .string().default("")
// .refine((year) =>year.length ===0 || /^\d{4}$/.test(year),{
// message:'4자리 연도만 입력하세요'
// }),
grntchBdstCertNo: z.string().nullish().default(""),
grntchBdstCertGrd: z.string().nullish().default(""),
// crgRdctYn: z.enum(["Y", "N"]),
// crgRdctBss: z.string().nullish().default(""),
// crgRdctAmt: z.number().nullish().default(0),
ruseFcltFlg: z.string().nullish().default(""),
bdstUsgCd: z.number().default(0),
lawTrgtYn: z.enum(["Y", "N"]).nullish(),
@@ -0,0 +1,30 @@
import type { customHtdflBdst } from "../../fcltReg/htdflReg";
export const excelHtdflSttnParsing = (data: customHtdflBdst[]): string[][] => {
const excelExportData: string[][] = [];
data.forEach((item) => {
excelExportData.push([
String(item.cityText??""),
String(item.sggText??""),
item.bdstNm ?? "",
item.daddr ?? "",
String(item.frstArchPrmsnDt ?? ""),
String(item.reuseBuilding?.[0]?.htdflObj.etgtType ?? ""),
String(item.reuseBuilding?.[0]?.htdflObj.fclCpct ?? ""), // fix: added missing parenthesis
String(item.reuseBuilding?.[0]?.htdflObj.plwtYn ? "Y" :"N"), // fix: added missing parenthesis
String(item.reuseBuilding?.[0]?.htdflObj.orgwtWtritSpt ?? ""), // fix: added missing parenthesis
String(item.reuseBuilding?.[0]?.htdflObj.wtritEntrcTp ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj.orgwtOcrnProcs ?? ""), // fix: removed as it doesn't exist in the provided context
String( item.reuseBuilding?.[0]?.htdflObj?.amtgnr ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.prcsProcsYn ?? ""), // fix: removed as it doesn't exist in the provided context
String( '컬럼확인'), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.prcsFcltCpct ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.fmYn ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.utztnCpct ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.utztnUsg ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.emsnExitTp ?? ""), // fix: removed as it doesn't exist in the provided context
]);
});
return excelExportData;
};
@@ -5,6 +5,8 @@ import type { z } from "zod";
import { controlHeadView } from "../rainSttn";
import type { customHtdflBdst } from "../../fcltReg/htdflReg";
import { fetchType, getFetch } from "@/components/lib/api";
import { excelHtdflSttnParsing } from "./excel";
import { tableData } from "@/components/lib/func/commom";
const htdflSttHeadList = htdflSttHeadListExport;
const htdflSttNodeList = htdflSttNodeListExport;
@@ -15,6 +17,8 @@ export type htdflSttnState = {
htdflSttHeadList: z.infer<typeof sttnHeadListType>;
htdflSttNodeList: CommonTableProps[];
htdflSttnRes:customHtdflBdst[]
excelList: [];
};
};
type htdflSttnActions = {
@@ -32,6 +36,7 @@ export const htdflSttnStateExport: htdflSttnState = {
htdflSttHeadList: htdflSttHeadList,
htdflSttNodeList: htdflSttNodeList,
htdflSttnRes:[],
excelList:[],
isInit: false,
},
};
@@ -66,18 +71,21 @@ export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
},
htdflSttnSearch: async (page: number, total: string, con: string) => {
try {
console.log(page)
const htdflSttnRes = await getFetch(
fetchType.WR,
`/drain/facilityList/${page}/${total}/${con}`
);
if (Number(total) > 9000) {
// const htdflExcel = excelHtdflSttnParsing(htdflSttnRes);
set((state: htdflSttnState) => {
return {
...state,
htdflSttn: {
...state.htdflSttn,
// excelList: htdflExcel,
excelList: htdflSttnRes,
},
};
});
@@ -111,5 +119,7 @@ export const htdflSttnActionsExport: (set: any) => htdflSttnActions = (
},
}));
},
}
}
Binary file not shown.