배치면초기설정 수정

This commit is contained in:
changkyu choi 2025-01-14 19:05:03 +09:00
parent e885e7b939
commit 55cb5bb6e2
3 changed files with 85 additions and 97 deletions

View File

@ -41,15 +41,30 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
hajebichi: useRef(null),
}
// (//)
const roofSizeSetArray = [
{ id: 'ra01', name: 'roofSizeSet', value: '1', checked: 'ture', message: 'modal.placement.initial.setting.size.roof' },
{ id: 'ra02', name: 'roofSizeSet', value: '2', checked: 'false', message: 'modal.placement.initial.setting.size.actual' },
{ id: 'ra03', name: 'roofSizeSet', value: '3', checked: 'false', message: 'modal.placement.initial.setting.size.none.pitch' },
]
// (/)
const roofAngleSetArray = [
{ id: 'ra04', name: 'roofAngleSet', value: 'slope', checked: 'true', message: 'modal.placement.initial.setting.roof.pitch'},
{ id: 'ra05', name: 'roofAngleSet', value: 'flat', checked: 'false', message: 'modal.placement.initial.setting.roof.angle' },
]
//
useEffect(() => {
if (!basicSetting || !currentRoof || Object.keys(currentRoof).length === 0 || Object.keys(basicSetting).length === 0) return
const raftCodeList = findCommonCode('203800')
setRaftCodes(raftCodeList)
setCurrentRoof({ ...currentRoof, roofSizeSet: basicSetting.roofMaterials.roofSizeSet, roofAngleSet: basicSetting.roofMaterials.roofAngleSet })
setCurrentRoof({ ...currentRoof, roofSizeSet: basicSetting.roofSizeSet, roofAngleSet: basicSetting.roofAngleSet })
console.log('🚀 ~ fetchBasicSettings ~ currentRoof 11:', currentRoof)
}, [])
useEffect(() => {
console.log('🚀 ~ fetchBasicSettings ~ currentRoof 22:', currentRoof)
setBasicSettings({
...basicSetting,
roofSizeSet: String(currentRoof.roofSizeSet),
@ -110,10 +125,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
}
const newAddedRoofs = [...addedRoofs]
if (addedRoofs.length === 1) {
newAddedRoofs[0] = { ...roofInfo }
setAddedRoofs(newAddedRoofs)
}
console.log('save Info', {
...basicSetting,
@ -179,42 +192,22 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
</th>
<td>
<div className="pop-form-radio">
{currentRoof &&
roofSizeSetArray.map((item) => (
<div className="d-check-radio pop">
<input
type="radio"
name="roofSizeSet"
id="ra01"
value="1" // roofSizeSet '1'
checked={currentRoof?.roofSizeSet === '1'} //
//onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} //
onClick={() => handleRoofSizeSetChange('1')}
<input type="radio"
key={item.id}
id={item.id}
name={item.name}
value={item.value}
checked={currentRoof?.roofSizeSet === item.value}
defaultChecked={'1'}
onChange={(e) => setCurrentRoof({ ...currentRoof, roofSizeSet: e.target.value })}
/>
<label htmlFor="ra01">{getMessage('modal.placement.initial.setting.size.roof')}</label>
</div>
<div className="d-check-radio pop">
<input
type="radio"
name="roofSizeSet"
id="ra02"
value="2" // roofSizeSet '2'
checked={currentRoof?.roofSizeSet === '2'} //
//onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} //
onClick={() => handleRoofSizeSetChange('2')}
/>
<label htmlFor="ra02">{getMessage('modal.placement.initial.setting.size.actual')}</label>
</div>
<div className="d-check-radio pop">
<input
type="radio"
name="roofSizeSet"
id="ra03"
value="3" // roofSizeSet '3'
checked={currentRoof?.roofSizeSet === '3'} //
//onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} //
onClick={() => handleRoofSizeSetChange('3')}
/>
<label htmlFor="ra03">{getMessage('modal.placement.initial.setting.size.none.pitch')}</label>
<label htmlFor={item.id}>{getMessage(item.message)}</label>
</div>
))
}
</div>
</td>
</tr>
@ -222,30 +215,22 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
<th>{getMessage('modal.placement.initial.setting.roof.angle.setting')}</th>
<td>
<div className="pop-form-radio">
{currentRoof &&
roofAngleSetArray.map((item) => (
<div className="d-check-radio pop">
<input
type="radio"
name="roofAngleSet"
id="ra04"
value="slope" //
checked={currentRoof?.roofAngleSet === 'slope'} //
//onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} //
onClick={() => handleRoofAngleSetChange('slope')}
<input type="radio"
key={item.id}
id={item.id}
name={item.name}
value={item.value}
checked={currentRoof?.roofAngleSet === item.value}
defaultChecked={'slope'}
onChange={(e) => setCurrentRoof({ ...currentRoof, roofAngleSet: e.target.value })}
/>
<label htmlFor="ra04">{getMessage('modal.placement.initial.setting.roof.pitch')}</label>
</div>
<div className="d-check-radio pop">
<input
type="radio"
name="roofAngleSet"
id="ra05"
value="flat" //
checked={currentRoof?.roofAngleSet === 'flat'} //
//onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} //
onClick={() => handleRoofAngleSetChange('flat')}
/>
<label htmlFor="ra05">{getMessage('modal.placement.initial.setting.roof.angle')}</label>
<label htmlFor={item.id}>{getMessage(item.message)}</label>
</div>
))
}
</div>
</td>
</tr>
@ -264,7 +249,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
currentRoof?.roofSizeSet === '3' ? getMessage('modal.placement.initial.setting.size.none.pitch') : currentRoof?.roofMatlNm
}
ref={roofRef.roofCd}
options={roofMaterials.map((roof, index) => {
options={roofMaterials.map((roof) => {
return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp }
})}
value={currentRoof?.roofSizeSet === '3' ? null : currentRoof?.roofMatlCd}

View File

@ -328,23 +328,27 @@ export function useCanvasSetting() {
// 데이터 설정
const addRoofs = []
for (let i = 0; i < roofsArray.length; i++) {
roofMaterials?.map((material) => {
if (material.roofMatlCd === roofsArray[0].roofMatlCd) {
if (material.roofMatlCd === roofsArray[i].roofMatlCd) {
addRoofs.push({
...material,
selected: true,
index: 0,
width: roofsArray[0].roofWidth,
length: roofsArray[0].roofHeight,
hajebichi: roofsArray[0].roofHajebichi,
raft: roofsArray[0].roofGap,
layout: roofsArray[0].roofLayout,
roofSizeSet: roofsRow[0].roofSizeSet,
roofAngleSet: roofsRow[0].roofAngleSet,
pitch: roofsArray[0].roofPitch,
angle: roofsArray[0].roofAngle,
selected: roofsArray[i].roofApply,
index: i,
width: roofsArray[i].roofWidth,
length: roofsArray[i].roofHeight,
hajebichi: roofsArray[i].roofHajebichi,
raft: roofsArray[i].roofGap,
layout: roofsArray[i].roofLayout,
roofSizeSet: roofsRow[i].roofSizeSet,
roofAngleSet: roofsRow[i].roofAngleSet,
pitch: roofsArray[i].roofPitch,
angle: roofsArray[i].roofAngle,
})
}
})
}
console.log('🚀 ~ fetchBasicSettings ~ addRoofs:', addRoofs)
setAddedRoofs(addRoofs)
setBasicSettings({
...basicSetting,
@ -354,8 +358,6 @@ export function useCanvasSetting() {
roofsData: roofsArray,
selectedRoofMaterial: addRoofs[0],
})
}
})
})
} catch (error) {
console.error('Data fetching error:', error)

View File

@ -151,10 +151,11 @@ export function useRoofAllocationSetting(id) {
pitch: roofsArray[i].roofPitch,
angle: roofsArray[i].roofAngle,
})
setCurrentRoofList(selectRoofs)
}
})
}
setCurrentRoofList(selectRoofs)
setBasicSetting({ ...basicSetting, roofsData: roofsArray })
})
} catch (error) {