From 103c5e05aea8923687d8264678e230160b2a6c9e Mon Sep 17 00:00:00 2001 From: leedj312 Date: Wed, 28 May 2025 17:18:35 +0900 Subject: [PATCH 1/4] Co-authored-by: truthplumage --- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 43 ++++- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 14 +- apps/wr/components/lib/api/index.ts | 99 ++++++----- apps/wr/components/lib/config/index.ts | 4 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 157 ++++++++++-------- apps/wr/middleware.ts | 2 +- 6 files changed, 187 insertions(+), 132 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 00b50d157..1693dbf16 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -1,6 +1,6 @@ import { z } from "zod"; import type { TableUpperProps } from "../rainReg"; -import { fetchType, getFetch, postFectch } from "@/components/lib/api"; +import { deleteFectch, fetchType, getFetch, postFectch } from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { exampleData, @@ -51,6 +51,8 @@ type pubFacActions = { pbnstRegSearch: (txt: string | undefined, sgg: string) => void; pbnstReg: (txt: string | undefined) => void; pbnstUpdate(pbnstRes: customPbnst) : Promise; + fileDelete:(atflCd:string)=>void + fileDownLoad: (atflCd: string) => void }; export type pubFacType = pubFacState & pubFacActions; @@ -151,9 +153,12 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { }, pbnstRegSearch: async (txt: string | undefined, sgg: string) => { try { + + const pbnstRes = await getFetch( "wr", - `/api/v1/reuseFc/pubFc` + (txt ? `/${txt}` : "") + `/${sgg}` + '' + // `/api/v1/prcsFclt/ruseInfo/${pageNo}/${pageCnt}/${searchingCd}/${nameCd}/${fcltCpct}/{oprtngSttsCd}/{bscFctClsCd}/{swtrmtFcltNm}` + (txt ? `/${txt}` : "") + `/${sgg}` ); // API 응답이 pbnstRegZod 타입의 단일 객체라고 가정 const pbnstBizCycle = @@ -205,16 +210,38 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (error) { console.error("Error updating pbnst:", error); } - },fileDelete(atflCd:string){ + },fileDelete: async (atflCd:string)=>{ try { - const response = postFectch( - `/ratfl/attachments/atflCd/${atflCd}`, - null, - fetchType.COMMON + const response = await deleteFectch( + `/attach-service/api/v1/atfl/attachments/atflCd//${atflCd}`, + undefined, + fetchType.CS ); - return response; + + console.log("File deleted successfully:", response); + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + isInit: false, + }, + }));; } catch (error) { + + console.error("Error deleting file:", error); + } + },fileDownLoad: async (atflCd: string) => { + + try{ + const response = await getFetch( fetchType.CS , `/api/v1/atflcd/download/${atflCd}`) + + + if (!response.ok) { + throw new Error(`Error downloading file: ${response.statusText}`); + } + }catch(error){ + console.error("Error downloading file:", error); } } }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 29bec52b9..358986465 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -44,6 +44,8 @@ export type fcOrgwtType = z.infer; export type ppInstlType = z.infer; export type operType = z.infer; +export type fcFileType = z.infer; + const pplInstlSchema = z.object({ ruseFcltBizFk: z.string(), @@ -52,13 +54,13 @@ const pplInstlSchema = z.object({ cpct: z.string(), }); const fcFileSchema = z.object({ - ruseFcltFk: z.number().default(0), - fileTkn: z.string().default("test"), - filePath: z.string().default("test"), - fileKnd: z.string().default("test"), - regDt: z.date().default(new Date()), + ruseFcltFk: z.number().default(0).nullish(), + fileTkn: z.string(), + filePath: z.string(), + fileKnd: z.string(), + regDt: z.date().default(new Date()).nullish(), rgtr: z.string(), - mdfcnDt: z.date().default(new Date()), + mdfcnDt: z.date().default(new Date()).nullish(), mdfr: z.string(), }); diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts index 6e3b9b1a8..7b8507910 100644 --- a/apps/wr/components/lib/api/index.ts +++ b/apps/wr/components/lib/api/index.ts @@ -1,69 +1,84 @@ //8880 -import { DEV_URL_FO, DEV_URL_WR } from "../config/"; +import { CS_URL, DEV_URL_FO, DEV_URL_WR, LOCAL_URL } from "../config/"; -export const fetchType={COMMON: "common", WR: "wr"} +export const fetchType = { COMMON: "common", WR: "wr", LOCAL: "LOCAL" , CS: "CS" }; -export const getFetch = async( type:string , url: string) => { - const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR - const response = await fetch( div+url , { +export const getFetch = async (type: string, url: string) => { + const div = + type === fetchType.COMMON + ? DEV_URL_FO + : type === fetchType.LOCAL + ? LOCAL_URL + : type === fetchType.CS + ? '' + : DEV_URL_WR; + + const response = await fetch(div + url, { method: "GET", headers: { - accept: "application/json", + accept: "application/json", }, }); - if(!response.ok) { + if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } - const res = await response.json() + const res = await response.json(); return res.data; -} +}; -export const postFectch = async (url: string, params: any , type?:string) => { - const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR +export const postFectch = async (url: string, params: any, type?: string) => { + const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR; - const response = await fetch(div+url, { + const response = await fetch(div + url, { method: "POST", headers: { - 'accept': 'application/json', + accept: "application/json", "Content-Type": "application/json", }, body: JSON.stringify(params), }); - if(!response.ok) { + if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } return await response.json(); -} - +}; export const putFectch = async (url: string, params: any) => { + const response = await fetch(DEV_URL_WR + url, { + method: "PUT", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(params), + }); + if (!response.ok) { + throw new Error(`오류 발생: ${response.status}`); + } + return response; +}; - const response = await fetch(DEV_URL_WR+url, { - method: "PUT", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(params), - }); - if(!response.ok) { - throw new Error(`오류 발생: ${response.status}`); - } - return response; - } +export const deleteFectch = async (url: string, params?: any, type?: string) => { + const div = + type === fetchType.COMMON + ? DEV_URL_FO + : type === fetchType.LOCAL + ? LOCAL_URL + : type === fetchType.CS + ? '' + : DEV_URL_WR; - -export const deleteFectch = async (url: string, params: any) => { - const response = await fetch(DEV_URL_WR+url, { - method: "DELETE", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(params), - }); - if(!response.ok) { - throw new Error(`오류 발생: ${response.status}`); - } - return response; - } \ No newline at end of file + console.log("deleteFectch url", div + url); + const response = await fetch(div + url, { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + body: params?JSON.stringify(params):undefined, + }); + if (!response.ok) { + throw new Error(`오류 발생: ${response.status}`); + } + return await response.text(); +}; \ No newline at end of file diff --git a/apps/wr/components/lib/config/index.ts b/apps/wr/components/lib/config/index.ts index 1348c2dc1..d0e076d81 100644 --- a/apps/wr/components/lib/config/index.ts +++ b/apps/wr/components/lib/config/index.ts @@ -1,5 +1,5 @@ -const LOCAL_PORT = "3000"; +const LOCAL_PORT = "3001"; const DEV_PORT = "11080"; const DEV_PORT_NEW="11082" @@ -12,6 +12,6 @@ export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`; export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`; - +export const LOCAL_URL = `http://localhost:${LOCAL_PORT}`; export const CS_URL= 'http://dev.onasys.co.kr:8000' export const CS_TUS_UPLOAD= "/attach-service/api/v1/tus/upload"; \ No newline at end of file diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 6f0a1ac02..89343cb93 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -5,7 +5,7 @@ import { FileUpload, FormUi } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useEffect, useRef, useState } from "react"; +import { use, useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; @@ -20,25 +20,28 @@ import type { Upload } from "tus-js-client"; import { pbnstRegZod, type customPbnst, + type fcFileType, type operType, type ruseFcltType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; export type FilesType = { - atflCd: String; + atflCd: string; file: File; }; export function PbnstMngForm({ data }: { data: customPbnst }) { - const { pbnst, pbnstUpdate } = useWrStore((state) => state); + const { pbnst, pbnstUpdate, fileDelete } = useWrStore((state) => state); const { pbnstMngUpHeadList } = pbnst; const [ruseOperData, setRuseOperData] = useState(); - const [planFiles, setPlanFiles] = useState(null); + const [planFiles, setPlanFiles] = useState(null); const [relationfiles, setRelationFiles] = useState(null); const [isModalOpen, setIsModalOpen] = useState(false); + const [regFileList, setRegFileList] = useState(null); const [upload, setUpload] = useState(null); const [progress, setProgress] = useState(0); - + //const new File([] as BlobPart[], "") 파일 다운로드 활용 const handleProgress = (percentage: string) => { setProgress(Number(percentage)); }; @@ -58,6 +61,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name: "fcOpers", }); + const fileDownload = (index: number) => {}; const plusHist = () => { append({ choose: false, @@ -80,8 +84,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { selectedIdxs.reverse().forEach((idx) => remove(idx)); }; - const onSelectValue = (val: string) => {}; - useEffect(() => { if (!data) return; form.reset(data); @@ -90,26 +92,37 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { // 2. Define a submit handler. function onSubmit(values: z.infer) { - console.log("submit", values); - // pbnstUpdate(values); values.fcOpers = ref.current || []; + values.fcFiles = regFileList || []; console.log("form values:", values); pbnstUpdate(values); } - const fileHandler = (files: File[]) => { - console.log('fileHandler', files); - let setReFiles = [...(relationfiles || [])]; - if (files && (!relationfiles || relationfiles.length < files.length)) { + + const fileHandler = (files: File[], type: string) => { + console.log("fileHandler", files); + let fileList = [] as FilesType[]; + if (type === "relation" && relationfiles) { + fileList = relationfiles; + } else if (type === "plan" && planFiles) { + fileList = planFiles; + } + + let setReFiles = [...(fileList || [])]; + if (files && (!fileList || fileList.length < files.length)) { files.find((item) => { if ( - !relationfiles || - relationfiles?.findIndex((reFile) => reFile.file === item) < 0 + !fileList || + fileList?.findIndex((reFile) => reFile.file === item) < 0 ) { TusClientUpload({ atflCd: "", file: item }) .then((tusFile) => { - setReFiles.push({ atflCd: tusFile.atflCd, file: item }); - console.log("after async setReFiles", setReFiles); - setRelationFiles(setReFiles); + setReFiles.push({ + atflCd: tusFile.atflCd.toString(), + file: item, + }); + type === "relation" + ? setRelationFiles(setReFiles) + : setPlanFiles(setReFiles); }) .catch((e) => { console.log(e); @@ -117,47 +130,54 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { return item; } }); - } else if ( - relationfiles && - (!files || relationfiles.length > files.length) - ) { + } else if (fileList && (!files || fileList.length > files.length)) { if (!files) { - //TODO: 파일삭제 + fileList.forEach((file) => { + fileDelete(file.atflCd as string); + }); setReFiles = []; setReFiles.length = 0; } else { - //TODO: 파일삭제 - relationfiles?.forEach((item, index) => { + fileList?.forEach((item, index) => { const idx = files?.indexOf(item.file); if (idx < 0) { - setReFiles.slice(index); + setReFiles.splice(index); + fileDelete(item.atflCd as string); } }); } - setRelationFiles(setReFiles) + type === "relation" + ? setRelationFiles(setReFiles) + : setPlanFiles(setReFiles); } }; + const regFileFilter=(files:FilesType[], fileKnd:string, regFile:fcFileType[])=>{ + const planDatas = regFile?.filter(item=>item.fileKnd!==fileKnd) || []; + const data = files.map((item) => ({ + fileTkn: item.atflCd, + filePath: item.file.name, + fileKnd: fileKnd, + rgtr: TEST_UUID, + mdfr: TEST_UUID, + })); + return [...planDatas, ...data] + } + useEffect(() => { + console.log("relationfiles:", relationfiles); + if (relationfiles) { + setRegFileList(regFileFilter(relationfiles, "계통도", regFileList||[])); + } + }, [relationfiles]); + useEffect(() => { + if (planFiles) { + setRegFileList(regFileFilter(planFiles, "평면도", regFileList||[])); + } + }, [planFiles]); useEffect(() => { - console.log("relationfiles changed:", relationfiles); - }, [relationfiles]); + console.log("regFileList:", regFileList); + }, [regFileList]); - const testFile = () => { - // if (relationfiles && relationfiles[0]) - // TusClientUpload(relationfiles[0], setUpload, { - // handleUploadStart: () => { - // console.log("handleUploadStart"); - // }, - // handleProgress, - // handleResponse: (req, res) => { - // console.log("handleResponse req", req); - // console.log("handleResponse res", res); - // }, - // handleSuccess: (a) => { - // console.log("req", a); - // }, - // }); - }; useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); @@ -288,36 +308,27 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
- ( - - item.file) || []} - setFiles={(files: File[] | null) => { - if (files) fileHandler(files); - }} - fileTypes="PDF" - > - - )} - /> + + item.file) || []} + setFiles={(files: File[] | null) => { + if (files) fileHandler(files, "relation"); + }} + fileTypes="PDF" + onFileClick={(index) => {}} + > +
- ( - - - - )} - /> + + item.file) || []} + setFiles={(files: File[] | null) => { + if (files) fileHandler(files, "plan"); + }} + fileTypes="PDF" + > +
diff --git a/apps/wr/middleware.ts b/apps/wr/middleware.ts index fdd0a3c9c..e30e04f4d 100644 --- a/apps/wr/middleware.ts +++ b/apps/wr/middleware.ts @@ -21,7 +21,7 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/attach-service")) { const requestHeaders = new Headers(req.headers); - const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDgzOTk3ODl9.wbYXSIFNSvVJKyofFW0C3Yg99AZ99oLYSCMjcoRvZB6DqfxCbqxHPxUgwWyFE6oHJWYrX6q4BvMY2TdVOtzxnA" + const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0MjU0NzJ9.rABGFEzyCEDYwnuzd-6V0lPtckSGx-h77-tJBYFz00KPowmWBpwMLrSynxmHpmtmga86ksIYxuoMkiT1_aI6Sw" const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0' //const token = req.cookies.get(CLAIM_NAME)?.value; //const userId = req.cookies.get(AUTH_USER_ID)?.value; From 50f94aa4c2a540d484afea42c60bd479bc7ce7d4 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Wed, 28 May 2025 23:59:12 +0900 Subject: [PATCH 2/4] Co-authored-by: truthplumage --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 21 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 74 ++-- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 5 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 351 +++++++++--------- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 75 ++-- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 65 +++- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 1 - apps/wr/middleware.ts | 2 +- 8 files changed, 350 insertions(+), 244 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 95666f8ca..7c5ebdb10 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -15,7 +15,7 @@ import { Tabs, TabsList, TabsTrigger, TabsContent } from "@common/components"; import { useEffect, useState } from "react"; import ListDiv from "@common/business_components/ui/list_div"; import { tableData } from "@/components/lib/func/commom"; -import type { customPbnst, fcBizSchema, fcBizType, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { customPbnst, fcBizSchema, fcBizType, pubHasuType, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; import { z } from "zod"; @@ -31,9 +31,9 @@ export default function PublicReuseFaciltyInsert() { const [issNewReg, setIsNewReg] = useState(false); const [searchTxt, setSearchTxt] = useState(); - const [bdstTable, setbdstTable] = useState(); + const [bdstTable, setbdstTable] = useState(); const [selectBdst, setSelectBdst] = useState(null); - const [selectedRow, setSelectedRow] = useState(null); + const [selectedRow, setSelectedRow] = useState(null); useEffect(() => { if (!pbnst.isInit ) { @@ -46,7 +46,6 @@ useEffect(() => { useEffect(() => { - console.log("pbnstHasuRes", pbnstHasuRes); if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { setbdstTable(tableData(pbnstHasuRes, { code })); } @@ -57,16 +56,14 @@ useEffect(() => { }; const cellClick = (val: number | undefined) => { if (val === undefined) return; - console.log("pbnstRes", pbnstRes) const selectRow = pbnstHasuRes?.[val]; setSelectedRow(selectRow); - console.log("아제발", selectRow) - if (pbnstRes === null){ + if (pbnstRes !== null){ alert("등록된 재이용시설 정보가 없습니다. 신규등록 하십시오.") return; } - setSelectBdst(pbnstRes); - setPbnstBiz(pbnstRes?.fcBizs) + // setSelectBdst(pbnstRes); + // setPbnstBiz(pbnstRes?.fcBizs) }; const resetContents = () => { setFcltMng([]); // 빈 배열로 설정하여 신규 모드로 전환 @@ -135,11 +132,17 @@ useEffect(() => { + + + 시설정보 차수별정보 + diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index e069b75f3..2d11c0e10 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -1,11 +1,17 @@ import { z } from "zod"; import type { TableUpperProps } from "../rainReg"; -import { deleteFectch, fetchType, getFetch, postFectch } from "@/components/lib/api"; +import { + deleteFectch, + fetchType, + getFetch, + postFectch, +} from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { exampleData, fcBizSchema, type customPbnst, + type fcBizType, type pubHasuType, } from "./type"; import type { SelectDataType } from "@common/business_components/ui"; @@ -26,8 +32,7 @@ const pbnstOrgwtHeadList = pbnstOrgwtHeadListRxport; const pbnstMngNm = pbnstMngNmExport; const pplInstlsHeadLisat = pplInstlsHeadListExport; const pbnstDemandHeadList = pbnstDemandHeadListExport; -const fcOrgwtsHeadList=fcOrgwtsHeadListExport - +const fcOrgwtsHeadList = fcOrgwtsHeadListExport; export type pubFacState = { pbnst: { @@ -43,6 +48,7 @@ export type pubFacState = { pplInstlsHeadLisat: TableUpperProps[]; pbnstDemandHeadList: TableUpperProps[]; fcOrgwtsHeadList: TableUpperProps[]; + pbnstMngRegData: customPbnst[]; }; }; type pubFacActions = { @@ -50,9 +56,11 @@ type pubFacActions = { pbnstRegInit: (sgg: string) => void; pbnstRegSearch: (txt: string | undefined, sgg: string) => void; pbnstReg: (txt: string | undefined) => void; - pbnstUpdate(pbnstRes: customPbnst) : Promise; - fileDelete:(atflCd:string)=>void - fileDownLoad: (atflCd: string) => void + pbnstUpdate(pbnstRes: customPbnst): Promise; + fileDelete: (atflCd: string) => void; + fileDownLoad: (atflCd: string) => void; + pbnstMngData: (data: customPbnst[]) => void; + pbnstBizData(data: fcBizType): void; }; export type pubFacType = pubFacState & pubFacActions; @@ -71,6 +79,7 @@ export const pubFacStateExport: pubFacState = { pplInstlsHeadLisat: pplInstlsHeadLisat, pbnstDemandHeadList: pbnstDemandHeadList, fcOrgwtsHeadList: fcOrgwtsHeadList, + pbnstMngRegData: [], }, }; @@ -110,8 +119,8 @@ const getBizCycle = (fcBizs: z.infer[]) => { return pbnstBizCycle; }; -const initFetch = async (code:string|undefined) => { - const pbnstRes =await getFetch("wr", `${code}`); +const initFetch = async (code: string | undefined) => { + const pbnstRes = await getFetch("wr", `${code}`); return pbnstRes; }; @@ -159,12 +168,10 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { }, pbnstRegSearch: async (txt: string | undefined, sgg: string) => { try { - - const pbnstRes = await getFetch( "wr", - '' - // `/api/v1/prcsFclt/ruseInfo/${pageNo}/${pageCnt}/${searchingCd}/${nameCd}/${fcltCpct}/{oprtngSttsCd}/{bscFctClsCd}/{swtrmtFcltNm}` + (txt ? `/${txt}` : "") + `/${sgg}` + "" + // `/api/v1/prcsFclt/ruseInfo/${pageNo}/${pageCnt}/${searchingCd}/${nameCd}/${fcltCpct}/{oprtngSttsCd}/{bscFctClsCd}/{swtrmtFcltNm}` + (txt ? `/${txt}` : "") + `/${sgg}` ); // API 응답이 pbnstRegZod 타입의 단일 객체라고 가정 const pbnstBizCycle = @@ -216,7 +223,8 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (error) { console.error("Error updating pbnst:", error); } - },fileDelete: async (atflCd:string)=>{ + }, + fileDelete: async (atflCd: string) => { try { const response = await deleteFectch( `/attach-service/api/v1/atfl/attachments/atflCd//${atflCd}`, @@ -231,24 +239,46 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { ...state.pbnst, isInit: false, }, - }));; - + })); } catch (error) { - console.error("Error deleting file:", error); } - },fileDownLoad: async (atflCd: string) => { - - try{ - const response = await getFetch( fetchType.CS , `/api/v1/atflcd/download/${atflCd}`) - + }, + fileDownLoad: async (atflCd: string) => { + try { + const response = await getFetch( + fetchType.CS, + `/api/v1/atflcd/download/${atflCd}` + ); if (!response.ok) { throw new Error(`Error downloading file: ${response.statusText}`); } - }catch(error){ + } catch (error) { console.error("Error downloading file:", error); } + }, + pbnstMngData: (data: customPbnst[]) => { + return set((state: pubFacState) => { + state.pbnst.pbnstMngRegData = data; + return state; + }); + }, + pbnstBizData:(data:fcBizType)=>{ + return set((state:pubFacState)=>{ + if(state.pbnst.pbnstMngRegData){ + const regData = state.pbnst.pbnstMngRegData.find(item=> + data.pbnstRuseFcltFk===item.pbnstRuseFcltPk + ) + if(regData){ + const bizIdx = regData.fcBizs.findIndex(item=>item.pbnstRuseFcltBizPk==data.pbnstRuseFcltBizPk) + if(bizIdx>=0){ + regData.fcBizs[bizIdx] = data; + } + } + } + return state; + }) } }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 3c39f4dbc..c04302663 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -49,6 +49,7 @@ export type fcFileType = z.infer; const pplInstlSchema = z.object({ ruseFcltBizFk: z.string(), + choose:z.boolean().default(false), pdmt: z.string(), ppMqlt: z.string(), cpct: z.string(), @@ -117,7 +118,7 @@ const fcPrfmncSchema = z.object({ export const fcBizSchema = z.object({ pbnstRuseFcltBizPk: z.number().default(0), - pbnstRuseFcltFk: z.number().default(0), + pbnstRuseFcltFk: z.string().default(''), cycl: z.string(), seCd: z.string(), bizMthdCd: z.string(), @@ -187,7 +188,7 @@ export const fcBizSchema = z.object({ }); export const pbnstRegZod = z.object({ - pbnstRuseFcltPk: z.number().default(0), + pbnstRuseFcltPk: z.string().default(""), swtrmtFcltFk: z.string().default(""), ruseUtztnFcltNm: z.string().default(""), fcltCpct: z.string().default(""), diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 60391fd18..3496e1140 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -13,11 +13,9 @@ import { fcBizSchema, type fcBizType, type fcOrgwtType, - type ppInstlType + type ppInstlType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; -import { - selectClass -} from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { commonButonSize, formH1Class, @@ -26,10 +24,7 @@ import { import FcOrgwtsRegModal from "@/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { SelectBox } from "@common/business_components"; -import { - UiModal, - type SelectDataType -} from "@common/business_components/ui"; +import { UiModal, type SelectDataType } from "@common/business_components/ui"; import { Form } from "@common/business_components/ui/form"; import { Button, Input, Label } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -39,10 +34,8 @@ import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; export function PbnstBuseForm({ data }: { data: fcBizType[] }) { // const ref = useRef(data[0]?.pplInstls ?? null); - const ref = useRef( - Array.isArray(data) && data.length > 0 ? data[0]?.pplInstls ?? null : null - ); - const { code, pbnst } = useWrStore((state) => state); + const ref = useRef( null); + const { code, pbnst, pbnstBizData } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [getBizCycle, setBizCycle] = useState("1"); const [ppiSelectList, setPpiSelectList] = @@ -51,8 +44,6 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { const [isFcOrgwts, setIsFcOrgwts] = useState(false); const [modalData, setModalData] = useState(null); - - const form = useForm({ resolver: zodResolver(fcBizSchema), }); @@ -67,30 +58,49 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { name: "fcOrgwts", }); - const { fields: pplInstls, append, remove } = useFieldArray({ + const { + fields: pplInstls, + append, + remove, + } = useFieldArray({ control: form.control, name: "pplInstls", }); + useEffect(() => { + pbnstBizData(form.watch() as fcBizType); + }, [form.formState]); + + useEffect(() => { + console.log("pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData); + }, [pbnst.pbnstMngRegData]); + const buttonClick = () => { - console.log("머임?", data[0]?.fcOrgwts) setIsFcOrgwts(true); - const moData = data[0]?.fcOrgwts; + const moData = data[0]?.fcOrgwts?.[0] ?? null; setModalData(moData); - } + }; - - const plusHist = () => { - append({ + const plusHist = () => { + const regData ={ + ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk??"", choose: false, ppMqlt: "", pdmt: "", cpct: "", + } + const currentTableDataFromRef = ref.current ? [...ref.current] : []; + const newDataForRHF = [...currentTableDataFromRef, regData]; + form.setValue("pplInstls", newDataForRHF, { + shouldValidate: true, // 필요하다면 유효성 검사 실행 + shouldDirty: true, // 폼 상태를 dirty로 변경 }); + const latestOpers = form.getValues("pplInstls"); + ref.current = [...latestOpers]; }; const removeSelected = () => { - if(!ref.current) return; + if (!ref.current) return; const selectedIdxs = ref.current .map((item, idx) => (item.choose ? idx : -1)) .filter((idx) => idx !== -1); @@ -101,10 +111,9 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { if (data) { const index = Number(getBizCycle) - 1; form.reset(data[index]); - ref.current = data[index]?.pplInstls ?? null; + ref.current = data[index]?.pplInstls ?? []; console.log("form reset with data:", data[index]); - } }, [getBizCycle, data]); @@ -131,161 +140,165 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { return ( <> -
- {/* 차수별 등록 현황 폼 */} -
-
- -
-

-
-

등록차수

+
+ {/* 차수별 등록 현황 폼 */} +
+ + +
+

+
+

등록차수

+ { + setBizCycle(String(val)); + }} + > + + +
+
+ + + + + + + +

