validation 방식 수정
This commit is contained in:
parent
ed721f36d0
commit
4c219ddce9
@ -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 {
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
if (result) {
|
||||
|
||||
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)}
|
||||
/>
|
||||
</div>
|
||||
<span className="thin">mm</span>
|
||||
@ -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)}
|
||||
/>
|
||||
</div>
|
||||
<span className="thin">mm</span>
|
||||
@ -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)}
|
||||
/>
|
||||
</div>
|
||||
<span className="thin">mm</span>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user