From ff5cd04b2713d3cd484a2ed5ace4dd3f49e5ddc9 Mon Sep 17 00:00:00 2001 From: ysCha Date: Mon, 15 Dec 2025 16:42:31 +0900 Subject: [PATCH] =?UTF-8?q?[1351]=EA=B2=BD=EC=82=AC=EB=8F=84=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=EC=88=98=EC=B9=98=20=EC=B6=94=EA=B0=80=20inclBase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../placementShape/PlacementShapeSetting.jsx | 34 ++++---- src/hooks/option/useCanvasSetting.js | 5 +- .../roofcover/useRoofAllocationSetting.js | 80 ++++++++++--------- 3 files changed, 67 insertions(+), 52 deletions(-) diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx index 51c16c1a..e283fff0 100644 --- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx +++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx @@ -170,8 +170,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla setCurrentRoof({ ...selectedRoofMaterial, - pitch: currentRoof?.pitch, - angle: currentRoof?.angle, + // pitch: currentRoof?.pitch, + // angle: currentRoof?.angle, index: 0, planNo: currentRoof.planNo, roofSizeSet: String(currentRoof.roofSizeSet), @@ -353,19 +353,21 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla value={index === 0 ? currentRoof?.pitch || '0' : currentRoof?.angle || '0'} onChange={(value) => { if (index === 0) { - const num = value === '' ? '' : Number(value) + const pitch = value === '' ? '' : Number(value); + const angle = pitch === '' ? '' : getDegreeByChon(pitch); setCurrentRoof(prev => ({ ...prev, - pitch: num === '' ? '' : num, - angle: num === '' ? '' : getDegreeByChon(num), - })) + pitch, + angle + })); } else { - const num = value === '' ? '' : Number(value) - setCurrentRoof( prev => ({ + const angle = value === '' ? '' : Number(value); + const pitch = angle === '' ? '' : getChonByDegree(angle); + setCurrentRoof(prev => ({ ...prev, - pitch: num === '' ? '' : getChonByDegree(num), - angle: num === '' ? '' : num, - })) + pitch, + angle + })); } }} options={{ @@ -514,13 +516,17 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla {/*/>*/} { - setCurrentRoof({ ...currentRoof, value }) + const hajebichi = value === '' ? '' : Number(value); + setCurrentRoof(prev => ({ + ...prev, + hajebichi + })); }} readOnly={currentRoof?.roofPchAuth === 'R'} disabled={currentRoof?.roofSizeSet === '3'} diff --git a/src/hooks/option/useCanvasSetting.js b/src/hooks/option/useCanvasSetting.js index af3cee04..072a2987 100644 --- a/src/hooks/option/useCanvasSetting.js +++ b/src/hooks/option/useCanvasSetting.js @@ -42,6 +42,7 @@ import { useEvent } from '@/hooks/useEvent' import { logger } from '@/util/logger' import { useText } from '@/hooks/useText' import { usePolygon } from '@/hooks/usePolygon' +import { getDegreeByChon } from '@/util/canvas-util' const defaultDotLineGridSetting = { INTERVAL: { @@ -177,8 +178,8 @@ export function useCanvasSetting(executeEffect = true) { raft: item.raftBase && parseInt(item.raftBase), layout: ['ROOF_ID_SLATE', 'ROOF_ID_SINGLE'].includes(item.roofMatlCd) ? ROOF_MATERIAL_LAYOUT.STAIRS : ROOF_MATERIAL_LAYOUT.PARALLEL, hajebichi: item.roofPchBase && parseInt(item.roofPchBase), - pitch: item.pitch ? parseInt(item.pitch) : 4, - angle: item.angle ? parseInt(item.angle) : 21.8, + pitch: item.inclBase ? parseInt(item.inclBase) : 4, + angle: getDegreeByChon(item.inclBase ? parseInt(item.inclBase): 4) //item.angle ? parseInt(item.angle) : 21.8, })) setRoofMaterials(roofLists) return roofLists diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index 4bc26098..f93e230d 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -114,46 +114,54 @@ export function useRoofAllocationSetting(id) { */ const fetchBasicSettings = async (planNo) => { try { - await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}/${planNo}` }).then((res) => { - let roofsArray = {} - - if (res.length > 0) { - roofsArray = res.map((item) => { - return { - planNo: item.planNo, - roofApply: item.roofApply, - roofSeq: item.roofSeq, - roofMatlCd: item.roofMatlCd, - roofWidth: item.roofWidth, - roofHeight: item.roofHeight, - roofHajebichi: item.roofHajebichi, - roofGap: item.roofGap, - roofLayout: item.roofLayout, - roofPitch: item.roofPitch, - roofAngle: item.roofAngle, - } - }) - } else { - if (roofList.length > 0) { - roofsArray = roofList - } else { - roofsArray = [ - { - planNo: planNo, - roofApply: true, - roofSeq: 0, - roofMatlCd: 'ROOF_ID_WA_53A', - roofWidth: 265, - roofHeight: 235, - roofHajebichi: 0, - roofGap: 'HEI_455', - roofLayout: 'P', + const response = await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}/${planNo}` }); + + let roofsArray = []; + + // API에서 데이터를 성공적으로 가져온 경우 + if (response && response.length > 0) { + roofsArray = response.map((item, index) => ({ + planNo: item.planNo, + roofApply: item.roofApply, + roofSeq: item.roofSeq || index, + roofMatlCd: item.roofMatlCd, + roofWidth: item.roofWidth, + roofHeight: item.roofHeight, + roofHajebichi: item.roofHajebichi, + roofGap: item.roofGap, + roofLayout: item.roofLayout, + roofPitch: item.roofPitch, + roofAngle: item.roofAngle, + selected: index === 0, // 첫 번째 항목을 기본 선택으로 설정 + index: index + })); + } + // API에서 데이터가 없고 기존 roofList가 있는 경우 + else if (roofList && roofList.length > 0) { + roofsArray = roofList.map((roof, index) => ({ + ...roof, + selected: index === 0 // 첫 번째 항목을 기본 선택으로 설정 + })); + } + // 둘 다 없는 경우 기본값 설정 + else { + roofsArray = [ + { + planNo: planNo, + roofApply: true, + roofSeq: 0, + roofMatlCd: 'ROOF_ID_WA_53A', + roofWidth: 265, + roofHeight: 235, + roofHajebichi: 0, + roofGap: 'HEI_455', + roofLayout: 'P', roofPitch: 4, roofAngle: 21.8, }, ] } - } + /** * 데이터 설정 @@ -205,7 +213,7 @@ export function useRoofAllocationSetting(id) { angle: roof.angle ?? '', })) setCurrentRoofList(normalizedRoofs) - }) + } catch (error) { console.error('Data fetching error:', error) }