재이용 원수취수 현황

+
+ + +
+

재이용 공급관로 설치 현황

+
+ { - setBizCycle(String(val)); - }} - > - - + selectArray={code.yn} + value={ppiYn} + className="w-32" + selectClass="w-full" + onSelectValue={(val) => setPpiYn(String(val))} + /> + + + +
-
- - - - - +
+ +
-

재이용 원수취수 현황

-
- - -
-

재이용 공급관로 설치 현황

-
- - setPpiYn(String(val))} - /> - - - - -
-
- -
+

하수처리수 재이용수 수요처

+
+ + +
+ + +
- - -

하수처리수 재이용수 수요처

-
- - -
- - + setIsFcOrgwts(open)} + bodyClass={"w-[60vw] max-w-none h-[60vh]"} + body={} + >
- - setIsFcOrgwts(open)} - bodyClass={"w-[60vw] max-w-none h-[60vh]"} - body={} - > -
); } diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 89343cb93..018f9b011 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -31,7 +31,9 @@ export type FilesType = { }; export function PbnstMngForm({ data }: { data: customPbnst }) { - const { pbnst, pbnstUpdate, fileDelete } = useWrStore((state) => state); + const { pbnst, pbnstUpdate, fileDelete, pbnstMngData } = useWrStore( + (state) => state + ); const { pbnstMngUpHeadList } = pbnst; const [ruseOperData, setRuseOperData] = useState(); const [planFiles, setPlanFiles] = useState(null); @@ -50,6 +52,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const form = useForm>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), + //mode:'onChange' }); const { @@ -61,9 +64,27 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name: "fcOpers", }); +useEffect(() => { + console.log("ref.current", ref.current); +},[ref.current]) + useEffect(() => { + const formData = form.getValues(); + + // 기존 코드: formData.fcOpers = ref.current ? [...ref.current] : []; + // 새 코드: 상태를 유지한 채 복사 + formData.fcOpers = form.getValues("fcOpers"); // ← form 내부 상태 기준으로 복사 + formData.fcFiles = regFileList ? [...regFileList] : []; + + pbnstMngData([formData] as customPbnst[]); + }, [form.formState, regFileList]); + + useEffect(() => { + console.log(" mngRegFrom ", pbnst.pbnstMngRegData); + }, [pbnst.pbnstMngRegData]); + const fileDownload = (index: number) => {}; const plusHist = () => { - append({ + const regData = { choose: false, rgtr: "", mdfr: "", @@ -73,7 +94,15 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { rprtvBzenty: "", bgngDt: new Date(), endDt: new Date(), + }; + const currentTableDataFromRef = ref.current ? [...ref.current] : []; + const newDataForRHF = [...currentTableDataFromRef, regData]; + form.setValue("fcOpers", newDataForRHF, { + shouldValidate: true, // 필요하다면 유효성 검사 실행 + shouldDirty: true, // 폼 상태를 dirty로 변경 }); + const latestOpers = form.getValues("fcOpers"); + ref.current = [...latestOpers]; }; const removeSelected = () => { @@ -85,9 +114,11 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { }; useEffect(() => { - if (!data) return; - form.reset(data); - setRuseOperData(data.fcOpers); + if (data) { + form.reset(data); + form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk); + ref.current = data.fcOpers || []; + } }, [data]); // 2. Define a submit handler. @@ -151,32 +182,32 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { : setPlanFiles(setReFiles); } }; - const regFileFilter=(files:FilesType[], fileKnd:string, regFile:fcFileType[])=>{ - const planDatas = regFile?.filter(item=>item.fileKnd!==fileKnd) || []; - const data = files.map((item) => ({ - fileTkn: item.atflCd, - filePath: item.file.name, - fileKnd: fileKnd, - rgtr: TEST_UUID, - mdfr: TEST_UUID, - })); - return [...planDatas, ...data] - } + const regFileFilter = ( + files: FilesType[], + fileKnd: string, + regFile: fcFileType[] + ) => { + const planDatas = regFile?.filter((item) => item.fileKnd !== fileKnd) || []; + const data = files.map((item) => ({ + fileTkn: item.atflCd, + filePath: item.file.name, + fileKnd: fileKnd, + rgtr: TEST_UUID, + mdfr: TEST_UUID, + })); + return [...planDatas, ...data]; + }; useEffect(() => { - console.log("relationfiles:", relationfiles); if (relationfiles) { - setRegFileList(regFileFilter(relationfiles, "계통도", regFileList||[])); + setRegFileList(regFileFilter(relationfiles, "계통도", regFileList || [])); } }, [relationfiles]); useEffect(() => { if (planFiles) { - setRegFileList(regFileFilter(planFiles, "평면도", regFileList||[])); + setRegFileList(regFileFilter(planFiles, "평면도", regFileList || [])); } }, [planFiles]); - useEffect(() => { - console.log("regFileList:", regFileList); - }, [regFileList]); useEffect(() => { console.log("form errors:", form.formState.errors); diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index b46bd028e..4d2553878 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -1,24 +1,41 @@ "use client"; import { useWrStore } from "@/app/store"; -import type { customPbnst, fcBizType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { + customPbnst, + fcBizType, + pubHasuType, +} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { getCity } from "@/components/lib/func/commom"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; -import { ScrollArea, SelectBox, UiTable, type SelectDataType } from "@common/business_components"; -import { Button, Input, Label, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components/ui"; +import { + ScrollArea, + SelectBox, + UiTable, + type SelectDataType, +} from "@common/business_components"; +import { + Button, + Input, + Label, + Tabs, + TabsContent, + TabsList, + TabsTrigger, +} from "@common/components/ui"; import { useEffect, useState } from "react"; import type { objSearchType } from "../bdstRegModal/bdstRegModal"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; - -export function PbnstRegModal({ data }: { data: customPbnst }) { - +export function PbnstRegModal({ data }: { data: pubHasuType }) { const { code, pbnst } = useWrStore((state) => { return state; }); const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst; - const [pbnstBdstForm, setPbnstBdstForm] = useState({} as customPbnst); + const [pbnstBdstForm, setPbnstBdstForm] = useState( + {} as customPbnst + ); const [currentTab, setCurrentTab] = useState("mng"); // const nodeList = headMakeColSpan(pubFacHeadList.moUpHeadList); @@ -27,32 +44,44 @@ export function PbnstRegModal({ data }: { data: customPbnst }) { }; useEffect(() => { - if (!data) return; - console.log("데이터", data) + + const regData = { + pbnstRuseFcltPk: String(data.bscFctCd + "R" + "1"), + fcBizs: [{ pbnstRuseFcltFk: String(data.bscFctCd + "R" + "1") } as unknown as fcBizType], + }; + + console.log("regData ", regData) + setPbnstBdstForm(regData as customPbnst); }, [data]); return ( <> -

