Merge pull request 'dev' (#472) from dev into prd-deploy

Reviewed-on: #472
This commit is contained in:
ysCha 2025-12-15 16:44:44 +09:00
commit be4e628c09
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);
setCurrentRoof( prev => ({ const pitch = angle === '' ? '' : getChonByDegree(angle);
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,46 +114,54 @@ 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 = {}
let roofsArray = [];
if (res.length > 0) {
roofsArray = res.map((item) => { // API에서 데이터를 성공적으로 가져온 경우
return { if (response && response.length > 0) {
planNo: item.planNo, roofsArray = response.map((item, index) => ({
roofApply: item.roofApply, planNo: item.planNo,
roofSeq: item.roofSeq, roofApply: item.roofApply,
roofMatlCd: item.roofMatlCd, roofSeq: item.roofSeq || index,
roofWidth: item.roofWidth, roofMatlCd: item.roofMatlCd,
roofHeight: item.roofHeight, roofWidth: item.roofWidth,
roofHajebichi: item.roofHajebichi, roofHeight: item.roofHeight,
roofGap: item.roofGap, roofHajebichi: item.roofHajebichi,
roofLayout: item.roofLayout, roofGap: item.roofGap,
roofPitch: item.roofPitch, roofLayout: item.roofLayout,
roofAngle: item.roofAngle, roofPitch: item.roofPitch,
} roofAngle: item.roofAngle,
}) selected: index === 0, // 첫 번째 항목을 기본 선택으로 설정
} else { index: index
if (roofList.length > 0) { }));
roofsArray = roofList }
} else { // API에서 데이터가 없고 기존 roofList가 있는 경우
roofsArray = [ else if (roofList && roofList.length > 0) {
{ roofsArray = roofList.map((roof, index) => ({
planNo: planNo, ...roof,
roofApply: true, selected: index === 0 // 첫 번째 항목을 기본 선택으로 설정
roofSeq: 0, }));
roofMatlCd: 'ROOF_ID_WA_53A', }
roofWidth: 265, // 둘 다 없는 경우 기본값 설정
roofHeight: 235, else {
roofHajebichi: 0, roofsArray = [
roofGap: 'HEI_455', {
roofLayout: 'P', planNo: planNo,
roofApply: true,
roofSeq: 0,
roofMatlCd: 'ROOF_ID_WA_53A',
roofWidth: 265,
roofHeight: 235,
roofHajebichi: 0,
roofGap: 'HEI_455',
roofLayout: 'P',
roofPitch: 4, roofPitch: 4,
roofAngle: 21.8, roofAngle: 21.8,
}, },
] ]
} }
}
/** /**
* 데이터 설정 * 데이터 설정
@ -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)
} }