diff --git a/apps/wr/app/page.tsx b/apps/wr/app/page.tsx index 9b2a51d7d..63c97952b 100644 --- a/apps/wr/app/page.tsx +++ b/apps/wr/app/page.tsx @@ -69,6 +69,13 @@ export default function Home() { +
+ +
diff --git a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx index b252121dc..956f7dc84 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx @@ -24,9 +24,10 @@ import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg"; import { headMakeColSpan } from "../rainReg/TableHead"; export default function Home() { - const { code, htdfl, initHtdfl } = useWrStore((state) => state); - const nodeList = headMakeColSpan(htdfl.upHeadList); + const { code, htdfl, initHtdfl,getHtdflBdstData } = useWrStore((state) => state); const [searchTxt, setSearchTxt] = useState(""); + const [pageNation, setPageNation] = useState(1); + const [htdflForm, setHtdflForm] = useState(); const [bdstTable, setbdstTable] = useState(); const [issNewReg,setIsNewReg] = useState( false); @@ -40,13 +41,23 @@ export default function Home() { useEffect(() => { if (!htdfl.isInit) { - initHtdfl(undefined); + initHtdfl('41'); } }, [htdfl.isInit, initHtdfl]); useEffect(() => { if (code.sggCd.length > 0) { - setbdstTable(tableData(htdflRes, { code })); + + const htdflData = tableData(htdflRes, { code }).map( + (item: customHtdflBdst) => { + return { + ...item, + bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N", + bdstUsgCd: item.reuseBuilding[0]?.bdstUsgCd + }; + } + ); + setbdstTable(htdflData); } }, [code, htdflRes]); @@ -64,13 +75,17 @@ export default function Home() { htdflRes[val]?.bdstInfoPk != null && htdflRes[val]?.chgBuilding?.length > 0 ) { - bdstChgModal(htdflRes[val]?.chgBuilding); + bdstChgModal(htdflRes[val]?.chgBuilding as chgBuilding[]); } } }; const bdstChgModal = (chgBuilding: chgBuilding[]) => { setBdstChgProps({ isOpen: true, chgBuilding: chgBuilding }); }; + useEffect(() => { + getHtdflBdstData(pageNation, "41"); + }, [pageNation]); + return ( <> @@ -112,9 +127,9 @@ export default function Home() { pageSize={100} total={10} headName={"○건축물 목록"} - cellClick={(val,headId)=>{cellClick(val||undefined , headId)}} - > - {nodeList} + cellClick={(val, headId) => { cellClick(val || undefined, headId); } } + onPageChange={setPageNation} + > diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx index b537fcfcc..7bfcc29b0 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/rainSttn/page.tsx @@ -2,7 +2,11 @@ "use client"; import { useWrStore } from "@/app/store"; import { btnClass } from "@/app/store/common/code"; -import { excelDownload, tableData } from "@/components/lib/func/commom"; +import { + excelDownload, + getCityOrSgg, + tableData, +} from "@/components/lib/func/commom"; import HeadChModal from "@/components/ui/modal/headChModal/headChModal"; import { ContentsDiv, @@ -10,7 +14,7 @@ import { Title, UiModal, UiTable, - type ReturnType + type ReturnType, } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button } from "@common/components/ui"; @@ -19,50 +23,32 @@ import type { customRainBdst } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; export default function RainSttn() { - const { code, rainSttn, rainSttnSearch } = - useWrStore((state) => state); + const { code, rainSttn, rainSttnSearch, rainSttnInit } = useWrStore( + (state) => state + ); + + const [pageNation, setPageNation] = useState(1); const { rainSttnRes } = rainSttn; const [isChHead, setIsChHead] = useState(false); const ref = useRef({} as ReturnType); const [bdstTable, setBdstTable] = useState(); + const codeData = getCityOrSgg(ref); + useEffect(() => { if (!rainSttn.isInit) { - let con - if (ref.current.sigunValue != '0') { - con = ref.current.sigunValue - }else{ - con = ref.current.sidoValue - } - rainSttnSearch('1', '20' ,con); + rainSttnInit(codeData ?? "0"); } - }, [rainSttn.isInit, rainSttnSearch]); - + }, [rainSttn.isInit, rainSttnInit]); useEffect(() => { - - if (rainSttnRes.length > 0 && code.cityCd.length>0) { + if (rainSttnRes.length > 0 && code.cityCd.length > 0) { const data = tableData(rainSttnRes, { code }); const chData = data .map((item: any) => ({ - ...item, ...item.reuseBuilding[0], ...item.reuseBuilding[0].rainyObj, - // cityText:item.cityText, - // sggText:item.sggText, - // bdstNm: item.bdstNm, - // daddr:item.daddr, - // bdstUsgCd:item.bdstUsgCd, - // frstArchPrmsnDt:item.frstArchPrmsnDt, - // archArea:item.archArea, - // lawTrgtYn:item.lawTrgtYn, - // instlCmptnDt:item.instlCmptnDt, - // instlCst:item.instlCst, - - - - })) .filter((item: any) => item.rainyObj !== undefined); @@ -70,29 +56,25 @@ export default function RainSttn() { } }, [code, rainSttnRes, rainSttn.rainSttHeadList]); - - useEffect(() =>{ -console.log(rainSttn.rainSttNodeList) - },[rainSttn.rainSttNodeList]) + useEffect(() => { + if (codeData != null) rainSttnSearch(pageNation, "20", codeData); + }, [pageNation]); useEffect(() => { - if(rainSttn.excelList.length>0){ - + if (rainSttn.excelList.length > 0) { if (rainSttn.excelList.length === 0) return; - excelDownload(rainSttn.excelList , '빗물재이용시설 현황','sample_rainSttn.xlsx') + excelDownload( + rainSttn.excelList, + "빗물재이용시설 현황", + "sample_rainSttn.xlsx" + ); } }, [rainSttn.excelList]); - - const excelClick = useCallback((returnType:ReturnType) => { - let con - if (returnType.sigunValue != '0') { - con = returnType.sigunValue - }else{ - con = returnType.sidoValue - } - rainSttnSearch('1', '10000' ,con); - },[rainSttnSearch]); + const excelClick = useCallback(() => { + if (codeData) rainSttnSearch(1, "10000", codeData); + }, [rainSttnSearch]); + return ( <> @@ -119,13 +101,13 @@ console.log(rainSttn.rainSttNodeList) leftChildren={undefined} queryClick={function (returnType: ReturnType): void { // '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}' - let con - if (returnType.sigunValue != '0') { - con = returnType.sigunValue - }else{ - con = returnType.sidoValue + let con; + if (returnType.sigunValue != "0") { + con = returnType.sigunValue; + } else { + con = returnType.sidoValue; } - rainSttnSearch('1', '20' ,con); + rainSttnSearch(1, "20", con); }} excelClick={excelClick} initClick={function (): void {}} @@ -140,16 +122,15 @@ console.log(rainSttn.rainSttNodeList) } + children={ + + } headlist={rainSttn.rainSttHeadList} - pageSize={0} - total={0} + pageSize={20} + total={100000} cellClick={undefined} - onPageChange={function (page: number): void { - throw new Error("Function not implemented."); - }} - > - + onPageChange={setPageNation} + > @@ -159,7 +140,15 @@ console.log(rainSttn.rainSttNodeList) setIsChHead(!isChHead); }} bodyClass={""} - body={} + body={ + ({ + ...item, + visible: item.visible ?? false, + }))} + /> + } /> diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/rswtSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/rswtSttn/page.tsx new file mode 100644 index 000000000..73ea9b13a --- /dev/null +++ b/apps/wr/app/ruseFcltMng/fcltSttn/rswtSttn/page.tsx @@ -0,0 +1,157 @@ +"use client"; +import { useWrStore } from "@/app/store"; +import { btnClass } from "@/app/store/common/code"; +import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg"; +import { excelDownload, getCityOrSgg, tableData } from "@/components/lib/func/commom"; +import HeadChModal from "@/components/ui/modal/headChModal/headChModal"; +import { + ContentsDiv, + SearchBaseForm, + Title, + UiModal, + UiTable, + type ReturnType, +} from "@common/business_components/ui"; +import ListDiv from "@common/business_components/ui/list_div"; +import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; +import { Button } from "@common/components/ui"; +import { useCallback, useEffect, useRef, useState } from "react"; + +export default function RswtSttn() { + const { code, rswtSttn, rswtSttnSearch ,rswtSttnInit} = useWrStore((state) => state); + const [pageNation, setPageNation] = useState(1); + + const { rswtSttnRes } = rswtSttn; + const [isChHead, setIsChHead] = useState(false); + const ref = useRef({} as ReturnType); + const [bdstTable, setBdstTable] = useState(); + + const codeData = getCityOrSgg(ref); + + + useEffect(() => { + if (!rswtSttn.isInit) { + + rswtSttnInit('0') + } + }, [rswtSttn.isInit, rswtSttnInit]); + + useEffect(() => { + if (rswtSttnRes.length > 0 && code.cityCd.length > 0) { + const data = tableData(rswtSttnRes, { code }); + const chData = data + .map((item: customRswtBdst) => ({ + ...item, + ...item.reuseBuilding[0], + ...item.reuseBuilding[0]?.rswtrObj, + chBuildingYn:item.chgBuilding.length>0?'Y':'N' + })) + .filter((item: customRswtBdst) => item.reuseBuilding[0]?.rswtrObj !== undefined); + + console.log("chData ", chData) + setBdstTable(chData); + } + }, [code, rswtSttnRes]); + + + useEffect(() => { + if (rswtSttn.excelList.length > 0) { + if (rswtSttn.excelList.length === 0) return; + excelDownload( + rswtSttn.excelList, + "중수도시설 현황", + "sample_rswtSttn.xlsx" + ); + } + }, [rswtSttn.excelList]); + + const excelClick = useCallback( + (returnType: ReturnType) => { + let con; + if (returnType.sigunValue != "0") { + con = returnType.sigunValue; + } else { + con = returnType.sidoValue; + } + rswtSttnSearch(1, "10000", con); + }, + [rswtSttnSearch] + ); + + useEffect(() => { + if (codeData != null) rswtSttnSearch(pageNation, "20", codeData); + }, [pageNation]); + + + return ( + <> + +
+
+ + <SearchBaseForm + selectSidoData={code.cityCd} + selectSigunData={code.sggCd} + selectRegionData={code.rvbsnCd} + selectUnitWaterShedData={code.lgbsnCd} + selectMiddleRegionData={code.mdmbsnCd} + selectEnvPartData={code.lclgvrnmntCd} + rightChildren={ + <Button + className={btnClass} + onClick={() => { + setIsChHead(true); + }} + > + 조회항목설정 + </Button> + } + leftChildren={undefined} + queryClick={function (returnType: ReturnType): void { + // '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}' + let con; + if (returnType.sigunValue != "0") { + con = returnType.sigunValue; + } else { + con = returnType.sidoValue; + } + rswtSttnSearch(1, "20", con); + }} + excelClick={excelClick} + initClick={function (): void {}} + btnClass={btnClass} + ref={ref} + /> + </div> + </div> + <div className="grid grid-cols-6 gap-4 "> + <div className="col-span-6"> + <ListDiv> + <UiTable + headName={[]} + tableData={bdstTable || []} + children={ + <HeadMakeColSpan upHeadList={rswtSttn.rswtSttNodeList} /> + } + headlist={rswtSttn.rswtSttHeadList} + pageSize={20} + total={10000} + cellClick={undefined} + onPageChange={setPageNation} + + ></UiTable> + </ListDiv> + </div> + </div> + <UiModal + open={isChHead} + onOpenChange={() => { + setIsChHead(!isChHead); + }} + bodyClass={""} + body={<HeadChModal headList={(rswtSttn.rswtSttHeadList||[]).map(item => ({ ...item, visible: item.visible ?? false }))} type={"RST"} />} + /> + </ContentsDiv> + </> + ); +} diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx index fc8fb1e0a..2e8b4ee48 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx @@ -9,7 +9,6 @@ import { excelDownload } from "@/components/lib/func/commom"; import ChkgdExcel from "@/components/ui/modal/chkgdExcel/chkgdExcel"; import ChkgdModal from "@/components/ui/modal/chkgdModal/chkgdModal"; import RainChkgdTable from "@/components/ui/table/chkgdTable/rainChkgd/rainChkgdTable"; -import RainChkgdTableModal from "@/components/ui/table/chkgdTable/rainChkgd/rainChkgdTableModal"; import RswtChkgdTable from "@/components/ui/table/chkgdTable/rswtChkgd/rswtChkgdTable"; import { ContentsDiv, @@ -61,6 +60,7 @@ export default function Page() { }, [rainChkgdn.excelList]); const excelClick= useCallback(()=>{ + rainChkExcelDownload(code.cityCd, code.sggCd); }, [rainChkExcelDownload, code.cityCd, code.sggCd]); @@ -72,9 +72,7 @@ export default function Page() { const clickDelete=(data:number[])=>{ if(data.length>0){ - data.forEach((data) =>{ - rainChkDelete( String(data) ) - }) + rainChkDelete( data ) } } diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx index 9f51eed50..ec3464ab8 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx @@ -313,7 +313,7 @@ type rainChkgdnActions = { rainChkGuidUpdate(rainChk: rainChkZodType): Promise<void>; rainChkExcelDownload(sidoCode: SelectDataType[],sggCode: SelectDataType[]): Promise<void> rainChkExcelDataUPload(excelData:rainChkZodType[]) : Promise<void> - rainChkDelete(chkgdnPk:string) :Promise<void> + rainChkDelete( chkgdnPks:number[] ) :Promise<void> }; export type rainChkgdnType = rainChkgdnState & rainChkgdnActions; @@ -367,7 +367,9 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( ) => { return { rainChkExcelDownload:async(sidoCode:SelectDataType[], sggCode:SelectDataType[])=>{ - const data = await getFetch(fetchType.WR, "/reuseFc/building/RNB/0") + + // 로그인한 아이디의 시도 or 시군구로 들어가야하는데 현재는 그냥 0으로 하드코딩 + const data = await getFetch(fetchType.WR, `/reuseFc/buildingFlg/RNB/41`) // const excelList = buildingToExcelType(data, sidoCode, sggCode); const excelList = buildingToExcelType(data, sidoCode, sggCode); @@ -454,9 +456,9 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( }, - rainChkDelete: async (chkgdnPk:string) =>{ + rainChkDelete: async (chkgdnPks:number[] ) =>{ try{ - const res = await deleteFectch(`/reuseChk/rainy/${chkgdnPk}`,''); + const res = await deleteFectch(`/reuseChk/rainy`,chkgdnPks); if(res.ok){ ToastFormUi({body:"삭제가 완료되었습니다. " ,title:'지도점검 삭제'}) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx index 2ac27be5a..80864d026 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx @@ -25,21 +25,21 @@ export const hdtflZod = z.object({ instlCst: z.number().nullish().default(0), operMngCd: z.string().nullish().default(""), anlOperCst: z.number().default(0), - instlCstSprtYn: z.enum(["Y", "N"]), + 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자리 연도만 입력하세요' - }), + // 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(""), + // 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"]), + lawTrgtYn: z.enum(["Y", "N"]).nullish(), rgtr:z.string().nullish().default(null), mdfr:z.string().nullish().default(null), // htdflObj 매핑 @@ -49,13 +49,13 @@ export const hdtflZod = z.object({ bdstRuseFcltFk: z.number().nullish(), etgtType: z.string().default(""), fclCpct: z.number().default(0), - plwtYn: z.string().default(""), + plwtYn: z.enum(["Y", "N"]), orgwtWtritSpt: z.number().default(0), orgwtOcrnProcs: z.string().default(""), wtritEntrcTp: z.number().max(4, "온도는 100이상이 될 수 없습니다.") .default(0), amtgnr: z.number().default(0), - prcsProcsYn: z.string().default(""), + prcsProcsYn: z.enum(["Y", "N"]), prcsFcltCpct: z.number().default(0), fmYn: z.string().default(""), utztnCpct: z.number().default(0), @@ -75,7 +75,10 @@ export const hdtflZod = z.object({ rgtr:z.string().nullish().default(null), mdfr:z.string().nullish().default(null), }) - .default({}), + .default({ + plwtYn: "N", + prcsProcsYn: "N", + }), }) ) .default([]), @@ -84,7 +87,7 @@ export const hdtflZod = z.object({ z.object({ bdstInfoFk: z.number().nullish(), archChgPrmsnDt: z.coerce.date() , - archChgArea: z.string().default("-"), + archChgArea: z.string().default("-").nullish(), bdstChgNm: z.string().default(""), rgtr:z.string().nullish().default(null), mdfr:z.string().nullish().default(null), @@ -94,7 +97,6 @@ export const hdtflZod = z.object({ }); export type customHtdflBdst = z.infer<typeof hdtflZod> - //export type customHtdflBdst = z.infer<typeof hdtflZod>; export type htdflFacState = { @@ -105,9 +107,11 @@ export type htdflFacState = { }; }; type htdflFacSActions = { - initHtdfl: (txt: string | undefined) => void; - htdflUpdate:(data: customHtdflBdst) => void; - htdflReg:(data: customHtdflBdst) => void; + initHtdfl: (code: string | number) => void; + htdflBdstUpdate:(data: customHtdflBdst, code:string|number) => void; + htdflBdstReg:(data: customHtdflBdst, code:string|number) => void; + getHtdflBdstData:(pageNation:number, code:string|number) =>void; + }; const htdflRes: customHtdflBdst[] = []; @@ -122,26 +126,43 @@ export const htdflFacStateExport: htdflFacState = { }, }; -const initFetch = async (txt: string | undefined) => { - const htdflRes = await getFetch( + +const initFetch = async (code:string|number) => { + const rswtRes = await getFetch( "wr", - `/drain/facilityList/1/20/0` + (txt ? `/${txt}` : "") - ); - const chHtdflRes = htdflRes.map((item: customHtdflBdst) => { - return { - ...item, - bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N", - }; - }); - return chHtdflRes; + `/facilityList/1/20/${code}`) + + return rswtRes; }; export const htdflFacActionsExport: (set: any) => htdflFacSActions = ( set: any ) => { return { - initHtdfl: async (txt: string | undefined) => { + getHtdflBdstData: async (pageNation: number, code: string | number) => { try { - const htdflRes = await initFetch(txt); + const rswtRes = await getFetch( + "wr", + `/drain/facilityList/${pageNation}/20/${code}` + ); + console.log(pageNation) + // 여기서 상태 업데이트 + return set((state: htdflFacState) => ({ + ...state, + htdfl: { + ...state.htdfl, + htdflRes: rswtRes, + isInit: false, + }, + })); + } catch (e) { + console.log(e); + } + }, + + + initHtdfl: async (code: string | number) => { + try { + const htdflRes = await initFetch(code); set((state: htdflFacState) => { return { ...state, @@ -156,7 +177,7 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = ( console.log(error); } }, - htdflUpdate: async (data: customHtdflBdst) => { + htdflBdstUpdate: async (data: customHtdflBdst, code:string|number) => { try { const chData=await makeMdfr(data) const res = await putFectch("/drain/facility", data); @@ -164,7 +185,7 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = ( alert(" 수정이 완료되었습니다."); } - const htdflRes = await initFetch(undefined); + const htdflRes = await initFetch(code); set((state: htdflFacState) => ({ ...state, htdfl: { @@ -180,7 +201,7 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = ( ); } }, - htdflReg: async (data: customHtdflBdst) => { + htdflBdstReg: async (data: customHtdflBdst , code:string|number) => { try { const chData=await makeRstr(data) const res = await postFectch("/drain/facility", data); @@ -211,7 +232,7 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = ( } } - const htdflRes = await initFetch(undefined); + const htdflRes = await initFetch(code); set((state: htdflFacState) => ({ ...state, htdfl: { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx index ea7f38244..bd7473bbb 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx @@ -17,6 +17,9 @@ export const rswtZod = z.object({ archChgArea: z.number().default(0), rgtr: z.string().nullish().default(null), mdfr: z.string().nullish().default(null), + bdstUsgText: z.string().default(''), + cityText: z.string().default(''), + sggText: z.string().default(''), reuseBuilding: z .array( @@ -56,6 +59,7 @@ export const rswtZod = z.object({ wtrUsqty: z.number().default(0), oblgTrgtWtrUsqty: z.number().nullish().default(0), orgwtKndCd: z.string().default(""), + filtrTrtmfctCpct: z.string().default(""), filtrTrtmfctProcs: z.string().default(""), filtrTrtmfctUsgCd: z.string().default(""), rswtrUsqty: z.number().default(0), @@ -128,7 +132,7 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( rswtBdstSearch: async(txt:string,pageNation:number,code:string|number) =>{ try{ - const rswtRes = await getFetch('wr' , `/reuseFc/rainyInfoList/${pageNation}/20/${code}` +(txt? `/${txt}`:'')) + const rswtRes = await getFetch('wr' , `/reuseFc/waterreuseFc/${pageNation}/20/${code}` +(txt? `/${txt}`:'')) set((state: rswtFacState) => { return { ...state, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx index 264e3b6cc..5387f4292 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx @@ -1,6 +1,6 @@ import type { customRainBdst } from "../../fcltReg/rainReg"; -export const excelSttnParsing = (data: customRainBdst[]): string[][] => { +export const excelRainSttnParsing = (data: customRainBdst[]): string[][] => { const excelExportData: string[][] = []; data.forEach((item) => { @@ -31,3 +31,4 @@ export const excelSttnParsing = (data: customRainBdst[]): string[][] => { }); return excelExportData; }; + diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx index c283194a1..354f98a1b 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/headList.tsx @@ -1,7 +1,8 @@ +import type { CommonTableProps } from "@/app/store/common/type/headder"; import { z } from "zod"; -export const rainSttnHeadListType = z.array( +export const sttnHeadListType = z.array( z.object({ id: z.string(), title: z.string(), @@ -10,7 +11,7 @@ export const rainSttnHeadListType = z.array( ); -export const rainSttHeadListExport: z.infer<typeof rainSttnHeadListType> = [ +export const rainSttHeadListExport: z.infer<typeof sttnHeadListType> = [ { id: "cityText", diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx index 3c9a507ac..c0f829e41 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx @@ -3,10 +3,10 @@ import { fetchType, getFetch } from "@/components/lib/api"; import { type customRainBdst, } from "../../fcltReg/rainReg"; -import { excelSttnParsing } from "./excel"; +import { excelRainSttnParsing } from "./excel"; import { rainSttHeadListExport, - rainSttnHeadListType, + sttnHeadListType, rainSttNodeListExport, } from "./headList"; import type { z } from "zod"; @@ -92,9 +92,10 @@ export type rainSttnState = { }; }; type rainSttnActions = { - rainSttnSearch: (page: string, total: string, con: string) => void; + rainSttnInit:(con:string) => void + rainSttnSearch: (page: number, total: string, con: string) => void; rainChSttnHead: ( - headList: z.infer<typeof rainSttnHeadListType>, + headList: z.infer<typeof sttnHeadListType>, ) => void; }; @@ -114,14 +115,35 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = ( set: any ) => { return { - rainSttnSearch: async (page: string, total: string, con: string) => { + rainSttnInit: async( con:string)=>{ + try{ + + const rainSttnRes = await getFetch( + fetchType.WR, + `/reuseFc/rainyInfoList/1/20/${con}` + ); + set((state: rainSttnState) => { + return { + ...state, + rainSttn: { + ...state.rainSttn, + rainSttnRes: rainSttnRes, + isInit: false, + }, + }; + }); + }catch(e){ + console.log(e) + } + }, + rainSttnSearch: async (page: number, total: string, con: string) => { try { const rainSttnRes = await getFetch( fetchType.WR, `/reuseFc/rainyInfoList/${page}/${total}/${con}` ); if (Number(total) > 9000) { - const rainExcel = excelSttnParsing(rainSttnRes); + const rainExcel = excelRainSttnParsing(rainSttnRes); set((state: rainSttnState) => { return { ...state, @@ -147,7 +169,7 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = ( } }, rainChSttnHead: async ( - headList: z.infer<typeof rainSttnHeadListType> + headList: z.infer<typeof sttnHeadListType> ) => { const changeNodeList= controlHeadView(headList,rainSttNodeList) diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx new file mode 100644 index 000000000..96edde5ca --- /dev/null +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx @@ -0,0 +1,33 @@ +import type { customRswtBdst } from "../../fcltReg/rswtReg"; + +export const excelRSwtSttnParsing = (data: customRswtBdst[]): string[][] => { + const excelExportData: string[][] = []; + + data.forEach((item) => { + excelExportData.push([ + String(item.cityText), + String(item.sggText), + item.bdstNm ?? "", + item.daddr ?? "", + String(item.bdstUsgText ?? ""), + String(item.frstArchPrmsnDt ?? ""), + String(item.archArea ?? ""), + String(item.chgBuilding.length>0 ? "Y" :"N"), + String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""), + String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""), + String(item.reuseBuilding?.[0]?.rswtrObj.oblgTrgtWtrUsqty ?? ""), + String(item.reuseBuilding?.[0]?.instlCst ?? ""), + item.reuseBuilding?.[0]?.rswtrObj?.orgwtKndCd ?? "", + String(item.reuseBuilding?.[0]?.rswtrObj.filtrTrtmfctCpct ?? ""), + String(item.reuseBuilding?.[0]?.rswtrObj?.filtrTrtmfctProcs ?? ""), + String(item.reuseBuilding?.[0]?.rswtrObj?.filtrTrtmfctUsgCd ?? ""), + String(item.reuseBuilding?.[0]?.instlCstSprtYn ?? ""), + String(item.reuseBuilding?.[0]?.instlCstSprtAmt ?? ""), + String(item.reuseBuilding?.[0]?.grntchBdstCertYn ?? ""), + String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""), + String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""), + String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "") + ]); + }); + return excelExportData; +}; \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx new file mode 100644 index 000000000..2e901b000 --- /dev/null +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/headList.tsx @@ -0,0 +1,400 @@ +import type { z } from "zod"; +import type { sttnHeadListType } from "../rainSttn/headList"; +import type { CommonTableProps } from "@/app/store/common/type/headder"; + +export const rswtSttHeadListExport: z.infer<typeof sttnHeadListType> = [ + { + id: "cityText", + title: "시도", + visible: true, + }, + { + id: "sggText", + title: "시군구", + visible: true, + }, + { + id: "bdstNm", + title: "건축물명", + visible: true, + }, + { + id: "daddr", + title: "주소", + visible: true, + }, + { + id: "bdsgUsgText", + title: "건축물용도", + visible: true, + }, + { + id: "frstArchPrmsnDt", + title: "최초건축허가일시", + visible: true, + }, + { + id: "archArea", + title: "건축면적", + visible: true, + }, + { + id: "wtrUsqty", + title: "물사용량", + visible: true, + }, + { + id: "chBuildingYn", + title: "중축・개축・재축여부", + visible: true, + }, + + { + id: "lawTrgtYn", + title: "법적의무대상여부", + visible: true, + }, + + { + id: "oblgTrgtWtrUsqty", + title: "의무대상물사용량 ", + visible: true, + }, + { + id: "instlCmptnDt", + title: "설치완료일시", + visible: true, + }, + { + id: "instlCst", + title: "설치비용", + visible: true, + }, + + { + id: "orgwtKndCd", + title: "원수종류", + visible: true, + }, + + { + id: "filtrTrtmfctCpct", + title: "처리시설용량", + visible: true, + }, + { + id: "filtrTrtmfctProcs", + title: "주요처리공정", + visible: true, + }, + { + id: "filtrTrtmfctUsgCd", + title: "이용용도", + visible: true, + }, + + { + id: "instlCstSprtYn", + title: "설치지원비용여부", + visible: true, + }, + { + id: "instlCstSprtAmt", + title: "설치지원비용", + visible: true, + }, + + { + id: "grntchBdstCertYn", + title: "녹색건축물인증여부", + visible: true, + }, + { + id: "grntchBdstCertYr", + title: "녹색건축물인증년도", + visible: true, + }, + { + id: "grntchBdstCertNo", + title: "녹색건축물인증번호", + visible: true, + }, + { + id: "grntchBdstCertGrd", + title: "녹색건축물인증등급", + visible: true, + }, +]; + +// id는 다확인해야함 +export const rswtSttNodeListExport: CommonTableProps[] = [ + { + id: "bdnstInfo", + title: "1.건축물정보", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 12, + }, + { + id: "rswtFcltInfo", + title: "2.중수도시설정보", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 5, + }, + { + id: "insenInfo", + title: "3.인센티브 정보", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 6, + }, + { + id: "adminDiv", + title: "행정구역", + visible: true, + row: 2, + upName: "bdnstInfo", + rowSpan: 1, + colSpan: 2, + }, + + // 3번째줄 시작 + { + id: "cityText", + title: "시도", + visible: true, + upName: "adminDiv", + row: 3, + rowSpan: 1, + colSpan: 1, + }, + { + id: "sggText", + title: "시군구", + visible: true, + upName: "adminDiv", + row: 3, + rowSpan: 1, + colSpan: 1, + }, + + // 2번째 줄 + // 1번째 줄 건축물정보 아래의 행으로 만들 헤더 + { + id: "bdstNm", + title: "건축물명", + visible: true, + upName: "bdnstInfo", + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "daddr", + title: "주소", + visible: true, + upName: "bdnstInfo", + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "bdsgUsgText", + title: "건축물용도", + upName: "bdnstInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "frstArchPrmsnDt", + title: "최초건축허가일시", + upName: "bdnstInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "archArea", + title: "건축면적", + upName: "bdnstInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "wtrUsqty", + title: "물사용량", + upName: "bdnstInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "chBuildingYn", + title: "중축・개축・재축여부", + upName: "bdnstInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + + { + id: "lawTrgtYn", + title: "법적의무대상여부", + upName: "bdnstInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "oblgTrgtWtrUsqty", + title: "의무대상물사용량", + upName: "bdnstInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "instlCmptnDt", + title: "설치완료일시", + upName: "bdnstInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "instlCst", + title: "설치비용", + upName: "rswtFcltInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + + { + id: "orgwtKndCd", + title: "원수종류", + upName: "rswtFcltInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + + { + id: "filtrTrtmfctCpct", + title: "처리시설용량", + upName: "rswtFcltInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "filtrTrtmfctProcs", + title: "주요처리공정", + upName: "rswtFcltInfo", + visible: true, + row: 2, + rowSpan: 2, + colSpan: 1, + }, + + { + id: "filtrTrtmfctUsgCd", + title: "이용용도", + visible: true, + upName: "rswtFcltInfo", + row: 2, + rowSpan: 2, + colSpan: 1, + }, + { + id: "instlCstSprtYn", + title: "설치지원비용여부", + upName: "instlCstSprt", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1, + }, + { + id: "instlCstSprtAmt", + title: "설치지원비용", + upName: "instlCstSprt", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1, + }, + + { + id: "instlCstSprt", + title: "설치비지원", + upName: "insenInfo", + visible: true, + row: 2, + rowSpan: 1, + colSpan: 2, + }, + + { + id: "grntchBdstCertYn", + title: "녹색건축물인증여부", + upName: "grntchBdstCert", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1, + }, + { + id: "grntchBdstCertYr", + title: "녹색건축물인증년도", + upName: "grntchBdstCert", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1, + }, + { + id: "grntchBdstCertNo", + title: "녹색건축물인증번호", + upName: "grntchBdstCert", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1, + }, + { + id: "grntchBdstCertGrd", + title: "녹색건축물인증등급", + upName: "grntchBdstCert", + visible: true, + row: 3, + rowSpan: 1, + colSpan: 1, + }, + { + id: "grntchBdstCert", + title: "녹색건축물인증", + upName: "insenInfo", + visible: true, + row: 2, + rowSpan: 1, + colSpan: 4, + }, +]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx new file mode 100644 index 000000000..b48fc3eae --- /dev/null +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx @@ -0,0 +1,129 @@ +import type { CommonTableProps } from "@/app/store/common/type/headder"; +import type { customRswtBdst } from "../../fcltReg/rswtReg"; +import type { sttnHeadListType } from "../rainSttn/headList"; +import type { z } from "zod"; +import { rswtSttHeadListExport, rswtSttNodeListExport } from "./headList"; +import { controlHeadView } from "../rainSttn"; +import { fetchType, getFetch } from "@/components/lib/api"; +import { excelRainSttnParsing } from "../rainSttn/excel"; + + + +// 테이블 헤드 리스트 +const rswtSttNodeList = rswtSttNodeListExport; +const rswtSttHeadList = rswtSttHeadListExport; +const rswtSttnRes: customRswtBdst[] = []; + + + +export type rswtSttnState = { + rswtSttn: { + rswtSttnRes: customRswtBdst[]; + rswtSttHeadList: CommonTableProps[]; + rswtSttNodeList: CommonTableProps[]; + excelList: []; + isInit: boolean; + }; +}; + + + +type rswtSttnActions = { + rswtSttnInit:(con:string) => void; + rswtSttnSearch: (page: number, total: string, con: string) => void; + rswtChSttnHead: ( + headList: z.infer<typeof sttnHeadListType>, + ) => void; +}; + +export type rswtSttnType = rswtSttnState & rswtSttnActions; + + + +export const rswtSttnStateExport: rswtSttnState = { + rswtSttn: { + rswtSttHeadList: rswtSttHeadList, + rswtSttNodeList: rswtSttNodeList, + rswtSttnRes: rswtSttnRes, + excelList: [], + isInit: false, + }, +}; + + + +export const rswtSttnActionsExport: (set: any) => rswtSttnActions = ( + set: any +) => { + return { + rswtSttnInit: async( con:string)=>{ + try{ + + const rswtSttnRes = await getFetch( + fetchType.WR, + `/reuseFc/waterreuseFc/1/20/${con}` + ); + set((state: rswtSttnState) => { + return { + ...state, + rswtSttn: { + ...state.rswtSttn, + rswtSttnRes: rswtSttnRes, + isInit: false, + }, + }; + }); + }catch(e){ + console.log(e) + } + }, + rswtSttnSearch: async (page: number, total: string, con: string) => { + try { + const rswtSttnRes = await getFetch( + fetchType.WR, + `/reuseFc/waterreuseFc/${page}/${total}/${con}` + ); + if (Number(total) > 9000) { + const rainExcel = excelRainSttnParsing(rswtSttnRes); + set((state: rswtSttnState) => { + return { + ...state, + rswtSttn: { + ...state.rswtSttn, + excelList: rainExcel, + }, + }; + }); + } else + set((state: rswtSttnState) => { + + return { + ...state, + rswtSttn: { + ...state.rswtSttn, + rswtSttnRes: rswtSttnRes, + isInit: false, + }, + }; + }); + } catch (erTxt) { + console.log("error", erTxt); + } + }, + rswtChSttnHead: async ( + headList: z.infer<typeof sttnHeadListType> + ): Promise<void> => { + + console.log('head ', headList) + const changeNodeList= controlHeadView(headList,rswtSttNodeList) + + return set((state: rswtSttnState) => ({ + rswtSttn: { + ...state.rswtSttn, + rswtSttHeadList: headList, + rswtSttNodeList: changeNodeList, + }, + })); + }, + }; +}; diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index 848ba0b03..ee124de68 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -34,6 +34,7 @@ import { type rswtFacType, } from "./ruseFcltMng/fcltReg/rswtReg"; import { rainSttnActionsExport, rainSttnStateExport, type rainSttnState, type rainSttnType } from "./ruseFcltMng/fcltSttn/rainSttn"; +import { rswtSttnActionsExport, rswtSttnStateExport, type rswtSttnState, type rswtSttnType } from "./ruseFcltMng/fcltSttn/rswtSttn"; export type WrStore = comCodeType& pubFacType & @@ -44,7 +45,8 @@ export type WrStore = comCodeType& bdstFulType& rainChkgdnType& rswtChkgdnType& - rainSttnType + rainSttnType& + rswtSttnType ; export const StoreZus = ( @@ -57,7 +59,9 @@ export const StoreZus = ( bdstState & rainChkgdnState& rswtChkgdnState& - rainSttnState + rainSttnState& + rswtSttnState + = { ...comCodeStateExport, ...pubFacStateExport, @@ -68,7 +72,8 @@ export const StoreZus = ( ...bdstStateExport, ...rainChkgdnStateExport, ...rswtChkgdnStateExport, - ...rainSttnStateExport + ...rainSttnStateExport, + ...rswtSttnStateExport } ) => { return createStore<WrStore>()((set) => { @@ -89,7 +94,8 @@ export const StoreZus = ( ...bdstActionsExport(set), ...rainChkgdnActionsExport(set), ...rswtChkgdnActionsExport(set), - ...rainSttnActionsExport(set) + ...rainSttnActionsExport(set), + ...rswtSttnActionsExport(set) }; }); }; diff --git a/apps/wr/components/lib/func/commom.tsx b/apps/wr/components/lib/func/commom.tsx index b7f9d9eed..a91750fce 100644 --- a/apps/wr/components/lib/func/commom.tsx +++ b/apps/wr/components/lib/func/commom.tsx @@ -1,70 +1,80 @@ -import type { comCodeState, } from "@/app/store/common/code"; -import { filePickedBlob, type SelectDataType } from "@common/business_components/ui"; - - - - +import type { comCodeState } from "@/app/store/common/code"; +import { + filePickedBlob, + type SelectDataType, + type ReturnType, +} from "@common/business_components/ui"; +import type { RefObject } from "react"; export const getCity = (val: string, sggCd: SelectDataType[]) => { - const data = sggCd - .filter((item) => String(item.val).substring(0, 2) === val) - .map((item) => ({ - val: item.val, - text: item.text // 한국어 텍스트 - })); - return data - - }; - + const data = sggCd + .filter((item) => String(item.val).substring(0, 2) === val) + .map((item) => ({ + val: item.val, + text: item.text, // 한국어 텍스트 + })); + return data; +}; // cd text 넣기 - export const tableData = ( data: any,code:comCodeState)=>{ - const chCode = code.code; - return data?.map((item: { sggCd: string; ctpvCd: string; reuseBuilding: { lawTrgtYn: any , bdstUsgCd:any}[]; }) => { +export const tableData = (data: any, code: comCodeState) => { + const chCode = code.code; + return data?.map( + (item: { + sggCd: string; + ctpvCd: string; + reuseBuilding: { lawTrgtYn: any; bdstUsgCd: any }[]; + }) => { let returnData = {}; const sggText = chCode.sggCd.find( - (cd) => cd.val === String(item.sggCd) + (cd) => cd.val === String(item.sggCd) )?.text; const cityText = chCode.cityCd.find( (cd) => cd.val === String(item.ctpvCd) )?.text; - console - .log(item?.reuseBuilding) - if (item?.reuseBuilding?.length >0) { - + if (item?.reuseBuilding?.length > 0) { const bdsgUsgText = chCode.bdstUsgCd.find( - (cd) =>Number(cd.val) === item?.reuseBuilding[0]?.bdstUsgCd - )?.text - const lawTrgtYn = item?.reuseBuilding[0]?.lawTrgtYn - console - .log(bdsgUsgText) + (cd) => Number(cd.val) === item?.reuseBuilding[0]?.bdstUsgCd + )?.text; + const lawTrgtYn = item?.reuseBuilding[0]?.lawTrgtYn; - returnData= { ...item, sggText: sggText??'없음', cityText: cityText??'없음' ,bdsgUsgText:bdsgUsgText ,lawTrgtYn:lawTrgtYn}; - }else{ - returnData= { ...item, sggText: sggText??'없음', cityText: cityText??'없음'}; + returnData = { + ...item, + sggText: sggText ?? "없음", + cityText: cityText ?? "없음", + bdsgUsgText: bdsgUsgText, + lawTrgtYn: lawTrgtYn, + }; + } else { + returnData = { + ...item, + sggText: sggText ?? "없음", + cityText: cityText ?? "없음", + }; } return returnData; - - }); - } - - - - export const excelDownload =(excelList: [][], fileNm:string ,sampleFile:string, headerRange='A1:V3') =>{ - if (excelList.length === 0) return; - fetch(`/${sampleFile}`, {}) - .then(async (response) => { - if (!response.ok) { - throw Error(response.statusText) - } - // 받은 파일 바인너리 처리 - const blobRet = await response.arrayBuffer() - // 버퍼에 있는 엑셀데이터 전달 후 json으로 변환 - await filePickedBlob(blobRet, excelList,fileNm, 4,headerRange) - }) -} + } + ); +}; +export const excelDownload = ( + excelList: [][], + fileNm: string, + sampleFile: string, + headerRange = "A1:V3" +) => { + if (excelList.length === 0) return; + fetch(`/${sampleFile}`, {}).then(async (response) => { + if (!response.ok) { + throw Error(response.statusText); + } + // 받은 파일 바인너리 처리 + const blobRet = await response.arrayBuffer(); + // 버퍼에 있는 엑셀데이터 전달 후 json으로 변환 + await filePickedBlob(blobRet, excelList, fileNm, 4, headerRange); + }); +}; // onchange 텍스트를 숫자로 and ,제거 export const handleCommaNumberChange = ( @@ -82,4 +92,15 @@ export const formatCommaNumber = ( ): string => { if (value === undefined || value === null || value === "") return ""; return Number(value).toLocaleString(); -}; \ No newline at end of file +}; + +export const getCityOrSgg = (ref: RefObject<ReturnType>) => { + let con; + if (ref.current != null) + if (ref.current.sigunValue != "0") { + con = ref.current.sigunValue; + } else { + con = ref.current.sidoValue; + } + return con; +}; diff --git a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx index 62af8cd19..17027335c 100644 --- a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx @@ -30,7 +30,7 @@ export default function HtdflRegForm({ htdflForm: customHtdflBdst; isModal: boolean; }) { - const { code, htdflUpdate, htdflReg } = useWrStore((state) => state); + const { code, htdflBdstUpdate, htdflBdstReg } = useWrStore((state) => state); const defaultValues: z.infer<typeof hdtflZod> = hdtflZod.parse({}); @@ -41,15 +41,12 @@ export default function HtdflRegForm({ const onSubmit = (values: z.infer<typeof hdtflZod>) => { if (isModal) { - htdflReg(values); + htdflBdstReg(values,'41'); } else { - htdflUpdate(values); + htdflBdstUpdate(values ,'41'); } }; - const onSelectValue = (val: string | number) => { - console.log(val); - }; const cleanHtdflData = (raw: any): z.infer<typeof hdtflZod> => { return { @@ -159,7 +156,7 @@ export default function HtdflRegForm({ label={""} selectClass={selectClass} selectArray={code.yn} - onSelectValue={onSelectValue} + onSelectValue={field.onChange} value={field.value ?? code.yn[0]?.val} /> </FormUi> @@ -259,7 +256,7 @@ export default function HtdflRegForm({ label={""} selectClass={selectClass} selectArray={code.yn} - onSelectValue={onSelectValue} + onSelectValue={field.onChange} value={field.value ?? code.yn[0]?.val} /> </FormUi> @@ -296,7 +293,7 @@ export default function HtdflRegForm({ selectClass={selectClass} label={""} selectArray={code.yn} - onSelectValue={onSelectValue} + onSelectValue={field.onChange} value={field.value ?? code.yn[0]?.val} /> </FormUi> diff --git a/apps/wr/components/ui/modal/headChModal/headChModal.tsx b/apps/wr/components/ui/modal/headChModal/headChModal.tsx index 2f1236f27..1f97373ca 100644 --- a/apps/wr/components/ui/modal/headChModal/headChModal.tsx +++ b/apps/wr/components/ui/modal/headChModal/headChModal.tsx @@ -1,5 +1,5 @@ import { useWrStore } from "@/app/store"; -import { rainSttnHeadListType } from "@/app/store/ruseFcltMng/fcltSttn/rainSttn/headList"; +import { sttnHeadListType } from "@/app/store/ruseFcltMng/fcltSttn/rainSttn/headList"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@common/business_components/ui"; import { Button, Checkbox } from "@common/components/ui"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -7,38 +7,32 @@ import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; -export default function HeadChModal({type }:{type: string }) { - const { rainSttn ,rainChSttnHead} = useWrStore((state) => state); +export default function HeadChModal({headList, type }:{headList : z.infer<typeof sttnHeadListType> ,type:string }) { + const { rainChSttnHead , rswtChSttnHead} = useWrStore((state) => state); - const { rainSttHeadList, rainSttNodeList } =rainSttn; - let items = rainSttHeadList.map(item => ({id:item.id, title:item.title, val:item.visible })); + let items = headList.map(item => ({id:item.id, title:item.title, val:item.visible })); - - // const FormSchema = - // z.object({ - // id: z.string().refine((value) => value.some((item) => item), { - // message: "최소한 하나를 선택해주시길 바랍니다.", - // }), - // visible: z.boolean() - // }) - - - const form = useForm<z.infer<typeof rainSttnHeadListType>>({ - resolver: zodResolver(rainSttnHeadListType), + const form = useForm<z.infer<typeof sttnHeadListType>>({ + resolver: zodResolver(sttnHeadListType), defaultValues: [], }) useEffect(() =>{ - form.reset(rainSttHeadList) + form.reset(headList) - },[rainSttHeadList]) + },[headList]) - const onSubmit = (headList : z.infer<typeof rainSttnHeadListType> ) =>{ - rainChSttnHead(headList) + const onSubmit = (valueList : z.infer<typeof sttnHeadListType> ) =>{ + if(type==='RNB'){ + + rainChSttnHead(valueList) + }else if(type=== 'RST'){ + rswtChSttnHead(valueList) + } } return ( diff --git a/apps/wr/public/sample_rswtSttn.xlsx b/apps/wr/public/sample_rswtSttn.xlsx new file mode 100644 index 000000000..9f6024752 Binary files /dev/null and b/apps/wr/public/sample_rswtSttn.xlsx differ