Compare commits

..

No commits in common. "27e6147ed752beafe4c395fe610a31fc4f155904" and "f893eece0991db8b520272da38d50333ecff2c21" have entirely different histories.

4 changed files with 60 additions and 79 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,21 +353,19 @@ 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 pitch = value === '' ? '' : Number(value); const num = value === '' ? '' : Number(value)
const angle = pitch === '' ? '' : getDegreeByChon(pitch);
setCurrentRoof(prev => ({ setCurrentRoof(prev => ({
...prev, ...prev,
pitch, pitch: num === '' ? '' : num,
angle angle: num === '' ? '' : getDegreeByChon(num),
})); }))
} else { } else {
const angle = value === '' ? '' : Number(value); const num = value === '' ? '' : Number(value)
const pitch = angle === '' ? '' : getChonByDegree(angle); setCurrentRoof( prev => ({
setCurrentRoof(prev => ({
...prev, ...prev,
pitch, pitch: num === '' ? '' : getChonByDegree(num),
angle angle: num === '' ? '' : num,
})); }))
} }
}} }}
options={{ options={{
@ -516,17 +514,13 @@ 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) => {
const hajebichi = value === '' ? '' : Number(value); setCurrentRoof({ ...currentRoof, value })
setCurrentRoof(prev => ({
...prev,
hajebichi
}));
}} }}
readOnly={currentRoof?.roofPchAuth === 'R'} readOnly={currentRoof?.roofPchAuth === 'R'}
disabled={currentRoof?.roofSizeSet === '3'} disabled={currentRoof?.roofSizeSet === '3'}

View File

@ -42,7 +42,6 @@ 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: {
@ -178,8 +177,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.inclBase ? parseInt(item.inclBase) : 4, pitch: item.pitch ? parseInt(item.pitch) : 4,
angle: getDegreeByChon(item.inclBase ? parseInt(item.inclBase): 4) //item.angle ? parseInt(item.angle) : 21.8, angle: item.angle ? parseInt(item.angle) : 21.8,
})) }))
setRoofMaterials(roofLists) setRoofMaterials(roofLists)
return roofLists return roofLists

View File

@ -114,54 +114,46 @@ export function useRoofAllocationSetting(id) {
*/ */
const fetchBasicSettings = async (planNo) => { const fetchBasicSettings = async (planNo) => {
try { try {
const response = await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}/${planNo}` }); await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}/${planNo}` }).then((res) => {
let roofsArray = {}
let roofsArray = [];
if (res.length > 0) {
// API에서 데이터를 성공적으로 가져온 경우 roofsArray = res.map((item) => {
if (response && response.length > 0) { return {
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, roofHajebichi: item.roofHajebichi,
roofHajebichi: item.roofHajebichi, roofGap: item.roofGap,
roofGap: item.roofGap, roofLayout: item.roofLayout,
roofLayout: item.roofLayout, roofPitch: item.roofPitch,
roofPitch: item.roofPitch, roofAngle: item.roofAngle,
roofAngle: item.roofAngle, }
selected: index === 0, // 첫 번째 항목을 기본 선택으로 설정 })
index: index } else {
})); if (roofList.length > 0) {
} roofsArray = roofList
// API에서 데이터가 없고 기존 roofList가 있는 경우 } else {
else if (roofList && roofList.length > 0) { roofsArray = [
roofsArray = roofList.map((roof, index) => ({ {
...roof, planNo: planNo,
selected: index === 0 // 첫 번째 항목을 기본 선택으로 설정 roofApply: true,
})); roofSeq: 0,
} roofMatlCd: 'ROOF_ID_WA_53A',
// 둘 다 없는 경우 기본값 설정 roofWidth: 265,
else { roofHeight: 235,
roofsArray = [ roofHajebichi: 0,
{ roofGap: 'HEI_455',
planNo: planNo, roofLayout: 'P',
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,
}, },
] ]
} }
}
/** /**
* 데이터 설정 * 데이터 설정
@ -213,7 +205,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)
} }

View File

@ -990,12 +990,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber(); const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber();
newPStart.y = Big(wallBaseLine.y1).minus(rLineM).abs().toNumber(); newPStart.y = Big(wallBaseLine.y1).minus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x })
if(inLine) { if(inLine.x2 > inLine.x1 ) {
if (inLine.x2 > inLine.x1) { getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y2, x: inLine.x2 }, 'purple')
getAddLine({ y: newPStart.y, x: newPStart.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') }else{
} else { getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x } , 'purple')
getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x }, 'purple')
}
} }
} }
@ -1044,12 +1042,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber(); const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber();
newPEnd.y = Big(wallBaseLine.y2).plus(rLineM).abs().toNumber(); newPEnd.y = Big(wallBaseLine.y2).plus(rLineM).abs().toNumber();
const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x })
if(inLine) { if(inLine.x2 > inLine.x1 ) {
if (inLine.x2 > inLine.x1) { getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple')
getAddLine({ y: newPEnd.y, x: newPEnd.x }, { y: inLine.y2, x: inLine.x2 }, 'purple') }else{
} else { getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x } , 'purple')
getAddLine({ y: inLine.y1, x: inLine.x1 }, { y: newPEnd.y, x: newPEnd.x }, 'purple')
}
} }
} }