From 465ed72a4c5756f05358326ae6dcebbc6b53419f Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Mon, 17 Feb 2025 15:51:00 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EC=8B=9C=20db=EB=8F=84=20?= =?UTF-8?q?update=20=ED=95=84=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/roofcover/useRoofShapeSetting.js | 53 ++++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/hooks/roofcover/useRoofShapeSetting.js b/src/hooks/roofcover/useRoofShapeSetting.js index 9146e615..8e1f97b6 100644 --- a/src/hooks/roofcover/useRoofShapeSetting.js +++ b/src/hooks/roofcover/useRoofShapeSetting.js @@ -11,7 +11,9 @@ import { useSwal } from '@/hooks/useSwal' import { usePopup } from '@/hooks/usePopup' import { getChonByDegree, getDegreeByChon } from '@/util/canvas-util' import RoofAllocationSetting from '@/components/floor-plan/modal/roofAllocation/RoofAllocationSetting' -import { addedRoofsState, basicSettingState, settingModalFirstOptionsState } from '@/store/settingAtom' +import { addedRoofsState, basicSettingState, correntObjectNoState, settingModalFirstOptionsState } from '@/store/settingAtom' +import { useAxios } from '@/hooks/useAxios' +import { globalLocaleStore } from '@/store/localeAtom' // 지붕형상 설정 export function useRoofShapeSetting(id) { @@ -55,6 +57,9 @@ export function useRoofShapeSetting(id) { const [addedRoofs, setAddedRoofs] = useRecoilState(addedRoofsState) const [basicSetting, setBasicSetting] = useRecoilState(basicSettingState) + const correntObjectNo = useRecoilValue(correntObjectNoState) + const globalLocaleState = useRecoilValue(globalLocaleStore) + const { post } = useAxios(globalLocaleState) useEffect(() => { pitchRef.current = currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch) @@ -492,7 +497,7 @@ export function useRoofShapeSetting(id) { const setRoofPitch = () => { const newAddedRoofs = addedRoofs.map((roof, index) => { if (index === 0) { - return { ...roof, pitch: pitchRef.current, angle: getDegreeByChon(pitchRef.current) } + return { ...roof, pitch: Number(pitchRef.current), angle: getDegreeByChon(pitchRef.current) } } else { return { ...roof } } @@ -500,8 +505,48 @@ export function useRoofShapeSetting(id) { const newBasicSetting = { ...basicSetting, selectedRoofMaterial: { ...newAddedRoofs[0] } } - setBasicSetting(newBasicSetting) - setAddedRoofs(newAddedRoofs) + try { + basicSettingSave(newAddedRoofs) + + setBasicSetting(newBasicSetting) + setAddedRoofs(newAddedRoofs) + } catch (error) { + swalFire({ text: error.message, icon: 'error' }) + } + } + + /** + * 지붕면 할당 저장 + */ + const basicSettingSave = async (newAddedRoofs) => { + try { + const patternData = { + objectNo: correntObjectNo, + planNo: Number(basicSetting.planNo), + roofSizeSet: Number(basicSetting.roofSizeSet), + roofAngleSet: basicSetting.roofAngleSet, + roofAllocationList: newAddedRoofs.map((item, index) => ({ + planNo: Number(basicSetting.planNo), + roofApply: item.selected, + roofSeq: index, + roofMatlCd: item.roofMatlCd === null || item.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : item.roofMatlCd, + roofWidth: item.width === null || item.width === undefined ? 0 : Number(item.width), + roofHeight: item.length === null || item.length === undefined ? 0 : Number(item.length), + roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : Number(item.hajebichi), + roofGap: !item.raft ? item.raftBaseCd : item.raft, + roofLayout: item.layout === null || item.layout === undefined ? 'P' : item.layout, + roofPitch: item.pitch === null || item.pitch === undefined ? 4 : Number(item.pitch), + roofAngle: item.angle === null || item.angle === undefined ? 21.8 : Number(item.angle), + })), + } + + await post({ url: `/api/canvas-management/roof-allocation-settings`, data: patternData }) + + //Recoil 설정 + //setCanvasSetting({ ...basicSetting }) + } catch (error) { + swalFire({ text: error.message, icon: 'error' }) + } } // 동, 서 선택 시 가로라인을 케라바로 설정