From b1f108c48596e523362e310b167991592b34293c Mon Sep 17 00:00:00 2001 From: leedj312 Date: Thu, 12 Jun 2025 20:00:58 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=20=EC=88=98=EC=9A=94=EC=B2=98=20=EB=93=B1=EB=A1=9D=EB=B0=8F=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/matMng/matDmd/coSttn/page.tsx | 25 +++++- apps/wr/app/store/common/searchCode/index.ts | 81 +++++++++++++++----- apps/wr/app/store/matDmd/coSttn/index.tsx | 3 +- 3 files changed, 85 insertions(+), 24 deletions(-) diff --git a/apps/wr/app/matMng/matDmd/coSttn/page.tsx b/apps/wr/app/matMng/matDmd/coSttn/page.tsx index 20f34ebac..b0e9a4931 100644 --- a/apps/wr/app/matMng/matDmd/coSttn/page.tsx +++ b/apps/wr/app/matMng/matDmd/coSttn/page.tsx @@ -29,6 +29,7 @@ import SdmInsertForm, { import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; import { Toaster } from "react-hot-toast"; import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; +import { fetchType, getFetch } from "@/components/lib/api"; export default function CoSttn() { const { @@ -38,8 +39,11 @@ export default function CoSttn() { coSttnSearch, getDemandCompList, regDemandCompany, + updateDemandCompany, coSttnTxtSearch, + checkDemand, demandCompList, + dmdIsSucees } = useWrStore((state) => state); const [bdstTable, setBdstTable] = useState(); @@ -215,7 +219,7 @@ export default function CoSttn() { bodyClass={"w-[40vw] max-w-none h-[90vh]"} open={isDmdModal.isMoal} onOpenChange={() => { - setIsDmdModal({ isMoal: false, data: {} as DemandCompType }); + setIsDmdModal({ isMoal: false, data: {} as DemandCompType }); }} body={ { getDemandCompList(searchText, pageCnt); }} - rtnInputData={(data) => { - regDemandCompany(data as DemandCompType); + rtnInputData={ async(data) => { + if(upadateData?.dmdInfoPk){ + updateDemandCompany(data as DemandCompType) + }else{ + const dmd= await getFetch(fetchType.WR,`/reuseFc/request/${data.dmdInfoPk}`) + if(dmd) { + ToastFormUi({body: `사업자번호 ${dmd.dmdInfoPk}는 이미 등록되었습니다. 다시등록해주세요`, title:"수요처 관리"}) + return + } + regDemandCompany(data as DemandCompType); + } + if(dmdIsSucees ==='success'){ + ToastFormUi({body: `수요처 등록 및 수정이 완료되었습니다.`, title:"수요처 관리"}) setIsDmdModal({ isMoal: false, data: data as DemandCompType }); + }else{ + ToastFormUi({body: `수요처 등록 및 수정 에러입니다.`, title:"수요처 관리"}) + } + }} bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"} updateList={upadateData} diff --git a/apps/wr/app/store/common/searchCode/index.ts b/apps/wr/app/store/common/searchCode/index.ts index 96bac028a..83234c2e1 100644 --- a/apps/wr/app/store/common/searchCode/index.ts +++ b/apps/wr/app/store/common/searchCode/index.ts @@ -1,16 +1,22 @@ -import { fetchType, getFetch, postFectch } from "@/components/lib/api"; +import { + fetchType, + getFetch, + postFectch, + putFectch, +} from "@/components/lib/api"; import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; import type { DemandCompType } from "@common/business_components/ui"; export type comFcltState = { - - searchFclts: pubHasuType; demandCompList: DemandCompType[]; + dmdIsSucees: string; + checkDemand: DemandCompType; }; export type comFcltActions = { getSwtrmtFcltNm: (searchNm: string) => void; - getDemandCompList :(searchNm: string,cnt:number) => void - regDemandCompany:(data:DemandCompType ) => void + getDemandCompList: (searchNm: string, cnt: number) => void; + regDemandCompany: (data: DemandCompType) => void; + updateDemandCompany: (data: DemandCompType) => void; }; export const searchActions: (set: any) => comFcltActions = (set: any) => { @@ -28,27 +34,64 @@ export const searchActions: (set: any) => comFcltActions = (set: any) => { addr: item.addr, fctCpc: item.fctCpc, })); - return set((state: comFcltState) => ({ + set((state: comFcltState) => ({ ...state, searchFclts: fcltNmCd, })); }, - getDemandCompList: async (searchNm: string ,cnt:number) => { + getDemandCompList: async (searchNm: string, cnt: number) => { const coList = await getFetch( fetchType.WR, - `/reuseFc/request/${searchNm}/${cnt}` + `/reuseFc/request/${searchNm}/${cnt}` ); - return set((state: comFcltState) => { - state.demandCompList= coList - return state + set((state: comFcltState) => { + state.demandCompList = coList; + return state; }); - },regDemandCompany: async (data:DemandCompType)=>{ - - try{ - const response = await postFectch('/reuseFc/request',data,fetchType.WR ) - }catch(err){ - console.log(err) - } + }, + regDemandCompany: async (data: DemandCompType) => { + try { + const response = await postFectch( + "/reuseFc/request", + data, + fetchType.WR + ); + let message = ""; + if (response.status === 200) { + message = "success"; + } else { + message = "fail"; + } + set((state: comFcltState) => { + state.dmdIsSucees = message; + return state; + + }); + } catch (err) { + console.log(err); + } + }, + updateDemandCompany: async (data: DemandCompType) => { + try { + const response = await putFectch("/reuseFc/request", data); + + let message = ""; + if (response.status === 200) { + message = "success"; + } else { + message = "fail"; + } + + set((state: comFcltState) => { + state.dmdIsSucees = message; + return state; + + }); + + + } catch (err) { + console.log(err); + } } - }; + } }; diff --git a/apps/wr/app/store/matDmd/coSttn/index.tsx b/apps/wr/app/store/matDmd/coSttn/index.tsx index 77782116b..4b8c60436 100644 --- a/apps/wr/app/store/matDmd/coSttn/index.tsx +++ b/apps/wr/app/store/matDmd/coSttn/index.tsx @@ -1,6 +1,5 @@ import type { CommonTableProps } from "@/app/store/common/type/header"; import { fetchType, getFetch } from "@/components/lib/api"; -import { z } from "zod"; import { coSttHeadListExport, coSttNodeListExport } from "./headList"; import { excelCoSttnParsing } from "./excel"; import type { DemandCompType } from "@common/business_components/ui"; @@ -116,6 +115,6 @@ export const coSttnActionsExport: (set: any) => coSttnActions = ( } catch (erTxt) { console.log("error", erTxt); } - }, + } } } \ No newline at end of file