This commit is contained in:
김민식 2024-12-30 10:58:51 +09:00
commit 15b4d8f74e
13 changed files with 150 additions and 164 deletions

1
.gitignore vendored
View File

@ -41,4 +41,5 @@ next-env.d.ts
#lock files #lock files
yarn.lock yarn.lock
package-lock.json package-lock.json
pnpm-lock.yaml
certificates certificates

View File

@ -1,6 +1,6 @@
'use client' 'use client'
import { createContext, useEffect, useState } from 'react' import { createContext, useState } from 'react'
import { ErrorBoundary } from 'next/dist/client/components/error-boundary' import { ErrorBoundary } from 'next/dist/client/components/error-boundary'
import { useCommonCode } from '@/hooks/common/useCommonCode' import { useCommonCode } from '@/hooks/common/useCommonCode'
import ServerError from './error' import ServerError from './error'

View File

@ -1,32 +1,28 @@
'use client' 'use client'
import { useContext, useEffect, useRef } from 'react' import { useEffect, useRef } from 'react'
import { useRecoilValue } from 'recoil' import { useRecoilValue } from 'recoil'
import QContextMenu from '@/components/common/context-menu/QContextMenu'
import PanelBatchStatistics from '@/components/floor-plan/modal/panelBatch/PanelBatchStatistics'
import ImgLoad from '@/components/floor-plan/modal/ImgLoad'
import { useCanvas } from '@/hooks/useCanvas' import { useCanvas } from '@/hooks/useCanvas'
import { useEvent } from '@/hooks/useEvent'
import { usePlan } from '@/hooks/usePlan' import { usePlan } from '@/hooks/usePlan'
import { useContextMenu } from '@/hooks/useContextMenu' import { useContextMenu } from '@/hooks/useContextMenu'
import { currentMenuState } from '@/store/canvasAtom'
import QContextMenu from '@/components/common/context-menu/QContextMenu'
import { useCanvasConfigInitialize } from '@/hooks/common/useCanvasConfigInitialize' import { useCanvasConfigInitialize } from '@/hooks/common/useCanvasConfigInitialize'
import { MENU } from '@/common/common' import { currentMenuState } from '@/store/canvasAtom'
import PanelBatchStatistics from '@/components/floor-plan/modal/panelBatch/PanelBatchStatistics'
import { totalDisplaySelector } from '@/store/settingAtom' import { totalDisplaySelector } from '@/store/settingAtom'
import ImgLoad from '@/components/floor-plan/modal/ImgLoad' import { MENU } from '@/common/common'
export default function CanvasFrame() { export default function CanvasFrame() {
const canvasRef = useRef(null) const canvasRef = useRef(null)
const { canvas, handleBackImageLoadToCanvas } = useCanvas('canvas') const { canvas } = useCanvas('canvas')
const { canvasLoadInit, gridInit } = useCanvasConfigInitialize() const { canvasLoadInit, gridInit } = useCanvasConfigInitialize()
const currentMenu = useRecoilValue(currentMenuState) const currentMenu = useRecoilValue(currentMenuState)
const { contextMenu, handleClick } = useContextMenu() const { contextMenu, handleClick } = useContextMenu()
const { selectedPlan, currentCanvasPlan } = usePlan() const { selectedPlan } = usePlan()
const totalDisplay = useRecoilValue(totalDisplaySelector) // const totalDisplay = useRecoilValue(totalDisplaySelector) //
// useEvent()
// const { initEvent } = useContext(EventContext)
// initEvent()
const loadCanvas = () => { const loadCanvas = () => {
if (canvas) { if (canvas) {

View File

@ -3,12 +3,12 @@
import { useContext, useEffect } from 'react' import { useContext, useEffect } from 'react'
import { useRecoilValue } from 'recoil' import { useRecoilValue } from 'recoil'
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider' import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
import { SessionContext } from '@/app/SessionProvider'
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { useSwal } from '@/hooks/useSwal' import { useSwal } from '@/hooks/useSwal'
import { usePlan } from '@/hooks/usePlan' import { usePlan } from '@/hooks/usePlan'
import { globalLocaleStore } from '@/store/localeAtom'
import { SessionContext } from '@/app/SessionProvider'
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu' import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
import { globalLocaleStore } from '@/store/localeAtom'
export default function CanvasLayout({ children }) { export default function CanvasLayout({ children }) {
// const { menuNumber } = props // const { menuNumber } = props

View File

@ -2,54 +2,47 @@
import { useContext, useEffect, useState } from 'react' import { useContext, useEffect, useState } from 'react'
import { usePathname, useRouter } from 'next/navigation'
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil' import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import { usePathname, useRouter } from 'next/navigation' import { v4 as uuidv4 } from 'uuid'
import MenuDepth01 from './MenuDepth01' import MenuDepth01 from './MenuDepth01'
import QSelectBox from '@/components/common/select/QSelectBox' import QSelectBox from '@/components/common/select/QSelectBox'
import { v4 as uuidv4 } from 'uuid' import SettingModal01 from '@/components/floor-plan/modal/setting01/SettingModal01'
import PlacementShapeSetting from '@/components/floor-plan/modal/placementShape/PlacementShapeSetting'
import EstimateCopyPop from '../estimate/popup/EstimateCopyPop'
import DocDownOptionPop from '../estimate/popup/DocDownOptionPop'
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { usePlan } from '@/hooks/usePlan' import { usePlan } from '@/hooks/usePlan'
import { useSwal } from '@/hooks/useSwal' import { useSwal } from '@/hooks/useSwal'
import { useEvent } from '@/hooks/useEvent' import { useEvent } from '@/hooks/useEvent'
import { usePopup } from '@/hooks/usePopup'
import { useCanvasEvent } from '@/hooks/useCanvasEvent'
import { useCommonUtils } from '@/hooks/common/useCommonUtils'
import useMenu from '@/hooks/common/useMenu'
import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController'
import { useAxios } from '@/hooks/useAxios'
import { useModuleBasicSetting } from '@/hooks/module/useModuleBasicSetting'
import { canvasSettingState, canvasState, canvasZoomState, currentMenuState, verticalHorizontalModeState } from '@/store/canvasAtom' import { canvasSettingState, canvasState, canvasZoomState, currentMenuState, verticalHorizontalModeState } from '@/store/canvasAtom'
import { sessionStore } from '@/store/commonAtom' import { sessionStore } from '@/store/commonAtom'
import { outerLinePointsState } from '@/store/outerLineAtom' import { outerLinePointsState } from '@/store/outerLineAtom'
import { appMessageStore, globalLocaleStore } from '@/store/localeAtom' import { appMessageStore, globalLocaleStore } from '@/store/localeAtom'
import { import { addedRoofsState, basicSettingState, selectedRoofMaterialSelector, settingModalFirstOptionsState } from '@/store/settingAtom'
addedRoofsSelector, import { placementShapeDrawingPointsState } from '@/store/placementShapeDrawingAtom'
addedRoofsState, import { commonUtilsState } from '@/store/commonUtilsAtom'
basicSettingState, import { menusState, menuTypeState } from '@/store/menuAtom'
roofMaterialsSelector, import { estimateState, floorPlanObjectState } from '@/store/floorPlanObjectAtom'
selectedRoofMaterialSelector, import { pwrGnrSimTypeState } from '@/store/simulatorAtom'
settingModalFirstOptionsState, import { isObjectNotEmpty } from '@/util/common-utils'
} from '@/store/settingAtom'
import KO from '@/locales/ko.json' import KO from '@/locales/ko.json'
import JA from '@/locales/ja.json' import JA from '@/locales/ja.json'
import { useCanvasEvent } from '@/hooks/useCanvasEvent'
import SettingModal01 from '@/components/floor-plan/modal/setting01/SettingModal01'
import { usePopup } from '@/hooks/usePopup'
import { placementShapeDrawingPointsState } from '@/store/placementShapeDrawingAtom'
import PlacementShapeSetting from '@/components/floor-plan/modal/placementShape/PlacementShapeSetting'
import { useCommonUtils } from '@/hooks/common/useCommonUtils'
import { commonUtilsState } from '@/store/commonUtilsAtom'
import { menusState, menuTypeState } from '@/store/menuAtom'
import useMenu from '@/hooks/common/useMenu'
import { MENU } from '@/common/common' import { MENU } from '@/common/common'
import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController'
import { estimateState, floorPlanObjectState } from '@/store/floorPlanObjectAtom'
import DocDownOptionPop from '../estimate/popup/DocDownOptionPop'
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
import EstimateCopyPop from '../estimate/popup/EstimateCopyPop'
import { pwrGnrSimTypeState } from '@/store/simulatorAtom'
import { useAxios } from '@/hooks/useAxios'
import { useModuleBasicSetting } from '@/hooks/module/useModuleBasicSetting'
import { isObjectNotEmpty } from '@/util/common-utils'
export default function CanvasMenu(props) { export default function CanvasMenu(props) {
const { menuNumber, setMenuNumber } = props const { menuNumber, setMenuNumber } = props
const pathname = usePathname() const pathname = usePathname()
@ -58,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 [appMessageState, setAppMessageState] = useRecoilState(appMessageStore) const setAppMessageState = useSetRecoilState(appMessageStore)
const [currentMenu, 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)
@ -123,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

@ -1,6 +1,6 @@
'use client' 'use client'
import { useContext, useEffect } from 'react' import { useEffect } from 'react'
//import { useRecoilState } from 'recoil' //import { useRecoilState } from 'recoil'
import CanvasMenu from '@/components/floor-plan/CanvasMenu' import CanvasMenu from '@/components/floor-plan/CanvasMenu'
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu' import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'

View File

@ -1,11 +1,12 @@
'use client' 'use client'
import { useEffect } from 'react'
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import useMenu from '@/hooks/common/useMenu'
import { canvasState, currentMenuState } from '@/store/canvasAtom' import { canvasState, currentMenuState } from '@/store/canvasAtom'
import { useRecoilState, useRecoilValue } from 'recoil' import { useRecoilState, useRecoilValue } from 'recoil'
import { menuTypeState, subMenusState } from '@/store/menuAtom' import { menuTypeState, subMenusState } from '@/store/menuAtom'
import useMenu from '@/hooks/common/useMenu'
import { useEffect } from 'react'
export default function MenuDepth01() { export default function MenuDepth01() {
const type = useRecoilValue(menuTypeState) const type = useRecoilValue(menuTypeState)

View File

@ -1,11 +1,12 @@
'use client' 'use client'
import { useMessage } from '@/hooks/useMessage'
import { useRecoilState, useSetRecoilState } from 'recoil' import { useRecoilState, useSetRecoilState } from 'recoil'
import { currentMenuState } from '@/store/canvasAtom'
import { MENU } from '@/common/common' import { MENU } from '@/common/common'
import { modalState } from '@/store/modalAtom'
import { ToggleonMouse } from '@/components/header/Header' import { ToggleonMouse } from '@/components/header/Header'
import { useMessage } from '@/hooks/useMessage'
import { currentMenuState } from '@/store/canvasAtom'
import { modalState } from '@/store/modalAtom'
export default function RoofCoveringMenu() { export default function RoofCoveringMenu() {
const { getMessage } = useMessage() const { getMessage } = useMessage()

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

@ -269,17 +269,6 @@ export function useCanvasSetting() {
roofSizeSet: item.roofSizeSet, roofSizeSet: item.roofSizeSet,
roofAngleSet: item.roofAngleSet, roofAngleSet: item.roofAngleSet,
} }
roofsArray = {
roofApply: true,
roofSeq: 1,
roofMatlCd: 'ROOF_ID_WA_53A',
roofWidth: 265,
roofHeight: 235,
roofHajebichi: 0,
roofGap: 'HEI_455',
roofLayout: 'P',
}
}) })
} else { } else {
roofsRow = [ roofsRow = [

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)
}, },
}) })