diff --git a/apps/wr/app/matMng/coMng/coSttn/page.tsx b/apps/wr/app/matMng/coMng/coSttn/page.tsx index 163ed1b40..781a02210 100644 --- a/apps/wr/app/matMng/coMng/coSttn/page.tsx +++ b/apps/wr/app/matMng/coMng/coSttn/page.tsx @@ -71,6 +71,7 @@ export default function CoSttn() { const getSgg = useCallback((val: string | number) => { setObjSearch((prev) => ({ ...prev, sgg: String(val) })); + setPageNation(1) }, []); useEffect(() => { @@ -109,18 +110,18 @@ export default function CoSttn() { } }, [coSttnRes, code]); - useEffect(() => { - if (coSttn.excelList.length > 0) { - if (coSttn.excelList.length === 0) return; - excelDownload( - coSttn.excelList, - "수요처 관리", - "sample_coSttn.xlsx", - "A1:G1", - 2 - ); - } - }, [coSttn.excelList]); + // useEffect(() => { + // if (coSttn.excelList.length > 0) { + // if (coSttn.excelList.length === 0) return; + // excelDownload( + // coSttn.excelList, + // "수요처 관리", + // "sample_coSttn.xlsx", + // "A1:H1", + // 2 + // ); + // } + // }, [coSttn.excelList]); @@ -133,7 +134,7 @@ export default function CoSttn() { excelData as [], "수요처 관리", "sample_coSttn.xlsx", - "A1:F1", + "A1:G1", 2 ); } @@ -146,12 +147,19 @@ export default function CoSttn() { if (con) { if (seartchTxt && seartchTxt?.length > 0) { - coSttnTxtSearch("1", "13", String(con), seartchTxt ?? ""); + coSttnTxtSearch(String(pageNation), "13", String(con), seartchTxt ?? ""); } else { - coSttnSearch("1", "13", String(con)); + coSttnSearch(String(pageNation), "13", String(con)); } } }; + + useEffect(() =>{ + + },[pageNation]) + + + return ( <> @@ -166,7 +174,10 @@ export default function CoSttn() { label="시도" selectClass={""} selectArray={code.cityCd || []} - onSelectValue={getSelCity} + onSelectValue={(val)=>{ + getSelCity(val) + setPageNation(1) + } } value={objSearch.city} /> { - setUpdateData(undefined); setIsDmdModal({ ...isDmdModal, isMoal: true }); }} @@ -243,7 +253,13 @@ export default function CoSttn() { cellClick={(index: number | undefined, headId: string) => { setUpdateData(coSttnRes[index as number]); }} - onPageChange={setPageNation} + onPageChange={(page) =>{ + const con = (objSearch.sgg && objSearch.sgg !== "0") ? objSearch.sgg : objSearch.city; + setPageNation(page) + coSttnSearch( String(page), "13", String(con)); + + + } } > diff --git a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx index 873ad85f3..c80d5b4b4 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/htdflReg/page.tsx @@ -38,7 +38,7 @@ export default function Home() { chgBuilding: chgBuilding[]; }>({ isOpen: false, chgBuilding: [] }); - const { htdflRes } = htdfl; + const { htdflRes ,htdflResCount} = htdfl; useEffect(() => { if (!htdfl.isInit) { @@ -101,7 +101,7 @@ export default function Home() { { setSearchTxt(e); @@ -137,9 +137,9 @@ export default function Home() { { cellClick(val || undefined, headId); }} diff --git a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx index 6c97f6c8c..5b358977b 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/rainReg/page.tsx @@ -29,7 +29,7 @@ export default function Home() { return state; } ); - const { rainRes,rainResCount } = rain; + const { rainRes, rainResCount } = rain; const [rainForm, setRainForm] = useState(); const [issNewReg, setIsNewReg] = useState(false); const [pageNation, setPageNation] = useState(1); @@ -48,26 +48,27 @@ export default function Home() { }, [rain.isInit, initRain]); useEffect(() => { - if (code.sggCd.length > 0) { + if (code.sggCd.length > 0) { + if (rainRes && rainRes.length > 0) { + const rainData = tableData(rainRes, { code }).map( + (item: customRainBdst) => { + let archArea = + item?.archArea.split(".")[0] !== "-1" + ? item?.archArea.split(".")[0] + : "확인불가"; + return { + ...item, + archArea: archArea, - if(rainRes&& rainRes.length>0){ + bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N", + }; + } + ); - const rainData = tableData(rainRes, { code }).map( - (item: customRainBdst) => { - let archArea = item?.archArea.split('.')[0]!=='-1'?item?.archArea.split('.')[0]:'확인불가' - return { - ...item, - archArea:archArea, - - bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N", - }; - } - ); - - setbdstTable(rainData); - }else{ - setbdstTable([]); - } + setbdstTable(rainData); + } else { + setbdstTable([]); + } } }, [code, rainRes]); const cellClick: (val: number | undefined, headId: string) => void = ( diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index baafd8053..50f0afeea 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -30,8 +30,10 @@ export default function PbnstSttn() { pbnSttnInit, getPbnStnDetail, pbnNmSearch, + getFlcts } = useWrStore((state) => state); + const { pbnstSttnRes, fclts,pbnstSttnResCount} =pbnstSttn const ref = useRef({} as ReturnType); const [searchYear, setSearchYear] = useState( String(new Date().getFullYear()) @@ -48,21 +50,21 @@ export default function PbnstSttn() { const [pbnRuseNm, setPbnRuseNm] = useState(""); const excelClick = useCallback(() => { - pbnstSttnSearch(true, String(pageNation), "20", ref.current, "", searchYear); - }, [pbnstSttnSearch]); + pbnstSttnSearch(true, String(pageNation), "100000", ref.current, pbnRuseNm, searchYear,fclts ); + }, [pbnstSttnSearch,fclts,pbnRuseNm]); const cellCLick = useCallback( (index: number | undefined) => { if ( index !== undefined && - pbnstSttn.pbnstSttnRes && - pbnstSttn.pbnstSttnRes[index] + pbnstSttnRes && + pbnstSttnRes[index] ) { - const pbnstRuseFcltPk = pbnstSttn.pbnstSttnRes[index].pbnstRuseFcltPk; + const pbnstRuseFcltPk = pbnstSttnRes[index].pbnstRuseFcltPk; getPbnStnDetail(pbnstRuseFcltPk); } }, - [getPbnStnDetail, pbnstSttn.pbnstSttnRes] + [getPbnStnDetail, pbnstSttnRes] ); useEffect(() => { @@ -71,31 +73,28 @@ export default function PbnstSttn() { pbnstSttn.excelList, "하수재이용시설 현황", "sample_pbnstSttn.xlsx", - "A1:U2" + "A1:U2", + 3 ); } }, [pbnstSttn.excelList]); useEffect(() => { if (!pbnstSttn.isInit) { - pbnSttnInit("1", "20", ref.current, searchYear); + getFlcts() + } }, [pbnstSttn.isInit, pbnSttnInit, ref.current]); useEffect(() => { - setBdstTable(pbnstSttn.pbnstSttnRes); - }, [pbnstSttn.pbnstSttnRes]); + if(pbnstSttnRes && pbnstSttnRes.length>0) { + setBdstTable(pbnstSttnRes); + }else{ + setBdstTable([]); + } + }, [pbnstSttnRes]); - // useEffect(() => { - // pbnstSttnSearch("1", "20", ref.current, pbnRuseNm, searchYear); - // }, [pageNation, ref.current, pbnRuseNm, searchYear, pbnstSttnSearch]); - - // useEffect(() => { - // if (pbnRuseNm.length > 1) - // pbnNmSearch(String(pageNation), "23", ref.current, pbnRuseNm, searchYear); - // }, [pbnRuseNm,pageNation]); - - useEffect(() => { - pbnstSttnSearch(false, String(pageNation), "20", returnType, pbnRuseNm, searchYear); - }, [pageNation]); + useEffect(() =>{ + pbnSttnInit("1", "15", ref.current, searchYear, pbnstSttn.fclts); + },[fclts]) useEffect(() => { if (pbnstSttn.pbnstDetail.pbnstRuseFcltPk) @@ -157,12 +156,14 @@ export default function PbnstSttn() { } queryClick={function (returnType: ReturnType): void { - console.log("시군구코드", returnType) setReturnType(returnType); - pbnstSttnSearch(false, "1", "20", returnType, pbnRuseNm, searchYear); + pbnstSttnSearch(false, "1", "15", returnType, pbnRuseNm, searchYear, fclts); }} excelClick={excelClick} - initClick={function (): void { }} + initClick={function (): void { + setPbnRuseNm('') + + }} btnClass={btnClass} ref={ref} isAdmin={false} @@ -179,8 +180,8 @@ export default function PbnstSttn() { } headlist={pbnstSttn.pbnstSttHeadList} - pageSize={20} - total={100000} + pageSize={15} + total={pbnstSttnResCount} cellClick={(index: number | undefined, headId: string) => { cellCLick(index); }} @@ -188,10 +189,11 @@ export default function PbnstSttn() { pbnstSttnSearch( false, String(page), - String(20), + String(15), ref.current, pbnRuseNm, - searchYear + searchYear, + fclts ); }} > diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index c54725ff2..20e3652dd 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -37,7 +37,6 @@ import { type PrfType, } from "@/app/store/prfmncReg/pbnstPrfmncReg/type"; import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel"; -import data from "@common/components/ui/icon-finder/data"; export default function prfmncPrfmncReg() { const { code, prfmnc, prfmncHasuInit, prfmnRegData } = useWrStore( @@ -169,7 +168,12 @@ export default function prfmncPrfmncReg() { } }, [prfmnc.isInit, prfmncHasuInit]); useEffect(() => { - setbdstTable(prfmncRes); + + + if(prfmncRes&&prfmncRes.length>0){ + + setbdstTable(prfmncRes); + } // cellNum이 0일 경우(첫 번째 행)도 유효한 인덱스이므로 undefined 여부만 체크합니다. if (cellNum !== undefined) { diff --git a/apps/wr/app/store/common/code/index.ts b/apps/wr/app/store/common/code/index.ts index b3cf48603..5eecb83c4 100644 --- a/apps/wr/app/store/common/code/index.ts +++ b/apps/wr/app/store/common/code/index.ts @@ -3,6 +3,11 @@ import type { EnvPartSelectDataType, SelectDataType } from "@common/business_com import { bdstFilterYn, bdstGrntchClass, bdstIncenYn, bdstUsgCd, chBuCd, dmdUszCd, erctUswtrPrcsMeth, htdPowerMthdCd, htdUtztnUsgCd, orgwtKndCd, pplLenght, pplQulity, rainFcltCd, rswtPrscCdMthdCd, ruseBizMthdCd, ruseMngMtd, rusePrcsMthdCd, ruseSeCd, yn } from "./basicCode"; export const btnClass = "p-4 m-2 text-white rounded-sm text-lg font-medium " + +const laeSecd = '41' +const ogdpSeCd = '0' + + export const buildingType = { RST:"RST", RNB:"RNB", @@ -167,6 +172,8 @@ export type comCodeState = { rswtPrscCdMthdCd:SelectDataType[]; htdPowerMthdCd:SelectDataType[] htdUtztnUsgCd:SelectDataType[] + userSiSggCd : string; + }; }; @@ -203,6 +210,7 @@ export const comCodeStateExport: comCodeState = { rswtPrscCdMthdCd:rswtPrscCdMthdCd, htdPowerMthdCd:htdPowerMthdCd, htdUtztnUsgCd:htdUtztnUsgCd, + userSiSggCd:laeSecd, }, }; diff --git a/apps/wr/app/store/matDmd/coSttn/excel.tsx b/apps/wr/app/store/matDmd/coSttn/excel.tsx index 05b45711a..3b6d73c8b 100644 --- a/apps/wr/app/store/matDmd/coSttn/excel.tsx +++ b/apps/wr/app/store/matDmd/coSttn/excel.tsx @@ -2,7 +2,6 @@ import moment from "moment"; export const excelCoSttnParsing = (data: any[]): string[][] => { const excelExportData: string[][] = []; - data.forEach((item) => { excelExportData.push([ String(item.cityText)??'', diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx index 53b43e0f3..408d746e3 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx @@ -87,9 +87,6 @@ export const buildingToExcelType = ( export const excelToRainChkData = (excelData: any, year: string) => { const errors: string[] = []; const rainChkgdData: rainChkZodType[] = excelData.map((item: any) => { - - - console.log('item ', item) if (item["점검일"] !== undefined) { const checkYmd = item["점검일"].replace(/\./g, "") let vltnDt = item["과태료 부과일(위반일)"] @@ -110,7 +107,6 @@ export const excelToRainChkData = (excelData: any, year: string) => { flg: "RNB", }; }); - return { bdstNm:item["시설명"] ?? "", bdstRuseFcltFk: Number(item["NO"]), @@ -138,64 +134,67 @@ export const excelToRainChkData = (excelData: any, year: string) => { } }).filter((el: any) => el !== undefined); - // ✨ 오류 검사 - 가공된 데이터 기준 - const isInvalidNumber = (val: any) => - val !== undefined && val !== null && val !== "" && isNaN(Number(val)); + return rainChkgdData; + // // ✨ 오류 검사 - 가공된 데이터 기준 + // const isInvalidNumber = (val: any) => + // val !== undefined && val !== null && val !== "" && isNaN(Number(val)); - const isInvalidDate = (val: any) => - typeof val === "string" && !/^\d{4}\.\d{2}\.\d{2}$/.test(val.trim()); + // const isInvalidDate = (val: any) => + // typeof val === "string" && !/^\d{4}\.\d{2}\.\d{2}$/.test(val.trim()); - const buildErrorMessage = (item: any, issues: string[]): string => { - const 시설명 = item.bdstNm ?? ""; - const 점검일 = item.chckYmd ?? ""; - const 이용용도 = item.utztnUsgCd ?? ""; - return `시설명: ${시설명}, 점검일: ${점검일}, 이용용도: ${이용용도} (=> ${issues.join(", ")})`; - }; + // const buildErrorMessage = (item: any, issues: string[]): string => { + // const 시설명 = item.bdstNm ?? ""; + // const 점검일 = item.chckYmd ?? ""; + // const 이용용도 = item.utztnUsgCd ?? ""; + // return `시설명: ${시설명}, 점검일: ${점검일}, 이용용도: ${이용용도} (=> ${issues.join(", ")})`; + // }; - if (rainChkgdData.length > 0) { - rainChkgdData.forEach((rain: any) => { - const item = rain.__origin; // 원본 item - const issues: string[] = []; + // if (rainChkgdData.length > 0) { + // rainChkgdData.forEach((rain: any) => { + // const item = rain.__origin; // 원본 item + // const issues: string[] = []; - if (rain.chckYmd && isInvalidDate(rain.chckYmd)) { - issues.push(`점검일: 날짜 형식 아님 (${rain.chckYmd})`); - } + // if (rain.chckYmd && isInvalidDate(rain.chckYmd)) { + // issues.push(`점검일: 날짜 형식 아님 (${rain.chckYmd})`); + // } - if (rain.vltnDt && isInvalidDate(rain.vltnDt)) { - issues.push(`과태료 부과일(위반일): 날짜 형식 아님 (${rain.vltnDt})`); - } + // if (rain.vltnDt && isInvalidDate(rain.vltnDt)) { + // issues.push(`과태료 부과일(위반일): 날짜 형식 아님 (${rain.vltnDt})`); + // } - // [ - // "연간운영비(원/년)", "PH", "탁도", "총대장균군수", "과태료부과금액(천원)" - // ].forEach((key) => { - // if (isInvalidNumber(item[key])) { - // issues.push(`${key}: 숫자 형식 아님 (${item[key]})`); - // } - // } + // // [ + // // "연간운영비(원/년)", "PH", "탁도", "총대장균군수", "과태료부과금액(천원)" + // // ].forEach((key) => { + // // if (isInvalidNumber(item[key])) { + // // issues.push(`${key}: 숫자 형식 아님 (${item[key]})`); + // // } + // // } - // ); + // // ); - for (let i = 1; i <= 12; i++) { - const month = `${i}월`; - if (isInvalidNumber(item[`대체_${month}`])) { - issues.push(`대체_${month}: 숫자 형식 아님 (${item[`대체_${month}`]})`); - } - if (isInvalidNumber(item[`빗물_${month}`])) { - issues.push(`빗물_${month}: 숫자 형식 아님 (${item[`빗물_${month}`]})`); - } - } + // for (let i = 1; i <= 12; i++) { + // const month = `${i}월`; + // if (isInvalidNumber(item[`대체_${month}`])) { + // issues.push(`대체_${month}: 숫자 형식 아님 (${item[`대체_${month}`]})`); + // } + // if (isInvalidNumber(item[`빗물_${month}`])) { + // issues.push(`빗물_${month}: 숫자 형식 아님 (${item[`빗물_${month}`]})`); + // } + // } - if (issues.length > 0) { - errors.push(buildErrorMessage(item, issues)); - } - }); - } + // if (issues.length > 0) { + // errors.push(buildErrorMessage(item, issues)); + // } + // }); + // } - if (errors.length > 0) { - return { rainChkgdData: [], errors }; - } + // if (errors.length > 0) { + // return { rainChkgdData: [], errors }; + // } - return { rainChkgdData, errors: [] }; + // return { rainChkgdData, errors: [] }; + + return rainChkgdData; }; diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx index 387f56eb7..87007d5f6 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx @@ -68,7 +68,7 @@ const hasuListFetch = async (page: number, sggOrCity: string) => { prfList: data.prfList, }); } - }); + }).filter(Boolean); // undefined 값을 제거합니다. return findData; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx index feaefc03f..b241fe7f1 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/htdflReg/index.tsx @@ -177,7 +177,7 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = ( if (res.status) { toast.success("온배수 건축물 수정이 완료되었습니다."); } - const htdflRes = await getFetch( + const htdflRes = await getFetchWithCount( "wr", `/drain/facilityList/1/10/${code}` ); diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 46287aa2c..569fad381 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -7,7 +7,7 @@ export const pubFacHeadListExport: TableUpperProps[] = [ { id: "bscFctNm", title: "시설명" }, { id: "addr", title: "위치" }, { id: "efflWqltStndrdNm", title: "지역구분" }, - { id: "fctCpc", title: "시설용량" }, + { id: "fctCpc", title: "시설용량(m³/일)" }, { id: "ruse", title: "재이용여부" }, { id: "rswtrYn", title: "등록여부" }, ]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx index 67ea71cb6..b0ea5fd37 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx @@ -28,8 +28,8 @@ const rainyObjSchema = z.object({ export const rainZod = z.object({ bdstInfoPk: z.number().optional(), - ctpvCd: z.number().default(0), - sggCd: z.number().default(0), + ctpvCd: z.number().optional(), + sggCd: z.number().optional(), daddr: z.string().default(""), bdstNm: z.string().default(""), frstArchPrmsnDt: z.date().default(() => new Date()), @@ -83,6 +83,7 @@ type rainFacSActions = { rainSearch: (txt:string,pageNation:number,code:string|number) => void; rainBdstReg: (data: customRainBdst, code:string|number) => void; rainBdstUpdate: (data: customRainBdst, code:string|number) => void; + }; export type rainFacType = rainFacState & rainFacSActions; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/type.tsx index 2d17b4601..80811d7ce 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/type.tsx @@ -11,7 +11,10 @@ export const baseReuseBuildingSchema = z.object({ bdstRuseFcltPk: z.number().nullish(), bdstInfoFk: z.number().nullish(), instlCmptnDt: z.coerce.date().default(() => new Date()), - instlCst: z.number().nullish(), + instlCst: z + .number() + .max(9_999_999, { message: "최대 9,999,999까지 입력 가능합니다." }) + .nullish(), operMngCd: z.string().optional().default(""), anlOperCst: z.number().default(0), instlCstSprtYn: z.string().default("Y"), diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx index 475c1797d..8c3579a5d 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rswtReg/index.tsx @@ -30,8 +30,8 @@ import toast from "react-hot-toast"; export const rswtZod = z.object({ bdstInfoPk: z.number().nullish(), - ctpvCd: z.number().default(0), - sggCd: z.number().default(0), + ctpvCd: z.number(), + sggCd: z.number(), daddr: z.string().default(""), bdstNm: z.string().default(""), frstArchPrmsnDt: z.date().default(() => new Date()), @@ -182,7 +182,7 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = ( const chData = await makeRstr(data); const res = await postFectch("/reuseFc/waterreuseFc", chData); if (res.status===200) { - if(data.chgBuilding.length > 0){ + if(data.chgBuilding ){ const chPK = res?.data?.bdstInfoPk const makeCh= res.data.chgBuilding.map((item: chgBuilding) => diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx index 8a1db05a2..d39a63680 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx @@ -13,15 +13,19 @@ export const excelPbnstSttnParsing = (data: any[]): string[][] => { String(item.gugun ?? ""), String(item.bscFctNm ?? ""), String(item.efflWqltStndrdNm ?? ""), - String(item.fctCpc ?? ""), String(item.tel ?? ""), + String(item.fctCpc ?? ""), String(item.ruseUtztnFcltNm ?? ""), String(item.fcltCpct ?? ""), String(item.splyExtraCpct ?? ""), String(item.ruseCpct ?? ""), String(item.usageTotal ?? ""), String(item.inUsage ?? ""), - String(item.outUsage ?? ""), + String(item.outUsage ?? ""), + String(item.operMthd ?? ""), + String(item.rprtvBzenty ?? ""), + String(item.bgngDt ?? ""), + String(item.endDt ?? ""), ]) }) return excelExportData; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx index 76a13943f..f54eb5cbd 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx @@ -1,5 +1,5 @@ import type { CommonTableProps, TableUpperProps } from "@/app/store/common/type/header"; -import type { z } from "zod"; +import { any, type z } from "zod"; import { pbnSttHeadListExport, pbnstSttNodeListExport, ruseDmdHeadListExport, ruseFcltHeadListExport, ruseFcltNodeListExport, ruseGuranteeHeadListExport, rusePplHeadListExport, ruseSplyHeadListExport } from "./headList"; import { fetchType, getFetch, postFectch } from "@/components/lib/api"; import { controlHeadView } from "../rainSttn"; @@ -27,7 +27,9 @@ export type pbnstSttnState = { ruseGuranteeHeadList: TableUpperProps[] ruseDmdHeadList: TableUpperProps[] ruseFcltHeadList: TableUpperProps[] + pbnstSttnResCount:number; excelList: []; + fclts:string[] isInit: boolean; }; }; @@ -41,12 +43,15 @@ type pbnstSttnActions = { reurnValue: ReturnType, searchNm: string | undefined, year: string, + fclts:string[] ) => void; + getFlcts:()=>void; pbnSttnInit: ( page: string, total: string, reurnValue: ReturnType, - year: string + year: string, + flcts:string[] ) => void; getPbnStnDetail: (pbnstRuseFcltPk: string) => void; pbnNmSearch: ( @@ -71,9 +76,11 @@ export const pbnstSttnStateExport: pbnstSttnState = { ruseDmdHeadList: ruseDmdHeadListExport, ruseFcltHeadList: ruseFcltHeadListExport, pbnstSttnRes: [], + pbnstSttnResCount:1, pbnstDetail: {} as customPbnst, pbnstSearchData: [], excelList: [], + fclts:[], isInit: false, }, }; @@ -83,105 +90,112 @@ const hasuListFetch = async ( total: string, reurnValue: ReturnType, searchNm: string | undefined, - year: string + year: string, + flcts:string[] ) => { + let url = `/prcsFclt/ruseInfo/`; - let url = ""; if (reurnValue.partValue === "A") { - url = `/prcsFclt/info/${page}/${total}/${reurnValue.partValue}/${ + url+=`${page}/${total}/${reurnValue.partValue}/${ // reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue reurnValue.sigunValue !== '0' ? reurnValue.sigunValue : reurnValue.sidoValue }/0/1/SW` } else if (reurnValue.partValue === "R") { - url = `/prcsFclt/info/${page}/${total}/${reurnValue.partValue}/${reurnValue.regionValue + url += `${page}/${total}/${reurnValue.partValue}/${reurnValue.regionValue ? reurnValue.regionValue : reurnValue.unitWaterShedValue ? reurnValue.unitWaterShedValue : reurnValue.middleRegionValue }/0/1/SW` - } else { - url = `/prcsFclt/info/${page}/${total}/${reurnValue.envPartValue}/${reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue}/0/1/SW` + } else if( reurnValue.partValue === 'G'){ + console.log('reurnValue.sigunValue ', reurnValue.sidoValue) + + console.log('reurnValue.sigunValue ', reurnValue.sigunValue) + url += `${page}/${total}/${reurnValue.envPartValue}/${reurnValue.sigunValue !== '0' ? reurnValue.sigunValue : reurnValue.sidoValue}/0/1/SW` + + }else{ + url += `1/2/A/0/0/1/SW` } + if (searchNm && searchNm?.length > 0) { url += "/" + searchNm } - - console.log("주소", url) - const pbnList = await getFetch(fetchType.COMMON, url); - console.log("pbnList", pbnList) - const arrayList = pbnList.map((item: pubHasuType) => item.bscFctCd); - console.log("어레이리스트", arrayList) + const pbnList = await postFectch(url, flcts,fetchType.COMMON); const getRuseList = await postFectch( `/reuseFc/pubDetailList/${year}`, - arrayList, + flcts, fetchType.WR ); - console.log("getRuseList", getRuseList) const checkWrRegListRes = getRuseList.data; + const count = getRuseList.count; const data: WaterReuseFacility[] = checkWrRegListRes.map( (item: FcPrfType) => { - const findData = pbnList.find( + const findData = pbnList.data.find( (fclt: pubHasuType) => fclt.bscFctCd === item.pbnstRuseFcltPk.substring(0, 11) ); + if(findData){ - const usage = item.prfList.reduce( - (acc, cur) => { - acc.inUsage += - cur.wshwtr + - cur.coolUswtr + - cur.cleanUswtr + - cur.drwtUswtr + - cur.dltnUswtr + - cur.ithlRswtr + - cur.ithlEtcUswtr + - cur.cleanToilUswtr + - cur.resn; - acc.outUsage += - cur.lndwtr + - cur.hydUswtr + - cur.ugwtChr + - cur.farmUswtr + - cur.rvrKeepUswtr + - cur.indstUswtr; - acc.total = acc.inUsage + acc.outUsage; + const usage = item.prfList.reduce( + (acc, cur) => { + acc.inUsage += + cur.wshwtr + + cur.coolUswtr + + cur.cleanUswtr + + cur.drwtUswtr + + cur.dltnUswtr + + cur.ithlRswtr + + cur.ithlEtcUswtr + + cur.cleanToilUswtr + + cur.resn; + acc.outUsage += + cur.lndwtr + + cur.hydUswtr + + cur.ugwtChr + + cur.farmUswtr + + cur.rvrKeepUswtr + + cur.indstUswtr; + acc.total = acc.inUsage + acc.outUsage; + + return acc; + }, + { total: 0, inUsage: 0, outUsage: 0 } + ); + + return { + rvbsn: findData?.rvbsn ||'-', + lgbsn: findData?.lgbsn||'-', + mdmbsn: findData?.mdmbsn||'-', + rgnNm: findData?.rgnNm||'-', + sido: findData?.sido||'-', + gugun: findData?.gugun||'-', + bscFctNm: findData?.bscFctNm||'-', + efflWqltStndrdNm: findData?.efflWqltStndrdNm||'-', + fctCpc: Number(findData?.fctCpc)||0, + tel: findData?.tel ?? "-", + ruseUtztnFcltNm: item?.ruseUtztnFcltNm||'-', + fcltCpct: item?.fcltCpct||'-', + splyExtraCpct: item?.splyExtraCpct||'-', + ruseCpct: item?.ruseCpct||'-', + pbnstRuseFcltPk: item.pbnstRuseFcltPk||'-', + usageTotal: usage?.total, + inUsage: usage?.inUsage, + outUsage: usage?.outUsage, + operMthd: item.operList[0]?.operMthd||'-', + rprtvBzenty: item.operList[0]?.rprtvBzenty, + bgngDt: moment(item.operList[0]?.bgngDt).format("YYYY-MM-DD") ?? "", + endDt: moment(item.operList[0]?.endDt).format("YYYY-MM-DD") ?? "", + searchNm: findData?.bscFctNm||'-', + searchPk: findData?.bscFctCd||'-', + prfList: item?.prfList ?? [] + }; + } - return acc; - }, - { total: 0, inUsage: 0, outUsage: 0 } - ); - - return { - rvbsn: findData?.rvbsn, - lgbsn: findData?.lgbsn, - mdmbsn: findData?.mdmbsn, - rgnNm: findData?.rgnNm, - sido: findData?.sido, - gugun: findData?.gugun, - bscFctNm: findData?.bscFctNm, - efflWqltStndrdNm: findData?.efflWqltStndrdNm, - fctCpc: findData.fctCpc, - tel: findData?.tel ?? "-", - ruseUtztnFcltNm: item.ruseUtztnFcltNm, - fcltCpct: item.fcltCpct, - splyExtraCpct: item.splyExtraCpct, - ruseCpct: item.ruseCpct, - pbnstRuseFcltPk: item.pbnstRuseFcltPk, - usageTotal: usage.total, - inUsage: usage.inUsage, - outUsage: usage.outUsage, - operMthd: item.operList[0]?.operMthd, - rprtvBzenty: item.operList[0]?.rprtvBzenty, - bgngDt: moment(item.operList[0]?.bgngDt).format("YYYY-MM-DD") ?? "", - endDt: moment(item.operList[0]?.endDt).format("YYYY-MM-DD") ?? "", - searchNm: findData.bscFctNm, - searchPk: findData.bscFctCd, - prfList: item?.prfList ?? [] - }; } - ); + ).filter(Boolean); + return data; }; @@ -189,6 +203,15 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( set: any ) => { return { + getFlcts:async ()=>{ + const fclts= await getFetch(fetchType.WR,'/reuseFc/pubFc') + return set((state: pbnstSttnState) => ({ + pbnstSttn: { + ...state.pbnstSttn, + fclts:fclts + }, + })); + }, pbnstChSttnHead: async ( headList: z.infer ): Promise => { @@ -209,22 +232,23 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( reurnValue: ReturnType, searchNm: string | undefined, year: string, + fclts:string[] ) => { try { - console.log("여기") + + const pbnstSttnRes = await hasuListFetch( page, total, reurnValue, searchNm, - year + year, + fclts, ); - console.log("pbnstSttnRes", pbnstSttnRes); // if (Number(total) > 9000) { if (isExcel) { const pbnstExcel = excelPbnstSttnParsing(pbnstSttnRes); - set((state: pbnstSttnState) => { return { ...state, @@ -234,43 +258,48 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( }, }; }); - } else + } else{ + set((state: pbnstSttnState) => { return { ...state, pbnstSttn: { ...state.pbnstSttn, pbnstSttnRes: pbnstSttnRes, - isInit: false, + pbnstSttnResCount:pbnstSttnRes.length + // isInit: false, }, }; }); + } } catch (erTxt) { console.log("error", erTxt); } }, - pbnSttnInit: async ( + pbnSttnInit: async( page: string, total: string, reurnValue: ReturnType, - year: string + year: string, + fclts:string[] ) => { try { - const pbnstSttnRes = await hasuListFetch( - page, - total, - reurnValue, - undefined, - year - ); + page, + total, + reurnValue, + undefined, + year, + fclts + ); - set((state: pbnstSttnState) => { + set( (state: pbnstSttnState) => { return { ...state, pbnstSttn: { ...state.pbnstSttn, pbnstSttnRes: pbnstSttnRes, + pbnstSttnResCount:pbnstSttnRes.length, isInit: false, }, }; @@ -321,6 +350,7 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( pbnstSttn: { ...state.pbnstSttn, pbnstSearchData: pbnstSttnRes, + pbnstSttnResCount:pbnstSttnRes.length, }, }; }); diff --git a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx index 886dd2da9..bceee1a17 100644 --- a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx +++ b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx @@ -24,6 +24,10 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { return state; }); + const {userSiSggCd } =code + const [useCityCd, setUserCityCd] = useState([]) + const [useSggCd, setUserSggCd] = useState([]) + const { fields, append, remove } = useFieldArray({ name: "chgBuilding", control: form?.control, // Provide a fallback to avoid errors @@ -52,6 +56,33 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { city: "", }); + useEffect(() =>{ + if(userSiSggCd.length===2 && code.cityCd.length>0){ + const city = code.cityCd.filter((item) => item.val === userSiSggCd) + const sgg = code.sggCd.filter((item) => item.val.slice(0,2) === userSiSggCd ) + sgg.unshift({text:'전체' , val:'0'}) + setUserCityCd(city) // Fix: Ensure city is of type SelectDataType[] + setUserSggCd(sgg) + if (city[0]?.val) { + // 여기 중요 + queueMicrotask(() => { + form.setValue("ctpvCd", Number(city[0]?.val), { shouldDirty: true, shouldTouch: true, shouldValidate: true }); + }); + } + }else if(userSiSggCd.length===5 && code.cityCd.length>0 && code.sggCd.length>0) { + const city = code.cityCd.filter((item) => item.val === userSiSggCd.slice(0,2)) + const sgg = code.sggCd.filter((item) => item.val === userSiSggCd) + setUserSggCd(sgg) + setUserCityCd(city) + form.setValue('ctpvCd',Number(city[0]?.val) ) + form.setValue('sggCd',Number(sgg[0]?.val) ) + + } + },[form, userSiSggCd, code.cityCd, code.sggCd]) + + + + const getSelCity = (val: string) => { const data = getCity(val, code.sggCd); setSelectSgg(data); @@ -87,6 +118,12 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { ); }; + useEffect(() =>{ + + console.log('form.formState ', form.watch()) + + },[form.formState]) + return ( <>

{ type !== "HTB"?"건축물 기본 정보": '시설 기본 정보'}

@@ -101,12 +138,11 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { className="col-span-3" label={""} selectClass={selectClass} - selectArray={code.cityCd} + selectArray={useCityCd} onSelectValue={(val) => { - getSelCity(String(val)); field.onChange(Number(val)); }} - value={field.value} + value={typeof field.value !== "undefined" ? field.value : useCityCd[0]?.val} /> )} @@ -122,9 +158,8 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) { className="col-span-3" label={""} selectClass={`w-full min-h-[2.9rem] ${selectClass}`} - selectArray={selectSgg ? selectSgg : code.sggCd || []} + selectArray={useSggCd} onSelectValue={(val) => { - getSgg(val); field.onChange(Number(val)); }} value={field.value} diff --git a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx index edd5bb1b5..5e0786f8b 100644 --- a/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/htdflReg/htdflRegForm.tsx @@ -61,7 +61,7 @@ export default function HtdflRegForm({ if (setIsModal) setIsModal(false); } else { - htdflBdstUpdate(values, "41"); + htdflBdstUpdate(values, "0"); } }; diff --git a/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx b/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx index da8011efd..974d9269c 100644 --- a/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/rainReg/rainRegForm.tsx @@ -39,7 +39,7 @@ export default function RainRegForm({ const defaultValues: z.infer = rainZod.parse({}); const form = useForm>({ resolver: zodResolver(rainZod), - defaultValues: defaultValues, + // defaultValues: defaultValues, }); const instlCst = form.watch(`reuseBuilding.0.instlCst`); diff --git a/apps/wr/components/ui/form/fcltReg/rswtrReg/rswtrRegForm.tsx b/apps/wr/components/ui/form/fcltReg/rswtrReg/rswtrRegForm.tsx index 3c8af831d..f70f4548c 100644 --- a/apps/wr/components/ui/form/fcltReg/rswtrReg/rswtrRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/rswtrReg/rswtrRegForm.tsx @@ -41,11 +41,11 @@ export default function RswtrRegForm({ (state) => state ); - const defaultValues: z.infer = rswtZod.parse({}); + // const defaultValues: z.infer = rswtZod.parse({}); const form = useForm>({ resolver: zodResolver(rswtZod), - defaultValues: defaultValues, + // defaultValues: defaultValues, }); const [grntchBdstCertYn, instlCstSprtYn, filtrTrtmfctProcs] = form.watch([ diff --git a/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx b/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx index a7b66d811..6ebbe4c6c 100644 --- a/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx +++ b/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx @@ -71,22 +71,26 @@ export default function ChkgdExcel({ type,setIsRegExcel }: { type: string, setI if (file) if (type === "RNB") { filePicked(file, 0).then((res) => { - if (res !== undefined){ + // if (res !== undefined){ - const excelData = excelToRainChkData(res, form.getValues("chckYr")) - - if( excelData&&excelData.errors.length>0){ + const excelData = excelToRainChkData(res, form.getValues("chckYr")) + if(res !== undefined) + setExcelData(excelData) + + // if( excelData&&excelData.errors.length>0){ - excelData.errors.forEach((err) =>{ - toast.error(err) - }) - }else{ + // excelData.errors.forEach((err) =>{ + // toast.error(err) + // }) + // }else{ - setExcelData(excelData.rainChkgdData) - } - } + // } + + // } - }); + + + }) } else if (type === "RST") { filePickedArray(file, 0).then((res) => { if (res && res?.length > 1) { diff --git a/apps/wr/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal.tsx index 25e5ef976..a049772e8 100644 --- a/apps/wr/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal.tsx @@ -4,7 +4,12 @@ import { selectClass, type customRainBdst, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { ScrollArea, SelectBox, UiTable, type SelectDataType } from "@common/business_components"; +import { + ScrollArea, + SelectBox, + UiTable, + type SelectDataType, +} from "@common/business_components"; import { Button, Input, Label } from "@common/components"; import { useEffect, useState } from "react"; import { getCity, tableData } from "@/components/lib/func/commom"; @@ -15,83 +20,117 @@ import RswtrRegForm from "@/components/ui/form/fcltReg/rswtrReg/rswtrRegForm"; import HtdflRegForm from "@/components/ui/form/fcltReg/htdflReg/htdflRegForm"; export type objSearchType = { - sgg: string|number; - city: string|number; - }; + sgg: string | number; + city: string | number; +}; //RNB(빗물), RST(중수도), HTB(온배수) - type MoType = 'RNB' | 'RST' | 'HTB'; // 여기에 'htdf' 추가 +type MoType = "RNB" | "RST" | "HTB"; // 여기에 'htdf' 추가 - type BdstTypeMap = { +type BdstTypeMap = { RNB: customRainBdst; RST: customRswtBdst; - HTB: customRswtBdst; // 해야해// 아직 아노딤 + HTB: customRswtBdst; // 해야해// 아직 아노딤 }; - interface BdstRegProps { +interface BdstRegProps { moType: T; - isModal:boolean; + isModal: boolean; + siSggCode?: string; setIsModal?: (open: boolean) => void; } -export function BdstReg({ moType,setIsModal,isModal }: BdstRegProps) { - const { rain, code, bdst,findBdst } = useWrStore((state) => { +export function BdstReg({ + moType, + setIsModal, + siSggCode, + isModal, +}: BdstRegProps) { + const { rain, code, bdst, findBdst } = useWrStore((state) => { return state; }); + + const { userSiSggCd } = code; + const [bdstTable, setbdstTable] = useState(); - const [rainBdstForm, setRainBdstForm] = useState({} as BdstTypeMap[T]); - const [searchTxt, setSearchTxt] = useState() - const [selectSgg, setSelectSgg] = useState() - const [objSearch, setObjSearch] = useState({sgg:"",city:""}); + const [rainBdstForm, setRainBdstForm] = useState( + {} as BdstTypeMap[T] + ); + const [searchTxt, setSearchTxt] = useState(); + const [selectSgg, setSelectSgg] = useState(); + const [objSearch, setObjSearch] = useState({ + sgg: "", + city: "", + }); + const [useCityCd, setUserCityCd] = useState([]); + const [useSggCd, setUserSggCd] = useState([]); + const [dataCode, setDataCode] = useState(); - const getSelCity = (val: string | number) => { - const cityValue = String(val); // Ensure val is treated as a string - const data = getCity(cityValue, code.sggCd); + const searchBdst = (searchTxt: string | undefined) => { + let data = objSearch.city; - setSelectSgg(data); - // getSgg(data[0]?.val || ""); - setObjSearch({ city: cityValue, sgg: '' }); + if (objSearch.sgg !== "" && objSearch.sgg !== "0") { + data = objSearch.sgg; + } + //RNB(빗물), RST(중수도), HTB(온배수) + findBdst(String(data), searchTxt || "", moType); }; - const getSgg = (val: string | number) => { - setObjSearch({...objSearch,sgg: String(val)}) - }; - - const searchBdst=(searchTxt: string | undefined)=>{ - let data =objSearch.city; - if(objSearch.city==="" ){ - - data = String(code.cityCd[0]?.val) - } - if(objSearch.sgg !=="" ){ - data = objSearch.sgg - } - - //RNB(빗물), RST(중수도), HTB(온배수) - findBdst(String(data), searchTxt || "",moType ) - - } - useEffect(() => { if (code.sggCd.length > 0) { - - setbdstTable( tableData(bdst.bdstBase, { code })); - } - }, [ bdst]); + const bdstData = bdst.bdstBase.map((bdst) => { + let archArea = + bdst?.archArea.split(".")[0] !== "-1" + ? bdst?.archArea.split(".")[0] + : "확인불가"; + return { + ...bdst, + archArea: archArea, + }; + }); + setbdstTable(tableData(bdstData, { code })); + } + }, [bdst]); + useEffect(() => { + if (userSiSggCd.length === 2 && code.cityCd.length > 0) { + const city = code.cityCd.filter((item) => item.val === userSiSggCd); + const sgg = code.sggCd.filter( + (item) => item.val.slice(0, 2) === userSiSggCd + ); + sgg.unshift({ text: "전체", val: "0" }); + setUserCityCd(city); // Fix: Ensure city is of type SelectDataType[] + setObjSearch({ ...objSearch, city: String(city[0]?.val) }); + setUserSggCd(sgg); + } else if ( + userSiSggCd.length === 5 && + code.cityCd.length > 0 && + code.sggCd.length > 0 + ) { + const city = code.cityCd.filter( + (item) => item.val === userSiSggCd.slice(0, 2) + ); + setUserCityCd(city); + const sgg = code.sggCd.filter((item) => item.val === userSiSggCd); + setUserSggCd(sgg); + setObjSearch({ city: String(city[0]?.val), sgg: String(sgg[0]?.val) }); + } + }, [userSiSggCd, code.cityCd, code.sggCd]); - const tableClick: (val: number | undefined , headId:string) => void = (val ,headId) => { - - if(val!==undefined && bdst?.bdstBase.length>0){ - const data:BdstTypeMap[T] =bdst?.bdstBase[val] - if (data) { - setRainBdstForm(data); - } + const tableClick: (val: number | undefined, headId: string) => void = ( + val, + headId + ) => { + if (val !== undefined && bdst?.bdstBase.length > 0) { + const data: BdstTypeMap[T] = bdst?.bdstBase[val]; + if (data) { + setRainBdstForm(data); } - } + } + }; - useEffect(()=>{ - setbdstTable([]) // 초기화 작업 - },[]) + useEffect(() => { + setbdstTable([]); // 초기화 작업 + }, []); return ( <>
@@ -99,31 +138,50 @@ export function BdstReg({ moType,setIsModal,isModal }: BdstReg className="col-span-3 h-full" label={"시도"} selectClass={selectClass} - selectArray={code.cityCd || []} - onSelectValue={getSelCity} - > - {""} - + selectArray={useCityCd} + onSelectValue={(val) => { + setObjSearch({ ...objSearch, city: String(val) }); + }} + value={objSearch.city || useCityCd[0]?.val} + > { + if (val) setObjSearch({ ...objSearch, sgg: String(val) }); + }} + value={objSearch.sgg || useSggCd[0]?.val} > {" "} - - setSearchTxt(e.target.value)}/> - + + setSearchTxt(e.target.value)} + /> +

건축물 목록 - (유의 사항: 신규등록하려는 건축물이 목록에 없을 경우 하단 건축물 정보에 추가하여 주시기 바랍니다.) + (유의 사항: 신규등록하려는 건축물이 목록에 없을 경우 하단 건축물 + 정보에 추가하여 주시기 바랍니다.)

@@ -134,24 +192,40 @@ export function BdstReg({ moType,setIsModal,isModal }: BdstReg pageSize={-10} total={-1} headName={undefined} - cellClick={(idx, headId) => (tableClick(idx, headId || ""))} + cellClick={(idx, headId) => tableClick(idx, headId || "")} onPageChange={function (page: number): void { throw new Error("Function not implemented."); - }}> - + }} + >
{/* */} -
- { moType === 'RNB'? - - :moType==='RST' - ? {setIsModal && setIsModal(open)}}> - :{setIsModal && setIsModal(open)}}> - } - -
+
+ {moType === "RNB" ? ( + + ) : moType === "RST" ? ( + { + setIsModal && setIsModal(open); + }} + > + ) : ( + { + setIsModal && setIsModal(open); + }} + > + )} +
{/*
*/}