배치면초기설정 수정

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

View File

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

View File

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