하수재이용 시설 신규등록

+

+ 하수재이용 시설 신규등록 +

- 시설정보 - 차수별정보 + + 시설정보 + + + 차수별정보 + + - + - + - - ) + ); } - - diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index d31c2efcd..aba220a4c 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -30,7 +30,6 @@ const RuseMngTable = React.forwardRef( }, ref) => { const [tableState, setTableState] = useState([...tableData]); useEffect(() => { - console.log("tableState", tableState); if (ref && typeof ref === "object" && "current" in ref) { ref.current = tableState; } diff --git a/apps/wr/middleware.ts b/apps/wr/middleware.ts index e30e04f4d..080ed30c9 100644 --- a/apps/wr/middleware.ts +++ b/apps/wr/middleware.ts @@ -21,7 +21,7 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/attach-service")) { const requestHeaders = new Headers(req.headers); - const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0MjU0NzJ9.rABGFEzyCEDYwnuzd-6V0lPtckSGx-h77-tJBYFz00KPowmWBpwMLrSynxmHpmtmga86ksIYxuoMkiT1_aI6Sw" + const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0Mzc0OTF9.JM2NHEwTpgDW9nonZY3186IK_frIh667SyxMQfPwqa_lc-5mcTFNtrWXH5b72_ng39qiPSi504iF1roFEJ0c6w" const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0' //const token = req.cookies.get(CLAIM_NAME)?.value; //const userId = req.cookies.get(AUTH_USER_ID)?.value; From fa1a9159eb50029231949467b971b787614af18c Mon Sep 17 00:00:00 2001 From: leedj312 Date: Thu, 29 May 2025 16:59:33 +0900 Subject: [PATCH 3/4] Co-authored-by: truthplumage --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 6 +- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 176 ++++++++-------- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 188 ++++++++---------- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 13 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 57 +++--- .../mngRegFormDetail/mngRegFormDetail.tsx | 2 +- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 43 ++-- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 8 +- 8 files changed, 249 insertions(+), 244 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 7c5ebdb10..67f02fdb2 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -57,7 +57,9 @@ useEffect(() => { const cellClick = (val: number | undefined) => { if (val === undefined) return; const selectRow = pbnstHasuRes?.[val]; - setSelectedRow(selectRow); + if (selectRow) { + setSelectedRow(selectRow); + } if (pbnstRes !== null){ alert("등록된 재이용시설 정보가 없습니다. 신규등록 하십시오.") return; @@ -145,7 +147,7 @@ useEffect(() => { - + diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index a0dce391a..f97a791dd 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -1,10 +1,6 @@ import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import type { TableUpperProps } from "../rainReg"; - - - - export const pubFacHeadListExport: TableUpperProps[] = [ { id: "sido", title: "시도" }, { id: "gugun", title: "시군구" }, @@ -18,118 +14,120 @@ export const pubFacHeadListExport: TableUpperProps[] = [ export const pbnstMngUpHeadListExport: TableUpperProps[] = [ { id: "choose", title: "선택", type: "checkbox" }, - { id: "operMthd", title: "운영방식", edit: true}, - { id: "rprtvBzenty", title: "대행업체", edit: true}, - { id: "bgngDt", title: "시작일", upName: "upChangeRe", upSequnce: 1, type: "date"}, - { id: "endDt", title: "종료일", upName: "upChangeRe", upSequnce: 2, type: "date"}, -]; - + { id: "operMthd", title: "운영방식", edit: true }, + { id: "rprtvBzenty", title: "대행업체", edit: true }, + { + id: "bgngDt", + title: "시작일", + upName: "upChangeRe", + upSequnce: 1, + type: "date", + }, + { + id: "endDt", + title: "종료일", + upName: "upChangeRe", + upSequnce: 2, + type: "date", + }, +]; export const pplInstlsHeadListExport: TableUpperProps[] = [ { id: "choose", title: "선택", type: "checkbox" }, - { id: "ppMqlt", title: "관재질", type: "select", selectData:'pplQulity' }, - { id: "pdmt", title: "관경", type: "select", selectData:'pplLenght'}, + { id: "ppMqlt", title: "관재질", type: "select", selectData: "pplQulity" }, + { id: "pdmt", title: "관경", type: "select", selectData: "pplLenght" }, { id: "cpct", title: "연장", edit: true, type: "number" }, ]; - export const pbnstDemandHeadListExport: TableUpperProps[] = [ { id: "dmdCoNm", title: "수요처명" }, { id: "daddr", title: "위치(주소)" }, - { id: "useUsgCd", title: "사용용도", }, - { id: "splyBgngDay", title: "공급시작일", }, - { id: "splyEndDay", title: "공급종료일", }, - { id: "splyCpct", title: "공급량(m³/일)", }, - { id: "splyFmYon", title: "공급유량계 유무", }, + { id: "useUsgCd", title: "사용용도" }, + { id: "splyBgngDay", title: "공급시작일" }, + { id: "splyEndDay", title: "공급종료일" }, + { id: "splyCpct", title: "공급량(m³/일)" }, + { id: "splyFmYon", title: "공급유량계 유무" }, ]; - export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ - { id: "ruseUtztnFcltNm", title: "운영방식" }, + { id: "ruseUtztnFcltNm", title: "운영방식" }, { id: "orgwtWtritQnt", title: "원수취수량" }, - { id: "tmsYn", title: "하수처리량TMS 전후", }, - { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​", }, - { id: "dtlPstnExpln", title: "상세위치 설명", }, + { id: "tmsYn", title: "하수처리량TMS 전후" }, + { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​" }, + { id: "dtlPstnExpln", title: "상세위치 설명" }, ]; export const fcOrgwtsHeadListExport: TableUpperProps[] = [ { id: "sido", title: "시도" }, - { id: "gugun", title: "시군구" }, + { id: "gugun", title: "시군구" }, { id: "bscFctNm", title: "시설명" }, { id: "addr", title: "위치" }, - -] +]; export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, ]; -export type formDetailType ={ - id:string, - lable:string - type?:string -} +export type formDetailType = { + id: string; + lable: string; + type?: string; +}; +export const wasteWaterFcltINfo: formDetailType[] = [ + { id: "wwtEmsnFcltPrmsnYn", lable: "폐수배출물신고 허가여부" }, + { id: "tmsInstlYn", lable: "Tms설치여부" }, + { id: "pbnstDrngInflwExclYn", lable: "공공하수도유입제외 허가여부" }, +]; -export const wasteWaterFcltINfo:formDetailType[]=[ - {id:'wwtEmsnFcltPrmsnYn' , lable:'폐수배출물신고 허가여부'}, - {id:'tmsInstlYn' , lable:'Tms설치여부'}, - {id:'pbnstDrngInflwExclYn' , lable:'공공하수도유입제외 허가여부'}, -] +export const concentratedWaterInfo: formDetailType[] = [ + { id: "erctWtrOcrnCpct", lable: "눙축수 발생량(m³/일)", type: "number" }, + { id: "erctUswtrLinkSpt", lable: "눙축수연계지점" }, + { id: "erctUswtrFcltCpct", lable: "시설용량(m³/일)", type: "number" }, + { id: "erctUswtrPrcsMeth", lable: "눙축수처리방식" }, + { id: "erctUswtrPrcsMsrcCd", lable: "눙축수처리공법" }, +]; -export const concentratedWaterInfo:formDetailType[]=[ -{id:'erctWtrOcrnCpct' , lable:'눙축수 발생량(m³/일)'}, -{id:'erctUswtrLinkSpt' , lable:'눙축수연계지점'}, -{id:'erctUswtrFcltCpct' , lable:'시설용량(m³/일)'}, -{id:'erctUswtrPrcsMeth' , lable:'눙축수처리방식'}, -{id:'erctUswtrPrcsMsrcCd' , lable:'눙축수처리공법'}, -] +export const ruseFcltinfo: formDetailType[] = [ + { id: "rprcsFcltCpct", lable: "시설용량(m³/일)", type: "number" }, + { id: "majorPrcsMsrcCd", lable: "주처리공법" }, + { id: "addr", lable: "위치(주소)" }, + { id: "rprcsMthdCd", lable: "재처리방식" }, + { id: "inoutYn", lable: "위치(처리장 내외)" }, // 머가 내? 외?, + { id: "mainSplyPumpCpct", lable: "메인공급펌프 용량", type: "number" }, +]; -export const ruseFcltinfo:formDetailType[]=[ - {id:'rprcsFcltCpct' , lable:'시설용량(m³/일)'}, - {id:'majorPrcsMsrcCd' , lable:'주처리공법'}, - {id:'addr' , lable:'위치(주소)'}, - {id:'rprcsMthdCd' , lable:'재처리방식'}, - {id:'inoutYn' , lable:'위치(처리장 내외)'},// 머가 내? 외?, - {id:'mainSplyPumpCpct' , lable:'메인공급펌프 용량'}, - ] - +export const businessMoneyInfo: formDetailType[] = [ + { id: "gvsbs", lable: "국고", type: "number" }, + { id: "lcep", lable: "지방비", type: "number" }, + { id: "cusrAlotm", lable: "민간투자비", type: "number" }, + { id: "etc", lable: "기타" }, + { id: "totalMoney", lable: "합계", type: "number" }, +]; -export const businessMoneyInfo:formDetailType[]=[ - {id:'gvsbs' , lable:'국고'}, - {id:'lcep' , lable:'지방비'}, - {id:'username' , lable:'민간투자비'}, - {id:'cusrAlotm' , lable:'원인자부담금'}, - {id:'etc' , lable:'기타'}, - {id:'totalMoney' , lable:'합계'}, -] - -export const businessSttnInfo:formDetailType[]=[ - {id:'seCd' , lable:'구분'}, - {id:'bizMthdCd' , lable:'사업방식'}, - {id:'bizCmcnDay' , lable:'사업준공일' ,type:'date'}, - {id:'instlAprvSncnDt' , lable:'설치승인인가일' ,type:'date'} , -] - - -export const ruseFcltIntakeList:formDetailType[]=[ - {id:'seCd' , lable:'구분'}, - {id:'bizMthdCd' , lable:'사업방식'}, - {id:'bizCmcnDay' , lable:'사업준공일' ,type:'date'}, - {id:'instlAprvSncnDt' , lable:'설치승인인가일' ,type:'date'} , -] - -export const ruseWaterQulityList:formDetailType[]=[ - {id:'bod' , lable:'BOD(mg/L)'}, - {id:'grssClfg' , lable:'총대장균군수(개/mg)'}, - {id:'combResdch' , lable:'결합잔류염소(mh/L)'}, - {id:'trbt' , lable:'탁도(NTU)'}, - {id:'smll' , lable:'냄새'}, - {id:'crmty' , lable:'색도'}, - {id:'tn' , lable:'총질소(mg/L)'}, - {id:'tph' , lable:'총인(mg/L)'}, - {id:'ph' , lable:'수소이온농도'}, - {id:'clIonQnt' , lable:'염화물(mg/L)'}, - {id:'cdtnv' , lable:'전기전도도(μs/cm)​'}, -] +export const businessSttnInfo: formDetailType[] = [ + { id: "seCd", lable: "구분" }, + { id: "bizMthdCd", lable: "사업방식" }, + { id: "bizCmcnDay", lable: "사업준공일", type: "date" }, + { id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" }, +]; +export const ruseFcltIntakeList: formDetailType[] = [ + { id: "seCd", lable: "구분" }, + { id: "bizMthdCd", lable: "사업방식" }, + { id: "bizCmcnDay", lable: "사업준공일", type: "date" }, + { id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" }, +]; +export const ruseWaterQulityList: formDetailType[] = [ + { id: "bod", lable: "BOD(mg/L)", type: "number" }, + { id: "grssClfg", lable: "총대장균군수(개/mg)", type: "number" }, + { id: "combResdch", lable: "결합잔류염소(mh/L)", type: "number" }, + { id: "trbt", lable: "탁도(NTU)", type: "number" }, + { id: "smll", lable: "냄새", type: "number" }, + { id: "crmty", lable: "색도", type: "number" }, + { id: "tn", lable: "총질소(mg/L)", type: "number" }, + { id: "tph", lable: "총인(mg/L)", type: "number" }, + { id: "ph", lable: "수소이온농도", type: "number" }, + { id: "clIonQnt", lable: "염화물(mg/L)", type: "number" }, + { id: "cdtnv", lable: "전기전도도(μs/cm)​", type: "number" }, +]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index c04302663..903fe01b9 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -50,137 +50,116 @@ export type fcFileType = z.infer; const pplInstlSchema = z.object({ ruseFcltBizFk: z.string(), choose:z.boolean().default(false), - pdmt: z.string(), - ppMqlt: z.string(), - cpct: z.string(), + pdmt: z.string().default(''), + ppMqlt: z.string().default(""), + cpct: z.number().default(0), }); const fcFileSchema = z.object({ - ruseFcltFk: z.number().default(0).nullish(), + ruseFcltFk: z.number().nullish(), fileTkn: z.string(), filePath: z.string(), fileKnd: z.string(), regDt: z.date().default(new Date()).nullish(), - rgtr: z.string(), + rgtr: z.string().nullish(), mdfcnDt: z.date().default(new Date()).nullish(), - mdfr: z.string(), + mdfr: z.string().nullish(), }); const fcOperSchema = z.object({ - pbnstRuseFcltOperInfoPk: z.number().default(0), - pbnstRuseFcltFk: z.number().default(0), + pbnstRuseFcltOperInfoPk: z.number().nullish(), + pbnstRuseFcltFk: z.number().nullish(), operMthd: z.string(), rprtvBzenty: z.string(), bgngDt: z.date().default(new Date()), endDt: z.date().default(new Date()), regDt: z.date().nullish(), - rgtr: z.string(), + rgtr: z.string().default(""), mdfcnDt: z.date().nullish(), - mdfr: z.string().default("test"), + mdfr: z.string().default(""), choose: z.boolean().default(false), }); const fcOrgwtSchema = z.object({ - pbnstRuseFcltBizFk: z.number().default(0), - swtrmtFcltFk: z.string().default(''), - orgwtWtritQnt: z.string(), - tmsYn: z.string(), - dschgFmYn: z.string(), - dtlPstnExpln: z.string(), - regDt: z.string().nullish(), - rgtr: z.string(), - mdfcnDt: z.string().nullish(), - mdfr: z.string(), + pbnstRuseFcltBizFk: z.number().nullish(), + swtrmtFcltFk: z.number().default(0), + orgwtWtritQnt: z.number(), + tmsYn: z.enum(["Y", "N"] ).default("N"), + dschgFmYn: z.enum(["Y", "N"] ).default("N"), + dtlPstnExpln: z.string().default(''), + regDt: z.date().nullish(), + rgtr: z.string().default(''), + mdfcnDt: z.date().nullish(), + mdfr: z.string().default(''), + choose: z.boolean().default(false), }); -const fcPrfmncSchema = z.object({ - pbnstRuseFcltFk: z.number().default(0), - ym: z.string(), - wshwtr: z.string(), - coolUswtr: z.string(), - cleanUswtr: z.string(), - drwtUswtr: z.string(), - dltnUswtr: z.string(), - ithlRswtr: z.string(), - ithlEtcUswtr: z.string(), - cleanToilUswtr: z.string(), - resn: z.string(), - lndwtr: z.string(), - hydUswtr: z.string(), - rvrKeepUswtr: z.string(), - farmUswtr: z.string(), - ugwtChr: z.string(), - indstUswtr: z.string(), - regDt: z.date().nullish(), - rgtr: z.string(), - mdfcnDt: z.date().nullish(), - mdfr: z.string(), -}); export const fcBizSchema = z.object({ - pbnstRuseFcltBizPk: z.number().default(0), - pbnstRuseFcltFk: z.string().default(''), - cycl: z.string(), + pbnstRuseFcltBizPk: z.number().default(1), + pbnstRuseFcltFk: z.number().nullish(), + superkey: z.string().default(""), + cycl: z.number(), seCd: z.string(), bizMthdCd: z.string(), - instlAprvSncnDt: z.string(), - bizCmcnDay: z.string(), - gvsbs: z.string(), - lcep: z.string(), - cusrAlotm: z.string(), - etc: z.string(), - totalMoney: z.string(), - rprcsFcltCpct: z.string(), + instlAprvSncnDt: z.date().nullish(), + bizCmcnDay: z.date().nullish(), + gvsbs: z.number().default(0), + lcep: z.number().default(0), + cusrAlotm: z.number().default(0), + etc: z.string().default(''), + totalMoney: z.number().default(0).nullish(), + rprcsFcltCpct: z.number(), majorPrcsMsrcCd: z.string(), addr: z.string(), rprcsMthdCd: z.string(), - inoutYn: z.string(), - mainSplyPumpCpct: z.string(), - erctWtrOcrnCpct: z.string(), - erctUswtrLinkSpt: z.string(), - erctUswtrFcltCpct: z.string(), - erctUswtrPrcsMeth: z.string(), - erctUswtrPrcsMsrcCd: z.string(), - wwtEmsnFcltPrmsnYn: z.string(), - tmsInstlYn: z.string(), - pbnstDrngInflwExclYn: z.string(), - bod: z.string(), - grssClfg: z.string(), - combResdch: z.string(), - trbt: z.string(), - clIonQnt: z.string(), - smll: z.string(), - crmty: z.string(), - tph: z.string(), - tn: z.string(), - ph: z.string(), - cdtnv: z.string(), - designCst: z.string(), - cstrnSpvsCst: z.string(), - fcltSbsdCst: z.string(), - wstCst: z.string(), - cnstCmcnCst: z.string(), - mntrgEqpmntInstlCst: z.string(), - gisDbCst: z.string(), - elpwrMtrngCst: z.string(), - mchnCst: z.string(), - archCst: z.string(), - pplCst: z.string(), - ruseFcltCst: z.string(), - designCstClcln: z.string(), - cstrnSpvsCstClcln: z.string(), - fcltSbsdCstClcln: z.string(), - wstCstClcln: z.string(), - cnstCmcnCstClcln: z.string(), - mntrgEqpmntInstlCstClcln: z.string(), - gisDbCstClcln: z.string(), - elpwrMtrngCstClcln: z.string(), - mchnCstClcln: z.string(), - archCstClcln: z.string(), - pplCstClcln: z.string(), - ruseFcltCstClcln: z.string(), + inoutYn: z.enum(["Y", "N"]), + mainSplyPumpCpct: z.number().nullish(), + erctWtrOcrnCpct: z.number().nullish(), + erctUswtrLinkSpt: z.string().nullish(), + erctUswtrFcltCpct: z.number().nullish(), + erctUswtrPrcsMeth: z.string().nullish(), + erctUswtrPrcsMsrcCd: z.string().nullish(), + wwtEmsnFcltPrmsnYn: z.enum(["Y", "N"]), + tmsInstlYn: z.enum(["Y", "N"]), + pbnstDrngInflwExclYn: z.enum(["Y", "N"]), + bod: z.number(), + grssClfg: z.number(), + combResdch: z.number(), + trbt: z.number(), + clIonQnt: z.number(), + smll: z.number(), + crmty: z.number(), + tph: z.number(), + tn: z.number(), + ph: z.number(), + cdtnv: z.number(), + designCst: z.number().nullish(), + cstrnSpvsCst: z.number().nullish(), + fcltSbsdCst: z.number().nullish(), + wstCst: z.number().nullish(), + cnstCmcnCst: z.number().nullish(), + mntrgEqpmntInstlCst: z.number().nullish(), + gisDbCst: z.number().nullish(), + elpwrMtrngCst: z.number().nullish(), + mchnCst: z.number().nullish(), + archCst: z.number().nullish(), + pplCst: z.number().nullish(), + ruseFcltCst: z.number().nullish(), + designCstClcln: z.number().nullish(), + cstrnSpvsCstClcln: z.number().nullish(), + fcltSbsdCstClcln: z.number().nullish(), + wstCstClcln: z.number().nullish(), + cnstCmcnCstClcln: z.number().nullish(), + mntrgEqpmntInstlCstClcln: z.number(), + gisDbCstClcln: z.number().nullish(), + elpwrMtrngCstClcln: z.number().nullish(), + mchnCstClcln: z.number().nullish(), + archCstClcln: z.number().nullish(), + pplCstClcln: z.number().nullish(), + ruseFcltCstClcln: z.number().nullish(), fcOrgwts: z.array(fcOrgwtSchema), pplInstls: z.array(pplInstlSchema), - flg: z.string(), + flg: z.string().nullish(), regDt: z.string().nullish(), rgtr: z.string(), mdfcnDt: z.string().nullish(), @@ -188,12 +167,13 @@ export const fcBizSchema = z.object({ }); export const pbnstRegZod = z.object({ - pbnstRuseFcltPk: z.string().default(""), + pbnstRuseFcltPk: z.number().default(1), swtrmtFcltFk: z.string().default(""), + superkey:z.string().default(""), ruseUtztnFcltNm: z.string().default(""), - fcltCpct: z.string().default(""), - ruseCpct: z.string().default(""), - splyExtraCpct: z.string().default(""), + fcltCpct: z.number().default(0), + ruseCpct: z.number().default(0), + splyExtraCpct: z.number().default(0), regDt: z.date().default(new Date()), rgtr: z.string().default("test"), mdfcnDt: z.date().default(new Date()), diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 3496e1140..aa8d181e9 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -68,7 +68,13 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }); useEffect(() => { - pbnstBizData(form.watch() as fcBizType); + + const formData = form.watch() + + formData.pplInstls = ref.current? [...ref.current]:[] // ← form 내부 상태 기준으로 복사 + console.log("formData pplReg", formData) + + pbnstBizData(formData as fcBizType); }, [form.formState]); useEffect(() => { @@ -86,8 +92,8 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk??"", choose: false, ppMqlt: "", - pdmt: "", - cpct: "", + pdmt: '', + cpct: 0, } const currentTableDataFromRef = ref.current ? [...ref.current] : []; const newDataForRHF = [...currentTableDataFromRef, regData]; @@ -131,7 +137,6 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }, [code]); useEffect(() => { - console.log("ppiSelectList:", ppiSelectList); }, [ppiSelectList]); useEffect(() => { diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 018f9b011..3477c5b81 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -8,6 +8,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { use, useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; +import moment from "moment"; import { commonButonSize, @@ -16,7 +17,6 @@ import { } from "@/components/lib/class/comClass"; import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; -import type { Upload } from "tus-js-client"; import { pbnstRegZod, type customPbnst, @@ -34,14 +34,10 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const { pbnst, pbnstUpdate, fileDelete, pbnstMngData } = useWrStore( (state) => state ); - const { pbnstMngUpHeadList } = pbnst; - const [ruseOperData, setRuseOperData] = useState(); + const [planFiles, setPlanFiles] = useState(null); const [relationfiles, setRelationFiles] = useState(null); - const [isModalOpen, setIsModalOpen] = useState(false); const [regFileList, setRegFileList] = useState(null); - - const [upload, setUpload] = useState(null); const [progress, setProgress] = useState(0); //const new File([] as BlobPart[], "") 파일 다운로드 활용 const handleProgress = (percentage: string) => { @@ -52,7 +48,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const form = useForm>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), - //mode:'onChange' }); const { @@ -64,22 +59,17 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name: "fcOpers", }); -useEffect(() => { - console.log("ref.current", ref.current); -},[ref.current]) - useEffect(() => { - const formData = form.getValues(); - // 기존 코드: formData.fcOpers = ref.current ? [...ref.current] : []; - // 새 코드: 상태를 유지한 채 복사 - formData.fcOpers = form.getValues("fcOpers"); // ← form 내부 상태 기준으로 복사 + useEffect(() => { + const formData = form.watch(); + formData.fcOpers = ref.current ? [...ref.current] : []; formData.fcFiles = regFileList ? [...regFileList] : []; pbnstMngData([formData] as customPbnst[]); }, [form.formState, regFileList]); useEffect(() => { - console.log(" mngRegFrom ", pbnst.pbnstMngRegData); + pbnstMngData(pbnst.pbnstMngRegData); }, [pbnst.pbnstMngRegData]); const fileDownload = (index: number) => {}; @@ -88,8 +78,6 @@ useEffect(() => { choose: false, rgtr: "", mdfr: "", - pbnstRuseFcltFk: 0, - pbnstRuseFcltOperInfoPk: 0, operMthd: "", rprtvBzenty: "", bgngDt: new Date(), @@ -99,7 +87,7 @@ useEffect(() => { const newDataForRHF = [...currentTableDataFromRef, regData]; form.setValue("fcOpers", newDataForRHF, { shouldValidate: true, // 필요하다면 유효성 검사 실행 - shouldDirty: true, // 폼 상태를 dirty로 변경 + shouldDirty: true, // 폼 상태를 dirty로 변경 }); const latestOpers = form.getValues("fcOpers"); ref.current = [...latestOpers]; @@ -115,12 +103,23 @@ useEffect(() => { useEffect(() => { if (data) { + console.log(" data ", data ) + console.log(" pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData) form.reset(data); form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk); - ref.current = data.fcOpers || []; + ref.current = data.fcOpers; } }, [data]); + // useEffect(() => { + // if (pbnst.pbnstMngRegData && !mountCheck.current) { + // console.log('pbnst.pbnstMngRegData ', pbnst.pbnstMngRegData) + // mountCheck.current=true + // // form.reset(data); + // // form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk); + // // ref.current = data.fcOpers || []; + // } + // }, [ ]); // 2. Define a submit handler. function onSubmit(values: z.infer) { values.fcOpers = ref.current || []; @@ -130,7 +129,6 @@ useEffect(() => { } const fileHandler = (files: File[], type: string) => { - console.log("fileHandler", files); let fileList = [] as FilesType[]; if (type === "relation" && relationfiles) { fileList = relationfiles; @@ -208,7 +206,6 @@ useEffect(() => { } }, [planFiles]); - useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); @@ -278,7 +275,9 @@ useEffect(() => { { + field.onChange(Number(e.target.value)); + }} value={field.value} /> @@ -294,7 +293,9 @@ useEffect(() => { { + field.onChange(Number(e.target.value)); + }} value={field.value} /> @@ -310,7 +311,9 @@ useEffect(() => { { + field.onChange(Number(e.target.value)); + }} value={field.value} /> @@ -326,7 +329,9 @@ useEffect(() => { { + field.onChange(Number(e.target.value)); + }} value={field.value} /> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 21b3f7ce0..0afb35206 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -45,7 +45,7 @@ export default function MngRegFormDetail({ className={"rounded-lg !w-full"} /> ) : item.type === "number" ? ( - + {field.onChange(Number(e.target.value))}} /> ) : ( )} diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index 4d2553878..e58f7b856 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -11,33 +11,33 @@ import { getCity } from "@/components/lib/func/commom"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { ScrollArea, - SelectBox, - UiTable, - type SelectDataType, } from "@common/business_components"; import { Button, - Input, - Label, Tabs, TabsContent, TabsList, TabsTrigger, } from "@common/components/ui"; import { useEffect, useState } from "react"; -import type { objSearchType } from "../bdstRegModal/bdstRegModal"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; export function PbnstRegModal({ data }: { data: pubHasuType }) { - const { code, pbnst } = useWrStore((state) => { + const { pbnst ,pbnstUpdate} = useWrStore((state) => { return state; }); - const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst; const [pbnstBdstForm, setPbnstBdstForm] = useState( {} as customPbnst ); const [currentTab, setCurrentTab] = useState("mng"); - // const nodeList = headMakeColSpan(pubFacHeadList.moUpHeadList); + +const pbnstRegTotal = ()=>{ + console.log(" pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData) + + if(pbnst.pbnstMngRegData[0]) + pbnstUpdate(pbnst.pbnstMngRegData[0]) +} + const handleTabChange = (value: string) => { setCurrentTab(value); @@ -45,15 +45,26 @@ export function PbnstRegModal({ data }: { data: pubHasuType }) { useEffect(() => { - const regData = { - pbnstRuseFcltPk: String(data.bscFctCd + "R" + "1"), - fcBizs: [{ pbnstRuseFcltFk: String(data.bscFctCd + "R" + "1") } as unknown as fcBizType], - }; - console.log("regData ", regData) - setPbnstBdstForm(regData as customPbnst); + if(data ){ + + let regData = { + superKey: String(data.bscFctCd + "1"), + swtrmtFcltFk: String(data.bscFctCd ), + pbnstRuseFcltPk: 1, + fcBizs: [{ pbnstRuseFcltFk: 1 ,cycl:1 } as unknown as fcBizType], + }; + + setPbnstBdstForm(regData as unknown as customPbnst); + } + }, [data]); + + useEffect(() =>{ + + console.log('pbnst.pbnstMngRegData ', pbnst.pbnstMngRegData) + },[pbnst.pbnstMngRegData]) return ( <>

