From f528c0e893fbd4967abd92e37713dc0bb1f06ed4 Mon Sep 17 00:00:00 2001 From: jsyang Date: Thu, 2 Apr 2026 15:44:40 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=8B=A0=EC=B2=AD=ED=98=84?= =?UTF-8?q?=ED=99=A9=EC=97=90=EC=84=9C=20=EC=88=98=EC=9A=94=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/(with-layout)/apply/status/page.tsx | 115 ++++++++++++++++-- apps/dm_new/app/store/sdmMng/index.tsx | 18 +++ 2 files changed, 123 insertions(+), 10 deletions(-) diff --git a/apps/dm_new/app/(with-layout)/apply/status/page.tsx b/apps/dm_new/app/(with-layout)/apply/status/page.tsx index afd1bfd96..182fd6221 100644 --- a/apps/dm_new/app/(with-layout)/apply/status/page.tsx +++ b/apps/dm_new/app/(with-layout)/apply/status/page.tsx @@ -123,7 +123,7 @@ function DateInput({ } export default function DemandStatusPage() { - const { getSdmInfoStatusList, Sdm, Common } = useDmStore((state) => state); + const { getSdmInfoStatusList, updateSdmInfoData, Sdm, Common } = useDmStore((state) => state); const { successLogin, sdmInfoStatusList } = Sdm; const { selectSidoData, selectSigunData } = Common; @@ -243,13 +243,15 @@ export default function DemandStatusPage() { }, [selectedSdmInfoStatus]); const candidateNames = useMemo(() => { - const list = selectedSdmInfoStatus?.splyCndtList ?? []; + const list = isEditMode + ? editData?.splyCndtList ?? [] + : selectedSdmInfoStatus?.splyCndtList ?? []; return [ list[0]?.ruseUtztnFcltNm ?? "", list[1]?.ruseUtztnFcltNm ?? "", list[2]?.ruseUtztnFcltNm ?? "", ]; - }, [selectedSdmInfoStatus]); + }, [isEditMode, editData, selectedSdmInfoStatus]); const onSelectSdmInfoStatus = (dmdInfoSn: number | "") => { if(isEditMode){ @@ -269,6 +271,61 @@ export default function DemandStatusPage() { return { a, b }; }; + const searchCandidate = (e: React.MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + const dmdInfoId = JSON.parse( + sessionStorage.getItem("user") || "{}" + )?.dmdInfoId?.toString(); + + const url = `/map/popup?dmdInfoId=${encodeURIComponent(dmdInfoId)}`; + const width = window.screen.availWidth; + const height = window.screen.availHeight; + const left = 0; + const top = 0; + const popupOptions = `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`; + window.open(url, "candidatePopup", popupOptions); + }; + + const saveInfo = () => { + if(confirm('수정된 데이터를 저장하시겠습니까?')){ + const payload = { + ...editData, + splyCndtList : editData.splyCndtList ?? [] + }; + + updateSdmInfoData(payload).then((res) => { + if (res) { + const user = JSON.parse(sessionStorage.getItem("user") || "{}"); + if (user?.dmdInfoId) { + getSdmInfoStatusList(user.dmdInfoId); + } + setIsEditMode(false); + } + }); + } + } + + useEffect(() => { + const handler = (event: MessageEvent) => { + if (!event.data) return; + + if (event.data.type === "SET_SUBS_INFO") { + const list = event.data.payload || []; + setEditData((prev) => ({ + ...prev, + splyCndtList: list, + })); + } + }; + + window.addEventListener("message", handler); + + return () => { + window.removeEventListener("message", handler); + }; + }, []); + return (
@@ -372,13 +429,7 @@ export default function DemandStatusPage() { type="button" className="h-8 rounded-md bg-[#888] px-4 text-base text-white hover:bg-neutral-700" onClick={() => { - setOriginData(editData); - setIsEditMode(false); - - if(confirm('수정된 데이터를 저장하시겠습니까?')){ - //todo - // updateSdmInfoData(editData); - } + saveInfo(); }} > 저장 @@ -582,9 +633,53 @@ export default function DemandStatusPage() {
공급처 후보지 + { + isEditMode && + + } +
{candidateNames.map((candidateName, index) => ( + isEditMode ? ( +
+
+ 후보지{index + 1} +
+
+ { + setEditData((prev) => { + const newList = [...(prev.splyCndtList || [])]; + newList[index] = { + ...newList[index], + ruseUtztnFcltNm: v, + }; + return { + ...prev, + splyCndtList: newList, + }; + }); + }} + /> +
+
+ ) :
=> { } } +// 수요정보 수정 +const fetchUpdateSdmInfoData = async (data: SdmInfoFormData): Promise => { + try { + await postFetch("/reuseFc/request/updateDemandInfo", data); + alert('수요 정보 수정에 성공하였습니다.'); + return true; + } catch (error) { + console.log(error); + alert('수요 정보 수정에 실패하였습니다.'); + return false; + } +} + const postSdmLoginData = async (data: DemandCompType) => { try { const res = await postFetch("/reuseFc/request/login", data); @@ -539,6 +552,7 @@ export type SdmActions = { initializeSdmData: () => void; insertSdmData: (data: DemandCompType) => Promise; insertSdmInfoData: (data: SdmInfoFormData) => Promise; + updateSdmInfoData: (data: SdmInfoFormData) => Promise; getDemandCompList: (searchText: string, pageCnt: number) => Promise; actionLogin: (data: DemandCompType) => Promise; getSdmInfoStatusList: (dmdInfoId: string) => Promise; @@ -617,6 +631,10 @@ export const SdmReducer = (set: any): SdmActions => { return await postSdmInfoData(data); }, + updateSdmInfoData: async (data: SdmInfoFormData): Promise => { + return await fetchUpdateSdmInfoData(data); + }, + // 수요처 정보 getDemandCompList: async (searchText: string, pageCnt: number) => { const res = await getDemandCompList(searchText, pageCnt);