Merge pull request '[1351]경사도 기본 수치 추가 inclBase' (#471) from dev_ysCha into dev

Reviewed-on: #471
This commit is contained in:
ysCha 2025-12-15 16:44:05 +09:00
commit 9a37959b60
3 changed files with 67 additions and 52 deletions

View File

@ -170,8 +170,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
setCurrentRoof({ setCurrentRoof({
...selectedRoofMaterial, ...selectedRoofMaterial,
pitch: currentRoof?.pitch, // pitch: currentRoof?.pitch,
angle: currentRoof?.angle, // angle: currentRoof?.angle,
index: 0, index: 0,
planNo: currentRoof.planNo, planNo: currentRoof.planNo,
roofSizeSet: String(currentRoof.roofSizeSet), 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'} value={index === 0 ? currentRoof?.pitch || '0' : currentRoof?.angle || '0'}
onChange={(value) => { onChange={(value) => {
if (index === 0) { if (index === 0) {
const num = value === '' ? '' : Number(value) const pitch = value === '' ? '' : Number(value);
const angle = pitch === '' ? '' : getDegreeByChon(pitch);
setCurrentRoof(prev => ({ setCurrentRoof(prev => ({
...prev, ...prev,
pitch: num === '' ? '' : num, pitch,
angle: num === '' ? '' : getDegreeByChon(num), angle
})) }));
} else { } else {
const num = value === '' ? '' : Number(value) const angle = value === '' ? '' : Number(value);
const pitch = angle === '' ? '' : getChonByDegree(angle);
setCurrentRoof(prev => ({ setCurrentRoof(prev => ({
...prev, ...prev,
pitch: num === '' ? '' : getChonByDegree(num), pitch,
angle: num === '' ? '' : num, angle
})) }));
} }
}} }}
options={{ options={{
@ -514,13 +516,17 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
{/*/>*/} {/*/>*/}
<CalculatorInput <CalculatorInput
id="" id=""
name={'hajebichi'} name="hajebichi"
label="" label=""
className="input-origin block" className="input-origin block"
ref={roofRef.hajebichi} ref={roofRef.hajebichi}
value={currentRoof?.hajebichi||0} value={currentRoof?.hajebichi || '0'}
onChange={(value) => { onChange={(value) => {
setCurrentRoof({ ...currentRoof, value }) const hajebichi = value === '' ? '' : Number(value);
setCurrentRoof(prev => ({
...prev,
hajebichi
}));
}} }}
readOnly={currentRoof?.roofPchAuth === 'R'} readOnly={currentRoof?.roofPchAuth === 'R'}
disabled={currentRoof?.roofSizeSet === '3'} disabled={currentRoof?.roofSizeSet === '3'}

View File

@ -42,6 +42,7 @@ import { useEvent } from '@/hooks/useEvent'
import { logger } from '@/util/logger' import { logger } from '@/util/logger'
import { useText } from '@/hooks/useText' import { useText } from '@/hooks/useText'
import { usePolygon } from '@/hooks/usePolygon' import { usePolygon } from '@/hooks/usePolygon'
import { getDegreeByChon } from '@/util/canvas-util'
const defaultDotLineGridSetting = { const defaultDotLineGridSetting = {
INTERVAL: { INTERVAL: {
@ -177,8 +178,8 @@ export function useCanvasSetting(executeEffect = true) {
raft: item.raftBase && parseInt(item.raftBase), raft: item.raftBase && parseInt(item.raftBase),
layout: ['ROOF_ID_SLATE', 'ROOF_ID_SINGLE'].includes(item.roofMatlCd) ? ROOF_MATERIAL_LAYOUT.STAIRS : ROOF_MATERIAL_LAYOUT.PARALLEL, layout: ['ROOF_ID_SLATE', 'ROOF_ID_SINGLE'].includes(item.roofMatlCd) ? ROOF_MATERIAL_LAYOUT.STAIRS : ROOF_MATERIAL_LAYOUT.PARALLEL,
hajebichi: item.roofPchBase && parseInt(item.roofPchBase), hajebichi: item.roofPchBase && parseInt(item.roofPchBase),
pitch: item.pitch ? parseInt(item.pitch) : 4, pitch: item.inclBase ? parseInt(item.inclBase) : 4,
angle: item.angle ? parseInt(item.angle) : 21.8, angle: getDegreeByChon(item.inclBase ? parseInt(item.inclBase): 4) //item.angle ? parseInt(item.angle) : 21.8,
})) }))
setRoofMaterials(roofLists) setRoofMaterials(roofLists)
return roofLists return roofLists

View File

@ -114,15 +114,16 @@ export function useRoofAllocationSetting(id) {
*/ */
const fetchBasicSettings = async (planNo) => { const fetchBasicSettings = async (planNo) => {
try { try {
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}/${planNo}` }).then((res) => { const response = await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}/${planNo}` });
let roofsArray = {}
if (res.length > 0) { let roofsArray = [];
roofsArray = res.map((item) => {
return { // API에서 데이터를 성공적으로 가져온 경우
if (response && response.length > 0) {
roofsArray = response.map((item, index) => ({
planNo: item.planNo, planNo: item.planNo,
roofApply: item.roofApply, roofApply: item.roofApply,
roofSeq: item.roofSeq, roofSeq: item.roofSeq || index,
roofMatlCd: item.roofMatlCd, roofMatlCd: item.roofMatlCd,
roofWidth: item.roofWidth, roofWidth: item.roofWidth,
roofHeight: item.roofHeight, roofHeight: item.roofHeight,
@ -131,12 +132,19 @@ export function useRoofAllocationSetting(id) {
roofLayout: item.roofLayout, roofLayout: item.roofLayout,
roofPitch: item.roofPitch, roofPitch: item.roofPitch,
roofAngle: item.roofAngle, roofAngle: item.roofAngle,
selected: index === 0, // 첫 번째 항목을 기본 선택으로 설정
index: index
}));
} }
}) // API에서 데이터가 없고 기존 roofList가 있는 경우
} else { else if (roofList && roofList.length > 0) {
if (roofList.length > 0) { roofsArray = roofList.map((roof, index) => ({
roofsArray = roofList ...roof,
} else { selected: index === 0 // 첫 번째 항목을 기본 선택으로 설정
}));
}
// 둘 다 없는 경우 기본값 설정
else {
roofsArray = [ roofsArray = [
{ {
planNo: planNo, planNo: planNo,
@ -153,7 +161,7 @@ export function useRoofAllocationSetting(id) {
}, },
] ]
} }
}
/** /**
* 데이터 설정 * 데이터 설정
@ -205,7 +213,7 @@ export function useRoofAllocationSetting(id) {
angle: roof.angle ?? '', angle: roof.angle ?? '',
})) }))
setCurrentRoofList(normalizedRoofs) setCurrentRoofList(normalizedRoofs)
})
} catch (error) { } catch (error) {
console.error('Data fetching error:', error) console.error('Data fetching error:', error)
} }