지붕면할당 수정

This commit is contained in:
changkyu choi 2025-01-13 20:34:16 +09:00
parent aa153ecea0
commit 369e62615f
4 changed files with 62 additions and 53 deletions

View File

@ -45,13 +45,13 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
useEffect(() => { useEffect(() => {
const raftCodeList = findCommonCode('203800') const raftCodeList = findCommonCode('203800')
setRaftCodes(raftCodeList) setRaftCodes(raftCodeList)
setCurrentRoof({...currentRoof, roofSizeSet: basicSetting.roofMaterials.roofSizeSet, roofAngleSet: basicSetting.roofMaterials.roofAngleSet})
}, []) }, [])
useEffect(() => { useEffect(() => {
console.log('🚀 ~ useEffect ~ basicSetting:', currentRoof)
setBasicSettings({ setBasicSettings({
...basicSetting, ...basicSetting,
roofSizeSet: currentRoof.roofSizeSet, roofSizeSet: String(currentRoof.roofSizeSet),
roofAngleSet: currentRoof.roofAngleSet, roofAngleSet: currentRoof.roofAngleSet,
roofsData: { roofsData: {
roofApply: true, roofApply: true,
@ -62,6 +62,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,
roofPitch: currentRoof.pitch,
roofAngle: currentRoof.angle,
}, },
}) })
}, [currentRoof]) }, [currentRoof])
@ -77,8 +79,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
// 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)
console.log('🚀 ~ handleRoofTypeChange ~ selectedRoofMaterial:', selectedRoofMaterial) setCurrentRoof({...selectedRoofMaterial, index: 0, roofSizeSet: String(currentRoof.roofSizeSet), roofAngleSet: currentRoof.roofAngleSet})
setCurrentRoof({...selectedRoofMaterial, index: 0, roofSizeSet: currentRoof.roofSizeSet, roofAngleSet: currentRoof.roofAngleSet})
} }
const changeInput = (value, e) => { const changeInput = (value, e) => {
@ -139,6 +140,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
roofLayout: currentRoof.layout, roofLayout: currentRoof.layout,
roofSizeSet: currentRoof.roofSizeSet, roofSizeSet: currentRoof.roofSizeSet,
roofAngleSet: currentRoof.roofAngleSet, roofAngleSet: currentRoof.roofAngleSet,
roofPitch: currentRoof.pitch,
roofAngle: currentRoof.angle,
}, },
}) })
@ -183,7 +186,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
value="1" // roofSizeSet '1' value="1" // roofSizeSet '1'
checked={currentRoof.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)} 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>
@ -195,7 +198,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
value="2" // roofSizeSet '2' value="2" // roofSizeSet '2'
checked={currentRoof.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)} 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>
@ -207,7 +210,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
value="3" // roofSizeSet '3' value="3" // roofSizeSet '3'
checked={currentRoof.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)} 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>
@ -256,17 +259,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={currentRoof.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={currentRoof.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={currentRoof.roofSizeSet == 3} disabled={currentRoof.roofSizeSet === '3'}
/> />
{/* <select {/* <select
className="select-light dark" className="select-light dark"
@ -298,7 +301,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={currentRoof.roofSizeSet == 3} disabled={currentRoof.roofSizeSet === '3'}
/> />
</div> </div>
{/* <div className="input-grid" style={{ width: '63px' }}> {/* <div className="input-grid" style={{ width: '63px' }}>
@ -323,7 +326,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={currentRoof.roofSizeSet == 3} disabled={currentRoof.roofSizeSet === '3'}
/> />
</div> </div>
{/* <div className="input-grid" style={{ width: '63px' }}> {/* <div className="input-grid" style={{ width: '63px' }}>
@ -350,7 +353,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={currentRoof.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) => {
@ -377,7 +380,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={currentRoof.roofSizeSet == 3} disabled={currentRoof.roofSizeSet === '3'}
/> />
</div> </div>
</div> </div>

View File

@ -119,7 +119,7 @@ export default function RoofAllocationSetting(props) {
type="text" type="text"
className="input-origin block" className="input-origin block"
onChange={(e) => { onChange={(e) => {
handleChangeInput(e, 'pitch', index) handleChangeInput(e, currentAngleType === 'slope' ? 'pitch' : 'angle', index)
}} }}
defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle} defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle}
/> />

View File

@ -282,7 +282,7 @@ export function useCanvasSetting() {
if (res.length > 0) { if (res.length > 0) {
roofsRow = res.map((item) => { roofsRow = res.map((item) => {
return { return {
roofSizeSet: item.roofSizeSet, roofSizeSet: String(item.roofSizeSet),
roofAngleSet: item.roofAngleSet, roofAngleSet: item.roofAngleSet,
} }
}) })
@ -296,12 +296,14 @@ export function useCanvasSetting() {
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 {
roofsRow = [ roofsRow = [
{ {
roofSizeSet: 1, roofSizeSet: '1',
roofAngleSet: 'slope', roofAngleSet: 'slope',
}, },
] ]
@ -316,6 +318,7 @@ export function useCanvasSetting() {
roofHajebichi: 0, roofHajebichi: 0,
roofGap: 'HEI_455', roofGap: 'HEI_455',
roofLayout: 'P', roofLayout: 'P',
roofPitch: 4,
}, },
] ]
} }
@ -333,6 +336,8 @@ export function useCanvasSetting() {
, layout: roofsArray[0].roofLayout , layout: roofsArray[0].roofLayout
, roofSizeSet: roofsRow[0].roofSizeSet , roofSizeSet: roofsRow[0].roofSizeSet
, roofAngleSet: roofsRow[0].roofAngleSet , roofAngleSet: roofsRow[0].roofAngleSet
, pitch: roofsArray[0].roofPitch
, angle: roofsArray[0].roofAngle
}) })
setAddedRoofs(addRoofs) setAddedRoofs(addRoofs)
@ -359,7 +364,7 @@ export function useCanvasSetting() {
try { try {
const patternData = { const patternData = {
objectNo: correntObjectNo, objectNo: correntObjectNo,
roofSizeSet: basicSetting.roofSizeSet, roofSizeSet: Number(basicSetting.roofSizeSet),
roofAngleSet: basicSetting.roofAngleSet, roofAngleSet: basicSetting.roofAngleSet,
roofMaterialsAddList: [ roofMaterialsAddList: [
{ {
@ -371,8 +376,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, roofPitch: basicSetting.roofsData.roofPitch === null || basicSetting.roofsData.roofPitch === undefined ? 0 : basicSetting.roofsData.roofPitch,
roofAngle: 21.8, roofAngle: basicSetting.roofsData.roofAngle === null || basicSetting.roofsData.roofAngle === undefined ? 0 : basicSetting.roofsData.roofAngle,
}, },
], ],
} }
@ -380,11 +385,12 @@ export function useCanvasSetting() {
console.log('basicSettingSave patternData ', patternData) console.log('basicSettingSave patternData ', patternData)
await post({ url: `/api/canvas-management/canvas-basic-settings`, data: patternData }).then((res) => { await post({ url: `/api/canvas-management/canvas-basic-settings`, data: patternData }).then((res) => {
console.log('basicSettingSave res ', res)
swalFire({ text: getMessage(res.returnMessage) }) swalFire({ text: getMessage(res.returnMessage) })
}) })
//Recoil 설정 //Recoil 설정
setCanvasSetting({ ...basicSetting }) //setCanvasSetting({ ...basicSetting })
fetchBasicSettings() fetchBasicSettings()
} catch (error) { } catch (error) {
swalFire({ text: error.message, icon: 'error' }) swalFire({ text: error.message, icon: 'error' })

View File

@ -33,9 +33,7 @@ export function useRoofAllocationSetting(id) {
const { drawDirectionArrow, addLengthText, splitPolygonWithLines, splitPolygonWithSeparate } = usePolygon() const { drawDirectionArrow, addLengthText, splitPolygonWithLines, splitPolygonWithSeparate } = usePolygon()
const [popupId, setPopupId] = useState(uuidv4()) const [popupId, setPopupId] = useState(uuidv4())
const { addPopup, closePopup, closeAll } = usePopup() const { addPopup, closePopup, closeAll } = usePopup()
const { getMessage } = useMessage() const currentObject = useRecoilValue(currentObjectState)
const currentObject = useRecoilValue(currentObjectState)
const { swalFire } = useSwal()
const { setMenuNumber } = useCanvasMenu() const { setMenuNumber } = useCanvasMenu()
const setMenuType = useSetRecoilState(menuTypeState) const setMenuType = useSetRecoilState(menuTypeState)
const roofMaterials = useRecoilValue(roofMaterialsSelector) const roofMaterials = useRecoilValue(roofMaterialsSelector)
@ -46,9 +44,10 @@ export function useRoofAllocationSetting(id) {
const [editingLines, setEditingLines] = useState([]) const [editingLines, setEditingLines] = useState([])
const [currentRoofList, setCurrentRoofList] = useState(roofList) const [currentRoofList, setCurrentRoofList] = useState(roofList)
const currentAngleType = useRecoilValue(currentAngleTypeSelector) const currentAngleType = useRecoilValue(currentAngleTypeSelector)
const globalLocaleState = useRecoilValue(globalLocaleStore) const globalLocaleState = useRecoilValue(globalLocaleStore)
const { get, post } = useAxios(globalLocaleState) const { get, post } = useAxios(globalLocaleState)
const { getMessage } = useMessage()
const { swalFire } = useSwal()
const { setSurfaceShapePattern } = useRoofFn() const { setSurfaceShapePattern } = useRoofFn()
@ -165,38 +164,38 @@ export function useRoofAllocationSetting(id) {
// 지붕면 할당 저장 // 지붕면 할당 저장
const basicSettingSave = async () => { const basicSettingSave = async () => {
const patternData = { try {
objectNo: correntObjectNo, const patternData = {
roofSizeSet: basicSetting.roofSizeSet, objectNo: correntObjectNo,
roofAngleSet: basicSetting.roofAngleSet, roofSizeSet: Number(basicSetting.roofSizeSet),
roofMaterialsAddList: currentRoofList.map((item, index) => ({ roofAngleSet: basicSetting.roofAngleSet,
roofApply: item.selected === null || item.selected === undefined ? 'true' : item.selected, roofAllocationList: currentRoofList.map((item, index) => ({
roofSeq: index, roofApply: item.selected === null || item.selected === undefined ? 'true' : item.selected,
roofMatlCd: item.roofMatlCd === null || item.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : item.roofMatlCd, roofSeq: index,
roofWidth: item.width === null || item.width === undefined ? 0 : item.width, roofMatlCd: item.roofMatlCd === null || item.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : item.roofMatlCd,
roofHeight: item.length === null || item.length === undefined ? 0 : item.length, roofWidth: item.width === null || item.width === undefined ? 0 : Number(item.width),
roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : item.hajebichi, roofHeight: item.length === null || item.length === undefined ? 0 : Number(item.length),
roofGap: item.raft === null || item.raft === undefined ? 'HEI_455' : item.raft, roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : Number(item.hajebichi),
roofLayout: item.layout === null || item.layout === undefined ? 'P' : item.layout, roofGap: item.raft === null || item.raft === undefined ? 'HEI_455' : item.raft,
roofPitch: item.pitch === null || item.pitch === undefined ? 4 : item.pitch, roofLayout: item.layout === null || item.layout === undefined ? 'P' : item.layout,
roofAngle: item.angle === null || item.angle === undefined ? 21.8 : item.angle, roofPitch: item.pitch === null || item.pitch === undefined ? 4 : Number(item.pitch),
})), roofAngle: item.angle === null || item.angle === undefined ? 21.8 : Number(item.angle),
} })),
}
console.log('🚀 ~ basicSettingSave ~ patternData >>>>>>>>>>>>> :', patternData) console.log('🚀 ~ basicSettingSave ~ patternData >>>>>>>>>>>>> :', patternData)
// HTTP POST 요청 보내기 await post({ url: `/api/canvas-management/roof-allocation-settings`, data: patternData }).then((res) => {
await post({ url: `/api/canvas-management/roof-allocation-settings`, data: patternData }) console.log('roof-allocation-settings res ', res)
.then((res) => { swalFire({ text: getMessage(res.returnMessage) })
swalFire({ text: getMessage(res.returnMessage) }) })
//Recoil 설정 //Recoil 설정
// setCanvasSetting({ ...basicSetting }) //setCanvasSetting({ ...basicSetting })
fetchBasicSettings() fetchBasicSettings()
}) } catch (error) {
.catch((error) => { swalFire({ text: error.message, icon: 'error' })
swalFire({ text: error.message, icon: 'error' }) }
})
} }
const onAddRoofMaterial = () => { const onAddRoofMaterial = () => {
@ -457,6 +456,7 @@ export function useRoofAllocationSetting(id) {
return return
} }
const newRoofList = currentRoofList.map((roof, idx) => { const newRoofList = currentRoofList.map((roof, idx) => {
if (idx === index) { if (idx === index) {
return { ...roof, [type]: value } return { ...roof, [type]: value }