diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx index 2e8b4ee48..7eadc17c1 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/chkgdnReg/page.tsx @@ -28,7 +28,7 @@ import { Toaster } from "react-hot-toast"; //----------------------- export default function Page() { - const { code, rainChkgdn, rainChkInit,rainChkDetilUpdate, rainChkDelete , rainChkExcelDownload } = useWrStore((state) => { + const { code, rainChkgdn, rainChkInit,rainChkDetilUpdate, rainChkDelete , rainChkExcelDownload, rswtrChkExcelDownload } = useWrStore((state) => { return state; }); const [isRegExcel, setIsRegExcel] = useState(false); @@ -60,9 +60,12 @@ export default function Page() { }, [rainChkgdn.excelList]); const excelClick= useCallback(()=>{ - - rainChkExcelDownload(code.cityCd, code.sggCd); - }, [rainChkExcelDownload, code.cityCd, code.sggCd]); + if(selFcltDiv === "RNB") { + rainChkExcelDownload(code.cityCd, code.sggCd); + } else { + rswtrChkExcelDownload(code.cityCd, code.sggCd); + } + }, [rainChkExcelDownload, rswtrChkExcelDownload, code.cityCd, code.sggCd]); diff --git a/apps/wr/app/store/common/code/index.ts b/apps/wr/app/store/common/code/index.ts index e5f25e318..86a03a120 100644 --- a/apps/wr/app/store/common/code/index.ts +++ b/apps/wr/app/store/common/code/index.ts @@ -3,25 +3,25 @@ import type { EnvPartSelectDataType, SelectDataType } from "@common/business_com -export const btnClass= "p-4 m-2 text-white rounded-sm text-lg font-medium " +export const btnClass = "p-4 m-2 text-white rounded-sm text-lg font-medium " - const yn :SelectDataType[]=[ - {val:'Y', text:'Y'}, - {val:'N', text:'N'}, +const yn: SelectDataType[] = [ + { val: 'Y', text: 'Y' }, + { val: 'N', text: 'N' }, ] //공통 건축물 용도 - const bdstUsgCd: SelectDataType[] = [ - { val: '-1', text: "확인불가" }, - { val: '1', text: "운동장" }, - { val: '2', text: "체육관" }, - { val: '3', text: "공공업무시설" }, - { val: '4', text: "공공기관의청사" }, - { val: '5', text: "아파트" }, - { val: '6', text: "연립주택" }, - { val: '7', text: "다세대주택" }, - { val: '8', text: "기숙사" }, - { val: '9', text: "초등학교" }, +const bdstUsgCd: SelectDataType[] = [ + { val: '-1', text: "확인불가" }, + { val: '1', text: "운동장" }, + { val: '2', text: "체육관" }, + { val: '3', text: "공공업무시설" }, + { val: '4', text: "공공기관의청사" }, + { val: '5', text: "아파트" }, + { val: '6', text: "연립주택" }, + { val: '7', text: "다세대주택" }, + { val: '8', text: "기숙사" }, + { val: '9', text: "초등학교" }, { val: '10', text: "중학교" }, { val: '11', text: "고등학교" }, { val: '12', text: "전문대학" }, @@ -31,7 +31,7 @@ export const btnClass= "p-4 m-2 text-white rounded-sm text-lg font-medium " { val: '16', text: "기타" }, ]; //빗물 집수면 종류 용도 - const rainFcltCd = [ +const rainFcltCd = [ { val: "1", text: "지붕" }, { val: "2", text: "건물옥상" }, { val: "3", text: "골프장 연못" }, @@ -44,7 +44,7 @@ export const btnClass= "p-4 m-2 text-white rounded-sm text-lg font-medium " { val: "10", text: "확인불가" }, ]; // 중수도 필수 원수종류 - const rswtBdstType: SelectDataType[] = [ +const rswtBdstType: SelectDataType[] = [ { text: "숙박업", val: "17" }, { text: "목욕장업", val: "18" }, { text: "공장", val: "19" }, @@ -84,28 +84,36 @@ const orgwtKndCd = [ { text: "기타", val: "5" }, ]; - const chBuCd = [ +const chBuCd = [ { val: "증축", text: "증축" }, { val: "개축", text: "개축" }, { val: "재축", text: "재축" }, ] - - +export const buildingType = { + RST:"RST", + RNB:"RNB", + HTB:"HTB" +} export type comCodeState = { code: { isInit: boolean; - chBuCd:SelectDataType[] + chBuCd: SelectDataType[] rainFcltCd: SelectDataType[]; bdstUsgCd: SelectDataType[]; cityCd: SelectDataType[]; sggCd: SelectDataType[]; - rvbsnCd:SelectDataType[]; - mdmbsnCd:SelectDataType[]; - lgbsnCd:SelectDataType[]; - lclgvrnmntCd:EnvPartSelectDataType[]; - orgwtKndCd:SelectDataType[]; - yn:SelectDataType[]; + rvbsnCd: SelectDataType[]; + mdmbsnCd: SelectDataType[]; + lgbsnCd: SelectDataType[]; + lclgvrnmntCd: EnvPartSelectDataType[]; + orgwtKndCd: SelectDataType[]; + yn: SelectDataType[]; + buildingType: { + RST:string, + RNB:string, + HTB:string + } }; }; @@ -114,7 +122,7 @@ export type comCodeType = comCodeState & comCodeActions; export const getSggCd = async (set: any) => { const sgg = await getFetch("common", "/addr/sgg"); const sggCd = sgg.map((item: any) => ({ - val:item.adstDstrCd, + val: item.adstDstrCd, text: item.gugun, })); set((state: comCodeState) => ({ @@ -130,7 +138,7 @@ export const getCityCd = async (set: any) => { val: item.adstDstrCd, text: item.sido, })); - cityCd.unshift({val:'0',text:'전체'}) + cityCd.unshift({ val: '0', text: '전체' }) set((state: comCodeState) => ({ code: { ...state.code, @@ -141,61 +149,61 @@ export const getCityCd = async (set: any) => { // 권역 API 호출 함수 추가 export const getRegionCd = async (set: any) => { - try{ - const rvbsn = await getFetch("common", "/addr/sarea"); - const rvbsnCd = rvbsn.map((item: any) => ({ - val: item.rvbsnCd, - text: item.rvbsn, - })); - rvbsnCd.unshift({val:'0',text:'전체'}) - set((state: comCodeState) => ({ - code: { - ...state.code, - rvbsnCd: rvbsnCd, - }, - })); -}catch(error){ - console.error('권역 데이터를 가져오는데 실패했습니다:', error); -} + try { + const rvbsn = await getFetch("common", "/addr/sarea"); + const rvbsnCd = rvbsn.map((item: any) => ({ + val: item.rvbsnCd, + text: item.rvbsn, + })); + rvbsnCd.unshift({ val: '0', text: '전체' }) + set((state: comCodeState) => ({ + code: { + ...state.code, + rvbsnCd: rvbsnCd, + }, + })); + } catch (error) { + console.error('권역 데이터를 가져오는데 실패했습니다:', error); + } }; // 중권역 API 호출 함수 추가 export const getMiddleRegionCd = async (set: any) => { - try{ - const mdmbsn = await getFetch("common", "/addr/midArea"); - const mdmbsnCd = mdmbsn.map((item: any) => ({ - val: item.rvbsnCd, - text: item.mdmbsn, - })); - mdmbsnCd.unshift({val:'0',text:'전체'}) - set((state: comCodeState) => ({ - code: { - ...state.code, - mdmbsnCd: mdmbsnCd, - }, - })); -}catch(error){ - console.error('중권역 데이터를 가져오는데 실패했습니다:', error); -} + try { + const mdmbsn = await getFetch("common", "/addr/midArea"); + const mdmbsnCd = mdmbsn.map((item: any) => ({ + val: item.rvbsnCd, + text: item.mdmbsn, + })); + mdmbsnCd.unshift({ val: '0', text: '전체' }) + set((state: comCodeState) => ({ + code: { + ...state.code, + mdmbsnCd: mdmbsnCd, + }, + })); + } catch (error) { + console.error('중권역 데이터를 가져오는데 실패했습니다:', error); + } }; // 단위유역 API 호출 함수 추가 -export const getUnitWaterShedCd =async (set: any) => { - try{ +export const getUnitWaterShedCd = async (set: any) => { + try { const lgbsn = await getFetch("common", "/addr/largeArea"); const lgbsnCd = lgbsn.map((item: any) => ({ val: item.rvbsnCd, text: item.lgbsn, })); - lgbsnCd.unshift({val:'0',text:'전체'}) + lgbsnCd.unshift({ val: '0', text: '전체' }) set((state: comCodeState) => ({ code: { ...state.code, lgbsnCd: lgbsnCd, }, })); - }catch(error){ + } catch (error) { console.error('대영역 데이터를 가져오는데 실패했습니다:', error); } }; @@ -203,23 +211,23 @@ export const getUnitWaterShedCd =async (set: any) => { // 환경청 데이터 -export const getEnvPartCd =async (set: any) => { - try{ +export const getEnvPartCd = async (set: any) => { + try { const lclgvrnmnt = await getFetch('common', '/addr/govArea'); const lclgvrnmntCd = lclgvrnmnt.map((item: any) => ({ val: item.lclgvrnmntCd, text: item.lclgvrnmntNm, - adstDliStrCd: item.adstDliStrCd || '' + adstDliStrCd: item.adstDliStrCd || '' })); - lclgvrnmntCd.unshift({val:'0',text:'전체' ,adstDliStrCd: '' }) + lclgvrnmntCd.unshift({ val: '0', text: '전체', adstDliStrCd: '' }) set((state: comCodeState) => ({ code: { ...state.code, lclgvrnmntCd: lclgvrnmntCd, }, })); - }catch(error){ + } catch (error) { console.error('환경청 데이터를 가져오는데 실패했습니다:', error); } }; @@ -231,16 +239,16 @@ export const comCodeStateExport: comCodeState = { isInit: false, rainFcltCd: rainFcltCd, bdstUsgCd: bdstUsgCd, - chBuCd:chBuCd, - orgwtKndCd:orgwtKndCd, + chBuCd: chBuCd, + orgwtKndCd: orgwtKndCd, cityCd: [], sggCd: [], - rvbsnCd:[], - mdmbsnCd:[], - lgbsnCd:[], - lclgvrnmntCd:[], - yn:yn, - + rvbsnCd: [], + mdmbsnCd: [], + lgbsnCd: [], + lclgvrnmntCd: [], + yn: yn, + buildingType:buildingType, }, }; @@ -276,11 +284,11 @@ export const codeActionExport: (set: any) => comCodeActions = (set: any) => { })); }, - divCityCd: async(cd: string) => { + divCityCd: async (cd: string) => { set((state: comCodeState) => ({ code: { ...state.code, - sggCd:state.code.sggCd.filter((item) => { return item.val.toString().slice(0,2) === cd }), + sggCd: state.code.sggCd.filter((item) => { return item.val.toString().slice(0, 2) === cd }), }, })); }, diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx index d6c8d8345..e8783ecef 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx @@ -1,7 +1,7 @@ +import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import type { SelectDataType } from "@common/business_components"; import type { rainChkZodType } from "."; -import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { excelSerialToDateString } from "@/components/lib/func/commom"; +import { buildingType } from '../../../common/code/index'; const useTypes = [ "조경용수", "청소화장실용수", @@ -29,58 +29,25 @@ export type Buildingtype = { export const buildingToExcelType = ( buildings: Buildingtype[], sidoCode: SelectDataType[], - sggCdoe: SelectDataType[] + sggCdoe: SelectDataType[], + bdType: string, ) => { const excelData: string[][] = []; - buildings.forEach((building) => { - useTypes.forEach((useType) => { - excelData.push([ - building.bdstInfoPk.toString(), - sidoCode.find((sido) => sido.val === building.ctpvCd.toString()) - ?.text || "", - sggCdoe.find((sido) => sido.val === building.sggCd.toString())?.text || - "", - building.daddr, - building.bdstNm, - "", - "", - "", - "", - useType, - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - ]); + if(bdType===buildingType.RNB){ + buildings.forEach((building) => { + useTypes.forEach((useType) => { + excelData.push([ + building.bdstInfoPk.toString(), + sidoCode.find((sido) => sido.val === building.ctpvCd.toString()) + ?.text || "", + sggCdoe.find((sido) => sido.val === building.sggCd.toString())?.text || "",building.daddr,building.bdstNm,"","","","",useType,"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", + ]); + }); }); - }); - return excelData; + return excelData; + }else if(bdType===buildingType.RST){ + + } }; export const excelToRainChkData = ( @@ -106,7 +73,7 @@ export const excelToRainChkData = ( return { bdstRuseFcltFk: Number(item["NO"]), - chckYmd: item["점검일"] , + chckYmd: item["점검일"] , spwtPositn: item["유량측정방법"], rgtr: TEST_UUID, oilqMeasMthd: item["운영관리형태"], diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx index ec3464ab8..d544013d6 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/index.tsx @@ -1,15 +1,15 @@ +import { buildingType } from "@/app/store/common/code"; import { TEST_UUID, type TableUpperProps, } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { deleteFectch, fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api"; +import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; 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"; +import { buildingToExcelType } from "./excel"; -const guideDetail=z.object({ +const guideDetail = z.object({ chkgdnFk: z.number().nullable(), utztnUsgCd: z.string(), chckYmd: z.string(), @@ -44,7 +44,7 @@ export const rainChkZod = z.object({ rgtr: z.string().nullable(), mdfcnDt: z.string().nullable(), mdfr: z.string().nullable(), - }).nullable() , + }).nullable(), rainyDetails: z.array( z.object({ chkgdnFk: z.number().nullable(), @@ -69,21 +69,21 @@ export type rainChkZodType = z.infer; export const rainRegExcel = z.object({ bdstInfoPk: z.number().default(111111111), chckYr: z.string() - .default("") - .refine( - (year) => year.length === 0 || /^\d{4}$/.test(year), - { message: "4자리 연도만 입력하세요" } - ) - .refine( - (year) => { - if (year.length === 0) return true; // 빈 문자열은 통과 - const numYear = Number(year); - return !isNaN(numYear) && numYear <= new Date().getFullYear(); - }, - { message: "현재 년도보다 높은 수를 입력할 수 없습니다." } - ), -file: z.instanceof(File).optional(), -}); + .default("") + .refine( + (year) => year.length === 0 || /^\d{4}$/.test(year), + { message: "4자리 연도만 입력하세요" } + ) + .refine( + (year) => { + if (year.length === 0) return true; // 빈 문자열은 통과 + const numYear = Number(year); + return !isNaN(numYear) && numYear <= new Date().getFullYear(); + }, + { message: "현재 년도보다 높은 수를 입력할 수 없습니다." } + ), + file: z.instanceof(File).optional(), +}); export const fcltDiv = [ { val: "RST", text: "중수도시설" }, @@ -167,16 +167,16 @@ export const rainChkgdnHeadList: TableUpperProps[] = [ export const ruseHeadList: TableUpperProps[] = [ { id: "utztnUsgCd", title: "이용용도" }, - { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 }, - { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 }, - { id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 }, - { id: "ruse03", title: "3월", upName: "ruseWater", upSequnce: 4 }, - { id: "ruse04", title: "4월", upName: "ruseWater", upSequnce: 5 }, - { id: "ruse05", title: "5월", upName: "ruseWater", upSequnce: 6 }, - { id: "ruse06", title: "6월", upName: "ruseWater", upSequnce: 7 }, - { id: "ruse07", title: "7월", upName: "ruseWater", upSequnce: 8 }, - { id: "ruse08", title: "8월", upName: "ruseWater", upSequnce: 9 }, - { id: "ruse09", title: "9월", upName: "ruseWater", upSequnce: 10 }, + { id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 }, + { id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 }, + { id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 }, + { id: "ruse03", title: "3월", upName: "ruseWater", upSequnce: 4 }, + { id: "ruse04", title: "4월", upName: "ruseWater", upSequnce: 5 }, + { id: "ruse05", title: "5월", upName: "ruseWater", upSequnce: 6 }, + { id: "ruse06", title: "6월", upName: "ruseWater", upSequnce: 7 }, + { id: "ruse07", title: "7월", upName: "ruseWater", upSequnce: 8 }, + { id: "ruse08", title: "8월", upName: "ruseWater", upSequnce: 9 }, + { id: "ruse09", title: "9월", upName: "ruseWater", upSequnce: 10 }, { id: "ruse10", title: "10월", upName: "ruseWater", upSequnce: 11 }, { id: "ruse11", title: "11월", upName: "ruseWater", upSequnce: 12 }, { id: "ruse12", title: "12월", upName: "ruseWater", upSequnce: 13 }, @@ -184,16 +184,16 @@ export const ruseHeadList: TableUpperProps[] = [ export const splHeadList: TableUpperProps[] = [ { id: "utztnUsgCd", title: "이용용도" }, - { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1 }, - { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2 }, - { id: "spl02", title: "2월", upName: "splWater", upSequnce: 3 }, - { id: "spl03", title: "3월", upName: "splWater", upSequnce: 4 }, - { id: "spl04", title: "4월", upName: "splWater", upSequnce: 5 }, - { id: "spl05", title: "5월", upName: "splWater", upSequnce: 6 }, - { id: "spl06", title: "6월", upName: "splWater", upSequnce: 7 }, - { id: "spl07", title: "7월", upName: "splWater", upSequnce: 8 }, - { id: "spl08", title: "8월", upName: "splWater", upSequnce: 9 }, - { id: "spl09", title: "9월", upName: "splWater", upSequnce: 10 }, + { id: "splTotal", title: "계", upName: "splWater", upSequnce: 1 }, + { id: "spl01", title: "1월", upName: "splWater", upSequnce: 2 }, + { id: "spl02", title: "2월", upName: "splWater", upSequnce: 3 }, + { id: "spl03", title: "3월", upName: "splWater", upSequnce: 4 }, + { id: "spl04", title: "4월", upName: "splWater", upSequnce: 5 }, + { id: "spl05", title: "5월", upName: "splWater", upSequnce: 6 }, + { id: "spl06", title: "6월", upName: "splWater", upSequnce: 7 }, + { id: "spl07", title: "7월", upName: "splWater", upSequnce: 8 }, + { id: "spl08", title: "8월", upName: "splWater", upSequnce: 9 }, + { id: "spl09", title: "9월", upName: "splWater", upSequnce: 10 }, { id: "spl10", title: "10월", upName: "splWater", upSequnce: 11 }, { id: "spl11", title: "11월", upName: "splWater", upSequnce: 12 }, { id: "spl12", title: "12월", upName: "splWater", upSequnce: 13 }, @@ -302,8 +302,8 @@ export type rainChkgdnState = { splHeadList: TableUpperProps[]; rswtDetailHeadList: TableUpperProps[]; isInit: boolean; - isModalClose:boolean; - excelList:[]; + isModalClose: boolean; + excelList: []; }; }; @@ -311,9 +311,9 @@ type rainChkgdnActions = { rainChkInit: (sggCd: string, searchTxt: string) => void; rainChkDetilUpdate(rainChk: rainChkZodType[]): Promise; rainChkGuidUpdate(rainChk: rainChkZodType): Promise; - rainChkExcelDownload(sidoCode: SelectDataType[],sggCode: SelectDataType[]): Promise - rainChkExcelDataUPload(excelData:rainChkZodType[]) : Promise - rainChkDelete( chkgdnPks:number[] ) :Promise + rainChkExcelDownload(sidoCode: SelectDataType[], sggCode: SelectDataType[]): Promise + rainChkExcelDataUPload(excelData: rainChkZodType[]): Promise + rainChkDelete(chkgdnPks: number[]): Promise }; export type rainChkgdnType = rainChkgdnState & rainChkgdnActions; @@ -323,20 +323,20 @@ export const rainChkgdnStateExport: rainChkgdnState = { rainChkgdnHeadList: rainChkgdnHeadList, rainHeadNm: rainHeadNm, rainChk: rainChk, - splHeadList:splHeadList, + splHeadList: splHeadList, ruseHeadList: ruseHeadList, rswtDetailHeadList: rswtDetailHeadList, isInit: false, - isModalClose:false, - excelList:[] + isModalClose: false, + excelList: [] }, }; const makeMdfrChk = (data: rainChkZodType[], type: string, toDo: string) => { - const chData=data.map((item) => { + const chData = data.map((item) => { item.mdfr = TEST_UUID; - + if (type === "rainyDetails") { item.rainyDetails.forEach((item) => { item.mdfr = TEST_UUID; @@ -366,25 +366,23 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( set: any ) => { return { - rainChkExcelDownload:async(sidoCode:SelectDataType[], sggCode:SelectDataType[])=>{ - - // 로그인한 아이디의 시도 or 시군구로 들어가야하는데 현재는 그냥 0으로 하드코딩 - const data = await getFetch(fetchType.WR, `/reuseFc/buildingFlg/RNB/41`) - // const excelList = buildingToExcelType(data, sidoCode, sggCode); + rainChkExcelDownload: async (sidoCode: SelectDataType[], sggCode: SelectDataType[]) => { - const excelList = buildingToExcelType(data, sidoCode, sggCode); + // 로그인한 아이디의 시도 or 시군구로 들어가야하는데 현재는 그냥 0으로 하드코딩 + const data = await getFetch(fetchType.WR, `/reuseFc/buildingFlg/${buildingType.RNB}/41`) + const excelList = buildingToExcelType(data, sidoCode, sggCode, buildingType.RNB); set((state: rainChkgdnState) => ({ rainChkgdn: { ...state.rainChkgdn, - excelList:excelList + excelList: excelList }, })); }, - rainChkExcelDataUPload: async(excelData:rainChkZodType[] ) =>{ - try{ + rainChkExcelDataUPload: async (excelData: rainChkZodType[]) => { + try { const res = await postFectch("/reuseChk/rainyExcel", excelData); if (res.ok) { - ToastFormUi({body:"지도점검 등록이 완료되었습니다. " ,title:'지도점검 등록'}) + ToastFormUi({ body: "지도점검 등록이 완료되었습니다. ", title: '지도점검 등록' }) } const rainChkRes = await initFetch('2024', '0'); return set((state: rainChkgdnState) => ({ @@ -394,9 +392,9 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( rainChk: rainChkRes, }, })); - }catch(error){ + } catch (error) { console.log(error); - ToastFormUi({body:"지도점검 등록이 실패되었습니다." ,title:'지도점검 등록'}) + ToastFormUi({ body: "지도점검 등록이 실패되었습니다.", title: '지도점검 등록' }) } }, rainChkInit: async (searchTxt: string, sggCd: string) => { @@ -414,13 +412,13 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( console.log(error); } }, - rainChkDetilUpdate: async (rainChk: rainChkZodType[] ) => { + rainChkDetilUpdate: async (rainChk: rainChkZodType[]) => { try { const chData = await makeMdfrChk(rainChk, "rain", "rainDetil"); const res = await postFectch("/reuseChk/rainyExcel", rainChk); if (res.ok) { - ToastFormUi({body:"지도점검 보급수 및 밋물이용량 수정이 완료되었습니다. " ,title:'지도점검 수정'}) + ToastFormUi({ body: "지도점검 보급수 및 밋물이용량 수정이 완료되었습니다. ", title: '지도점검 수정' }) } const rainChkRes = await initFetch('2024', '0'); return set((state: rainChkgdnState) => ({ @@ -436,49 +434,45 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = ( } }, rainChkGuidUpdate: async (rainChk: rainChkZodType) => { - try{ - //const chData = await makeMdfrChk(rainChk, "guideDetails", "rainDetil"); - const res = await putFectch("/reuseChk/rainy", rainChk); - if (res.ok) { - ToastFormUi({body:"지도점검 수질 및 과태료 수정이 완료되었습니다. " ,title:'지도점검 수정'}) - } - const rainChkRes = await initFetch('2024', '0'); - return set((state: rainChkgdnState) => ({ - ...state, - rainChkgdn: { - ...state.rainChkgdn, - rainChk: rainChkRes, - }, - })); - }catch(error){ - console.log(error); + try { + //const chData = await makeMdfrChk(rainChk, "guideDetails", "rainDetil"); + const res = await putFectch("/reuseChk/rainy", rainChk); + if (res.ok) { + ToastFormUi({ body: "지도점검 수질 및 과태료 수정이 완료되었습니다. ", title: '지도점검 수정' }) } - - - }, - rainChkDelete: async (chkgdnPks:number[] ) =>{ - try{ - const res = await deleteFectch(`/reuseChk/rainy`,chkgdnPks); - - if(res.ok){ - ToastFormUi({body:"삭제가 완료되었습니다. " ,title:'지도점검 삭제'}) - } - const rainChkRes = await initFetch('2024', '0'); - return set((state: rainChkgdnState) => ({ - ...state, - rainChkgdn: { - ...state.rainChkgdn, - rainChk: rainChkRes, - }, - })); - - - }catch(error){ - ToastFormUi({body:"삭제를 실패했습니다.. " ,title:'지도점검 삭제'}) - + const rainChkRes = await initFetch('2024', '0'); + return set((state: rainChkgdnState) => ({ + ...state, + rainChkgdn: { + ...state.rainChkgdn, + rainChk: rainChkRes, + }, + })); + } catch (error) { + console.log(error); } + }, + rainChkDelete: async (chkgdnPks: number[]) => { + try { + const res = await deleteFectch(`/reuseChk/rainy`, chkgdnPks); + + if (res.ok) { + ToastFormUi({ body: "삭제가 완료되었습니다. ", title: '지도점검 삭제' }) + } + const rainChkRes = await initFetch('2024', '0'); + return set((state: rainChkgdnState) => ({ + ...state, + rainChkgdn: { + ...state.rainChkgdn, + rainChk: rainChkRes, + }, + })); + } catch (error) { + ToastFormUi({ body: "삭제를 실패했습니다.. ", title: '지도점검 삭제' }) + + } } diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx index 7cfc37c65..9ba3e1404 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx @@ -1,5 +1,9 @@ import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import type { chHeadType } from "../rainChkgdn"; +import type { SelectDataType } from "@common/business_components"; +import { fetchType, getFetch } from "@/components/lib/api"; +import { buildingToExcelType } from "../rainChkgdn/excel"; +import { buildingType } from "@/app/store/common/code"; @@ -50,6 +54,7 @@ export type rswtChkgdnState = { type rswtChkgdnActions = { rswtChkgdnInit: (sggCd: string, searchTxt: string, flag: string) => void; + rswtrChkExcelDownload(sidoCode: SelectDataType[],sggCode: SelectDataType[]): Promise }; export type rswtChkgdnType = rswtChkgdnState & rswtChkgdnActions; @@ -64,9 +69,21 @@ export const rswtChkgdnStateExport: rswtChkgdnState = { export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = ( set: any ) => { + rswtrChkExcelDownload: async (sidoCode: SelectDataType[],sggCode: SelectDataType[]) => { + const data = await getFetch(fetchType.WR, `/reuseFc/buildingFlg/${buildingType.RST}/41`) + const excelList = buildingToExcelType(data, sidoCode, sggCode, buildingType.RST); + set((state: rswtChkgdnState) => ({ + rswtChkgdn: { + ...state.rswtChkgdn, + excelList:excelList + }, + })); + } + } return { rswtChkgdnInit: async (sggCd: string, searchTxt: string, flg: string) => { }, + , }; }; diff --git a/apps/wr/components/ui/modal/chkgdExcel/chkgdExcel.tsx b/apps/wr/components/ui/modal/chkgdExcel/chkgdExcel.tsx index 895af4388..ddd762a12 100644 --- a/apps/wr/components/ui/modal/chkgdExcel/chkgdExcel.tsx +++ b/apps/wr/components/ui/modal/chkgdExcel/chkgdExcel.tsx @@ -1,21 +1,18 @@ import { useWrStore } from "@/app/store"; -import { rainChkZod, rainRegExcel, type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; +import { rainRegExcel, type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"; import { excelToRainChkData } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel"; -import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { - DatePicker, filePicked, FileUpload, Form, FormField, FormUi, - Title, + Title } from "@common/business_components/ui"; 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";