엑셀 to json 작업중

This commit is contained in:
leedj312
2025-05-02 14:58:18 +09:00
parent bf2eade311
commit a9b8129361
19 changed files with 817 additions and 515 deletions
@@ -17,10 +17,10 @@ import HeadChModal from "@/components/ui/modal/headChModal/headChModal";
import { useState } from "react";
export default function PbnstSttn() {
const { code, sttnCommon } = useWrStore((state) => state);
const { code, rainSttn } = useWrStore((state) => state);
const [isChHead, setIsChHead] = useState(false);
const nodeList = headMakeprfmnc(sttnCommon.pbnSttHeadList, sttnCommon.pbnSttHeadNm);
const nodeList = headMakeprfmnc(rainSttn.pbnSttHeadList, rainSttn.pbnSttHeadNm);
return (
<>
@@ -113,7 +113,7 @@ export default function PbnstSttn() {
<UiTable
headName={undefined}
tableData={[]}
headlist={sttnCommon.pbnSttHeadList}
headlist={rainSttn.pbnSttHeadList}
pageSize={0}
total={0}
cellClick={undefined}
@@ -18,20 +18,19 @@ import { useCallback, useEffect, useRef, useState } from "react";
import { headMakeTriple } from "./TableHead";
export default function RainSttn() {
const { code, sttnCommon, rainSttnSearch } =
const { code, rainSttn, rainSttnSearch } =
useWrStore((state) => state);
const { rainRes } = sttnCommon;
const { rainSttnRes } = rainSttn;
const [isChHead, setIsChHead] = useState(false);
const ref = useRef<ReturnType>({} as ReturnType);
const [bdstTable, setBdstTable] = useState<any[]>();
const nodeList = headMakeTriple(
sttnCommon.rainSttHeadList,
sttnCommon.rainSttHeadNm
);
// const nodeList = headMakeTriple(
// rainSttn.rainSttHeadList,
// rainSttn.rainSttHeadNm
// );
useEffect(() => {
if (!sttnCommon.isInit) {
if (!rainSttn.isInit) {
let con
if (ref.current.sigunValue != '0') {
con = ref.current.sigunValue
@@ -40,15 +39,12 @@ export default function RainSttn() {
}
rainSttnSearch('1', '20' ,con);
}
}, [sttnCommon.isInit, rainSttnSearch]);
}, [rainSttn.isInit, rainSttnSearch]);
useEffect(() => {
if (rainRes.length > 0) {
const data = tableData(rainRes, { code });
// data 는 위 JSON 객체라고 가정
if (rainSttnRes.length > 0) {
const data = tableData(rainSttnRes, { code });
const chData = data
.map((item: any) => ({
@@ -60,15 +56,14 @@ export default function RainSttn() {
setBdstTable(chData);
}
}, [code, rainRes, sttnCommon.rainSttHeadList]);
}, [code, rainSttnRes, rainSttn.rainSttHeadList]);
useEffect(() => {
if(sttnCommon.excelList.length>0){
console.log('sttnCommon.excelList', sttnCommon.excelList);
if(rainSttn.excelList.length>0){
if (sttnCommon.excelList.length === 0) return;
excelDownload(sttnCommon.excelList , '빗물재이용시설 현황','sample_rainSttn.xlsx')
if (rainSttn.excelList.length === 0) return;
excelDownload(rainSttn.excelList , '빗물재이용시설 현황','sample_rainSttn.xlsx')
}
}, [sttnCommon.excelList]);
}, [rainSttn.excelList]);
const excelClick = useCallback((returnType:ReturnType) => {
@@ -127,7 +122,7 @@ export default function RainSttn() {
<UiTable
headName={[]}
tableData={bdstTable || []}
headlist={sttnCommon.rainSttHeadList}
headlist={rainSttn.rainSttHeadList}
pageSize={0}
total={0}
cellClick={undefined}
@@ -135,7 +130,7 @@ export default function RainSttn() {
throw new Error("Function not implemented.");
}}
>
{nodeList}
{/* {nodeList} */}
</UiTable>
</ListDiv>
</div>
@@ -70,7 +70,7 @@ export default function Page() {
<SearchDiv>
<SearchFormLeft>
<SearchInput
className="col-span-3 my-7"
className="col-span-3 my-7 !text-xl"
label=" 지도점검년도"
textValue={searchTxt??''}
setText={(e) => {setSearchTxt(e);}}
@@ -97,16 +97,16 @@ export const excelToRainChkData = (
return {
utztnUsgCd: item["이용용도"],
ym: year + month,
chckYmd: excelSerialToDateString(item["점검일"]) ,
splyUswtrUtztnQnt: splyData !== undefined ? splyData : 0,
ruseFcltUtztnQnt: ruseData !== undefined ? ruseData : 0,
chckYmd: item["점검일"] ,
splyUswtrUtztnQnt: splyData !== "" ? splyData : 0,
ruseFcltUtztnQnt: ruseData !== "" ? ruseData : 0,
flg: "RNB",
};
});
return {
bdstRuseFcltFk: Number(item["NO"]),
chckYmd: excelSerialToDateString(item["점검일"]) ,
chckYmd: item["점검일"] ,
spwtPositn: item["유량측정방법"],
rgtr: TEST_UUID,
oilqMeasMthd: item["운영관리형태"],
@@ -6,6 +6,8 @@ import { fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api
import type { SelectDataType } from "@common/business_components/ui";
import { z } from "zod";
import { buildingToExcelType, excelToRainChkData } from "./excel";
import toast from "react-hot-toast";
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
export const rainChkZod = z.object({
chkgdnPk: z.number().nullable(),
@@ -307,7 +309,7 @@ type rainChkgdnActions = {
rainChkDetilUpdate(rainChk: rainChkZodType[]): Promise<void>;
rainChkGuidUpdate(rainChk: rainChkZodType): Promise<void>;
rainChkExcelDownload(sidoCode: SelectDataType[],sggCode: SelectDataType[]): Promise<void>
excelDataUPload(excelData:rainChkZodType[]) : Promise<void>
rainChkExcelDataUPload(excelData:rainChkZodType[]) : Promise<void>
};
export type rainChkgdnType = rainChkgdnState & rainChkgdnActions;
@@ -371,11 +373,11 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
},
}));
},
excelDataUPload: async(excelData:rainChkZodType[] ) =>{
rainChkExcelDataUPload: async(excelData:rainChkZodType[] ) =>{
try{
const res = await postFectch("/reuseChk/rainyExcel", excelData);
if (res.ok) {
alert(" 데이터 입력 완료");
ToastFormUi({body:"엑셀 데이터 업로드가 성공하였습니다. " ,title:'엑셀등록'})
}
const rainChkRes = await initFetch('2024', '0');
return set((state: rainChkgdnState) => ({
@@ -387,7 +389,7 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
}));
}catch(error){
console.log(error);
alert("데이터 입력을 실패하였습니다.");
ToastFormUi({body:"엑셀 데이터 업로드를 실패하였습니다. " ,title:'엑셀등록'})
}
},
rainChkInit: async (searchTxt: string, sggCd: string) => {
@@ -133,7 +133,7 @@ export const upHeadList: TableUpperProps[] = [
const rainRes: customRainBdst[] = [];
export const selectClass = "w-full h-full text-2xl";
export const selectClass = "w-full h-full !text-2xl";
const selectYN = [
{ text: "Y", val: "1" },
{ text: "N", val: "2" },
@@ -0,0 +1,169 @@
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import type { TableUpperProps } from "../../fcltReg/rainReg";
export const pbnSttHeadNmExport: chHeadType[] = [
{ headNm: "catchment", text: "유역", length: 3 },
{ headNm: "adminDiv", text: "행정구역", length: 2 },
{ headNm: "rusSup", text: "재이용수공급가능량", length: 3 },
{ headNm: "yearResult", text: "연간실적정보(m³)", length: 3 },
{ headNm: "mngInfo", text: "운영정보", length: 4 },
];
// id는 다확인해야함
export const pbnSttHeadListExport: TableUpperProps[] = [
{ id: "a", title: "권역", upName: "catchment", upSequnce: 1, visible: true },
{
id: "aaa",
title: "단위유역",
upName: "catchment",
upSequnce: 2,
visible: true,
},
{
id: "aaaa",
title: "중권역",
upName: "catchment",
upSequnce: 3,
visible: false,
},
{ id: "operMngCd", title: "환경청", visible: true },
{
id: "cityText",
title: "시도",
upName: "adminDiv",
upSequnce: 1,
visible: false,
},
{
id: "sggText",
title: "시군구",
upName: "adminDiv",
upSequnce: 2,
visible: true,
},
{ id: "bdnstNm", title: "시설명", visible: true },
{ id: "locDiv", title: "지역구분", visible: true },
{ id: "phone", title: "전화번호", visible: true },
{ id: "fcltQuantity", title: "시설용량(톤/일)", visible: true },
{ id: "rusNm", title: "재이용시설명", visible: true },
{
id: "fcltCpct",
title: "시설용량(m³/일)",
upName: "rusSup",
upSequnce: 1,
visible: true,
},
{
id: "trbt",
title: "하수처리량(m³/일)",
upName: "rusSup",
upSequnce: 2,
visible: true,
},
{
id: "ruseCpct",
title: "재이용량(m³/일)",
upName: "rusSup",
upSequnce: 3,
visible: true,
},
{
id: "total",
title: "합계",
upName: "yearResult",
upSequnce: 1,
visible: true,
},
{
id: "ithlWtr",
title: "장내용수",
upName: "yearResult",
upSequnce: 2,
visible: true,
},
{
id: "othlWtr",
title: "장외용수",
upName: "yearResult",
upSequnce: 3,
visible: true,
},
{
id: "mngMeth",
title: "운영방식",
upName: "mngInfo",
upSequnce: 1,
visible: true,
},
{
id: "rprtvBzenty",
title: "대행업체",
upName: "mngInfo",
upSequnce: 2,
visible: true,
},
{
id: "firstDay",
title: "시작일",
upName: "mngInfo",
upSequnce: 3,
visible: true,
},
{
id: "LastDay",
title: "종료일",
upName: "mngInfo",
upSequnce: 4,
visible: true,
},
];
// 참고용 지워야함.
// rainChSttnHead: async (checkList: string[], type: string) => {
// const headList =
// type === "pbn"
// ? pbnSttHeadList
// : type === "rain"
// ? rainSttHeadList
// : null;
// let chNm = type === "pbn" ? pbnSttHeadNm : rainSttHeadNm;
// headList?.forEach((item) => {
// if (checkList.find((ch) => ch === item.id)) {
// item.visible = false;
// if (item.upName) {
// const upNames = Array.isArray(item.upName)
// ? item.upName
// : [item.upName];
// upNames?.forEach((up) => {
// chNm.find((ch) => {
// if (ch.headNm === up) {
// ch.length = ch.length - 1;
// }
// });
// });
// }
// }
// });
// set((state: rainSttnState) => ({
// sttnCommon: {
// ...state.sttnCommon,
// pbnSttHeadList:
// type === "pbn" ? headList : state.sttnCommon.pbnSttHeadList,
// rainSttHeadList:
// type === "rain" ? headList : state.sttnCommon.rainSttHeadList,
// rainSttHeadNm:
// type === "rain" ? chNm : state.sttnCommon.rainSttHeadNm,
// pbnSttHeadNm: type === "rain" ? chNm : state.sttnCommon.pbnSttHeadNm,
// },
// }));
// },
// };
// };
@@ -0,0 +1,428 @@
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import type { TableTripleProps, TableUpperProps } from "../../fcltReg/rainReg";
export type TableUpperPropsTest = {
id: string;
title: string;
upName?: string;
upSequnce?: number;
row?: number;
rowSpan?: number;
colSpan?: number;
visible?: boolean;
};
// id는 다확인해야함
export const rainSttHeadListExportTest: TableUpperPropsTest[] = [
{
id: "bdnstInfo",
title: "1.건축물정보",
visible: true,
row: 1,
rowSpan: 1,
colSpan: 9,
},
{
id: "rainFcltInfo",
title: "2.빗물이용시설정보",
visible: true,
row: 1,
rowSpan: 1,
colSpan: 6,
},
{ id: "insenInfo",
title: "3.인센티브 정보",
visible: true,
row: 1,
rowSpan: 1,
colSpan: 7
},
// 2번째 줄
{ id: "adminDiv",
title: "행정구역",
visible: true,
row: 2,
rowSpan: 1,
colSpan: 2 },
// 1번째 줄 건축물정보 아래의 행으로 만들 헤더
{
id: "bdstNm",
title: "건축물명",
visible: true,
row: 2,
rowSpan: 2,
colSpan: 1 },
{
id: "daddr",
title: "주소",
visible: true,
row: 2,
rowSpan: 2,
colSpan: 1 },
{
id: "bdstUsgCd",
title: "건축물용도코드",
row: 2,
rowSpan: 2,
colSpan: 1 },
{
id: "frstArchPrmsnDt",
title: "최초건축허가일시",
visible: true,
row: 2,
rowSpan: 2,
colSpan: 1 },
{
id: "archArea",
title: "건축면적",
visible: true,
row: 2,
rowSpan: 2,
colSpan: 1 },
{
id: "lawTrgtYn",
title: "법적의무대상여부",
visible: true,
row: 2,
rowSpan: 2,
colSpan: 1 },
{
id: "instlCmptnDt",
title: "설치완료일시",
visible: true,
row: 2,
rowSpan: 2,
colSpan: 1 },
{
id: "instlCst",
title: "설치비용",
visible: true,
row: 2,
rowSpan: 1,
colSpan: 2
},
{ id: "pntfCol",
title: "집수면",
visible: true,
row: 2,
rowSpan: 1,
colSpan: 2
},
{ id: "filtrTrtmfct",
title: "여과등 처리시설",
visible: true,
row: 2,
rowSpan: 1,
colSpan: 3
},
{
id: "dtfcltCpct",
title: "저류조용량",
visible: true,
row: 2,
rowSpan: 2,
colSpan: 1
},
{ id: "instlCstSprt",
title: "설치비지원",
visible: true,
row: 2,
rowSpan: 1,
colSpan: 2
},
{ id: "grntchBdstCert",
title: "녹색건축물인증여부",
visible: true,
row: 2,
rowSpan: 1,
colSpan: 4
},
// 3번째줄 시작
{
id: "cityText",
title: "시도",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "sggText",
title: "시군구",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "pntfColKnd",
title: "집수지점종류",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "pntfColArea",
title: "집수지점면적",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "filtrTrtmfctYn",
title: "여과처리시설유무",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "filtrTrtmfctCpct",
title: "여과처리시설용량",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "filtrTrtmfctPrs",
title: "여과처리시설처리공정",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "instlCstSprtYn",
title: "설치지원비용여부",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "instlCstSprtAmt",
title: "설치지원비용",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "grntchBdstCertYn",
title: "녹색건축물인증여부",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "grntchBdstCertYr",
title: "녹색건축물인증년도",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "grntchBdstCertNo",
title: "녹색건축물인증번호",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
{
id: "grntchBdstCertGrd",
title: "녹색건축물인증등급",
visible: true,
row: 3,
rowSpan: 1,
colSpan: 1
},
];
export const rainSttHeadNmExport: chHeadType[] = [
{ headNm: "bdnstInfo", text: "1.건축물정보", length: 9 },
{ headNm: "rainFcltInfo", text: "2.빗물이용시설정보", length: 7 },
{ headNm: "insenInfo", text: "3.인센티브 정보", length: 9 },
];
// id는 다확인해야함
export const rainSttHeadListExport: TableTripleProps[] = [
{
id: "cityText",
title: "시도",
visible: true,
upName: ["bdnstInfo", "adminDiv"],
upSequnce: [1, 1],
},
{
id: "sggText",
title: "시군구",
visible: true,
upName: ["bdnstInfo", "adminDiv"],
upSequnce: [2, 2],
},
{
id: "bdstNm",
title: "건축물명",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [3],
},
{
id: "daddr",
title: "주소",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [4],
},
{
id: "bdstUsgCd",
title: "건축물용도코드",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [5],
},
{
id: "frstArchPrmsnDt",
title: "최초건축허가일시",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [6],
},
{
id: "archArea",
title: "건축면적",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [7],
},
{
id: "lawTrgtYn",
title: "법적의무대상여부",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [8],
},
{
id: "instlCmptnDt",
title: "설치완료일시",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [9],
},
{
id: "instlCst",
title: "설치비용",
visible: true,
upName: ["rainFcltInfo"],
upSequnce: [1],
},
{
id: "pntfColKnd",
title: "집수지점종류",
visible: true,
upName: ["rainFcltInfo", "pntfCol"],
upSequnce: [2, 1],
},
{
id: "pntfColArea",
title: "집수지점면적",
visible: true,
upName: ["rainFcltInfo", "pntfCol"],
upSequnce: [3, 2],
},
{
id: "filtrTrtmfctYn",
title: "여과처리시설유무",
visible: true,
upName: ["rainFcltInfo", "filtrTrtmfct"],
upSequnce: [4, 1],
},
{
id: "filtrTrtmfctCpct",
title: "여과처리시설용량",
visible: true,
upName: ["rainFcltInfo", "filtrTrtmfct"],
upSequnce: [5, 2],
},
{
id: "filtrTrtmfctPrs",
title: "여과처리시설처리공정",
visible: true,
upName: ["rainFcltInfo", "filtrTrtmfct"],
upSequnce: [6, 3],
},
{
id: "dtfcltCpct",
title: "저류조용량",
visible: true,
upName: ["rainFcltInfo"],
upSequnce: [7],
},
{
id: "instlCstSprtYn",
title: "설치지원비용여부",
visible: true,
upName: ["insenInfo", "instlCstSprt"],
upSequnce: [1, 1],
},
{
id: "instlCstSprtAmt",
title: "설치지원비용",
visible: true,
upName: ["insenInfo", "instlCstSprt"],
upSequnce: [2, 2],
},
{
id: "grntchBdstCertYn",
title: "녹색건축물인증여부",
visible: true,
upName: ["insenInfo", "grntchBdstCert"],
upSequnce: [3, 1],
},
{
id: "grntchBdstCertYr",
title: "녹색건축물인증년도",
visible: true,
upName: ["insenInfo", "grntchBdstCert"],
upSequnce: [4, 2],
},
{
id: "grntchBdstCertNo",
title: "녹색건축물인증번호",
visible: true,
upName: ["insenInfo", "grntchBdstCert"],
upSequnce: [5, 3],
},
{
id: "grntchBdstCertGrd",
title: "녹색건축물인증등급",
visible: true,
upName: ["insenInfo", "grntchBdstCert"],
upSequnce: [6, 4],
},
];
@@ -0,0 +1,109 @@
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import { fetchType, getFetch } from "@/components/lib/api";
import {
type customRainBdst,
type TableTripleProps,
} from "../../fcltReg/rainReg";
import { excelSttnParsing } from "./excel";
import { rainSttHeadListExport, rainSttHeadListExportTest, rainSttHeadNmExport, type TableUpperPropsTest } from "./headList";
// 테이블 헤드 리스트
const rainSttHeadNm = rainSttHeadNmExport;
//const rainSttHeadList = rainSttHeadListExport;
const rainSttHeadList = rainSttHeadListExportTest;
const rainSttnRes: customRainBdst[] = [];
export type rainSttnState = {
rainSttn: {
rainSttnRes: customRainBdst[];
// rainSttHeadList: TableTripleProps[];
rainSttHeadList: TableUpperPropsTest[];
rainSttHeadNm: chHeadType[];
excelList: [];
isInit: boolean;
};
};
type rainSttnActions = {
rainSttnSearch: (page: string, total: string, con: string) => void;
rainChSttnHead: (checkList: string[]) => void;
};
export type rainSttnType = rainSttnState & rainSttnActions;
export const rainSttnStateExport: rainSttnState = {
rainSttn: {
rainSttHeadList: rainSttHeadList,
rainSttHeadNm: rainSttHeadNm,
rainSttnRes: rainSttnRes,
excelList: [],
isInit: false,
},
};
export const rainSttnActionsExport: (set: any) => rainSttnActions = (
set: any
) => {
return {
rainSttnSearch: async (page: string, total: string, con: string) => {
try {
const rainSttnRes = await getFetch(
fetchType.WR,
`/reuseFc/rainyInfoList/${page}/${total}/${con}`
);
if (Number(total) > 9000) {
const rainExcel = excelSttnParsing(rainSttnRes);
set((state: rainSttnState) => {
return {
...state,
rainSttn: {
...state.rainSttn,
excelList: rainExcel,
},
};
});
} else
set((state: rainSttnState) => {
return {
...state,
rainSttn: {
...state.rainSttn,
rainSttnRes: rainSttnRes,
isInit: false,
},
};
});
} catch (erTxt) {
console.log("error", erTxt);
}
},
rainChSttnHead: async (checkList: string[]) => {
const headList = rainSttHeadList;
let chNm = rainSttHeadNm;
headList?.forEach((item) => {
if (checkList.find((ch) => ch === item.id)) {
item.visible = false;
if (item.upName) {
const upNames = Array.isArray(item.upName)
? item.upName
: [item.upName];
upNames?.forEach((up) => {
chNm.find((ch) => {
if (ch.headNm === up) {
ch.length = ch.length - 1;
}
});
});
}
}
});
set((state: rainSttnState) => ({
rainSttn: {
...state.rainSttn,
rainSttHeadList: headList,
rainSttHeadNm: chNm,
},
}));
},
};
};
@@ -1,412 +0,0 @@
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import { fetchType, getFetch } from "@/components/lib/api";
import {
type customRainBdst,
type TableTripleProps,
type TableUpperProps,
} from "../../fcltReg/rainReg";
import { excelSttnParsing, } from "./excel";
const pbnSttHeadNm: chHeadType[] = [
{ headNm: "catchment", text: "유역", length: 3 },
{ headNm: "adminDiv", text: "행정구역", length: 2 },
{ headNm: "rusSup", text: "재이용수공급가능량", length: 3 },
{ headNm: "yearResult", text: "연간실적정보(m³)", length: 3 },
{ headNm: "mngInfo", text: "운영정보", length: 4 },
];
// id는 다확인해야함
const pbnSttHeadList: TableUpperProps[] = [
{ id: "a", title: "권역", upName: "catchment", upSequnce: 1, visible: true },
{
id: "aaa",
title: "단위유역",
upName: "catchment",
upSequnce: 2,
visible: true,
},
{
id: "aaaa",
title: "중권역",
upName: "catchment",
upSequnce: 3,
visible: false,
},
{ id: "operMngCd", title: "환경청", visible: true },
{
id: "cityText",
title: "시도",
upName: "adminDiv",
upSequnce: 1,
visible: false,
},
{
id: "sggText",
title: "시군구",
upName: "adminDiv",
upSequnce: 2,
visible: true,
},
{ id: "bdnstNm", title: "시설명", visible: true },
{ id: "locDiv", title: "지역구분", visible: true },
{ id: "phone", title: "전화번호", visible: true },
{ id: "fcltQuantity", title: "시설용량(톤/일)", visible: true },
{ id: "rusNm", title: "재이용시설명", visible: true },
{
id: "fcltCpct",
title: "시설용량(m³/일)",
upName: "rusSup",
upSequnce: 1,
visible: true,
},
{
id: "trbt",
title: "하수처리량(m³/일)",
upName: "rusSup",
upSequnce: 2,
visible: true,
},
{
id: "ruseCpct",
title: "재이용량(m³/일)",
upName: "rusSup",
upSequnce: 3,
visible: true,
},
{
id: "total",
title: "합계",
upName: "yearResult",
upSequnce: 1,
visible: true,
},
{
id: "ithlWtr",
title: "장내용수",
upName: "yearResult",
upSequnce: 2,
visible: true,
},
{
id: "othlWtr",
title: "장외용수",
upName: "yearResult",
upSequnce: 3,
visible: true,
},
{
id: "mngMeth",
title: "운영방식",
upName: "mngInfo",
upSequnce: 1,
visible: true,
},
{
id: "rprtvBzenty",
title: "대행업체",
upName: "mngInfo",
upSequnce: 2,
visible: true,
},
{
id: "firstDay",
title: "시작일",
upName: "mngInfo",
upSequnce: 3,
visible: true,
},
{
id: "LastDay",
title: "종료일",
upName: "mngInfo",
upSequnce: 4,
visible: true,
},
];
const rainSttHeadNm: chHeadType[] = [
{ headNm: "bdnstInfo", text: "1.건축물정보", length: 9 },
{ headNm: "rainFcltInfo", text: "2.빗물이용시설정보", length: 7 },
{ headNm: "insenInfo", text: "3.인센티브 정보", length: 9 },
{ headNm: "adminDiv", text: "행정구역", length: 2 },
{ headNm: "pntfCol", text: "집수면", length: 2 },
{ headNm: "filtrTrtmfct", text: "여과등 처리시설", length: 3 },
{ headNm: "instlCstSprt", text: "설치비지원", length: 2 },
{ headNm: "grntchBdstCert", text: "녹색건축물인증여부", length: 4 },
];
// id는 다확인해야함
const rainSttHeadList: TableTripleProps[] = [
{
id: "cityText",
title: "시도",
visible: true,
upName: ["bdnstInfo", "adminDiv"],
upSequnce: [1, 1],
},
{
id: "sggText",
title: "시군구",
visible: true,
upName: ["bdnstInfo", "adminDiv"],
upSequnce: [2, 2],
},
{
id: "bdstNm",
title: "건축물명",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [3],
},
{
id: "daddr",
title: "주소",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [4],
},
{
id: "bdstUsgCd",
title: "건축물용도코드",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [5],
},
{
id: "frstArchPrmsnDt",
title: "최초건축허가일시",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [6],
},
{
id: "archArea",
title: "건축면적",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [7],
},
{
id: "lawTrgtYn",
title: "법적의무대상여부",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [8],
},
{
id: "instlCmptnDt",
title: "설치완료일시",
visible: true,
upName: ["bdnstInfo"],
upSequnce: [9],
},
{
id: "instlCst",
title: "설치비용",
visible: true,
upName: ["rainFcltInfo"],
upSequnce: [1],
},
{
id: "pntfColKnd",
title: "집수지점종류",
visible: true,
upName: ["rainFcltInfo", "pntfCol"],
upSequnce: [2, 1],
},
{
id: "pntfColArea",
title: "집수지점면적",
visible: true,
upName: ["rainFcltInfo", "pntfCol"],
upSequnce: [3, 2],
},
{
id: "filtrTrtmfctYn",
title: "여과처리시설유무",
visible: true,
upName: ["rainFcltInfo", "filtrTrtmfct"],
upSequnce: [4, 1],
},
{
id: "filtrTrtmfctCpct",
title: "여과처리시설용량",
visible: true,
upName: ["rainFcltInfo", "filtrTrtmfct"],
upSequnce: [5, 2],
},
{
id: "filtrTrtmfctPrs",
title: "여과처리시설처리공정",
visible: true,
upName: ["rainFcltInfo", "filtrTrtmfct"],
upSequnce: [6, 3],
},
{
id: "dtfcltCpct",
title: "저류조용량",
visible: true,
upName: ["rainFcltInfo"],
upSequnce: [7],
},
{
id: "instlCstSprtYn",
title: "설치지원비용여부",
visible: true,
upName: ["insenInfo", "instlCstSprt"],
upSequnce: [1, 1],
},
{
id: "instlCstSprtAmt",
title: "설치지원비용",
visible: true,
upName: ["insenInfo", "instlCstSprt"],
upSequnce: [2, 2],
},
{
id: "grntchBdstCertYn",
title: "녹색건축물인증여부",
visible: true,
upName: ["insenInfo", "grntchBdstCert"],
upSequnce: [3, 1],
},
{
id: "grntchBdstCertYr",
title: "녹색건축물인증년도",
visible: true,
upName: ["insenInfo", "grntchBdstCert"],
upSequnce: [4, 2],
},
{
id: "grntchBdstCertNo",
title: "녹색건축물인증번호",
visible: true,
upName: ["insenInfo", "grntchBdstCert"],
upSequnce: [5, 3],
},
{
id: "grntchBdstCertGrd",
title: "녹색건축물인증등급",
visible: true,
upName: ["insenInfo", "grntchBdstCert"],
upSequnce: [6, 4],
},
];
const rainRes: customRainBdst[] = [];
export type sttnState = {
sttnCommon: {
rainRes: customRainBdst[];
pbnSttHeadList: TableUpperProps[];
pbnSttHeadNm: chHeadType[];
rainSttHeadList: TableTripleProps[];
rainSttHeadNm: chHeadType[];
excelList:[];
isInit:boolean
};
};
type sttnActions = {
rainSttnSearch: (page: string, total: string, con: string) => void;
chSttnHead: (checkList: string[], type: string) => void;
};
export type sttnType = sttnState & sttnActions;
export const sttnStateExport: sttnState = {
sttnCommon: {
pbnSttHeadList: pbnSttHeadList,
pbnSttHeadNm: pbnSttHeadNm,
rainSttHeadList: rainSttHeadList,
rainSttHeadNm: rainSttHeadNm,
rainRes: rainRes,
excelList: [],
isInit:false
},
};
export const sttnActionsExport: (set: any) => sttnActions = (set: any) => {
return {
rainSttnSearch: async (page: string, total: string, con: string) => {
try {
const rainRes = await getFetch(
fetchType.WR,
`/reuseFc/rainyInfoList/${page}/${total}/${con}`
);
if(Number(total) > 9000){
const rainExcel= excelSttnParsing(rainRes)
set((state: sttnState) => {
return {
...state,
sttnCommon: {
...state.sttnCommon,
excelList: rainExcel,
},
};
});
}
else
set((state: sttnState) => {
return {
...state,
sttnCommon: {
...state.sttnCommon,
rainRes: rainRes,
isInit: false,
},
};
});
} catch (erTxt) {
console.log("error", erTxt);
}
},
chSttnHead: async (checkList: string[], type: string) => {
const headList =
type === "pbn"
? pbnSttHeadList
: type === "rain"
? rainSttHeadList
: null;
let chNm = type === "pbn" ? pbnSttHeadNm : rainSttHeadNm;
headList?.forEach((item) => {
if (checkList.find((ch) => ch === item.id)) {
item.visible = false;
if (item.upName) {
const upNames = Array.isArray(item.upName)
? item.upName
: [item.upName];
upNames?.forEach((up) => {
chNm.find((ch) => {
if (ch.headNm === up) {
ch.length = ch.length - 1;
}
});
});
}
}
});
set((state: sttnState) => ({
sttnCommon: {
...state.sttnCommon,
pbnSttHeadList:
type === "pbn" ? headList : state.sttnCommon.pbnSttHeadList,
rainSttHeadList:
type === "rain" ? headList : state.sttnCommon.rainSttHeadList,
rainSttHeadNm:
type === "rain" ? chNm : state.sttnCommon.rainSttHeadNm,
pbnSttHeadNm: type === "rain" ? chNm : state.sttnCommon.pbnSttHeadNm,
},
}));
},
};
};
+5 -5
View File
@@ -33,7 +33,7 @@ import {
type rswtFacState,
type rswtFacType,
} from "./ruseFcltMng/fcltReg/rswtReg";
import { sttnActionsExport, sttnStateExport, type sttnState, type sttnType } from "./ruseFcltMng/fcltSttn/sttn";
import { rainSttnActionsExport, rainSttnStateExport, type rainSttnState, type rainSttnType } from "./ruseFcltMng/fcltSttn/rainSttn";
export type WrStore = comCodeType&
pubFacType &
@@ -44,7 +44,7 @@ export type WrStore = comCodeType&
bdstFulType&
rainChkgdnType&
rswtChkgdnType&
sttnType
rainSttnType
;
export const StoreZus = (
@@ -57,7 +57,7 @@ export const StoreZus = (
bdstState &
rainChkgdnState&
rswtChkgdnState&
sttnState
rainSttnState
= {
...comCodeStateExport,
...pubFacStateExport,
@@ -68,7 +68,7 @@ export const StoreZus = (
...bdstStateExport,
...rainChkgdnStateExport,
...rswtChkgdnStateExport,
...sttnStateExport
...rainSttnStateExport
}
) => {
return createStore<WrStore>()((set) => {
@@ -89,7 +89,7 @@ export const StoreZus = (
...bdstActionsExport(set),
...rainChkgdnActionsExport(set),
...rswtChkgdnActionsExport(set),
...sttnActionsExport(set)
...rainSttnActionsExport(set)
};
});
};
+1 -1
View File
@@ -126,7 +126,7 @@ export const chRowspanTable = (
`${value}`
) : (
<Input
className={`${head.type === "number" ? "text-right" : "text-center"} text-3xl`}
className={`${head.type === "number" ? "text-right" : "text-center"} !text-xl`}
type={head.type}
onChange={(e) => {
handleChange(rowIndex, head.id, e.target.value);
+1 -1
View File
@@ -74,6 +74,6 @@ export const excelSerialToDateString = (excelDate: number|undefined): string =>
}else{
date =new Date()
}
return date.toISOString().split("T")[0] || ""; // "YYYY-MM-DD"
return date.toISOString().split("T")[0]?.replaceAll("-",'') || ""; // "YYYY-MM-DD"
};
@@ -101,7 +101,7 @@ useEffect(() =>{
const inputClass = '!text-lg'
return (
<div className="">
@@ -109,7 +109,7 @@ useEffect(() =>{
<form onSubmit={form.handleSubmit(onSubmit)}>
<div>
<div className="grid grid-cols-12">
<h1 className="pl-3 text-xl col-span-10">
<h1 className="pl-3 !text-lg col-span-10">
{isModal ? "○건축물 운영정보" : "○ 빗물이용시설 정보"}
</h1>
<Button type="submit" className="mr-4 rounded-lg col-span-2">
@@ -145,7 +145,7 @@ useEffect(() =>{
: new Date(), // Provide a default Date value
onChange: (date) => field.onChange(date),
}}
selectClass={""}
selectClass={'w-full'}
/>
</FormUi>
)}
@@ -159,7 +159,7 @@ useEffect(() =>{
render={({ field }) => (
<FormUi label="설치비">
<Input
className=""
className={inputClass}
placeholder="1,000,000"
type="number"
value={field.value ?? 0}
@@ -207,7 +207,7 @@ useEffect(() =>{
render={({ field }) => (
<FormUi label="면적(m³)">
<Input
className=""
className={selectClass}
placeholder="1,000,000"
type="number"
value={field.value ?? 0}
@@ -248,7 +248,7 @@ useEffect(() =>{
render={({ field }) => (
<FormUi label="용량(m³/일)">
<Input
className=""
className={selectClass}
placeholder="1,000,000"
type="number"
value={field.value ?? 0}
@@ -267,7 +267,7 @@ useEffect(() =>{
render={({ field }) => (
<FormUi label="처리공정">
<Input
className=""
className={selectClass}
placeholder="1,000,000"
type=""
value={field.value ?? ""}
@@ -15,10 +15,12 @@ import { Button, Input } from "@common/components/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import toast, { Toaster } from "react-hot-toast";
import type { z } from "zod";
import { ToastFormUi } from "../../toast/toastFromUi";
export default function ChkgdExcel({ type }: { type: string }) {
const { excelDataUPload } = useWrStore((state) => {
const { rainChkExcelDataUPload } = useWrStore((state) => {
return state;
});
const [files, setFiles] = useState<File[] | null>(null);
@@ -37,20 +39,31 @@ export default function ChkgdExcel({ type }: { type: string }) {
if(form.getValues("chckYr").length<1 ){
alert("등록년도를 입력해주세요");
setFiles(null)
return
}
if (file)
filePicked(file, 0).then((res) => {
if (res !== undefined)
console.log("exex ", excelToRainChkData(res, form.getValues("chckYr")))
setExcelData(excelToRainChkData(res, form.getValues("chckYr")))
});
}
}, [files]);
const onSubmit =(values: z.infer<typeof rainRegExcel>)=> {
if(values.chckYr ===''){
console.log(values.chckYr)
ToastFormUi({body:"등록년도를 작성해주세요" ,title:'엑셀등록'})
return
}else if(excelData ===undefined || excelData?.length === 0 ){
ToastFormUi({body:"빈 파일입니다." ,title:'엑셀등록'})
return
}
if (excelData) {
excelDataUPload(excelData);
console.log("excelData ", excelData)
rainChkExcelDataUPload(excelData);
}
}
@@ -113,6 +126,7 @@ export default function ChkgdExcel({ type }: { type: string }) {
</form>
</Form>
</div>
<Toaster position="top-center" />
</>
);
}
@@ -9,11 +9,12 @@ import { useForm } from "react-hook-form";
import { z } from "zod";
export default function HeadChModal({type }:{type: string }) {
const { sttnCommon ,chSttnHead} = useWrStore((state) => state);
const { rainSttn ,rainChSttnHead} = useWrStore((state) => state);
const { rainSttHeadList,pbnSttHeadList } =sttnCommon;
let items = rainSttHeadList.map(item => ({id:item.id, label:item.title}));
const { rainSttHeadList } =rainSttn;
let items = rainSttHeadList.map(item => ({id:item.id, label:item.title, val:item.visible }));
const FormSchema = z.object({
@@ -31,12 +32,17 @@ export default function HeadChModal({type }:{type: string }) {
})
useEffect(() =>{
form.reset({ data: items.map((el) => el.val!==undefined ? el.val.toString():undefined )})
},[rainSttHeadList])
const onSubmit = (val : z.infer<typeof FormSchema>) =>{
if(val?.data.length > 0)
chSttnHead(val?.data, 'rain')
rainChSttnHead(val?.data, )
}
@@ -1,6 +1,6 @@
'use client'
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/page";
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
import { useWrStore } from "@/app/store";
import { UiTable } from "@common/business_components/ui";
+37 -46
View File
@@ -1,55 +1,46 @@
import { Button } from "@common/components/ui";
import Link from "next/link";
import toast from "react-hot-toast";
interface toastFormType {
body: string;
title: string;
url?: string;
buttonName?: string;
}
export function ToastFormUi(body:string,title:string,url:string,buttonName:string){
export function ToastFormUi({ body, title, url, buttonName }: toastFormType) {
//const router = useRouter();
return(
toast.custom((t) => (
<div
className={`${
t.visible ? 'animate-enter' : 'animate-leave'
} w-4/12 h-40 bg-white shadow-lg rounded-lg pointer-events-auto flex ring-1 ring-black ring-opacity-5`}
>
<div className="w-full flex-1 py-10">
<div className="flex items-start">
<div className="flex-shrink-0 pt-0.5">
</div>
<div className="ml-3 flex-1">
<p className="text-xl font-medium underline">
{title}
</p>
<p className="mt-1 text-2xl">
{body}
</p>
</div>
</div>
</div>
<div className="flex py-20">
<Button
size='sm'
onClick={() => toast.dismiss(t.id)}
>
<Link href={url}> {buttonName}</Link>
</Button>
</div>
<div className="flex pl-4 pr-4 py-20">
<Button
onClick={() => toast.dismiss(t.id)}
size='sm'
>
닫기
</Button>
return toast.custom((t) => (
<div
className={`${
t.visible ? "animate-enter" : "animate-leave"
} w-4/12 h-40 bg-white shadow-lg rounded-lg pointer-events-auto flex ring-1 ring-black ring-opacity-5`}
>
<div className="w-full flex-1 py-10">
<div className="flex items-start">
<div className="flex-shrink-0 pt-0.5"></div>
<div className="ml-3 flex-1">
<p className="text-xl font-medium underline">{title}</p>
<p className="mt-1 text-2xl">{body}</p>
</div>
</div>
))
)
}
</div>
<div className="flex py-20">
{url && buttonName ? (
<Button size="sm" onClick={() => toast.dismiss(t.id)}>
<Link href={url}> {buttonName}</Link>
</Button>
) : (
<></>
)}
</div>
<div className="flex pl-4 pr-4 py-20">
<Button onClick={() => toast.dismiss(t.id)} size="sm">
닫기
</Button>
</div>
</div>
));
}