지붕재 할당 컬럼 추가

This commit is contained in:
changkyu choi 2025-01-10 19:03:33 +09:00
parent 08bcf1c858
commit 6c4bbbb63f
3 changed files with 61 additions and 49 deletions

View File

@ -48,8 +48,11 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
}, []) }, [])
useEffect(() => { useEffect(() => {
console.log('🚀 ~ useEffect ~ basicSetting:', currentRoof)
setBasicSettings({ setBasicSettings({
...basicSetting, ...basicSetting,
roofSizeSet: currentRoof.roofSizeSet,
roofAngleSet: currentRoof.roofAngleSet,
roofsData: { roofsData: {
roofApply: true, roofApply: true,
roofSeq: 0, roofSeq: 0,
@ -61,12 +64,21 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
roofLayout: currentRoof.layout, 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 // 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)
setCurrentRoof({...selectedRoofMaterial, index: 0}) console.log('🚀 ~ handleRoofTypeChange ~ selectedRoofMaterial:', selectedRoofMaterial)
setCurrentRoof({...selectedRoofMaterial, index: 0, roofSizeSet: currentRoof.roofSizeSet, roofAngleSet: currentRoof.roofAngleSet})
} }
const changeInput = (value, e) => { const changeInput = (value, e) => {
@ -125,6 +137,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
roofHajebichi: currentRoof.hajebichi, roofHajebichi: currentRoof.hajebichi,
roofGap: currentRoof.raft, roofGap: currentRoof.raft,
roofLayout: currentRoof.layout, 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" name="roofSizeSet"
id="ra01" id="ra01"
value="1" // roofSizeSet '1' value="1" // roofSizeSet '1'
checked={basicSetting.roofSizeSet == '1'} // checked={currentRoof.roofSizeSet === '1'} //
onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // //onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} //
onClick={() => handleRoofSizeSetChange(1)}
/> />
<label htmlFor="ra01">{getMessage('modal.placement.initial.setting.size.roof')}</label> <label htmlFor="ra01">{getMessage('modal.placement.initial.setting.size.roof')}</label>
</div> </div>
@ -178,8 +193,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
name="roofSizeSet" name="roofSizeSet"
id="ra02" id="ra02"
value="2" // roofSizeSet '2' value="2" // roofSizeSet '2'
checked={basicSetting.roofSizeSet == '2'} // checked={currentRoof.roofSizeSet === '2'} //
onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // //onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} //
onClick={() => handleRoofSizeSetChange(2)}
/> />
<label htmlFor="ra02">{getMessage('modal.placement.initial.setting.size.actual')}</label> <label htmlFor="ra02">{getMessage('modal.placement.initial.setting.size.actual')}</label>
</div> </div>
@ -189,8 +205,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
name="roofSizeSet" name="roofSizeSet"
id="ra03" id="ra03"
value="3" // roofSizeSet '3' value="3" // roofSizeSet '3'
checked={basicSetting.roofSizeSet == '3'} // checked={currentRoof.roofSizeSet === '3'} //
onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // //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="ra03">{getMessage('modal.placement.initial.setting.size.none.pitch')}</label>
</div> </div>
@ -207,8 +224,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
name="roofAngleSet" name="roofAngleSet"
id="ra04" id="ra04"
value="slope" // value="slope" //
checked={basicSetting.roofAngleSet == 'slope'} // checked={currentRoof.roofAngleSet === 'slope'} //
onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // //onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} //
onClick={() => handleRoofAngleSetChange('slope')}
/> />
<label htmlFor="ra04">{getMessage('modal.placement.initial.setting.roof.pitch')}</label> <label htmlFor="ra04">{getMessage('modal.placement.initial.setting.roof.pitch')}</label>
</div> </div>
@ -218,8 +236,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
name="roofAngleSet" name="roofAngleSet"
id="ra05" id="ra05"
value="flat" // value="flat" //
checked={basicSetting.roofAngleSet == 'flat'} // checked={currentRoof.roofAngleSet === 'flat'} //
onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // //onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} //
onClick={() => handleRoofAngleSetChange('flat')}
/> />
<label htmlFor="ra05">{getMessage('modal.placement.initial.setting.roof.angle')}</label> <label htmlFor="ra05">{getMessage('modal.placement.initial.setting.roof.angle')}</label>
</div> </div>
@ -237,17 +256,17 @@ 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') : currentRoof.roofMatlNm} title={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, index) => {
return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp } 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)} onChange={(e) => handleRoofTypeChange(e.roofMatlCd)}
sourceKey="id" sourceKey="id"
targetKey="id" targetKey="id"
showKey="name" showKey="name"
disabled={basicSetting.roofSizeSet == 3} disabled={currentRoof.roofSizeSet == 3}
/> />
{/* <select {/* <select
className="select-light dark" className="select-light dark"
@ -267,7 +286,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
})} })}
</select> */} </select> */}
</div> </div>
{basicSetting && ['R', 'C'].includes(currentRoof.widAuth) && ( {currentRoof && ['R', 'C'].includes(currentRoof.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' }}>
@ -279,7 +298,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
value={parseInt(currentRoof.width)} value={parseInt(currentRoof.width)}
onChange={(e) => onlyNumberInputChange(e, changeInput)} onChange={(e) => onlyNumberInputChange(e, changeInput)}
readOnly={currentRoof.widAuth === 'R'} readOnly={currentRoof.widAuth === 'R'}
disabled={basicSetting.roofSizeSet == 3} disabled={currentRoof.roofSizeSet == 3}
/> />
</div> </div>
{/* <div className="input-grid" style={{ width: '63px' }}> {/* <div className="input-grid" style={{ width: '63px' }}>
@ -292,7 +311,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
</div> */} </div> */}
</div> </div>
)} )}
{basicSetting && ['R', 'C'].includes(currentRoof.lenAuth) && ( {currentRoof && ['R', 'C'].includes(currentRoof.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' }}>
@ -304,7 +323,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
value={parseInt(currentRoof.length)} value={parseInt(currentRoof.length)}
onChange={(e) => onlyNumberInputChange(e, changeInput)} onChange={(e) => onlyNumberInputChange(e, changeInput)}
readOnly={currentRoof.lenAuth === 'R'} readOnly={currentRoof.lenAuth === 'R'}
disabled={basicSetting.roofSizeSet == 3} disabled={currentRoof.roofSizeSet == 3}
/> />
</div> </div>
{/* <div className="input-grid" style={{ width: '63px' }}> {/* <div className="input-grid" style={{ width: '63px' }}>
@ -317,7 +336,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
</div> */} </div> */}
</div> </div>
)} )}
{basicSetting && ['C', 'R'].includes(currentRoof.raftAuth) && ( {currentRoof && ['C', 'R'].includes(currentRoof.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 && (
@ -331,7 +350,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
sourceKey="clCode" sourceKey="clCode"
targetKey={currentRoof.raft ? 'raft' : 'raftBaseCd'} targetKey={currentRoof.raft ? 'raft' : 'raftBaseCd'}
showKey="clCodeNm" showKey="clCodeNm"
disabled={basicSetting.roofSizeSet == 3} disabled={currentRoof.roofSizeSet == 3}
/> />
{/* <select className="select-light dark" name="roofGap" ref={roofRef.rafter}> {/* <select className="select-light dark" name="roofGap" ref={roofRef.rafter}>
{raftCodes.map((raft, index) => { {raftCodes.map((raft, index) => {
@ -346,7 +365,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
)} )}
</div> </div>
)} )}
{basicSetting && ['C', 'R'].includes(currentRoof.roofPchAuth) && ( {currentRoof && ['C', 'R'].includes(currentRoof.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' }}>
@ -358,7 +377,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
value={parseInt(currentRoof.hajebichi)} value={parseInt(currentRoof.hajebichi)}
onChange={(e) => onlyNumberInputChange(e, changeInput)} onChange={(e) => onlyNumberInputChange(e, changeInput)}
readOnly={currentRoof.roofPchAuth === 'R'} readOnly={currentRoof.roofPchAuth === 'R'}
disabled={basicSetting.roofSizeSet == 3} disabled={currentRoof.roofSizeSet == 3}
/> />
</div> </div>
</div> </div>

View File

@ -274,7 +274,7 @@ export function useCanvasSetting() {
// 기본설정(PlacementShapeSetting) 조회 및 초기화 // 기본설정(PlacementShapeSetting) 조회 및 초기화
const fetchBasicSettings = async () => { const fetchBasicSettings = async () => {
try { 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 roofsRow = {}
let roofsArray = {} 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 = [] const addRoofs = []
roofMaterials?.map((material) => { roofMaterials?.map((material) => {
@ -340,6 +331,8 @@ export function useCanvasSetting() {
, hajebichi: roofsArray[0].roofHajebichi , hajebichi: roofsArray[0].roofHajebichi
, raft: roofsArray[0].roofGap , raft: roofsArray[0].roofGap
, layout: roofsArray[0].roofLayout , layout: roofsArray[0].roofLayout
, roofSizeSet: roofsRow[0].roofSizeSet
, roofAngleSet: roofsRow[0].roofAngleSet
}) })
setAddedRoofs(addRoofs) setAddedRoofs(addRoofs)
@ -378,6 +371,8 @@ export function useCanvasSetting() {
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 === null || basicSetting.roofsData.roofLayout === undefined ? 'P' : basicSetting.roofsData.roofLayout, roofLayout: basicSetting.roofsData.roofLayout === null || basicSetting.roofsData.roofLayout === undefined ? 'P' : basicSetting.roofsData.roofLayout,
roofPitch: 4,
roofAngle: 21.8,
}, },
], ],
} }

View File

@ -90,18 +90,13 @@ export function useRoofAllocationSetting(id) {
closePopup(id) closePopup(id)
} }
// console.log('🚀 ~ useEffect ~ roofMaterials >>>>>>>>>>>>> :', roofMaterials)
// console.log('🚀 ~ useEffect ~ basicSetting >>>>>>>>>>>>> :', basicSetting)
// console.log('🚀 ~ useEffect ~ roofList >>>>>>>>>>>>> :', roofList)
// console.log('🚀 ~ useEffect ~ currentRoofList >>>>>>>>>>>>> :', currentRoofList)
fetchBasicSettings() fetchBasicSettings()
}, []) }, [])
// 조회 및 초기화 // 지붕면 할당 조회 및 초기화
const fetchBasicSettings = async () => { const fetchBasicSettings = async () => {
try { 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) console.log('🚀 ~ useRoofAllocationSetting ~ fetchBasicSettings ~ res >>>>>>>>>>>>>>>>>>>>> :', res)
let roofsArray = {} let roofsArray = {}
@ -116,6 +111,8 @@ export function useRoofAllocationSetting(id) {
roofHajebichi: item.roofHajebichi, roofHajebichi: item.roofHajebichi,
roofGap: item.roofGap, roofGap: item.roofGap,
roofLayout: item.roofLayout, roofLayout: item.roofLayout,
roofPitch: item.roofPitch,
roofAngle: item.roofAngle,
} }
}) })
} else { } else {
@ -129,15 +126,12 @@ export function useRoofAllocationSetting(id) {
roofHajebichi: 0, roofHajebichi: 0,
roofGap: 'HEI_455', roofGap: 'HEI_455',
roofLayout: 'P', roofLayout: 'P',
roofPitch: 4,
roofAngle: 21.8,
}, },
] ]
} }
// 나머지 데이터와 함께 'roofs' 배열을 patternData에 넣음
const patternData = {
roofs: roofsArray, // 만들어진 roofs 배열
}
console.log('fetchBasicSettings roofsArray', roofsArray) console.log('fetchBasicSettings roofsArray', roofsArray)
// 데이터 설정 // 데이터 설정
@ -155,6 +149,8 @@ export function useRoofAllocationSetting(id) {
hajebichi: roofsArray[i].roofHajebichi, hajebichi: roofsArray[i].roofHajebichi,
raft: roofsArray[i].roofGap, raft: roofsArray[i].roofGap,
layout: roofsArray[i].roofLayout, layout: roofsArray[i].roofLayout,
pitch: roofsArray[i].roofPitch,
angle: roofsArray[i].roofAngle,
}) })
setCurrentRoofList(selectRoofs) setCurrentRoofList(selectRoofs)
} }
@ -167,28 +163,30 @@ export function useRoofAllocationSetting(id) {
} }
} }
// 저장 // 지붕면 할당 저장
const basicSettingSave = async () => { const basicSettingSave = async () => {
const patternData = { const patternData = {
objectNo: correntObjectNo, objectNo: correntObjectNo,
roofSizeSet: basicSetting.roofSizeSet, roofSizeSet: basicSetting.roofSizeSet,
roofAngleSet: basicSetting.roofAngleSet, roofAngleSet: basicSetting.roofAngleSet,
roofMaterialsAddList: currentRoofList.map((item) => ({ roofMaterialsAddList: currentRoofList.map((item, index) => ({
roofApply: item.selected === null || item.selected === undefined ? 'true' : item.selected, 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, roofMatlCd: item.roofMatlCd === null || item.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : item.roofMatlCd,
roofWidth: item.width === null || item.width === undefined ? 0 : item.width, roofWidth: item.width === null || item.width === undefined ? 0 : item.width,
roofHeight: item.length === null || item.length === undefined ? 0 : item.length, roofHeight: item.length === null || item.length === undefined ? 0 : item.length,
roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : item.hajebichi, roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : item.hajebichi,
roofGap: item.raft === null || item.raft === undefined ? 'HEI_455' : item.raft, roofGap: item.raft === null || item.raft === undefined ? 'HEI_455' : item.raft,
roofLayout: item.layout === null || item.layout === undefined ? 'P' : item.layout, 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) console.log('🚀 ~ basicSettingSave ~ patternData >>>>>>>>>>>>> :', patternData)
// HTTP POST 요청 보내기 // 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) => { .then((res) => {
swalFire({ text: getMessage(res.returnMessage) }) swalFire({ text: getMessage(res.returnMessage) })