From 2eedb90cb2043dabce40b3a3d21bb0b4d4af5af9 Mon Sep 17 00:00:00 2001 From: yjnoh Date: Tue, 4 Feb 2025 18:06:42 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=EB=A9=B4=ED=98=95=EC=83=81=20=EB=B0=B0?= =?UTF-8?q?=EC=B9=98=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useModuleBasicSetting.js | 22 ++++++++++------------ src/hooks/surface/useSurfaceShapeBatch.js | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 20575fd7..67a5e467 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -258,6 +258,8 @@ export function useModuleBasicSetting(tabNum) { //설치 범위 지정 클릭 이벤트 const toggleSelection = (setupSurface) => { + console.log('setupSurface', setupSurface) + const isExist = selectedModuleInstSurfaceArray.some((obj) => obj.parentId === setupSurface.parentId) //최초 선택일때 if (!isExist) { @@ -442,12 +444,12 @@ export function useModuleBasicSetting(tabNum) { let intvHor = flowDirection === 'south' || flowDirection === 'north' - ? moduleSetupSurfaces[i].trestleDetail.moduleIntvlHor - : moduleSetupSurfaces[i].trestleDetail.moduleIntvlVer + ? moduleSetupSurfaces[i].trestleDetail.moduleIntvlHor / 10 + : moduleSetupSurfaces[i].trestleDetail.moduleIntvlVer / 10 let intvVer = flowDirection === 'south' || flowDirection === 'north' - ? moduleSetupSurfaces[i].trestleDetail.moduleIntvlVer - : moduleSetupSurfaces[i].trestleDetail.moduleIntvlHor + ? moduleSetupSurfaces[i].trestleDetail.moduleIntvlVer / 10 + : moduleSetupSurfaces[i].trestleDetail.moduleIntvlHor / 10 const trestleLeft = moduleSetupSurfaces[i].left const trestleTop = moduleSetupSurfaces[i].top @@ -667,8 +669,6 @@ export function useModuleBasicSetting(tabNum) { 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 @@ -1262,16 +1262,14 @@ export function useModuleBasicSetting(tabNum) { const flowDirection = moduleSetupSurface.flowDirection - console.log('moduleSetupSurface', moduleSetupSurface) - let intvHor = flowDirection === 'south' || flowDirection === 'north' - ? moduleSetupSurface.trestleDetail.moduleIntvlHor - : moduleSetupSurface.trestleDetail.moduleIntvlVer + ? moduleSetupSurface.trestleDetail.moduleIntvlHor / 10 + : moduleSetupSurface.trestleDetail.moduleIntvlVer / 10 let intvVer = flowDirection === 'south' || flowDirection === 'north' - ? moduleSetupSurface.trestleDetail.moduleIntvlVer - : moduleSetupSurface.trestleDetail.moduleIntvlHor + ? moduleSetupSurface.trestleDetail.moduleIntvlVer / 10 + : moduleSetupSurface.trestleDetail.moduleIntvlHor / 10 //처마면 배치 if (setupLocation === 'eaves') { diff --git a/src/hooks/surface/useSurfaceShapeBatch.js b/src/hooks/surface/useSurfaceShapeBatch.js index 54993dbb..5c7b7f97 100644 --- a/src/hooks/surface/useSurfaceShapeBatch.js +++ b/src/hooks/surface/useSurfaceShapeBatch.js @@ -637,7 +637,7 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) { y: pointer.y + length3 / 2, }, { - x: pointer.x - length1 / 2 + length4 * Math.cos(angle), + x: pointer.x - length1 / 2 + length4 * Math.cos(degreesToRadians(angle)), y: pointer.y + length3 / 2 - length4 * Math.sin(degreesToRadians(angle)), }, { From 1d724e275d6294fd65b51865d8e3396527c7f3b8 Mon Sep 17 00:00:00 2001 From: basssy Date: Tue, 4 Feb 2025 18:14:00 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C=20=EB=B6=81?= =?UTF-8?q?=EB=A9=B4=EC=84=A4=EC=B9=98=20=EA=B4=80=EB=A0=A8=20=EB=A9=94?= =?UTF-8?q?=EC=84=B8=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/ja.json | 2 ++ src/locales/ko.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/locales/ja.json b/src/locales/ja.json index 0951418c..38723da7 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -877,6 +877,7 @@ "estimate.detail.roofCns": "屋根材・仕様施工", "estimate.detail.remarks": "備考", "estimate.detail.fileFlg": "後日資料提出", + "estimate.detail.dragFileGuide": "(※北面設置の場合、ファイル添付が必須です.)", "estimate.detail.header.fileList1": "ファイル添付", "estimate.detail.fileList.btn": "ファイル選択", "estimate.detail.fileList.extCheck": "画像ファイルのみ添付可能です。", @@ -942,6 +943,7 @@ "estimate.detail.save.alertMsg": "保存されました。見積書で製品を変更すると、図面や回路には反映されません。", "estimate.detail.copy.alertMsg": "コピーされました。", "estimate.detail.save.requiredFileUpload": "ファイル添付が必須のアイテムがあります。ファイルを添付するか、後日添付をチェックしてください。", + "estimate.detail.save.requiredNorthArrangementFileUpload": "北面にモジュールを配置した場合、北面配置許可書を必ず添付する必要があります.", "estimate.detail.save.requiredItem": "製品は1つ以上登録する必要があります。", "estimate.detail.save.requiredCharger": "担当者は必須です。", "estimate.detail.save.requiredObjectName": "案件名は必須です。", diff --git a/src/locales/ko.json b/src/locales/ko.json index 9037ade4..5c7c17d6 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -877,6 +877,7 @@ "estimate.detail.roofCns": "지붕재・사양시공", "estimate.detail.remarks": "비고", "estimate.detail.fileFlg": "후일자료제출", + "estimate.detail.dragFileGuide": "(※ 북면설치인 경우, 파일 첨부가 필수입니다.)", "estimate.detail.header.fileList1": "파일첨부", "estimate.detail.fileList.btn": "파일선택", "estimate.detail.fileList.extCheck": "이미지 파일만 첨부 가능합니다.", @@ -942,6 +943,7 @@ "estimate.detail.save.alertMsg": "저장되었습니다. 견적서에서 제품을 변경할 경우 도면 및 회로에 반영되지 않습니다.", "estimate.detail.copy.alertMsg": "복사되었습니다.", "estimate.detail.save.requiredFileUpload": "파일첨부가 필수인 아이템이 있습니다. 파일을 첨부하거나 후일첨부를 체크해주십시오.", + "estimate.detail.save.requiredNorthArrangementFileUpload": "북면에 모듈을 배치한 경우, 북면배치허가서를 반드시 첨부해야 합니다.", "estimate.detail.save.requiredItem": "제품은 1개이상 등록해야 됩니다.", "estimate.detail.save.requiredCharger": "담당자는 필수값 입니다.", "estimate.detail.save.requiredObjectName": "안건명은 필수값 입니다.", From 8299cef5a3f8d4f596c9660b6e58f6bc227dbb36 Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Tue, 4 Feb 2025 18:18:25 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=93=8Cfix:=20=EB=B0=B0=EA=B2=BD?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B6=88?= =?UTF-8?q?=EB=9F=AC=EC=98=A4=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/floor-plan/modal/ImgLoad.jsx | 10 +++++----- src/hooks/common/useRefFiles.js | 16 ++++++++++------ src/hooks/usePlan.js | 1 + src/lib/fileAction.js | 3 ++- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/components/floor-plan/modal/ImgLoad.jsx b/src/components/floor-plan/modal/ImgLoad.jsx index 2a5e77aa..341f9b94 100644 --- a/src/components/floor-plan/modal/ImgLoad.jsx +++ b/src/components/floor-plan/modal/ImgLoad.jsx @@ -34,11 +34,11 @@ export default function ImgLoad() { const handleModal = () => { setFloorPlanState({ ...floorPlanState, refFileModalOpen: false, toggleRotate: false }) - setCurrentCanvasPlan({ - ...currentCanvasPlan, - bgImageName: refImage?.name ?? null, - mapPositionAddress, - }) + // setCurrentCanvasPlan({ + // ...currentCanvasPlan, + // bgImageName: refImage?.name ?? null, + // mapPositionAddress, + // }) } useEffect(() => { diff --git a/src/hooks/common/useRefFiles.js b/src/hooks/common/useRefFiles.js index bb079bc7..027a2d87 100644 --- a/src/hooks/common/useRefFiles.js +++ b/src/hooks/common/useRefFiles.js @@ -131,12 +131,16 @@ export function useRefFiles() { // setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: currentCanvasPlan.id, mapPositionAddress: queryRef.current.value })) } + /** + * 배경 이미지 로드를 위한 세팅 + */ useEffect(() => { if (!currentBgImage) { return } console.log('🚀 ~ useEffect ~ currentBgImage:', currentBgImage) - handleBackImageLoadToCanvas(`plan-images/${currentCanvasPlan.id}.png`) + // handleBackImageLoadToCanvas(`plan-images/${currentCanvasPlan.id}.png`) + handleBackImageLoadToCanvas(currentBgImage) setCurrentCanvasPlan((prev) => ({ ...prev, bgImageName: refImage?.name ?? null, mapPositionAddress: queryRef.current.value })) }, [currentBgImage]) @@ -147,15 +151,15 @@ export function useRefFiles() { const handleUploadImageRefFile = async (file) => { const formData = new FormData() formData.append('file', file) - formData.append('fileName', currentCanvasPlan.id) + // formData.append('fileName', currentCanvasPlan.id) // const res = await post({ url: `${process.env.NEXT_PUBLIC_API_SERVER_PATH}/api/image-upload`, data: formData }) - const res = await post({ url: `http://localhost:3000/api/image-upload`, data: formData }) + const res = await post({ url: `${process.env.NEXT_PUBLIC_HOST_URL}/image/upload`, data: formData }) console.log('🚀 ~ handleUploadImageRefFile ~ res:', res) - const image = await readImage(res.fileNm) - console.log('🚀 ~ handleUploadImageRefFile ~ file:', image) + // const image = await readImage(res.filePath) + // console.log('🚀 ~ handleUploadImageRefFile ~ file:', image) - setCurrentBgImage(image) + setCurrentBgImage(`${process.env.NEXT_PUBLIC_HOST_URL}${res.filePath}`) setRefImage(file) } diff --git a/src/hooks/usePlan.js b/src/hooks/usePlan.js index b904611d..3691035e 100644 --- a/src/hooks/usePlan.js +++ b/src/hooks/usePlan.js @@ -394,6 +394,7 @@ export function usePlan(params = {}) { canvas, plans, currentCanvasPlan, + setCurrentCanvasPlan, selectedPlan, saveCanvas, handleCurrentPlan, diff --git a/src/lib/fileAction.js b/src/lib/fileAction.js index d2c4cff9..6b531d77 100644 --- a/src/lib/fileAction.js +++ b/src/lib/fileAction.js @@ -72,7 +72,8 @@ const writeImage = async (fileName, file) => { } const readImage = async (fileName) => { - const file = await fs.readFile(`${FILE_PATH}/${fileName}`) + // const file = await fs.readFile(`${FILE_PATH}/${fileName}`) + const file = await fs.readFile(`${process.env.NEXT_PUBLIC_HOST_URL}${fileName}`) // .then((res) => { // console.log('readImage-then', res) // }) From 09507122be23f8c83212c56e3cc969d118207efa Mon Sep 17 00:00:00 2001 From: Daseul Kim Date: Tue, 4 Feb 2025 18:18:53 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=EB=8F=84=EB=A9=B4=20=EA=B2=AC?= =?UTF-8?q?=EC=A0=81=EC=84=9C=20=EC=A0=80=EC=9E=A5=20api=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../circuitTrestle/CircuitTrestleSetting.jsx | 6 +- src/hooks/module/useTrestle.js | 12 ++-- src/hooks/useEstimate.js | 59 +++++++++++++++++++ 3 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 src/hooks/useEstimate.js diff --git a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx index adeb0300..e53c8619 100644 --- a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx @@ -21,6 +21,7 @@ import { selectedModuleState } from '@/store/selectedModuleOptions' import { v4 as uuidv4 } from 'uuid' import { stepUpListDataState } from '@/store/circuitTrestleAtom' +import { useEstimate } from '@/hooks/useEstimate' const ALLOCATION_TYPE = { AUTO: 'auto', @@ -31,6 +32,7 @@ export default function CircuitTrestleSetting({ id }) { const { closePopup } = usePopup() const { apply } = useTrestle() const { swalFire } = useSwal() + const { saveEstimate } = useEstimate() const canvas = useRecoilValue(canvasState) const [makers, setMakers] = useRecoilState(makersState) @@ -336,8 +338,10 @@ export default function CircuitTrestleSetting({ id }) { }) const result = await apply() + if (result) { + await saveEstimate(result) + } removeNotAllocationModules() - apply() } const removeNotAllocationModules = () => { diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index 083c24c3..f39d3057 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -1,18 +1,16 @@ -import { useRecoilState, useRecoilValue } from 'recoil' +import { useRecoilValue } from 'recoil' import { canvasState, currentAngleTypeSelector } from '@/store/canvasAtom' import { POLYGON_TYPE } from '@/common/common' import { moduleSelectionDataState } from '@/store/selectedModuleOptions' import { getDegreeByChon, getTrestleLength } from '@/util/canvas-util' import { v4 as uuidv4 } from 'uuid' import { useMasterController } from '@/hooks/common/useMasterController' -import { estimateParamAtom } from '@/store/estimateAtom' // 회로 및 가대설정 export const useTrestle = () => { const canvas = useRecoilValue(canvasState) const moduleSelectionData = useRecoilValue(moduleSelectionDataState) //다음으로 넘어가는 최종 데이터 const { getQuotationItem } = useMasterController() - const [estimateParam, setEstimateParam] = useRecoilState(estimateParamAtom) const currentAngleType = useRecoilValue(currentAngleTypeSelector) const apply = () => { @@ -462,7 +460,7 @@ export const useTrestle = () => { return setEstimateData() } catch (e) { - return false + return null } } @@ -480,7 +478,7 @@ export const useTrestle = () => { //견적서 itemList 조회 const res = await getQuotationItem(params) if (!res.data) { - return false + return null } const itemList = res.data //northArrangement 북면 설치 여부 @@ -540,10 +538,10 @@ export const useTrestle = () => { } }) - setEstimateParam({ ...estimateParam, itemList, northArrangement, roofSurfaceList, circuitItemList }) + const estimateParam = { itemList, northArrangement, roofSurfaceList, circuitItemList } // 정상적으로 완료 되면 true 반환 - return true + return estimateParam } const getNorthArrangement = () => { diff --git a/src/hooks/useEstimate.js b/src/hooks/useEstimate.js new file mode 100644 index 00000000..7fa4ff60 --- /dev/null +++ b/src/hooks/useEstimate.js @@ -0,0 +1,59 @@ +import { useContext } from 'react' + +import { useRecoilValue } from 'recoil' + +import { useAxios } from '@/hooks/useAxios' +import { useSwal } from '@/hooks/useSwal' +import { GlobalDataContext } from '@/app/GlobalDataProvider' +import { currentCanvasPlanState } from '@/store/canvasAtom' +import { loginUserStore } from '@/store/commonAtom' + +export function useEstimate() { + const { managementStateLoaded } = useContext(GlobalDataContext) + + const loginUserState = useRecoilValue(loginUserStore) + const currentCanvasPlan = useRecoilValue(currentCanvasPlanState) + + const { swalFire } = useSwal() + const { promisePost } = useAxios() + + /** + * 도면 견적서 저장 + */ + const saveEstimate = async (estimateParam) => { + const userId = loginUserState.userId + const saleStoreId = managementStateLoaded.saleStoreId + const objectNo = currentCanvasPlan.objectNo + const planNo = currentCanvasPlan.planNo + const slope = estimateParam.roofSurfaceList[0].slope + const angle = estimateParam.roofSurfaceList[0].angle + const surfaceType = managementStateLoaded.surfaceType + const setupHeight = managementStateLoaded.installHeight + const standardWindSpeedId = managementStateLoaded.standardWindSpeedId + const snowfall = managementStateLoaded.verticalSnowCover + const drawingFlg = '1' + + const saveEstimateData = { + ...estimateParam, + userId: userId, + saleStoreId: saleStoreId, + objectNo: objectNo, + planNo: planNo, + slope: slope, + angle: angle, + surfaceType: surfaceType, + setupHeight: setupHeight, + standardWindSpeedId: standardWindSpeedId, + snowfall: snowfall, + drawingFlg: drawingFlg, + } + + await promisePost({ url: '/api/estimate/save-estimate', data: saveEstimateData }).catch((error) => { + swalFire({ text: error.message, icon: 'error' }) + }) + } + + return { + saveEstimate, + } +}