@@ -70,7 +81,7 @@ export function PbnstRegModal({ data }: { data: pubHasuType }) { 차수별정보 - diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index aba220a4c..73add7846 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -36,6 +36,7 @@ const RuseMngTable = React.forwardRef( }, [tableState]); useEffect(() => { + if(tableData) setTableState(tableData); }, [tableData]); return ( @@ -75,7 +76,9 @@ const RuseMngTable = React.forwardRef( return next; }) }} - value={tableState[i][head.id] || ""} + value={head.type === "number" ? + Number(tableState[i][head.id])||0 : tableState[i][head.id] || "" + } /> ) : head.type === "select" ? ( ( }} > - ) : ( + ) : + ( `${item[head.id] || ""}` )} From 41df013bb382c91a18b3023e35f5e1f3f384b877 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Thu, 29 May 2025 19:56:18 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/chart/BarChart.tsx | 17 +++-- .../src/ui/chart/LineChart.tsx | 17 ++--- .../src/ui/excel/excelStyle.tsx | 11 ++-- .../src/ui/excel/index.tsx | 63 ++++++++----------- .../src/ui/file-upload/index.tsx | 8 ++- .../src/ui/file-upload/lib/file_upload.tsx | 19 +++--- .../src/ui/search_base_form/index.tsx | 2 + .../src/ui/search_form_left/index.tsx | 4 +- .../business_components/src/ui/tab/index.tsx | 54 ++++++++-------- .../src/ui/table/index.tsx | 2 + .../src/ui/table/lib/pagination.tsx | 17 ++--- 11 files changed, 117 insertions(+), 97 deletions(-) diff --git a/packages/common/business_components/src/ui/chart/BarChart.tsx b/packages/common/business_components/src/ui/chart/BarChart.tsx index b75bf373c..0802a72e4 100644 --- a/packages/common/business_components/src/ui/chart/BarChart.tsx +++ b/packages/common/business_components/src/ui/chart/BarChart.tsx @@ -64,10 +64,10 @@ const CustomLegend = (props: any) => { const { payload } = props; return (
- {payload.map((entry, index: number) => ( + {payload.map((entry: unknown, index: number) => (
-
- {entry.value} +
+ {(entry as {value: string}).value}
))}
@@ -76,7 +76,15 @@ const CustomLegend = (props: any) => { export default function Chart({chartConfig=undefined, chartData=[], chartTitle='차트', chartClassName='w-full h-full', graphSize=40, yFieldText='', showLegend=false} : BarChartProps) { const colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FFEEAD", "#D4A5A5"]; + const getMaxValue = (data: any[], keyPrefix: string) => { + return Math.max(...data.map(item => + Object.keys(item) + .filter(key => key.includes(keyPrefix)) + .map(key => item[key]) + ).flat()); + }; + const barMaxValue = getMaxValue(chartData, 'barVal'); return ( <> {chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( @@ -102,7 +110,8 @@ export default function Chart({chartConfig=undefined, chartData=[], chartTitle=' axisLine={true} fontSize={12} fontWeight={500} - label={yFieldText ? { value: yFieldText, className:"text-[13px] foont-bold", position: 'top', textAnchor: 'middle', offset: 20 } : undefined} + domain={[0, Math.ceil(barMaxValue * 1)]} + label={yFieldText ? { value: yFieldText, className:"text-[13px] font-bold", position: 'insideLeft', angle: -90, offset: 20 } : undefined} /> }/> {chartData && chartData.length > 0 && ( diff --git a/packages/common/business_components/src/ui/chart/LineChart.tsx b/packages/common/business_components/src/ui/chart/LineChart.tsx index a689af8ca..4014702b6 100644 --- a/packages/common/business_components/src/ui/chart/LineChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineChart.tsx @@ -113,20 +113,21 @@ export default function Linechart({ }, []); // 데이터의 최대값 계산 - const getMaxValue = (data: ChartDataType, keyPrefix: string) => { - return Math.max(...Object.values(data).map(item => - Object.keys(item) - .filter(key => key.includes(keyPrefix)) - .map(key => item[key] as unknown as number) - ).flat()); + const getMaxValue = (data: ChartDataType): number => { + return Math.max(...Object.values(data).flatMap(dataset => + dataset.map(entry => { + const val = parseFloat(entry.val); + return isNaN(val) ? 0 : val; + }) + )); }; - const lineMaxValue = getMaxValue(chartData, 'lineVal'); + const lineMaxValue = getMaxValue(chartData); return (
{chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( -
+
{chartTitle}
) : null} diff --git a/packages/common/business_components/src/ui/excel/excelStyle.tsx b/packages/common/business_components/src/ui/excel/excelStyle.tsx index 6674720dc..3c8f8d219 100644 --- a/packages/common/business_components/src/ui/excel/excelStyle.tsx +++ b/packages/common/business_components/src/ui/excel/excelStyle.tsx @@ -1,5 +1,6 @@ -import type { sheetParameter } from '@/index'; +// import type { sheetParameter } from '@/index'; import * as XlsxPopulate from '@xlsx/xlsx-populate'; +import type { SheetParameter } from './index'; @@ -38,13 +39,13 @@ export const excelStyle = async (data: ArrayBuffer, range: string = "A1:V3", fil } -export const excelArrayStyle = async (data: ArrayBuffer, range: [typeof sheetParameter], fileNm:string) => { +export const excelArrayStyle = async (data: ArrayBuffer, range: SheetParameter[], fileNm: string) => { const workbook = await XlsxPopulate.Workbook.fromData(data); - if(range){ - range.forEach((item , index)=>{ + if (range) { + range.forEach((item, index) => { const rangeCells = workbook.activeSheet(index)?.sheet(index)?.range(item.headerRange); console.log(rangeCells); - rangeCells?.style((styleQ)=>{ + rangeCells?.style((styleQ) => { makeCellStyle(styleQ) }); diff --git a/packages/common/business_components/src/ui/excel/index.tsx b/packages/common/business_components/src/ui/excel/index.tsx index 76b4ba2f9..96f3b3e5d 100644 --- a/packages/common/business_components/src/ui/excel/index.tsx +++ b/packages/common/business_components/src/ui/excel/index.tsx @@ -5,7 +5,7 @@ type ExcelDownloadProps = { data: JSON | JSON[]; fileName: string; sheetNameArray: string[]; - headerRange: string; + headerRange?: string; } export const downloadExcel = ({ data, fileName = new Date().getTime().toString() + '.xlsx', sheetNameArray = ["Sheet1"], headerRange='A1:V3'}: ExcelDownloadProps) => { @@ -15,17 +15,21 @@ export const downloadExcel = ({ data, fileName = new Date().getTime().toString() excelStyle(XLSX.write(workbook, { bookType: "xlsx", type: "buffer" }), headerRange, fileName); }; -export const sheetParameter ={ - data:[[]], headerNum:0, headerRange:'A1:V3', sheetName:'Sheet1', startCol:0 -} +export type SheetParameter = { + data: any[][]; + headerNum: number; + headerRange: string; + sheetName: string; + startCol?: string; +}; -export const downloadMultipleExcel = (fileName = new Date().getTime().toString() + '.xlsx', sheetArray: Array): Promise => { +export const downloadMultipleExcel = (fileName = new Date().getTime().toString() + '.xlsx', sheetArray: SheetParameter[]): Promise => { const workbook = XLSX.utils.book_new(); for (let i = 0; i < sheetArray.length; i++) { // Create a new worksheet for each sheet const worksheet = XLSX.utils.aoa_to_sheet(sheetArray[i]?.data || [[]]); // Add data to the worksheet starting from the specified header number - if (sheetArray&&sheetArray[i]?.headerNum) { + if (sheetArray && sheetArray[i]?.headerNum) { XLSX.utils.sheet_add_aoa(worksheet, sheetArray[i]?.data || [[]], { origin: `A${sheetArray[i]?.headerNum}` }); } // Append the worksheet to the workbook with the specified sheet name @@ -37,7 +41,6 @@ export const downloadMultipleExcel = (fileName = new Date().getTime().toString() return Promise.resolve(undefined); }; - export const filePicked=(oFile: File, headerNum:number=0, dateType="yyyymmdd"):Promise =>{ // Create A File Reader HTML5 const reader = new FileReader(); @@ -80,8 +83,6 @@ export const filePicked=(oFile: File, headerNum:number=0, dateType="yyyymmdd"):P }); } - - export const filePickedArray=(oFile: File, headerNum:number=0):Promise =>{ // Create A File Reader HTML5 const reader = new FileReader(); @@ -123,8 +124,6 @@ export const filePickedArray=(oFile: File, headerNum:number=0):Promise =>{ // Create A File Reader HTML5 return new Promise(() => { // Ready The Event For When A File Gets Selected @@ -149,28 +148,20 @@ export const filePickedBlob=(oFile: ArrayBuffer, data:[][],fileNm:string, header }); } - export const filePickedBlobArray= (oFile: ArrayBuffer,fileNm:string, sheetArray: [typeof sheetParameter]):Promise =>{ // Create A File Reader HTML5 - return new Promise (async () => { - // Ready The Event For When A File Gets Selected - const wb = XLSX.read(oFile, { type: 'binary' }); - // Loop Over Each Sheet - wb.SheetNames.forEach( function (sheetName, index) { - // Obtain The Current Row As CSV - if(sheetArray[index]){ - const sheet = wb.Sheets[sheetName]; - if (sheet) { - //오리진 확인 test 필요 - // const sheet = XLSX.utils.json_to_sheet(data); - const startCol = sheetArray[index].startCol?sheetArray[index].startCol.toString():'A'; - XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol+sheetArray[index].headerNum }); - // XLSX.utils.book_append_sheet(wb, sheet, 'test'); - } else { - console.error(`Sheet "${sheetName}" is undefined.`); - } - } - }); - - - await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm) - }); - } \ No newline at end of file +export const filePickedBlobArray = (oFile: ArrayBuffer, fileNm: string, sheetArray: SheetParameter[]): Promise => { + return new Promise(async () => { + const wb = XLSX.read(oFile, { type: 'binary' }); + wb.SheetNames.forEach(function (sheetName, index) { + if (sheetArray[index]) { + const sheet = wb.Sheets[sheetName]; + if (sheet) { + const startCol = sheetArray[index].startCol ? sheetArray[index].startCol : 'A'; + XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol + sheetArray[index].headerNum }); + } else { + console.error(`Sheet "${sheetName}" is undefined.`); + } + } + }); + await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm) + }); +} \ No newline at end of file diff --git a/packages/common/business_components/src/ui/file-upload/index.tsx b/packages/common/business_components/src/ui/file-upload/index.tsx index 1c70b99af..22ef56820 100644 --- a/packages/common/business_components/src/ui/file-upload/index.tsx +++ b/packages/common/business_components/src/ui/file-upload/index.tsx @@ -12,10 +12,12 @@ const dropZoneConfig = { files: File[]; // 파일 배열 setFiles: (files: File[] | null) => void; // 파일 배열 세터 fileTypes?: string; // 옵션 (파일 확장자 문자열) + onFileClick?:(index:number)=> void; // 파일 클릭 핸들러 + } export const FileUpload = -({ files, setFiles, fileTypes }: FileUploadProps) => { +({ files, setFiles, fileTypes ,onFileClick}: FileUploadProps) => { return ( 0 && files.map((file:File, i:number) => ( - + - {file.name} + {file.name} ))} diff --git a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx index c18c3740d..7b4f1995f 100644 --- a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx +++ b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx @@ -286,9 +286,9 @@ FileUploaderContent.displayName = "FileUploaderContent"; export const FileUploaderItem = forwardRef< HTMLDivElement, - { index: number } & React.HTMLAttributes ->(({ className, index, children, ...props }, ref) => { - const { removeFileFromSet, activeIndex, direction } = useFileUpload(); + { index: number } & React.HTMLAttributes &{onFileClick?:(index:number)=>void} +>(({ className, index, children, onFileClick, ...props }, ref) => { + const { removeFileFromSet , activeIndex, direction } = useFileUpload(); const isSelected = index === activeIndex; return (
{ - console.log('onclick'); - removeFileFromSet(index)}} + > -
+
{ + + + }}> {children}