지붕면 할당 작업중

This commit is contained in:
hyojun.choi 2024-12-30 10:46:51 +09:00
parent ebe0608f76
commit 96ec93412d
5 changed files with 107 additions and 102 deletions

View File

@ -51,8 +51,8 @@ export default function CanvasMenu(props) {
const canvasMenus = useRecoilValue(menusState) const canvasMenus = useRecoilValue(menusState)
const [type, setType] = useRecoilState(menuTypeState) const [type, setType] = useRecoilState(menuTypeState)
const [verticalHorizontalMode, setVerticalHorizontalMode] = useRecoilState(verticalHorizontalModeState) const [verticalHorizontalMode, setVerticalHorizontalMode] = useRecoilState(verticalHorizontalModeState)
const [setAppMessageState] = useRecoilState(appMessageStore) const setAppMessageState = useSetRecoilState(appMessageStore)
const [setCurrentMenu] = useRecoilState(currentMenuState) const setCurrentMenu = useSetRecoilState(currentMenuState)
const setOuterLinePoints = useSetRecoilState(outerLinePointsState) const setOuterLinePoints = useSetRecoilState(outerLinePointsState)
const setPlacementPoints = useSetRecoilState(placementShapeDrawingPointsState) const setPlacementPoints = useSetRecoilState(placementShapeDrawingPointsState)
const canvasSetting = useRecoilValue(canvasSettingState) const canvasSetting = useRecoilValue(canvasSettingState)
@ -116,13 +116,6 @@ export default function CanvasMenu(props) {
if (pathname !== '/floor-plan') router.push('/floor-plan') if (pathname !== '/floor-plan') router.push('/floor-plan')
} }
useEffect(() => {
console.log('addedRoofs', addedRoofs)
}, [addedRoofs])
useEffect(() => {
console.log('selectedRoofMaterial', selectedRoofMaterial)
}, [selectedRoofMaterial])
const changeSelectedRoofMaterial = (e) => { const changeSelectedRoofMaterial = (e) => {
setBasicSetting({ ...basicSetting, selectedRoofMaterial: e }) setBasicSetting({ ...basicSetting, selectedRoofMaterial: e })
} }

View File

