diff --git a/src/components/floor-plan/modal/basic/BasicSetting.jsx b/src/components/floor-plan/modal/basic/BasicSetting.jsx index 89560025..f4fc830d 100644 --- a/src/components/floor-plan/modal/basic/BasicSetting.jsx +++ b/src/components/floor-plan/modal/basic/BasicSetting.jsx @@ -1,6 +1,6 @@ import { useMessage } from '@/hooks/useMessage' import WithDraggable from '@/components/common/draggable/WithDraggable' -import { useEffect, useRef, useState } from 'react' +import { useContext, useEffect, useRef, useState } from 'react' import Module from '@/components/floor-plan/modal/basic/step/Module' import PitchModule from '@/components/floor-plan/modal/basic/step/pitch/PitchModule' import PitchPlacement from '@/components/floor-plan/modal/basic/step/pitch/PitchPlacement' @@ -16,6 +16,9 @@ import { addedRoofsState } from '@/store/settingAtom' import { isObjectNotEmpty } from '@/util/common-utils' import Swal from 'sweetalert2' import { useCanvasPopupStatusController } from '@/hooks/common/useCanvasPopupStatusController' +import { useMasterController } from '@/hooks/common/useMasterController' +import { loginUserStore } from '@/store/commonAtom' +import { currentCanvasPlanState } from '@/store/canvasAtom' export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) { const { getMessage } = useMessage() @@ -27,9 +30,12 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) { const [isManualModuleSetup, setIsManualModuleSetup] = useRecoilState(isManualModuleSetupState) const moduleSelectionData = useRecoilValue(moduleSelectionDataState) const addedRoofs = useRecoilValue(addedRoofsState) + const loginUserState = useRecoilValue(loginUserStore) + const currentCanvasPlan = useRecoilValue(currentCanvasPlanState) // const { initEvent } = useContext(EventContext) const { manualModuleSetup, autoModuleSetup, manualFlatroofModuleSetup, autoFlatroofModuleSetup } = useModuleBasicSetting() + const { updateObjectDate } = useMasterController() const handleBtnNextStep = () => { if (tabNum === 1) { orientationRef.current.handleNextStep() @@ -49,6 +55,16 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) { }) return } + + //물건정보 갱신일 수정 + updateObjectDataApi({ + objectNo: currentCanvasPlan.objectNo, //오브젝트_no + standardWindSpeedId: moduleSelectionData.common.stdWindSpeed, //기준풍속코드 + verticalSnowCover: moduleSelectionData.common.stdSnowLd, //적설량 + surfaceType: moduleSelectionData.common.illuminationTpNm, //면조도구분 + installHeight: moduleSelectionData.common.instHt, //설치높이 + userId: loginUserState.userId, //작성자아아디 + }) } setTabNum(tabNum + 1) @@ -72,6 +88,10 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) { manualModuleSetup() }, [isManualModuleSetup]) + const updateObjectDataApi = async (params) => { + const res = await updateObjectDate(params) + } + return (
diff --git a/src/components/floor-plan/modal/basic/step/ModuleTabContents.jsx b/src/components/floor-plan/modal/basic/step/ModuleTabContents.jsx index ad48695e..706fad9f 100644 --- a/src/components/floor-plan/modal/basic/step/ModuleTabContents.jsx +++ b/src/components/floor-plan/modal/basic/step/ModuleTabContents.jsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useState, useEffect } from 'react' import { useMessage } from '@/hooks/useMessage' import { isObjectNotEmpty } from '@/util/common-utils' import QSelectBox from '@/components/common/select/QSelectBox' @@ -15,6 +15,7 @@ export default function ModuleTabContents({ tabIndex, addRoof, setAddedRoofs, ro roofBaseList, constructionList, globalPitchText, + selectedRaftBase, selectedTrestle, selectedConstMthd, selectedRoofBase, @@ -27,8 +28,7 @@ export default function ModuleTabContents({ tabIndex, addRoof, setAddedRoofs, ro hajebichi, lengthRef, hajebichiRef, - setLengthBase, - setHajebichi, + handleHajebichiAndLength, handleChangeRaftBase, handleChangeTrestle, handleChangeConstMthd, @@ -59,7 +59,7 @@ export default function ModuleTabContents({ tabIndex, addRoof, setAddedRoofs, ro type="text" className="input-origin block" value={lengthBase} - onChange={(e) => setLengthBase(e.target.value)} + onChange={(e) => handleHajebichiAndLength(e, 'length')} disabled={roofMaterial.lenAuth === 'R' ? true : false} ref={lengthRef} /> @@ -77,9 +77,9 @@ export default function ModuleTabContents({ tabIndex, addRoof, setAddedRoofs, ro {raftCodes.length > 0 && ( setHajebichi(e.target.value)} + onChange={(e) => handleHajebichiAndLength(e, 'hajebichi')} value={hajebichi} ref={hajebichiRef} /> diff --git a/src/components/floor-plan/modal/basic/step/Placement.jsx b/src/components/floor-plan/modal/basic/step/Placement.jsx index 4938b1e9..eff568cd 100644 --- a/src/components/floor-plan/modal/basic/step/Placement.jsx +++ b/src/components/floor-plan/modal/basic/step/Placement.jsx @@ -57,10 +57,6 @@ const Placement = forwardRef((props, refs) => { refs.isChidori.current = e.target.value } - useEffect(() => { - console.log('isChidori', isChidori) - }, [isChidori]) - const handleSetupLocation = (e) => { setSetupLocation(e.target.value) refs.setupLocation.current = e.target.value @@ -81,6 +77,20 @@ const Placement = forwardRef((props, refs) => { setSelectedItems({ ...selectedItems, [e.target.name]: e.target.checked }) } + useEffect(() => { + if (moduleSelectionData && moduleSelectionData.module.itemList.length > 0) { + let initCheckedModule = {} + moduleSelectionData.module.itemList.forEach((obj, index) => { + if (index === 0) { + initCheckedModule = { [obj.itemId]: true } + } else { + initCheckedModule = { ...initCheckedModule, [obj.itemId]: true } + } + }) + setSelectedItems(initCheckedModule) + } + }, []) + return ( <>
@@ -111,7 +121,13 @@ const Placement = forwardRef((props, refs) => {
- +
diff --git a/src/hooks/common/useCommonUtils.js b/src/hooks/common/useCommonUtils.js index 26cbcc8a..731e3725 100644 --- a/src/hooks/common/useCommonUtils.js +++ b/src/hooks/common/useCommonUtils.js @@ -301,6 +301,8 @@ export function useCommonUtils() { ...commonUtilsState, dimension: false, }) + + initEvent() } // 캔버스 다시 그리기 diff --git a/src/hooks/common/useMasterController.js b/src/hooks/common/useMasterController.js index ef31962f..5d3e1ed9 100644 --- a/src/hooks/common/useMasterController.js +++ b/src/hooks/common/useMasterController.js @@ -12,7 +12,7 @@ import { useRecoilValue } from 'recoil' * @returns */ export function useMasterController() { - const { get, post } = useAxios() + const { get, post, put } = useAxios() const { getMessage } = useMessage() const { swalFire } = useSwal() @@ -216,6 +216,18 @@ export function useMasterController() { }) } + /** + * 물건 정보 업데이트 api 호출 + * @param {objectNo standardWindSpeedId verticalSnowCover surfaceType installHeight userId} params + * @param {물건번호 기준풍속코드 적설량 면조도구분 설치높이 작성자아아디 } params + * @returns + */ + const updateObjectDate = async (params = null) => { + return await put({ url: '/api/object/update-object-date', data: params }).then((res) => { + return res + }) + } + return { getRoofMaterialList, getModuleTypeItemList, @@ -228,5 +240,6 @@ export function useMasterController() { getPcsVoltageChk, getPcsManualConfChk, getPcsVoltageStepUpList, + updateObjectDate, } } diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 53966ee7..f003982c 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -394,6 +394,8 @@ export function useModuleBasicSetting() { return } + console.log('placementRef', placementRef) + const isChidori = placementRef.isChidori.current === 'true' ? true : false const setupLocation = placementRef.setupLocation.current const isMaxSetup = placementRef.isMaxSetup.current === 'true' ? true : false diff --git a/src/hooks/module/useModulePlace.js b/src/hooks/module/useModulePlace.js index 0af46cf9..8b1940f9 100644 --- a/src/hooks/module/useModulePlace.js +++ b/src/hooks/module/useModulePlace.js @@ -71,12 +71,16 @@ export function useModulePlace() { .forEach((roof) => { const roofIndex = roof.roofMaterial.index //지붕의 지붕재의 순번 trestleDetailList.forEach((detail) => { - if (Number(detail.data.roofIndex) === roofIndex) { - //roof에 상세 데이터 추가 - roof.set({ trestleDetail: detail.data }) - //배치면 설치 영역 - makeModuleInstArea(roof, detail.data) - //surface에 상세 데이터 추가 + if (detail.data !== null) { + if (Number(detail.data.roofIndex) === roofIndex) { + //roof에 상세 데이터 추가 + roof.set({ trestleDetail: detail.data }) + //배치면 설치 영역 + makeModuleInstArea(roof, detail.data) + //surface에 상세 데이터 추가 + } else { + console.log('가대 데이터가 없네요...') + } } }) }) diff --git a/src/hooks/module/useModuleSelection.js b/src/hooks/module/useModuleSelection.js index 22d1f88f..0321abaa 100644 --- a/src/hooks/module/useModuleSelection.js +++ b/src/hooks/module/useModuleSelection.js @@ -37,6 +37,7 @@ export function useModuleSelection(props) { bindInitData() const initParams = { illuminationTp: managementState?.surfaceTypeValue, //면조도 + illuminationTpNm: managementState?.surfaceType, //면조도명 instHt: managementState?.installHeight, //설치높이 stdWindSpeed: managementState?.standardWindSpeedId, //기준풍속 stdSnowLd: managementState?.verticalSnowCover, //기준적설량 @@ -119,6 +120,7 @@ export function useModuleSelection(props) { setModuleSelectionInitParams({ ...moduleSelectionInitParams, illuminationTp: option.clCode, + illuminationTpNm: option.clCodeNm, }) setManagementState({ diff --git a/src/hooks/module/useModuleTabContents.js b/src/hooks/module/useModuleTabContents.js index 56365f38..f15e643f 100644 --- a/src/hooks/module/useModuleTabContents.js +++ b/src/hooks/module/useModuleTabContents.js @@ -59,9 +59,10 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab const handleChangeRaftBase = (option) => { setSelectedRaftBase(option) setTrestleParams({ ...trestleParams, raftBaseCd: option.clCode }) //가대메이커 - setConstMthdList([]) //공법 초기화 - setRoofBaseList([]) //지붕밑바탕 초기화 - setConstructionList([]) //공법 초기화 + // setConstMthdList([]) //공법 초기화 + // setRoofBaseList([]) //지붕밑바탕 초기화 + // setConstructionList([]) //공법 초기화 + resetSelected() } //처마력바 체크 @@ -85,7 +86,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab useEffect(() => { setHajebichi(addRoof.hajebichi) - setLengthBase(addRoof.lenBase) + setLengthBase(addRoof.length) // 202600 경사도 const raftCodeList = findCommonCode('203800') @@ -96,7 +97,13 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab }) setRaftCodes(raftCodeList) - console.log('moduleSelectionData', moduleSelectionData) + if (addRoof.raft) { + setSelectedRaftBase({ + ...selectedRaftBase, + raftBaseCd: addRoof.raft, + clCode: addRoof.raft, + }) + } }, []) //리코일에 데이터가 담기는 시점에 시작 @@ -116,38 +123,18 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab } }, [moduleConstructionSelectionData]) - //높이를 변경하면 addRoofs에 적용 // useEffect(() => { - // const copyAddRoof = { ...addRoof } - // copyAddRoof.length = Number(lengthBase) - // copyAddRoof.lenBase = lengthBase - // const index = addRoof.index - // const newArray = [...addRoofsArray.slice(0, index), copyAddRoof, ...addRoofsArray.slice(index + 1)] - // setAddedRoofs(newArray) - // }, [lengthBase]) - - // //망둥어 피치를 변경하면 addRoof 변경 - // useEffect(() => { - // const copyAddRoof = { ...addRoof } - // copyAddRoof.hajebichi = Number(hajebichi) - // copyAddRoof.roofPchBase = hajebichi - // const index = addRoof.index - // const newArray = [...addRoofsArray.slice(0, index), copyAddRoof, ...addRoofsArray.slice(index + 1)] - // setAddedRoofs(newArray) - // }, [hajebichi]) - - useEffect(() => { - if (isExistData) { - setConstructionListParams({ - ...moduleSelectionInitParams, - ...roofBaseParams, - roofBaseCd: selectedRoofBase.roofBaseCd, - inclCd: addRoof.pitch, - roofPitch: hajebichiRef.current ? hajebichiRef.current.value : 0, - raftBaseCd: addRoof.raftBaseCd, - }) - } - }, [selectedRoofBase]) + // if (isExistData) { + // setConstructionListParams({ + // ...moduleSelectionInitParams, + // ...roofBaseParams, + // roofBaseCd: selectedRoofBase.roofBaseCd, + // inclCd: addRoof.pitch, + // roofPitch: hajebichiRef.current ? hajebichiRef.current.value : 0, + // raftBaseCd: selectedRaftBase.raftBaseCd ? selectedRaftBase.raftBaseCd : '', + // }) + // } + // }, [selectedRoofBase]) useEffect(() => { if ( @@ -172,7 +159,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab setTrestleParams({ moduleTpCd: selectedModules.itemTp, roofMatlCd: addRoof.roofMatlCd, - raftBaseCd: addRoof.raftBaseCd, + raftBaseCd: selectedRaftBase.raftBaseCd ? selectedRaftBase.raftBaseCd : '', workingWidth: lengthBase, }) } @@ -222,7 +209,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab roofBaseCd: option.roofBaseCd, inclCd: addRoof.pitch, roofPitch: hajebichiRef.current ? hajebichiRef.current.value : 0, - raftBaseCd: addRoof.raftBaseCd, + raftBaseCd: selectedRaftBase.clCode ? selectedRaftBase.clCode : '', roofMatlCd: addRoof.roofMatlCd, }) setSelectedRoofBase(option) @@ -309,29 +296,36 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab } }, [selectedConstruction]) + //거대메이커, 공법, 지붕밑바탕 api 조회 const getModuleOptionsListData = async (params, type) => { const optionsList = await getTrestleList(params) if (optionsList.data.length > 0) { if (type === 'trestle') { - setTrestleList(optionsList.data) + //가대 메이커일때 + setTrestleList(optionsList.data) //가대 목록 if (isExistData) { + //데이터가 있으면 선택된 가대 메이커를 선택한다 handleChangeTrestle(moduleConstructionSelectionData?.trestle) } else { - setConstMthdList([]) - setRoofBaseList([]) + setConstMthdList([]) //공법 목록 초기화 + setRoofBaseList([]) //지붕밑바탕 목록 초기화 } } else if (type === 'construction') { - setConstMthdList(optionsList.data) + //공법일때 + setConstMthdList(optionsList.data) //공법 목록 if (isExistData) { + //데이터가 있으면 선택된 공법을 선택한다 handleChangeConstMthd(moduleConstructionSelectionData?.trestle) } else { - setRoofBaseList([]) + setRoofBaseList([]) //지붕밑바탕 목록 초기화 } } else if (type === 'roofBase') { - setRoofBaseList(optionsList.data) + //지붕밑바탕일때 + setRoofBaseList(optionsList.data) //지붕밑바탕 목록 if (isExistData) { - handleChangeRoofBase(moduleConstructionSelectionData?.trestle) + //데이터가 있으면 선택된 지붕밑바탕을 선택한다 + handleChangeRoofBase(moduleConstructionSelectionData?.trestle) //선택된 지붕밑바탕을 선택한다 } } } @@ -342,51 +336,64 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab if (moduleSelectionInitOriginData.current.moduleItemId && moduleSelectionInitOriginData.current.moduleTpCd) { //초기에 들어온 데이터가 수정된 데이터가 값이 다르다면` if (!isEqualObjects(moduleSelectionInitOriginData.current, moduleSelectionInitParams)) { - //가대 선택 초기화 - setSelectedTrestle({}) - - //공법 선택 초기화 - setSelectedConstMthd({}) - - //지붕밑바탕 선택 초기화 - setSelectedRoofBase({}) - - //공법 리스트 초기화 - setConstructionList([]) - - // 기본 정보 초기화 - setModuleSelectionData({ - ...moduleSelectionData, - roofConstructions: [], - }) - - // 선택 데이터 초 기화 - setModuleConstructionSelectionData({ - addRoof: addRoof, - trestle: {}, - construction: {}, - }) - - //임시 데이터 초기화 - setTempModuleSelectionData({ - ...moduleSelectionData, - roofConstructions: [], - }) - - //처마커버 해제 - setCvrChecked(false) - //눈막이금구 해제 - setSnowGdChecked(false) - - // 데이터 없음으로 변경 - setIsExistData(false) - - //변경된 데이터를 ref에 저장 - moduleSelectionInitOriginData.current = moduleSelectionInitParams + resetSelected() } } }, [moduleSelectionInitParams]) + const handleHajebichiAndLength = (e, type) => { + if (type === 'length') { + setLengthBase(e.target.value) + } else { + setHajebichi(e.target.value) + } + resetSelected() + } + + const resetSelected = () => { + //가대 선택 초기화 + setSelectedTrestle({}) + + //공법 선택 초기화 + setSelectedConstMthd({}) + + //지붕밑바탕 선택 초기화 + setSelectedRoofBase({}) + + //공법 리스트 초기화 + setConstructionList([]) + + // 기본 정보 초기화 + setModuleSelectionData({ + ...moduleSelectionData, + roofConstructions: [], + }) + + // 선택 데이터 초 기화 + setModuleConstructionSelectionData({ + addRoof: addRoof, + trestle: {}, + construction: {}, + }) + + //임시 데이터 초기화 + setTempModuleSelectionData({ + ...moduleSelectionData, + roofConstructions: [], + }) + + //처마커버 해제 + setCvrChecked(false) + //눈막이금구 해제 + setSnowGdChecked(false) + + // 데이터 없음으로 변경 + setIsExistData(false) + + //변경된 데이터를 ref에 저장 + moduleSelectionInitOriginData.current = moduleSelectionInitParams + } + return { raftCodes, trestleList, @@ -394,6 +401,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab roofBaseList, constructionList, globalPitchText, + selectedRaftBase, selectedTrestle, selectedConstMthd, selectedRoofBase, @@ -406,8 +414,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab hajebichi, lengthRef, hajebichiRef, - setLengthBase, - setHajebichi, + handleHajebichiAndLength, handleChangeRaftBase, handleChangeTrestle, handleChangeConstMthd, diff --git a/src/hooks/surface/useSurfaceShapeBatch.js b/src/hooks/surface/useSurfaceShapeBatch.js index 4cb3586f..3f943792 100644 --- a/src/hooks/surface/useSurfaceShapeBatch.js +++ b/src/hooks/surface/useSurfaceShapeBatch.js @@ -200,12 +200,8 @@ export function useSurfaceShapeBatch() { } } if (surfaceId === 18) { - if (length1 >= length2) { - swalFire({ text: getMessage('surface.shape.validate.size.1to2'), icon: 'error' }) - check = false - } - if (length4 >= length3) { - swalFire({ text: getMessage('surface.shape.validate.size.3to4'), icon: 'error' }) + if (length2 >= length3) { + swalFire({ text: getMessage('surface.shape.validate.size.3to2'), icon: 'error' }) check = false } } @@ -242,7 +238,7 @@ export function useSurfaceShapeBatch() { swalFire({ text: getMessage('common.canvas.validate.size'), icon: 'error' }) check = false } - if (surfaceId === 9 || surfaceId === 10 || surfaceId === 11) { + if (surfaceId === 9 || surfaceId === 10) { if (length2 + length3 >= length1) { swalFire({ text: getMessage('surface.shape.validate.size.1to23'), icon: 'error' }) check = false @@ -253,6 +249,17 @@ export function useSurfaceShapeBatch() { } } + if (surfaceId === 11) { + if (length1 > length2 + length3) { + swalFire({ text: getMessage('surface.shape.validate.size.1to23low'), icon: 'error' }) + check = false + } + if (length5 >= length4) { + swalFire({ text: getMessage('surface.shape.validate.size.4to5'), icon: 'error' }) + check = false + } + } + if (surfaceId === 14) { if (length2 + length3 >= length1) { swalFire({ text: getMessage('surface.shape.validate.size.1to23'), icon: 'error' }) diff --git a/src/locales/ja.json b/src/locales/ja.json index 42509426..c0721401 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -851,6 +851,7 @@ "surface.shape.validate.size.1to2": "①길이는 ②보다 큰 값을 넣어주세요.", "surface.shape.validate.size.1to3": "①길이는 ③보다 큰 값을 넣어주세요.", "surface.shape.validate.size.1to23": "①길이는 ②+③보다 큰 값을 넣어주세요.", + "surface.shape.validate.size.1to23low": "①길이는 ②+③보다 클 수 없습니다..", "surface.shape.validate.size.2to3": "②길이는 ③보다 큰 값을 넣어주세요.", "surface.shape.validate.size.3to4": "③길이는 ④보다 큰 값을 넣어주세요.", "surface.shape.validate.size.4to5": "④길이는 ⑤보다 큰 값을 넣어주세요.", diff --git a/src/locales/ko.json b/src/locales/ko.json index d02746ea..aa91d0fc 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -856,7 +856,9 @@ "surface.shape.validate.size.1to2": "①길이는 ②보다 큰 값을 넣어주세요.", "surface.shape.validate.size.1to3": "①길이는 ③보다 큰 값을 넣어주세요.", "surface.shape.validate.size.1to23": "①길이는 ②+③보다 큰 값을 넣어주세요.", + "surface.shape.validate.size.1to23low": "②+③길이는 ①보다 큰 값을 넣어주세요.", "surface.shape.validate.size.2to3": "②길이는 ③보다 큰 값을 넣어주세요.", + "surface.shape.validate.size.3to2": "③길이는 ②보다 큰 값을 넣어주세요.", "surface.shape.validate.size.3to4": "③길이는 ④보다 큰 값을 넣어주세요.", "surface.shape.validate.size.4to5": "④길이는 ⑤보다 큰 값을 넣어주세요.", "estimate.detail.header.title": "기본정보",