저장 시 db도 update 필요
This commit is contained in:
parent
2a6f82c6ec
commit
465ed72a4c
@ -11,7 +11,9 @@ import { useSwal } from '@/hooks/useSwal'
|
|||||||
import { usePopup } from '@/hooks/usePopup'
|
import { usePopup } from '@/hooks/usePopup'
|
||||||
import { getChonByDegree, getDegreeByChon } from '@/util/canvas-util'
|
import { getChonByDegree, getDegreeByChon } from '@/util/canvas-util'
|
||||||
import RoofAllocationSetting from '@/components/floor-plan/modal/roofAllocation/RoofAllocationSetting'
|
import RoofAllocationSetting from '@/components/floor-plan/modal/roofAllocation/RoofAllocationSetting'
|
||||||
import { addedRoofsState, basicSettingState, settingModalFirstOptionsState } from '@/store/settingAtom'
|
import { addedRoofsState, basicSettingState, correntObjectNoState, settingModalFirstOptionsState } from '@/store/settingAtom'
|
||||||
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
|
import { globalLocaleStore } from '@/store/localeAtom'
|
||||||
|
|
||||||
// 지붕형상 설정
|
// 지붕형상 설정
|
||||||
export function useRoofShapeSetting(id) {
|
export function useRoofShapeSetting(id) {
|
||||||
@ -55,6 +57,9 @@ export function useRoofShapeSetting(id) {
|
|||||||
const [addedRoofs, setAddedRoofs] = useRecoilState(addedRoofsState)
|
const [addedRoofs, setAddedRoofs] = useRecoilState(addedRoofsState)
|
||||||
|
|
||||||
const [basicSetting, setBasicSetting] = useRecoilState(basicSettingState)
|
const [basicSetting, setBasicSetting] = useRecoilState(basicSettingState)
|
||||||
|
const correntObjectNo = useRecoilValue(correntObjectNoState)
|
||||||
|
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
||||||
|
const { post } = useAxios(globalLocaleState)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
pitchRef.current = currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch)
|
pitchRef.current = currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch)
|
||||||
@ -492,7 +497,7 @@ export function useRoofShapeSetting(id) {
|
|||||||
const setRoofPitch = () => {
|
const setRoofPitch = () => {
|
||||||
const newAddedRoofs = addedRoofs.map((roof, index) => {
|
const newAddedRoofs = addedRoofs.map((roof, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
return { ...roof, pitch: pitchRef.current, angle: getDegreeByChon(pitchRef.current) }
|
return { ...roof, pitch: Number(pitchRef.current), angle: getDegreeByChon(pitchRef.current) }
|
||||||
} else {
|
} else {
|
||||||
return { ...roof }
|
return { ...roof }
|
||||||
}
|
}
|
||||||
@ -500,8 +505,48 @@ export function useRoofShapeSetting(id) {
|
|||||||
|
|
||||||
const newBasicSetting = { ...basicSetting, selectedRoofMaterial: { ...newAddedRoofs[0] } }
|
const newBasicSetting = { ...basicSetting, selectedRoofMaterial: { ...newAddedRoofs[0] } }
|
||||||
|
|
||||||
setBasicSetting(newBasicSetting)
|
try {
|
||||||
setAddedRoofs(newAddedRoofs)
|
basicSettingSave(newAddedRoofs)
|
||||||
|
|
||||||
|
setBasicSetting(newBasicSetting)
|
||||||
|
setAddedRoofs(newAddedRoofs)
|
||||||
|
} catch (error) {
|
||||||
|
swalFire({ text: error.message, icon: 'error' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 지붕면 할당 저장
|
||||||
|
*/
|
||||||
|
const basicSettingSave = async (newAddedRoofs) => {
|
||||||
|
try {
|
||||||
|
const patternData = {
|
||||||
|
objectNo: correntObjectNo,
|
||||||
|
planNo: Number(basicSetting.planNo),
|
||||||
|
roofSizeSet: Number(basicSetting.roofSizeSet),
|
||||||
|
roofAngleSet: basicSetting.roofAngleSet,
|
||||||
|
roofAllocationList: newAddedRoofs.map((item, index) => ({
|
||||||
|
planNo: Number(basicSetting.planNo),
|
||||||
|
roofApply: item.selected,
|
||||||
|
roofSeq: index,
|
||||||
|
roofMatlCd: item.roofMatlCd === null || item.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : item.roofMatlCd,
|
||||||
|
roofWidth: item.width === null || item.width === undefined ? 0 : Number(item.width),
|
||||||
|
roofHeight: item.length === null || item.length === undefined ? 0 : Number(item.length),
|
||||||
|
roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : Number(item.hajebichi),
|
||||||
|
roofGap: !item.raft ? item.raftBaseCd : item.raft,
|
||||||
|
roofLayout: item.layout === null || item.layout === undefined ? 'P' : item.layout,
|
||||||
|
roofPitch: item.pitch === null || item.pitch === undefined ? 4 : Number(item.pitch),
|
||||||
|
roofAngle: item.angle === null || item.angle === undefined ? 21.8 : Number(item.angle),
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
|
||||||
|
await post({ url: `/api/canvas-management/roof-allocation-settings`, data: patternData })
|
||||||
|
|
||||||
|
//Recoil 설정
|
||||||
|
//setCanvasSetting({ ...basicSetting })
|
||||||
|
} catch (error) {
|
||||||
|
swalFire({ text: error.message, icon: 'error' })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 동, 서 선택 시 가로라인을 케라바로 설정
|
// 동, 서 선택 시 가로라인을 케라바로 설정
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user