From 4c219ddce9d51be8dbe96f88a93c70a55be98be3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=8B=9D?=
<43837214+Minsiki@users.noreply.github.com>
Date: Thu, 17 Apr 2025 14:12:50 +0900
Subject: [PATCH] =?UTF-8?q?validation=20=EB=B0=A9=EC=8B=9D=20=EC=88=98?=
=?UTF-8?q?=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../floor-plan/modal/basic/BasicSetting.jsx | 10 +-
.../floor-plan/modal/basic/step/Trestle.jsx | 129 +++++++++++++++---
2 files changed, 113 insertions(+), 26 deletions(-)
diff --git a/src/components/floor-plan/modal/basic/BasicSetting.jsx b/src/components/floor-plan/modal/basic/BasicSetting.jsx
index 7e026584..72f8e595 100644
--- a/src/components/floor-plan/modal/basic/BasicSetting.jsx
+++ b/src/components/floor-plan/modal/basic/BasicSetting.jsx
@@ -186,15 +186,7 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
// return
// }
trestleRef.current.isComplete().then((res) => {
- if (!res) {
- Swal.fire({
- title: getMessage('construction.length.difference'),
- icon: 'warning',
- })
- return
- } else {
- // setTabNum(tabNum + 1)
- }
+ if (!res) return
})
//물건정보 갱신일 수정
} else {
diff --git a/src/components/floor-plan/modal/basic/step/Trestle.jsx b/src/components/floor-plan/modal/basic/step/Trestle.jsx
index 6060d8c8..bd9bf705 100644
--- a/src/components/floor-plan/modal/basic/step/Trestle.jsx
+++ b/src/components/floor-plan/modal/basic/step/Trestle.jsx
@@ -8,6 +8,7 @@ import { roofsState } from '@/store/roofAtom'
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react'
import { useRecoilState, useRecoilValue } from 'recoil'
+import Swal from 'sweetalert2'
const Trestle = forwardRef((props, ref) => {
const { tabNum, setTabNum, trestleTrigger, roofs, setRoofs, moduleSelectionData, setModuleSelectionData, setRoofsStore } = props
@@ -303,30 +304,122 @@ const Trestle = forwardRef((props, ref) => {
})
let result = true
- newAddedRoofs.forEach((roof) => {
- if (!roof?.eavesMargin || !roof?.ridgeMargin || !roof?.kerabaMargin) result = false
- if (!roof.trestle?.trestleMkrCd) result = false
- if (!roof.trestle?.constMthdCd) result = false
- if (!roof.trestle?.roofBaseCd) result = false
- if (!roof.construction?.constTp) result = false
+ console.log(newAddedRoofs)
+ for (let i = 0; i < newAddedRoofs.length; i++) {
+ const roof = newAddedRoofs[i]
+
+ if (!roof.trestle?.trestleMkrCd) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error1', [roof.nameJp]), // 가대메이커를 선택해주세요.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
+
+ if (!roof.trestle?.constMthdCd) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error2', [roof.nameJp]), // 공법을 선택해주세요.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
+ if (!roof.trestle?.roofBaseCd) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error3', [roof.nameJp]), // 지붕밑바탕탕을 선택해주세요.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
+ if (!roof.construction?.constTp) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error4', [roof.nameJp]), // 시공법법을 선택해주세요.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
if (roof.lenAuth === 'C') {
- if (!roof.trestle?.length) result = false
+ if (!roof.trestle?.length) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error5', [roof.nameJp]), // L 값을 입력해주세요.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
}
if (['C', 'R'].includes(roof.raftAuth)) {
- if (!roof?.raftBaseCd) result = false
+ if (!roof?.raftBaseCd) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error6', [roof.nameJp]), // 서까래 간격을 입력해주세요.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
}
if (['C', 'R'].includes(roof.roofPchAuth)) {
- if (!roof?.roofPchBase) result = false
+ if (!roof?.roofPchBase) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error7', [roof.nameJp]), // 하제비치를 입력해주세요.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
}
- })
- const newRoofs = newAddedRoofs.map((roof) => {
- const { addRoof, construction, trestle, trestleDetail, roofConstructions, ...rest } = roof
- return rest
- })
+ if (!roof?.eavesMargin || !roof?.ridgeMargin || !roof?.kerabaMargin) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error8', [roof.nameJp]), // 모듈 배치 영영 값을 입력해주세요.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
+
+ if (roof.trestle.trestleMkrCd !== 'NO_DATA') {
+ // 가매 없음이 아닐때는 가대 정보보다 작을 수 없음
+ if (roof.trestleDetail?.eaveIntvl > roof.eavesMargin) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error9', [roof.trestleDetail?.eaveIntvl, roof.nameJp]), // 모듈 배치 영역은 {0}mm 이상이어야 합니다.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
+
+ if (roof.trestleDetail?.ridgeIntvl > roof.ridgeMargin) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error10', [roof.trestleDetail?.ridgeIntvl, roof.nameJp]), // 모듈 배치 영역은 {0}mm 이상이어야 합니다.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
+
+ if (roof.trestleDetail?.kerabaIntvl > roof.kerabaMargin) {
+ Swal.fire({
+ title: getMessage('modal.module.basic.settting.module.error11', [roof.trestleDetail?.kerabaIntvl, roof.nameJp]), // 모듈 배치 영역은 {0}mm 이상이어야 합니다.
+ icon: 'warning',
+ })
+ result = false
+ return false
+ }
+ }
+ }
+
if (result) {
+ const newRoofs = newAddedRoofs.map((roof) => {
+ const { addRoof, construction, trestle, trestleDetail, roofConstructions, ...rest } = roof
+ return rest
+ })
+
setModuleSelectionData({
...moduleSelectionData,
roofConstructions: newAddedRoofs.map((roof, index) => ({
@@ -388,6 +481,8 @@ const Trestle = forwardRef((props, ref) => {
return false
}
+ const onMarginCheck = (target, data) => {}
+
useImperativeHandle(ref, () => ({
isComplete,
}))
@@ -580,7 +675,7 @@ const Trestle = forwardRef((props, ref) => {
className="input-origin block"
value={eavesMargin ?? 0}
// onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, eavesMargin: e.target.value } })}
- onChange={(e) => setEavesMargin(e.target.value)}
+ onChange={(e) => setEavesMargin(+e.target.value)}
/>
mm
@@ -593,7 +688,7 @@ const Trestle = forwardRef((props, ref) => {
className="input-origin block"
value={ridgeMargin ?? 0}
// onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, ridgeMargin: e.target.value } })}
- onChange={(e) => setRidgeMargin(e.target.value)}
+ onChange={(e) => setRidgeMargin(+e.target.value)}
/>
mm
@@ -606,7 +701,7 @@ const Trestle = forwardRef((props, ref) => {
className="input-origin block"
value={kerabaMargin ?? 0}
// onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, kerabaMargin: e.target.value } })}
- onChange={(e) => setKerabaMargin(e.target.value)}
+ onChange={(e) => setKerabaMargin(+e.target.value)}
/>
mm