Merge branch 'dev' into dev-yj

This commit is contained in:
yjnoh 2025-01-03 10:27:06 +09:00
commit 94ec7803d0
2 changed files with 58 additions and 69 deletions

View File

@ -48,74 +48,61 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
}, []) }, [])
useEffect(() => { useEffect(() => {
if (basicSetting.roofs.length > 0) { if (addedRoofs.length > 0) {
setBasicSettings({ setBasicSettings({
...basicSetting, ...basicSetting,
roofsData: { roofsData: {
roofApply: true, roofApply: true,
roofSeq: 1, roofSeq: 0,
roofMatlCd: basicSetting.roofs[0].roofMatlCd, roofMatlCd: addedRoofs[0].roofMatlCd,
roofWidth: basicSetting.roofs[0].width, roofWidth: addedRoofs[0].width,
roofHeight: basicSetting.roofs[0].length, roofHeight: addedRoofs[0].length,
roofHajebichi: basicSetting.roofs[0].hajebichi, roofHajebichi: addedRoofs[0].hajebichi,
roofGap: basicSetting.roofs[0].raft, roofGap: addedRoofs[0].raft,
roofLayout: basicSetting.roofs[0].layout, roofLayout: addedRoofs[0].layout,
}, },
}) })
} }
}, [basicSetting.roofs, basicSetting.roofSizeSet, basicSetting.roofAngleSet]) }, [basicSetting.roofSizeSet, basicSetting.roofAngleSet, addedRoofs])
const changeInput = (value, e) => { const changeInput = (value, e) => {
const { name } = e.target const { name } = e.target
console.log('🚀 ~ changeInput ~ value name :', value, name) setAddedRoofs(addedRoofs.map((roof) => ({
setBasicSettings({ ...roof,
...basicSetting, [name]: Number(value),
roofs: basicSetting.roofs.map((roof) => ({ })))
...roof,
[name]: Number(value),
})),
});
} }
// Function to update the roofType and corresponding values // Function to update the roofType and corresponding values
const handleRoofTypeChange = (value) => { const handleRoofTypeChange = (value) => {
const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value) const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value)
setBasicSettings({ setAddedRoofs([selectedRoofMaterial])
...basicSetting,
roofs: [selectedRoofMaterial], // roofs
});
} }
const handleRafterChange = (value) => { const handleRafterChange = (value) => {
setBasicSettings({ setAddedRoofs(addedRoofs.map((roof) => ({
...basicSetting, ...roof,
roofs: basicSetting.roofs.map((roof) => ({ raft: value,
...roof, })))
raft: value,
})),
});
} }
const handleRoofLayoutChange = (value) => { const handleRoofLayoutChange = (value) => {
setBasicSettings({ setAddedRoofs(addedRoofs.map((roof) => ({
...basicSetting, ...roof,
roofs: basicSetting.roofs.map((roof) => ({ layout: value,
...roof, })))
layout: value,
})),
});
} }
const handleSaveBtn = () => { const handleSaveBtn = () => {
const roofInfo = { const roofInfo = {
...basicSetting.roofs, ...addedRoofs,
roofCd: roofRef.roofCd.current?.value, roofCd: roofRef.roofCd.current?.value,
width: roofRef.width.current?.value, width: roofRef.width.current?.value,
length: roofRef.length.current?.value, length: roofRef.length.current?.value,
hajebichi: roofRef.hajebichi.current?.value, hajebichi: roofRef.hajebichi.current?.value,
//raft: roofRef.rafter.current?.value, //raft: roofRef.rafter.current?.value,
selected: true, selected: true,
layout: basicSetting.roofs[0].layout, layout: addedRoofs[0].layout,
index: 0, index: 0,
} }
@ -139,16 +126,16 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
// //
...roofInfo, ...roofInfo,
}, },
roofs: addedRoofs, //roofs: addedRoofs,
roofsData: { roofsData: {
roofApply: true, roofApply: true,
roofSeq: 1, roofSeq: 0,
roofMatlCd: basicSetting.roofs[0].roofMatlCd, roofMatlCd: addedRoofs[0].roofMatlCd,
roofWidth: basicSetting.roofs[0].width, roofWidth: addedRoofs[0].width,
roofHeight: basicSetting.roofs[0].length, roofHeight: addedRoofs[0].length,
roofHajebichi: basicSetting.roofs[0].hajebichi, roofHajebichi: addedRoofs[0].hajebichi,
roofGap: basicSetting.roofs[0].raft, roofGap: addedRoofs[0].raft,
roofLayout: basicSetting.roofs[0].layout, roofLayout: addedRoofs[0].layout,
}, },
}) })
@ -261,14 +248,14 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
<div className="placement-option"> <div className="placement-option">
<div className="grid-select no-flx" style={{ width: '171px' }}> <div className="grid-select no-flx" style={{ width: '171px' }}>
<QSelectBox <QSelectBox
title={basicSetting.roofSizeSet == 3 ? getMessage('modal.placement.initial.setting.size.none.pitch') : basicSetting.roofs[0]?.roofMatlNm} title={basicSetting.roofSizeSet == 3 ? getMessage('modal.placement.initial.setting.size.none.pitch') : addedRoofs[0]?.roofMatlNm}
ref={roofRef.roofCd} ref={roofRef.roofCd}
options={roofMaterials.map((roof, index) => { options={roofMaterials.map((roof, index) => {
return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp } return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp }
})} })}
//value={roofMaterials.find((r) => r.roofMatlCd === basicSetting.roofs[0]?.roofMatlCd)} //value={roofMaterials.find((r) => r.roofMatlCd === basicSetting.roofs[0]?.roofMatlCd)}
//title={basicSetting.roofs[0]?.roofMatlNm} //title={basicSetting.roofs[0]?.roofMatlNm}
value={basicSetting.roofSizeSet == 3 ? null : basicSetting.roofs[0]?.roofMatlCd} value={basicSetting.roofSizeSet == 3 ? null : addedRoofs[0]?.roofMatlCd}
onChange={(e) => handleRoofTypeChange(e.roofMatlCd)} onChange={(e) => handleRoofTypeChange(e.roofMatlCd)}
//sourceKey="id" //sourceKey="id"
//targetKey="id" //targetKey="id"
@ -293,7 +280,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
})} })}
</select> */} </select> */}
</div> </div>
{basicSetting && ['R', 'C'].includes(basicSetting.roofs[0]?.widAuth) && ( {basicSetting && ['R', 'C'].includes(addedRoofs[0]?.widAuth) && (
<div className="flex-ment"> <div className="flex-ment">
<span>W</span> <span>W</span>
<div className="input-grid" style={{ width: '84px' }}> <div className="input-grid" style={{ width: '84px' }}>
@ -302,9 +289,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
className="input-origin block" className="input-origin block"
name={`width`} name={`width`}
ref={roofRef.width} ref={roofRef.width}
value={parseInt(basicSetting.roofs[0]?.width)} value={parseInt(addedRoofs[0]?.width)}
onChange={(e) => onlyNumberInputChange(e, changeInput)} onChange={(e) => onlyNumberInputChange(e, changeInput)}
readOnly={basicSetting.roofs[0]?.widAuth === 'R'} readOnly={addedRoofs[0]?.widAuth === 'R'}
disabled={basicSetting.roofSizeSet == 3} disabled={basicSetting.roofSizeSet == 3}
/> />
</div> </div>
@ -318,7 +305,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
</div> */} </div> */}
</div> </div>
)} )}
{basicSetting && ['R', 'C'].includes(basicSetting.roofs[0]?.lenAuth) && ( {basicSetting && ['R', 'C'].includes(addedRoofs[0]?.lenAuth) && (
<div className="flex-ment"> <div className="flex-ment">
<span>L</span> <span>L</span>
<div className="input-grid" style={{ width: '84px' }}> <div className="input-grid" style={{ width: '84px' }}>
@ -327,9 +314,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
className="input-origin block" className="input-origin block"
name={`length`} name={`length`}
ref={roofRef.length} ref={roofRef.length}
value={parseInt(basicSetting.roofs[0]?.length)} value={parseInt(addedRoofs[0]?.length)}
onChange={(e) => onlyNumberInputChange(e, changeInput)} onChange={(e) => onlyNumberInputChange(e, changeInput)}
readOnly={basicSetting.roofs[0]?.lenAuth === 'R'} readOnly={addedRoofs[0]?.lenAuth === 'R'}
disabled={basicSetting.roofSizeSet == 3} disabled={basicSetting.roofSizeSet == 3}
/> />
</div> </div>
@ -343,18 +330,18 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
</div> */} </div> */}
</div> </div>
)} )}
{basicSetting && ['C', 'R'].includes(basicSetting.roofs[0]?.raftAuth) && ( {basicSetting && ['C', 'R'].includes(addedRoofs[0]?.raftAuth) && (
<div className="flex-ment"> <div className="flex-ment">
<span>{getMessage('modal.placement.initial.setting.rafter')}</span> <span>{getMessage('modal.placement.initial.setting.rafter')}</span>
{raftCodes.length > 0 && ( {raftCodes.length > 0 && (
<div className="select-wrap" style={{ width: '160px' }}> <div className="select-wrap" style={{ width: '160px' }}>
<QSelectBox <QSelectBox
options={raftCodes} options={raftCodes}
title={raftCodes.find((r) => r.clCode === (basicSetting.roofs[0]?.raft === undefined ? basicSetting.roofs[0]?.raftBaseCd : basicSetting.roofs[0]?.raft))?.clCodeNm} title={raftCodes.find((r) => r.clCode === (addedRoofs[0]?.raft === undefined ? addedRoofs[0]?.raftBaseCd : addedRoofs[0]?.raft))?.clCodeNm}
value={basicSetting.roofs[0]?.raft === undefined ? basicSetting.roofs[0]?.raftBaseCd : basicSetting.roofs[0]?.raft} value={addedRoofs[0]?.raft === undefined ? addedRoofs[0]?.raftBaseCd : addedRoofs[0]?.raft}
onChange={(e) => handleRafterChange(e.clCode)} onChange={(e) => handleRafterChange(e.clCode)}
sourceKey="clCode" sourceKey="clCode"
targetKey={basicSetting.roofs[0]?.raft ? 'raft' : 'raftBaseCd'} targetKey={addedRoofs[0]?.raft ? 'raft' : 'raftBaseCd'}
showKey="clCodeNm" showKey="clCodeNm"
disabled={basicSetting.roofSizeSet == 3} disabled={basicSetting.roofSizeSet == 3}
/> />
@ -371,7 +358,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
)} )}
</div> </div>
)} )}
{basicSetting && ['C', 'R'].includes(basicSetting.roofs[0]?.roofPchAuth) && ( {basicSetting && ['C', 'R'].includes(addedRoofs[0]?.roofPchAuth) && (
<div className="flex-ment"> <div className="flex-ment">
<span>{getMessage('hajebichi')}</span> <span>{getMessage('hajebichi')}</span>
<div className="input-grid" style={{ width: '84px' }}> <div className="input-grid" style={{ width: '84px' }}>
@ -380,9 +367,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
className="input-origin block" className="input-origin block"
name={`hajebichi`} name={`hajebichi`}
ref={roofRef.hajebichi} ref={roofRef.hajebichi}
value={parseInt(basicSetting.roofs[0]?.hajebichi)} value={parseInt(addedRoofs[0]?.hajebichi)}
onChange={(e) => onlyNumberInputChange(e, changeInput)} onChange={(e) => onlyNumberInputChange(e, changeInput)}
readOnly={basicSetting.roofs[0]?.roofPchAuth === 'R'} readOnly={addedRoofs[0]?.roofPchAuth === 'R'}
disabled={basicSetting.roofSizeSet == 3} disabled={basicSetting.roofSizeSet == 3}
/> />
</div> </div>
@ -392,7 +379,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
<div className="placement-roof-btn-wrap"> <div className="placement-roof-btn-wrap">
<div className="icon-btn-wrap mt10"> <div className="icon-btn-wrap mt10">
<button <button
className={`${basicSetting.roofs[0]?.layout === ROOF_MATERIAL_LAYOUT.PARALLEL && 'act'}`} className={`${addedRoofs[0]?.layout === ROOF_MATERIAL_LAYOUT.PARALLEL && 'act'}`}
value={ROOF_MATERIAL_LAYOUT.PARALLEL} value={ROOF_MATERIAL_LAYOUT.PARALLEL}
onClick={() => handleRoofLayoutChange(ROOF_MATERIAL_LAYOUT.PARALLEL)} onClick={() => handleRoofLayoutChange(ROOF_MATERIAL_LAYOUT.PARALLEL)}
> >
@ -400,7 +387,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
<i className="allocation01"></i> <i className="allocation01"></i>
</button> </button>
<button <button
className={`${basicSetting.roofs[0]?.layout === ROOF_MATERIAL_LAYOUT.STAIRS && 'act'}`} className={`${addedRoofs[0]?.layout === ROOF_MATERIAL_LAYOUT.STAIRS && 'act'}`}
value={ROOF_MATERIAL_LAYOUT.STAIRS} value={ROOF_MATERIAL_LAYOUT.STAIRS}
onClick={() => handleRoofLayoutChange(ROOF_MATERIAL_LAYOUT.STAIRS)} onClick={() => handleRoofLayoutChange(ROOF_MATERIAL_LAYOUT.STAIRS)}
> >

View File

@ -142,7 +142,7 @@ export function useCanvasSetting() {
newAddedRoofs.push({ ...selectedRoofMaterial, selected: true, index: 0 }) newAddedRoofs.push({ ...selectedRoofMaterial, selected: true, index: 0 })
setAddedRoofs(newAddedRoofs) setAddedRoofs(newAddedRoofs)
} }
setBasicSettings({ ...basicSetting, selectedRoofMaterial: selectedRoofMaterial, roofMaterials: selectedRoofMaterial }) setBasicSettings({ ...basicSetting, selectedRoofMaterial: selectedRoofMaterial })
} }
useEffect(() => { useEffect(() => {
@ -317,19 +317,21 @@ export function useCanvasSetting() {
roofMaterials.map((material) => { roofMaterials.map((material) => {
if (material.id === roofsArray[0].roofMatlCd) { if (material.id === roofsArray[0].roofMatlCd) {
//setRoofMaterials({ ...roofMaterials, layout: roofsArray[0].roofLayout }) //setRoofMaterials({ ...roofMaterials, layout: roofsArray[0].roofLayout })
addRoofs.push({ ...material, selected: true addRoofs.push({ ...material, selected: true
, index: 0
, width: roofsArray[0].roofWidth , width: roofsArray[0].roofWidth
, length: roofsArray[0].roofHeight , length: roofsArray[0].roofHeight
, hajebichi: roofsArray[0].roofHajebichi , hajebichi: roofsArray[0].roofHajebichi
, raft: roofsArray[0].roofGap , raft: roofsArray[0].roofGap
, layout: roofsArray[0].roofLayout , layout: roofsArray[0].roofLayout
}) })
setBasicSettings({ ...basicSetting, roofMaterials: material
, roofs: addRoofs setAddedRoofs(addRoofs)
setBasicSettings({ ...basicSetting, roofMaterials: addRoofs[0]
, roofSizeSet: roofsRow[0].roofSizeSet , roofSizeSet: roofsRow[0].roofSizeSet
, roofAngleSet: roofsRow[0].roofAngleSet , roofAngleSet: roofsRow[0].roofAngleSet
, roofsData: roofsArray , roofsData: roofsArray
, selectedRoofMaterial: material }) , selectedRoofMaterial: addRoofs[0] })
} }
}) })
@ -354,13 +356,13 @@ export function useCanvasSetting() {
roofMaterialsAddList: [ roofMaterialsAddList: [
{ {
roofApply: true, roofApply: true,
roofSeq: 1, roofSeq: 0,
roofMatlCd: basicSetting.roofsData.roofMatlCd === null || basicSetting.roofsData.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : basicSetting.roofsData.roofMatlCd, roofMatlCd: basicSetting.roofsData.roofMatlCd === null || basicSetting.roofsData.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : basicSetting.roofsData.roofMatlCd,
roofWidth: basicSetting.roofsData.roofWidth === null || basicSetting.roofsData.roofWidth === undefined ? 0 : basicSetting.roofsData.roofWidth, roofWidth: basicSetting.roofsData.roofWidth === null || basicSetting.roofsData.roofWidth === undefined ? 0 : basicSetting.roofsData.roofWidth,
roofHeight: basicSetting.roofsData.roofHeight === null || basicSetting.roofsData.roofHeight === undefined ? 0 : basicSetting.roofsData.roofHeight, roofHeight: basicSetting.roofsData.roofHeight === null || basicSetting.roofsData.roofHeight === undefined ? 0 : basicSetting.roofsData.roofHeight,
roofHajebichi: basicSetting.roofsData.roofHajebichi === null || basicSetting.roofsData.roofHajebichi === undefined ? 0 : basicSetting.roofsData.roofHajebichi, roofHajebichi: basicSetting.roofsData.roofHajebichi === null || basicSetting.roofsData.roofHajebichi === undefined ? 0 : basicSetting.roofsData.roofHajebichi,
roofGap: basicSetting.roofsData.roofGap === null || basicSetting.roofsData.roofGap === undefined ? 'HEI_455' : basicSetting.roofsData.roofGap, roofGap: basicSetting.roofsData.roofGap === null || basicSetting.roofsData.roofGap === undefined ? 'HEI_455' : basicSetting.roofsData.roofGap,
roofLayout: basicSetting.roofsData.roofLayout, roofLayout: basicSetting.roofsData.roofLayout === null || basicSetting.roofsData.roofLayout === undefined ? 'P' : basicSetting.roofsData.roofLayout,
}, },
], ],
} }