@ -28,6 +28,7 @@ export default function ContextRoofAllocationSetting(props) {
handleChangeRaft, handleChangeRaft,
handleChangeLayout, handleChangeLayout,
handleSaveContext, handleSaveContext,
currentRoofList,
} = useRoofAllocationSetting(id) } = useRoofAllocationSetting(id)
const { findCommonCode } = useCommonCode() const { findCommonCode } = useCommonCode()
@ -39,7 +40,7 @@ export default function ContextRoofAllocationSetting(props) {
return ( return (
<WithDraggable isShow={true} pos={pos}> <WithDraggable isShow={true} pos={pos}>
<div className={`modal-pop-wrap ml mount`}> <div className={`modal-pop-wrap lr mount`}>
<div className="modal-head"> <div className="modal-head">
<h1 className="title">{getMessage('plan.menu.estimate.roof.alloc')}</h1> <h1 className="title">{getMessage('plan.menu.estimate.roof.alloc')}</h1>
<button className="modal-close" onClick={() => closePopup(id)}> <button className="modal-close" onClick={() => closePopup(id)}>
@ -53,10 +54,14 @@ export default function ContextRoofAllocationSetting(props) {
<div className="grid-select"> <div className="grid-select">
<QSelectBox <QSelectBox
options={roofMaterials} options={roofMaterials}
value={roofMaterials[0]}
onChange={(e) => { onChange={(e) => {
const selected = roofMaterials.find((roofMaterial) => roofMaterial.roofMatlCd === e.id) // const selected = roofMaterials.find((roofMaterial) => roofMaterial.roofMatlCd === e.id)
setCurrentRoofMaterial(selected) setCurrentRoofMaterial(e)
}} }}
showKey={'roofMatlNm'}
sourceKey={'roofMatlCd'}
targetKey={'roofMatlCd'}
/> />
</div> </div>
<button <button
@ -70,7 +75,7 @@ export default function ContextRoofAllocationSetting(props) {
</button> </button>
</div> </div>
<div className="grid-option-wrap"> <div className="grid-option-wrap">
{roofList.map((roof, index) => { {currentRoofList.map((roof, index) => {
return ( return (
<div className="grid-option-box" key={index}> <div className="grid-option-box" key={index}>
<div className="d-check-radio pop no-text"> <div className="d-check-radio pop no-text">
@ -88,78 +93,74 @@ export default function ContextRoofAllocationSetting(props) {
<div className="grid-select" style={{ width: '248px' }}> <div className="grid-select" style={{ width: '248px' }}>
<QSelectBox <QSelectBox
options={roofMaterials} options={roofMaterials}
value={roofMaterials.find((r) => r.id === roof.id)} value={roof}
showKey={'roofMatlNm'}
sourceKey={'roofMatlCd'}
targetKey={'roofMatlCd'}
onChange={(e) => handleChangeRoofMaterial(e, index)} onChange={(e) => handleChangeRoofMaterial(e, index)}
/> />
</div> </div>
{index === 0 && <span className="dec">基本屋根材</span>} {index === 0 && <span className="dec">{getMessage('modal.roof.alloc.default.roof.material')}</span>}
{index !== 0 && <button className="delete" onClick={() => onDeleteRoofMaterial(index)}></button>} {index !== 0 && <button className="delete" onClick={() => onDeleteRoofMaterial(index)}></button>}
</div> </div>
</div> </div>
<div className="block-box"> {(roof.widAuth || roof.lenAuth) && (
{roof.widAuth && ( <div className="block-box">
<div className="flex-ment"> {roof.widAuth && (
<span>W</span> <div className="flex-ment">
<div className="input-grid" style={{ width: '100px' }}> <span>W</span>
<input type="text" className="input-origin block" defaultValue={roof.width} readOnly /> <div className="input-grid" style={{ width: '100px' }}>
<input type="text" className="input-origin block" defaultValue={roof.width} readOnly={roof.widAuth === 'R'} />
</div>
</div> </div>
{/* <div className="select-wrap" style={{ width: '84px' }}> )}
<select className="select-light dark" name="" id=""> {roof.lenAuth && (
<option>265</option> <div className="flex-ment">
</select> <span>L</span>
</div> */} <div className="input-grid" style={{ width: '100px' }}>
</div> <input type="text" className="input-origin block" defaultValue={roof.length} readOnly={roof.lenAuth === 'R'} />
)} </div>
{roof.lenAuth && (
<div className="flex-ment">
<span>L</span>
<div className="input-grid" style={{ width: '100px' }}>
<input type="text" className="input-origin block" defaultValue={roof.length} readOnly />
</div> </div>
{/* <div className="select-wrap" style={{ width: '84px' }}> )}
<select className="select-light dark" name="" id=""> </div>
<option>235</option> )}
</select> {(roof.raftAuth || roof.roofPchAuth) && (
</div> */} <div className="block-box">
</div> {roof.raftAuth && (
)} <div className="block-box">
{roof.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 && (
<div className="grid-select" style={{ width: '84px' }}> <div className="grid-select" style={{ width: '160px' }}>
{raftCodes.length > 0 && ( <QSelectBox
<QSelectBox options={raftCodes}
options={raftCodes.map((raft) => ({ name: raft.clCodeNm, value: raft.clCode }))} value={roof}
onChange={(e) => handleChangeRaft(e, index)} showKey={'clCodeNm'}
value={raftCodes.find((r) => r.value === roof.raft)} sourceKey={'clCode'}
/> targetKey={roof.raft ? 'raft' : 'raftBaseCd'}
)} />
{/* <select className="select-light dark" name="roofGap" ref={roofRef.rafter}> </div>
{raftCodes.map((raft, index) => { )}
return ( </div>
<option key={index} value={raft.clCode}>
{raft.clCodeNm}
</option>
)
})}
</select> */}
</div> </div>
</div> )}
)} {roof.roofPchAuth && (
{roof.roofPchAuth && ( <div className="block-box">
<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' }}>
<input type="text" className="input-origin block" value={parseInt(roof.hajebichi)} readOnly={roof.roofPchAuth === 'R'} /> <input
type="text"
className="input-origin block"
value={parseInt(roof.hajebichi)}
readOnly={roof.roofPchAuth === 'R'}
/>
</div>
</div>
</div> </div>
{/* <div className="grid-select no-flx" style={{ width: '84px' }}> )}
<select className="select-light dark" name="" id=""> </div>
<option>265</option> )}
</select>
</div> */}
</div>
)}
</div>
<div className="block-box"> <div className="block-box">
<div className="icon-btn-wrap"> <div className="icon-btn-wrap">
<button <button

View File

@ -27,6 +27,7 @@ export default function RoofAllocationSetting(props) {
handleChangeRoofMaterial, handleChangeRoofMaterial,
handleChangeRaft, handleChangeRaft,
handleChangeLayout, handleChangeLayout,
currentRoofList,
} = useRoofAllocationSetting(id) } = useRoofAllocationSetting(id)
const { findCommonCode } = useCommonCode() const { findCommonCode } = useCommonCode()
const [raftCodes, setRaftCodes] = useState([]) const [raftCodes, setRaftCodes] = useState([])
@ -73,7 +74,7 @@ export default function RoofAllocationSetting(props) {
</button> </button>
</div> </div>
<div className="grid-option-wrap"> <div className="grid-option-wrap">
{roofList.map((roof, index) => { {currentRoofList.map((roof, index) => {
return ( return (
<div className="grid-option-box" key={index}> <div className="grid-option-box" key={index}>
<div className="d-check-radio pop no-text"> <div className="d-check-radio pop no-text">

View File

@ -13,6 +13,7 @@ import useMenu from '@/hooks/common/useMenu'
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu' import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
import { menuTypeState } from '@/store/menuAtom' import { menuTypeState } from '@/store/menuAtom'
import { useRoofFn } from '@/hooks/common/useRoofFn' import { useRoofFn } from '@/hooks/common/useRoofFn'
import { ROOF_MATERIAL_LAYOUT } from '@/components/floor-plan/modal/placementShape/PlacementShapeSetting'
// 지붕면 할당 // 지붕면 할당
export function useRoofAllocationSetting(id) { export function useRoofAllocationSetting(id) {
@ -32,7 +33,7 @@ export function useRoofAllocationSetting(id) {
const [currentRoofMaterial, setCurrentRoofMaterial] = useState(roofMaterials[0]) // 팝업 내 기준 지붕재 const [currentRoofMaterial, setCurrentRoofMaterial] = useState(roofMaterials[0]) // 팝업 내 기준 지붕재
const [roofList, setRoofList] = useRecoilState(addedRoofsState) // 배치면 초기설정에서 선택한 지붕재 배열 const [roofList, setRoofList] = useRecoilState(addedRoofsState) // 배치면 초기설정에서 선택한 지붕재 배열
const [editingLines, setEditingLines] = useState([]) const [editingLines, setEditingLines] = useState([])
const isFirstRef = useRef(0) const [currentRoofList, setCurrentRoofList] = useState(roofList)
const { setSurfaceShapePattern } = useRoofFn() const { setSurfaceShapePattern } = useRoofFn()
@ -76,20 +77,25 @@ export function useRoofAllocationSetting(id) {
}, []) }, [])
const onAddRoofMaterial = () => { const onAddRoofMaterial = () => {
if (roofList.length >= 4) { if (currentRoofList.length >= 4) {
swalFire({ type: 'alert', icon: 'error', text: getMessage('지붕재는 4개까지 선택 가능합니다.') }) swalFire({ type: 'alert', icon: 'error', text: getMessage('지붕재는 4개까지 선택 가능합니다.') })
return return
} }
setRoofList([...roofList, { ...currentRoofMaterial, selected: false, id: currentRoofMaterial.roofMatlCd, name: currentRoofMaterial.roofMatlNm }]) setCurrentRoofList([
...currentRoofList,
{ ...currentRoofMaterial, selected: false, id: currentRoofMaterial.roofMatlCd, name: currentRoofMaterial.roofMatlNm },
])
} }
const onDeleteRoofMaterial = (idx) => { const onDeleteRoofMaterial = (idx) => {
setRoofList([...roofList.filter((_, index) => index !== idx)]) const isSelected = currentRoofList[idx].selected
const newRoofList = [...currentRoofList].filter((_, index) => index !== idx)
if (isSelected) {
newRoofList[0].selected = true
}
setCurrentRoofList(newRoofList)
} }
const { handleMenu } = useMenu()
const [currentMenu, setCurrentMenu] = useRecoilState(currentMenuState)
// 선택한 지붕재로 할당 // 선택한 지붕재로 할당
const handleSave = () => { const handleSave = () => {
// 모두 actualSize 있으면 바로 적용 없으면 actualSize 설정 // 모두 actualSize 있으면 바로 적용 없으면 actualSize 설정
@ -102,7 +108,7 @@ export function useRoofAllocationSetting(id) {
// 지붕재 오른쪽 마우스 클릭 후 단일로 지붕재 변경 필요한 경우 // 지붕재 오른쪽 마우스 클릭 후 단일로 지붕재 변경 필요한 경우
const handleSaveContext = () => { const handleSaveContext = () => {
const selectedRoofMaterial = roofList.find((roof) => roof.selected) const selectedRoofMaterial = currentRoofList.find((roof) => roof.selected)
setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial) setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial)
closeAll() closeAll()
} }
@ -169,11 +175,11 @@ export function useRoofAllocationSetting(id) {
setBasicSetting((prev) => { setBasicSetting((prev) => {
return { return {
...prev, ...prev,
selectedRoofMaterial: roofList.find((roof) => roof.selected), selectedRoofMaterial: currentRoofList.find((roof) => roof.selected),
} }
}) })
setRoofList(roofList) setRoofList(currentRoofList)
const roofs = canvas.getObjects().filter((obj) => obj.name === 'roof') const roofs = canvas.getObjects().filter((obj) => obj.name === 'roof')
@ -182,7 +188,12 @@ export function useRoofAllocationSetting(id) {
roof.set({ roof.set({
isFixed: true, isFixed: true,
}) })
setSurfaceShapePattern(roof, roofDisplay.column) setSurfaceShapePattern(
roof,
roofDisplay.column,
false,
currentRoofList.find((roof) => roof.selected),
)
drawDirectionArrow(roof) drawDirectionArrow(roof)
}) })
@ -216,54 +227,53 @@ export function useRoofAllocationSetting(id) {
// 지붕재 변경 // 지붕재 변경
const handleChangeRoofMaterial = (value, index) => { const handleChangeRoofMaterial = (value, index) => {
if (isFirstRef.current === 0) { const selectedIndex = roofMaterials.findIndex((roof) => roof.selected)
isFirstRef.current++
return
}
const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value.id) const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value.id)
const newRoofList = roofList.map((roof, idx) => { const newRoofList = currentRoofList.map((roof, idx) => {
if (idx === index) { if (idx === index) {
return { ...selectedRoofMaterial } return { ...selectedRoofMaterial }
} }
return roof return roof
}) })
setRoofList(newRoofList) newRoofList[selectedIndex].selected = true
setCurrentRoofList(newRoofList)
} }
// 기본 지붕재 radio값 변경 // 기본 지붕재 radio값 변경
const handleDefaultRoofMaterial = (index) => { const handleDefaultRoofMaterial = (index) => {
const newRoofList = roofList.map((roof, idx) => { const newRoofList = currentRoofList.map((roof, idx) => {
return { ...roof, selected: idx === index } return { ...roof, selected: idx === index }
}) })
setRoofList(newRoofList) setCurrentRoofList(newRoofList)
} }
// 서까래 변경 // 서까래 변경
const handleChangeRaft = (e, index) => { const handleChangeRaft = (e, index) => {
const raftValue = e.value const raftValue = e.value
const newRoofList = roofList.map((roof, idx) => { const newRoofList = currentRoofList.map((roof, idx) => {
if (idx === index) { if (idx === index) {
return { ...roof, raft: raftValue } return { ...roof, raft: raftValue }
} }
return roof return roof
}) })
setRoofList(newRoofList) setCurrentRoofList(newRoofList)
} }
const handleChangeLayout = (layoutValue, index) => { const handleChangeLayout = (layoutValue, index) => {
const newRoofList = roofList.map((roof, idx) => { const newRoofList = currentRoofList.map((roof, idx) => {
if (idx === index) { if (idx === index) {
return { ...roof, layout: layoutValue } return { ...roof, layout: layoutValue }
} }
return roof return roof
}) })
setRoofList(newRoofList) setCurrentRoofList(newRoofList)
} }
return { return {
@ -278,11 +288,11 @@ export function useRoofAllocationSetting(id) {
setBasicSetting, setBasicSetting,
currentRoofMaterial, currentRoofMaterial,
setCurrentRoofMaterial, setCurrentRoofMaterial,
roofList,
handleDefaultRoofMaterial, handleDefaultRoofMaterial,
handleChangeRoofMaterial, handleChangeRoofMaterial,
handleChangeRaft, handleChangeRaft,
handleChangeLayout, handleChangeLayout,
handleSaveContext, handleSaveContext,
currentRoofList,
} }
} }

View File

@ -224,9 +224,9 @@ export const roofMaterialsAtom = atom({
export const selectedRoofMaterialSelector = selector({ export const selectedRoofMaterialSelector = selector({
key: 'selectedRoofMaterialSelector', key: 'selectedRoofMaterialSelector',
get: ({ get }) => { get: ({ get }) => {
const basicSetting = get(basicSettingState) const addedRoofs = get(addedRoofsState)
return { ...basicSetting.selectedRoofMaterial } return addedRoofs.find((roof) => roof.selected)
}, },
}) })