diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx index 1ca8b420..921d5fdb 100644 --- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx +++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx @@ -48,8 +48,11 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set }, []) useEffect(() => { + console.log('๐Ÿš€ ~ useEffect ~ basicSetting:', currentRoof) setBasicSettings({ ...basicSetting, + roofSizeSet: currentRoof.roofSizeSet, + roofAngleSet: currentRoof.roofAngleSet, roofsData: { roofApply: true, roofSeq: 0, @@ -61,12 +64,21 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set roofLayout: currentRoof.layout, }, }) - }, [basicSetting.roofSizeSet, basicSetting.roofAngleSet, currentRoof]) + }, [currentRoof]) + + const handleRoofSizeSetChange = (value) => { + setCurrentRoof({...currentRoof, roofSizeSet: value}) + } + + const handleRoofAngleSetChange = (value) => { + setCurrentRoof({...currentRoof, roofAngleSet: value}) + } // Function to update the roofType and corresponding values const handleRoofTypeChange = (value) => { const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value) - setCurrentRoof({...selectedRoofMaterial, index: 0}) + console.log('๐Ÿš€ ~ handleRoofTypeChange ~ selectedRoofMaterial:', selectedRoofMaterial) + setCurrentRoof({...selectedRoofMaterial, index: 0, roofSizeSet: currentRoof.roofSizeSet, roofAngleSet: currentRoof.roofAngleSet}) } const changeInput = (value, e) => { @@ -125,6 +137,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set roofHajebichi: currentRoof.hajebichi, roofGap: currentRoof.raft, roofLayout: currentRoof.layout, + roofSizeSet: currentRoof.roofSizeSet, + roofAngleSet: currentRoof.roofAngleSet, }, }) @@ -167,8 +181,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set name="roofSizeSet" id="ra01" value="1" // roofSizeSet ๊ฐ’์ด '1'์ธ ๊ฒฝ์šฐ - checked={basicSetting.roofSizeSet == '1'} // ์„ ํƒ ์—ฌ๋ถ€ ํ™•์ธ - onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + checked={currentRoof.roofSizeSet === '1'} // ์„ ํƒ ์—ฌ๋ถ€ ํ™•์ธ + //onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + onClick={() => handleRoofSizeSetChange(1)} /> @@ -178,8 +193,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set name="roofSizeSet" id="ra02" value="2" // roofSizeSet ๊ฐ’์ด '2'์ธ ๊ฒฝ์šฐ - checked={basicSetting.roofSizeSet == '2'} // ์„ ํƒ ์—ฌ๋ถ€ ํ™•์ธ - onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + checked={currentRoof.roofSizeSet === '2'} // ์„ ํƒ ์—ฌ๋ถ€ ํ™•์ธ + //onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + onClick={() => handleRoofSizeSetChange(2)} /> @@ -189,8 +205,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set name="roofSizeSet" id="ra03" value="3" // roofSizeSet ๊ฐ’์ด '3'์ธ ๊ฒฝ์šฐ - checked={basicSetting.roofSizeSet == '3'} // ์„ ํƒ ์—ฌ๋ถ€ ํ™•์ธ - onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + checked={currentRoof.roofSizeSet === '3'} // ์„ ํƒ ์—ฌ๋ถ€ ํ™•์ธ + //onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + onClick={() => handleRoofSizeSetChange(3)} /> @@ -207,8 +224,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set name="roofAngleSet" id="ra04" value="slope" // ์ฒซ ๋ฒˆ์งธ ๋ผ๋””์˜ค ๋ฒ„ํŠผ์˜ ๊ฐ’ - checked={basicSetting.roofAngleSet == 'slope'} // ํ˜„์žฌ ์„ ํƒ๋œ ๊ฐ’์ธ์ง€ ํ™•์ธ - onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + checked={currentRoof.roofAngleSet === 'slope'} // ํ˜„์žฌ ์„ ํƒ๋œ ๊ฐ’์ธ์ง€ ํ™•์ธ + //onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + onClick={() => handleRoofAngleSetChange('slope')} /> @@ -218,8 +236,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set name="roofAngleSet" id="ra05" value="flat" // ๋‘ ๋ฒˆ์งธ ๋ผ๋””์˜ค ๋ฒ„ํŠผ์˜ ๊ฐ’ - checked={basicSetting.roofAngleSet == 'flat'} // ํ˜„์žฌ ์„ ํƒ๋œ ๊ฐ’์ธ์ง€ ํ™•์ธ - onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + checked={currentRoof.roofAngleSet === 'flat'} // ํ˜„์žฌ ์„ ํƒ๋œ ๊ฐ’์ธ์ง€ ํ™•์ธ + //onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // ์ƒํƒœ ์—…๋ฐ์ดํŠธ + onClick={() => handleRoofAngleSetChange('flat')} /> @@ -237,17 +256,17 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
{ return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp } })} - value={basicSetting.roofSizeSet == 3 ? null : currentRoof.roofMatlCd} + value={currentRoof.roofSizeSet == 3 ? null : currentRoof.roofMatlCd} onChange={(e) => handleRoofTypeChange(e.roofMatlCd)} sourceKey="id" targetKey="id" showKey="name" - disabled={basicSetting.roofSizeSet == 3} + disabled={currentRoof.roofSizeSet == 3} /> {/* {raftCodes.map((raft, index) => { @@ -346,7 +365,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set )}
)} - {basicSetting && ['C', 'R'].includes(currentRoof.roofPchAuth) && ( + {currentRoof && ['C', 'R'].includes(currentRoof.roofPchAuth) && (
{getMessage('hajebichi')}
@@ -358,7 +377,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set value={parseInt(currentRoof.hajebichi)} onChange={(e) => onlyNumberInputChange(e, changeInput)} readOnly={currentRoof.roofPchAuth === 'R'} - disabled={basicSetting.roofSizeSet == 3} + disabled={currentRoof.roofSizeSet == 3} />
diff --git a/src/hooks/option/useCanvasSetting.js b/src/hooks/option/useCanvasSetting.js index c4ac79c9..dc2488f2 100644 --- a/src/hooks/option/useCanvasSetting.js +++ b/src/hooks/option/useCanvasSetting.js @@ -274,7 +274,7 @@ export function useCanvasSetting() { // ๊ธฐ๋ณธ์„ค์ •(PlacementShapeSetting) ์กฐํšŒ ๋ฐ ์ดˆ๊ธฐํ™” const fetchBasicSettings = async () => { try { - await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/1/${correntObjectNo}` }).then((res) => { + await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}` }).then((res) => { let roofsRow = {} let roofsArray = {} @@ -320,15 +320,6 @@ export function useCanvasSetting() { ] } - // ๋‚˜๋จธ์ง€ ๋ฐ์ดํ„ฐ์™€ ํ•จ๊ป˜ 'roofs' ๋ฐฐ์—ด์„ patternData์— ๋„ฃ์Œ - const patternData = { - roofSizeSet: roofsRow[0].roofSizeSet, - roofAngleSet: roofsRow[0].roofAngleSet, - roofs: roofsArray, // ๋งŒ๋“ค์–ด์ง„ roofs ๋ฐฐ์—ด - } - - //console.log('fetchBasicSettings patternData', patternData) - // ๋ฐ์ดํ„ฐ ์„ค์ • const addRoofs = [] roofMaterials?.map((material) => { @@ -340,6 +331,8 @@ export function useCanvasSetting() { , hajebichi: roofsArray[0].roofHajebichi , raft: roofsArray[0].roofGap , layout: roofsArray[0].roofLayout + , roofSizeSet: roofsRow[0].roofSizeSet + , roofAngleSet: roofsRow[0].roofAngleSet }) setAddedRoofs(addRoofs) @@ -378,6 +371,8 @@ export function useCanvasSetting() { 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, roofLayout: basicSetting.roofsData.roofLayout === null || basicSetting.roofsData.roofLayout === undefined ? 'P' : basicSetting.roofsData.roofLayout, + roofPitch: 4, + roofAngle: 21.8, }, ], } diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index 3e999380..f0884969 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -90,18 +90,13 @@ export function useRoofAllocationSetting(id) { closePopup(id) } - // console.log('๐Ÿš€ ~ useEffect ~ roofMaterials >>>>>>>>>>>>> :', roofMaterials) - // console.log('๐Ÿš€ ~ useEffect ~ basicSetting >>>>>>>>>>>>> :', basicSetting) - // console.log('๐Ÿš€ ~ useEffect ~ roofList >>>>>>>>>>>>> :', roofList) - // console.log('๐Ÿš€ ~ useEffect ~ currentRoofList >>>>>>>>>>>>> :', currentRoofList) - fetchBasicSettings() }, []) - // ์กฐํšŒ ๋ฐ ์ดˆ๊ธฐํ™” + // ์ง€๋ถ•๋ฉด ํ• ๋‹น ์กฐํšŒ ๋ฐ ์ดˆ๊ธฐํ™” const fetchBasicSettings = async () => { try { - await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/1/${correntObjectNo}` }).then((res) => { + await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}` }).then((res) => { console.log('๐Ÿš€ ~ useRoofAllocationSetting ~ fetchBasicSettings ~ res >>>>>>>>>>>>>>>>>>>>> :', res) let roofsArray = {} @@ -116,6 +111,8 @@ export function useRoofAllocationSetting(id) { roofHajebichi: item.roofHajebichi, roofGap: item.roofGap, roofLayout: item.roofLayout, + roofPitch: item.roofPitch, + roofAngle: item.roofAngle, } }) } else { @@ -129,15 +126,12 @@ export function useRoofAllocationSetting(id) { roofHajebichi: 0, roofGap: 'HEI_455', roofLayout: 'P', + roofPitch: 4, + roofAngle: 21.8, }, ] } - // ๋‚˜๋จธ์ง€ ๋ฐ์ดํ„ฐ์™€ ํ•จ๊ป˜ 'roofs' ๋ฐฐ์—ด์„ patternData์— ๋„ฃ์Œ - const patternData = { - roofs: roofsArray, // ๋งŒ๋“ค์–ด์ง„ roofs ๋ฐฐ์—ด - } - console.log('fetchBasicSettings roofsArray', roofsArray) // ๋ฐ์ดํ„ฐ ์„ค์ • @@ -155,6 +149,8 @@ export function useRoofAllocationSetting(id) { hajebichi: roofsArray[i].roofHajebichi, raft: roofsArray[i].roofGap, layout: roofsArray[i].roofLayout, + pitch: roofsArray[i].roofPitch, + angle: roofsArray[i].roofAngle, }) setCurrentRoofList(selectRoofs) } @@ -167,28 +163,30 @@ export function useRoofAllocationSetting(id) { } } - // ์ €์žฅ + // ์ง€๋ถ•๋ฉด ํ• ๋‹น ์ €์žฅ const basicSettingSave = async () => { const patternData = { objectNo: correntObjectNo, roofSizeSet: basicSetting.roofSizeSet, roofAngleSet: basicSetting.roofAngleSet, - roofMaterialsAddList: currentRoofList.map((item) => ({ + roofMaterialsAddList: currentRoofList.map((item, index) => ({ roofApply: item.selected === null || item.selected === undefined ? 'true' : item.selected, - roofSeq: item.index === null || item.index === undefined ? 0 : item.index, + roofSeq: index, roofMatlCd: item.roofMatlCd === null || item.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : item.roofMatlCd, roofWidth: item.width === null || item.width === undefined ? 0 : item.width, roofHeight: item.length === null || item.length === undefined ? 0 : item.length, roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : item.hajebichi, roofGap: item.raft === null || item.raft === undefined ? 'HEI_455' : item.raft, roofLayout: item.layout === null || item.layout === undefined ? 'P' : item.layout, + roofPitch: item.pitch === null || item.pitch === undefined ? 4 : item.pitch, + roofAngle: item.angle === null || item.angle === undefined ? 21.8 : item.angle, })), } console.log('๐Ÿš€ ~ basicSettingSave ~ patternData >>>>>>>>>>>>> :', patternData) // HTTP POST ์š”์ฒญ ๋ณด๋‚ด๊ธฐ - await post({ url: `/api/canvas-management/canvas-basic-settings`, data: patternData }) + await post({ url: `/api/canvas-management/roof-allocation-settings`, data: patternData }) .then((res) => { swalFire({ text: getMessage(res.returnMessage) })