Compare commits

...

6 Commits

9 changed files with 167 additions and 149 deletions

View File

@ -13,7 +13,7 @@ import dayjs from 'dayjs'
import { useCommonCode } from '@/hooks/common/useCommonCode' import { useCommonCode } from '@/hooks/common/useCommonCode'
import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController' import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController'
import { SessionContext } from '@/app/SessionProvider' import { SessionContext } from '@/app/SessionProvider'
import Select, {components} from 'react-select' import Select, { components } from 'react-select'
import { convertNumberToPriceDecimal, convertNumberToPriceDecimalToFixed } from '@/util/common-utils' import { convertNumberToPriceDecimal, convertNumberToPriceDecimalToFixed } from '@/util/common-utils'
import ProductFeaturesPop from './popup/ProductFeaturesPop' import ProductFeaturesPop from './popup/ProductFeaturesPop'
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
@ -504,7 +504,8 @@ export default function Estimate({}) {
saleStoreId: estimateContextState.sapSaleStoreId, saleStoreId: estimateContextState.sapSaleStoreId,
sapSalesStoreCd: estimateContextState.sapSalesStoreCd, sapSalesStoreCd: estimateContextState.sapSalesStoreCd,
docTpCd: estimateContextState.estimateType, docTpCd: estimateContextState.estimateType,
secSapSalesStoreCd:(estimateContextState.secSapSalesStoreCd?.length > 0 && showPriceCd === 'QSP_PRICE')? estimateContextState.secSapSalesStoreCd :'', secSapSalesStoreCd:
estimateContextState.secSapSalesStoreCd?.length > 0 && showPriceCd === 'QSP_PRICE' ? estimateContextState.secSapSalesStoreCd : '',
priceCd: showPriceCd, priceCd: showPriceCd,
itemIdList: estimateContextState.itemList.filter((item) => item.delFlg === '0' && item.paDispOrder === null), itemIdList: estimateContextState.itemList.filter((item) => item.delFlg === '0' && item.paDispOrder === null),
} }
@ -1220,19 +1221,17 @@ export default function Estimate({}) {
const [agencyCustList, setAgencyCustList] = useState([]) const [agencyCustList, setAgencyCustList] = useState([])
useEffect(() => { useEffect(() => {
// 952 - 2 sapSalesStoreCd // 952 - 2 sapSalesStoreCd
if(estimateContextState?.sapSalesStoreCd && session?.storeLvl === '1') { if (estimateContextState?.sapSalesStoreCd && session?.storeLvl === '1') {
const param = { const param = {
sapSalesStoreCd: estimateContextState.sapSalesStoreCd, sapSalesStoreCd: estimateContextState.sapSalesStoreCd,
} }
const apiUrl = `api/estimate/agency-cust-list?${queryStringFormatter(param)}` const apiUrl = `api/estimate/agency-cust-list?${queryStringFormatter(param)}`
get({ url: apiUrl }).then((res) => { get({ url: apiUrl }).then((res) => {
if (isNotEmptyArray(res?.data)) { if (isNotEmptyArray(res?.data)) {
setAgencyCustList(res?.data); setAgencyCustList(res?.data)
} }
}) })
} }
}, [estimateContextState?.sapSalesStoreCd]) }, [estimateContextState?.sapSalesStoreCd])
return ( return (
<div className="sub-content estimate"> <div className="sub-content estimate">
@ -1381,11 +1380,16 @@ export default function Estimate({}) {
<div className="form-flex-wrap"> <div className="form-flex-wrap">
<div className="radio-wrap"> <div className="radio-wrap">
{/*pkgRank is null, empty 인 경우 : 사용불가, 이전에 등록된 경우 사용가능, style로 제어*/} {/*pkgRank is null, empty 인 경우 : 사용불가, 이전에 등록된 경우 사용가능, style로 제어*/}
<div className="d-check-radio light mr10" style={{display: <div
(isNotEmptyArray(storePriceList) > 0 className="d-check-radio light mr10"
&& storePriceList[0].pkgRank !== null style={{
&& storePriceList[0].pkgRank !== '' display:
|| estimateContextState?.estimateType === 'YJSS') ? "" : "none"}}> (isNotEmptyArray(storePriceList) > 0 && storePriceList[0].pkgRank !== null && storePriceList[0].pkgRank !== '') ||
estimateContextState?.estimateType === 'YJSS'
? ''
: 'none',
}}
>
<input <input
type="radio" type="radio"
name="estimateType" name="estimateType"
@ -1415,35 +1419,37 @@ export default function Estimate({}) {
<label htmlFor="YJOD">{getMessage('estimate.detail.estimateType.yjod')}</label> <label htmlFor="YJOD">{getMessage('estimate.detail.estimateType.yjod')}</label>
</div> </div>
</div> </div>
{ (session?.storeLvl === '1' && agencyCustList.length > 0 )? ( {session?.storeLvl === '1' && agencyCustList.length > 0 ? (
<div className="form-flex-select ml10"> <div className="form-flex-select ml10">
<label htmlFor="">{getMessage('estimate.detail.agency')}</label> <label htmlFor="">{getMessage('estimate.detail.agency')}</label>
<div className="select-wrap" style={{ width: '400px' }}> <div className="select-wrap" style={{ width: '400px' }}>
<Select <Select
id="agencyName" id="agencyName"
instanceId="agencyName" instanceId="agencyName"
className="react-select-custom" className="react-select-custom"
classNamePrefix="custom" classNamePrefix="custom"
placeholder="Select" placeholder="Select"
options={agencyCustList} options={agencyCustList}
onChange={(e) => { onChange={(e) => {
if (isObjectNotEmpty(e)) { if (isObjectNotEmpty(e)) {
setEstimateContextState({ secSapSalesStoreCd: e.sapSalesStoreCd }) setEstimateContextState({ secSapSalesStoreCd: e.sapSalesStoreCd })
} else { } else {
setEstimateContextState({ secSapSalesStoreCd: '' }) setEstimateContextState({ secSapSalesStoreCd: '' })
} }
}} }}
getOptionLabel={(x) => x.sapSalesStoreNm} getOptionLabel={(x) => x.sapSalesStoreNm}
getOptionValue={(x) => x.sapSalesStoreCd} getOptionValue={(x) => x.sapSalesStoreCd}
isClearable={true} isClearable={true}
isSearchable={true} isSearchable={true}
value={agencyCustList.filter(function (option) { value={agencyCustList.filter(function (option) {
return option.sapSalesStoreCd === estimateContextState.secSapSalesStoreCd return option.sapSalesStoreCd === estimateContextState.secSapSalesStoreCd
})} })}
/> />
</div> </div>
</div> </div>
) : ('')} ) : (
''
)}
</div> </div>
</td> </td>
</tr> </tr>
@ -1932,16 +1938,12 @@ export default function Estimate({}) {
} }
}} }}
menuPlacement={'auto'} menuPlacement={'auto'}
getOptionLabel={(x) => x.itemName + " (" + x.itemNo + ")"} getOptionLabel={(x) => x.itemName + ' (' + x.itemNo + ')'}
getOptionValue={(x) => x.itemNo} getOptionValue={(x) => x.itemNo}
components={{ components={{
SingleValue:({children, ...props}) =>{ SingleValue: ({ children, ...props }) => {
return ( return <components.SingleValue {...props}>{props.data.itemName}</components.SingleValue>
<components.SingleValue{...props}> },
{props.data.itemName}
</components.SingleValue>
)
}
}} }}
isClearable={false} isClearable={false}
isDisabled={!!item?.paDispOrder} isDisabled={!!item?.paDispOrder}
@ -1962,16 +1964,12 @@ export default function Estimate({}) {
placeholder="Select" placeholder="Select"
options={cableItemList} options={cableItemList}
menuPlacement={'auto'} menuPlacement={'auto'}
getOptionLabel={(x) => x.clRefChr3 + " (" + x.clRefChr1 + ")"} getOptionLabel={(x) => x.clRefChr3 + ' (' + x.clRefChr1 + ')'}
getOptionValue={(x) => x.clRefChr1} getOptionValue={(x) => x.clRefChr1}
components={{ components={{
SingleValue:({children, ...props}) =>{ SingleValue: ({ children, ...props }) => {
return ( return <components.SingleValue {...props}>{props.data.clRefChr3}</components.SingleValue>
<components.SingleValue{...props}> },
{props.data.clRefChr3}
</components.SingleValue>
)
}
}} }}
isClearable={false} isClearable={false}
isDisabled={true} isDisabled={true}
@ -2027,7 +2025,11 @@ export default function Estimate({}) {
<input <input
type="text" type="text"
className="input-light al-r" className="input-light al-r"
value={convertNumberToPriceDecimal(item?.showSalePrice === '0' ? null : item?.salePrice?.replaceAll(',', ''))} value={
item.openFlg === '1'
? 'OPEN'
: convertNumberToPriceDecimal(item?.showSalePrice === '0' ? null : item?.salePrice?.replaceAll(',', ''))
}
disabled={ disabled={
item.openFlg === '1' item.openFlg === '1'
? true ? true

View File

@ -84,6 +84,18 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
useModuleBasicSetting(tabNum) useModuleBasicSetting(tabNum)
const { updateObjectDate } = useMasterController() const { updateObjectDate } = useMasterController()
useEffect(() => {
let hasModules = canvas
.getObjects()
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
.some((obj) => obj.modules?.length > 0)
if (hasModules) {
orientationRef.current.handleNextStep()
setTabNum(3)
}
}, [])
useEffect(() => { useEffect(() => {
if (roofsStore && addedRoofs) { if (roofsStore && addedRoofs) {
setRoofs( setRoofs(
@ -113,18 +125,6 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
} }
}, [roofsStore, addedRoofs]) }, [roofsStore, addedRoofs])
useEffect(() => {
let hasModules = canvas
.getObjects()
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
.some((obj) => obj.modules?.length > 0)
if (hasModules) {
orientationRef.current.handleNextStep()
setTabNum(3)
}
}, [])
useEffect(() => { useEffect(() => {
if (basicSetting.roofSizeSet !== '3') { if (basicSetting.roofSizeSet !== '3') {
manualModuleSetup() manualModuleSetup()
@ -144,18 +144,10 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
if (tabNum === 1) { if (tabNum === 1) {
orientationRef.current.handleNextStep() orientationRef.current.handleNextStep()
setAddedRoofs(roofs) setAddedRoofs(roofs)
setTabNum(tabNum + 1) // setTabNum(tabNum + 1)
return return
} else if (tabNum === 2) { } else if (tabNum === 2) {
if (basicSetting.roofSizeSet !== '3') { if (basicSetting.roofSizeSet !== '3') {
if (!isObjectNotEmpty(moduleSelectionData.module)) {
Swal.fire({
title: getMessage('module.not.found'),
icon: 'warning',
})
return
}
// if (addedRoofs.length !== moduleSelectionData.roofConstructions.length) { // if (addedRoofs.length !== moduleSelectionData.roofConstructions.length) {
// Swal.fire({ // Swal.fire({
// title: getMessage('construction.length.difference'), // title: getMessage('construction.length.difference'),

View File

@ -9,6 +9,7 @@ import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import QSelectBox from '@/components/common/select/QSelectBox' import QSelectBox from '@/components/common/select/QSelectBox'
import { moduleSelectionDataState } from '@/store/selectedModuleOptions' import { moduleSelectionDataState } from '@/store/selectedModuleOptions'
import { roofsState } from '@/store/roofAtom' import { roofsState } from '@/store/roofAtom'
import Swal from 'sweetalert2'
export const Orientation = forwardRef((props, ref) => { export const Orientation = forwardRef((props, ref) => {
const { getMessage } = useMessage() const { getMessage } = useMessage()
@ -50,6 +51,7 @@ export const Orientation = forwardRef((props, ref) => {
} = props } = props
const [inputCompasDeg, setInputCompasDeg] = useState(compasDeg ?? 0) const [inputCompasDeg, setInputCompasDeg] = useState(compasDeg ?? 0)
const [inputInstallHeight, setInputInstallHeight] = useState('0') const [inputInstallHeight, setInputInstallHeight] = useState('0')
const [inputMargin, setInputMargin] = useState('0')
const [inputVerticalSnowCover, setInputVerticalSnowCover] = useState('0') const [inputVerticalSnowCover, setInputVerticalSnowCover] = useState('0')
const [inputRoughness, setInputRoughness] = useState(selectedSurfaceType) const [inputRoughness, setInputRoughness] = useState(selectedSurfaceType)
const [inputStandardWindSpeed, setInputStandardWindSpeed] = useState(standardWindSpeed) const [inputStandardWindSpeed, setInputStandardWindSpeed] = useState(standardWindSpeed)
@ -92,7 +94,7 @@ export const Orientation = forwardRef((props, ref) => {
useEffect(() => { useEffect(() => {
if (addedRoofs) { if (addedRoofs) {
setRoofs(addedRoofs) // setRoofs(addedRoofs)
// setAddedRoofs(roofsStore) // setAddedRoofs(roofsStore)
} }
}, [addedRoofs]) }, [addedRoofs])
@ -112,6 +114,7 @@ export const Orientation = forwardRef((props, ref) => {
saleStoreNorthFlg: managementState?.saleStoreNorthFlg, saleStoreNorthFlg: managementState?.saleStoreNorthFlg,
moduleTpCd: selectedModules.itemTp, moduleTpCd: selectedModules.itemTp,
moduleItemId: selectedModules.itemId, moduleItemId: selectedModules.itemId,
margin: inputMargin,
} }
setCompasDeg(inputCompasDeg) setCompasDeg(inputCompasDeg)
setInstallHeight(inputInstallHeight) setInstallHeight(inputInstallHeight)
@ -150,6 +153,14 @@ export const Orientation = forwardRef((props, ref) => {
userId: loginUserState.userId, // userId: loginUserState.userId, //
}) })
setTabNum(2) setTabNum(2)
} else {
if (!selectedModules || !selectedModules.itemId) {
Swal.fire({
title: getMessage('module.not.found'),
icon: 'warning',
})
return
}
} }
} }
@ -172,7 +183,7 @@ export const Orientation = forwardRef((props, ref) => {
} }
const isComplete = () => { const isComplete = () => {
if (!selectedModules) return false if (!selectedModules || !selectedModules.itemId) return false
if (basicSetting && basicSetting.roofSizeSet !== '3') { if (basicSetting && basicSetting.roofSizeSet !== '3') {
if (inputInstallHeight <= 0) { if (inputInstallHeight <= 0) {
return false return false
@ -373,23 +384,18 @@ export const Orientation = forwardRef((props, ref) => {
</tbody> </tbody>
</table> </table>
</div> </div>
{basicSetting && basicSetting.roofSizeSet === '3' && ( {basicSetting && basicSetting.roofSizeSet == '3' && (
<div className="outline-form mt15"> <div className="outline-form mt15">
<span>{getMessage('modal.module.basic.setting.module.placement.area')}</span> <span>{getMessage('modal.module.basic.setting.module.placement.area')}</span>
<div className="input-grid mr10" style={{ width: '60px' }}> <div className="input-grid mr10" style={{ width: '60px' }}>
<input <input type="text" className="input-origin block" value={inputMargin} onChange={(e) => setInputMargin(e.target.value)} />
type="text"
className="input-origin block"
value={inputInstallHeight}
onChange={(e) => setInputInstallHeight(e.target.value)}
/>
</div> </div>
<span className="thin">m</span> <span className="thin">m</span>
</div> </div>
)} )}
</div> </div>
{basicSetting && basicSetting.roofSizeSet !== '3' && ( {basicSetting && basicSetting.roofSizeSet != '3' && (
<div className="compas-table-box"> <div className="compas-table-box">
<div className="compas-grid-table"> <div className="compas-grid-table">
<div className="outline-form"> <div className="outline-form">

View File

@ -266,6 +266,8 @@ const Trestle = forwardRef((props, ref) => {
} }
const isComplete = async () => { const isComplete = async () => {
console.log('roofs', roofs)
const newAddedRoofs = roofs.map((roof, i) => { const newAddedRoofs = roofs.map((roof, i) => {
if (i === selectedRoof?.index) { if (i === selectedRoof?.index) {
return { return {
@ -291,6 +293,7 @@ const Trestle = forwardRef((props, ref) => {
}) })
let result = true let result = true
console.log('newAddedRoofs', newAddedRoofs)
newAddedRoofs.forEach((roof) => { newAddedRoofs.forEach((roof) => {
if (!roof?.eavesMargin || !roof?.ridgeMargin || !roof?.kerabaMargin) result = false if (!roof?.eavesMargin || !roof?.ridgeMargin || !roof?.kerabaMargin) result = false
if (!roof.trestle?.trestleMkrCd) result = false if (!roof.trestle?.trestleMkrCd) result = false

View File

@ -91,16 +91,10 @@ export function useModuleBasicSetting(tabNum) {
const roofConstructions = moduleSelectionData.roofConstructions const roofConstructions = moduleSelectionData.roofConstructions
if (roofConstructions && roofConstructions.length > 0) { if (roofConstructions && roofConstructions.length > 0) {
const listParams = roofConstructions.map((item) => { //roofIndex 넣기
return { const roofConstructionArray = roofConstructions.map((detail) => ({ ...detail.trestleDetail, roofIndex: detail.roofIndex }))
...common,
...item.addRoof, setTrestleDetailList(roofConstructionArray)
...item.trestle,
roofPitch: item.addRoof.hajebichi ? item.addRoof.hajebichi : 0,
inclCd: String(item.addRoof.pitch),
}
})
setTrestleDetailParams(listParams)
//북면 설치 가능 판매점 //북면 설치 가능 판매점
if (moduleSelectionData.common.saleStoreNorthFlg === '1') { if (moduleSelectionData.common.saleStoreNorthFlg === '1') {
@ -119,23 +113,10 @@ export function useModuleBasicSetting(tabNum) {
} }
} }
//가대 상세 데이터 조회
const getTrestleDetailListData = async () => {
const trestleDetailList = await getTrestleDetailList(trestleDetailParams)
if (trestleDetailList.length > 0) {
setTrestleDetailList(trestleDetailList)
}
}
//가대 상세 데이터 파라메터 담기면 실행
useEffect(() => {
if (trestleDetailParams.length > 0) {
getTrestleDetailListData(trestleDetailParams)
}
}, [trestleDetailParams])
//가대 상세 데이터 들어오면 실행 //가대 상세 데이터 들어오면 실행
useEffect(() => { useEffect(() => {
console.log('trestleDetailList', trestleDetailList)
if (trestleDetailList.length > 0) { if (trestleDetailList.length > 0) {
let rowColArray = [] let rowColArray = []
//지붕을 가져옴 //지붕을 가져옴
@ -147,11 +128,11 @@ export function useModuleBasicSetting(tabNum) {
const roofIndex = roof.roofMaterial.index //지붕의 지붕재의 순번 const roofIndex = roof.roofMaterial.index //지붕의 지붕재의 순번
trestleDetailList.forEach((detail) => { trestleDetailList.forEach((detail) => {
if (detail.data !== null) { if (isObjectNotEmpty(detail)) {
if (Number(detail.data.roofIndex) === roofIndex) { if (Number(detail.roofIndex) === roofIndex) {
//roof에 상세 데이터 추가 //roof에 상세 데이터 추가
roof.set({ roof.set({
trestleDetail: detail.data, trestleDetail: detail,
stroke: roofOutlineColor(roofIndex), stroke: roofOutlineColor(roofIndex),
strokeWidth: 7, strokeWidth: 7,
}) })
@ -162,7 +143,7 @@ export function useModuleBasicSetting(tabNum) {
line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line.attributes.type) } line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line.attributes.type) }
}) })
//배치면 설치 영역 //배치면 설치 영역
makeModuleInstArea(roof, detail.data) makeModuleInstArea(roof, detail)
} }
} }
}) })
@ -170,8 +151,8 @@ export function useModuleBasicSetting(tabNum) {
trestleDetailList.forEach((detail) => { trestleDetailList.forEach((detail) => {
const moduleRowArray = [] const moduleRowArray = []
if (detail.data !== null && detail.data.module.length > 0) { if (isObjectNotEmpty(detail) && detail.module.length > 0) {
detail.data.module.forEach((module) => { detail.module.forEach((module) => {
moduleRowArray.push({ moduleMaxRows: module.moduleMaxRows, mixModuleMaxRows: module.mixModuleMaxRows }) moduleRowArray.push({ moduleMaxRows: module.moduleMaxRows, mixModuleMaxRows: module.mixModuleMaxRows })
}) })
} }
@ -407,6 +388,8 @@ export function useModuleBasicSetting(tabNum) {
//모듈,회로에서 다른메뉴 -> 배치면으로 갈 경수 초기화 //모듈,회로에서 다른메뉴 -> 배치면으로 갈 경수 초기화
const restoreModuleInstArea = () => { const restoreModuleInstArea = () => {
console.log('tabnum', tabNum)
//설치면 삭제 //설치면 삭제
const setupArea = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE || obj.name === POLYGON_TYPE.OBJECT_SURFACE) const setupArea = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE || obj.name === POLYGON_TYPE.OBJECT_SURFACE)

View File

@ -96,7 +96,7 @@ export function useModuleSelection(props) {
getModuleData(roofsIds) getModuleData(roofsIds)
//모듈설치면 초기화 //모듈설치면 초기화
restoreModuleInstArea() // restoreModuleInstArea()
resetStatisticsData() resetStatisticsData()
}, []) }, [])

View File

@ -2,8 +2,9 @@ import { use, useContext, useEffect, useReducer, useState } from 'react'
import { useCommonCode } from '../common/useCommonCode' import { useCommonCode } from '../common/useCommonCode'
import { useMasterController } from '../common/useMasterController' import { useMasterController } from '../common/useMasterController'
import { selectedModuleState } from '@/store/selectedModuleOptions' import { selectedModuleState } from '@/store/selectedModuleOptions'
import { useRecoilValue } from 'recoil' import { useRecoilState, useRecoilValue } from 'recoil'
import { GlobalDataContext } from '@/app/GlobalDataProvider' import { GlobalDataContext } from '@/app/GlobalDataProvider'
import { popSpinnerState } from '@/store/popupAtom'
const RAFT_BASE_CODE = '203800' const RAFT_BASE_CODE = '203800'
@ -62,6 +63,7 @@ export function useModuleTrestle(props) {
const [kerabaMargin, setKerabaMargin] = useState(0) const [kerabaMargin, setKerabaMargin] = useState(0)
const [trestleState, dispatch] = useReducer(trestleReducer, null) const [trestleState, dispatch] = useReducer(trestleReducer, null)
const [trestleDetail, setTrestleDetail] = useState(null) const [trestleDetail, setTrestleDetail] = useState(null)
const [popSpinnerStore, setPopSpinnerStore] = useRecoilState(popSpinnerState)
useEffect(() => { useEffect(() => {
const raftCodeList = findCommonCode(RAFT_BASE_CODE) const raftCodeList = findCommonCode(RAFT_BASE_CODE)
@ -120,39 +122,58 @@ export function useModuleTrestle(props) {
}, [trestleState]) }, [trestleState])
const handleSetTrestleList = () => { const handleSetTrestleList = () => {
setPopSpinnerStore(true)
getTrestleList({ getTrestleList({
moduleTpCd: trestleState?.moduleTpCd ?? '', moduleTpCd: trestleState?.moduleTpCd ?? '',
roofMatlCd: trestleState?.roofMatlCd ?? '', roofMatlCd: trestleState?.roofMatlCd ?? '',
raftBaseCd: trestleState?.raftBaseCd ?? '', raftBaseCd: trestleState?.raftBaseCd ?? '',
}).then((res) => {
if (res?.data) setTrestleList(res.data)
}) })
.then((res) => {
if (res?.data) setTrestleList(res.data)
setPopSpinnerStore(false)
})
.catch((e) => {
setPopSpinnerStore(false)
})
} }
const handleSetConstMthdList = () => { const handleSetConstMthdList = () => {
setPopSpinnerStore(true)
getTrestleList({ getTrestleList({
moduleTpCd: trestleState?.moduleTpCd ?? '', moduleTpCd: trestleState?.moduleTpCd ?? '',
roofMatlCd: trestleState?.roofMatlCd ?? '', roofMatlCd: trestleState?.roofMatlCd ?? '',
raftBaseCd: trestleState?.raftBaseCd ?? '', raftBaseCd: trestleState?.raftBaseCd ?? '',
trestleMkrCd: trestleState?.trestleMkrCd ?? '', trestleMkrCd: trestleState?.trestleMkrCd ?? '',
}).then((res) => {
if (res?.data) setConstMthdList(res.data)
}) })
.then((res) => {
if (res?.data) setConstMthdList(res.data)
setPopSpinnerStore(false)
})
.catch((e) => {
setPopSpinnerStore(false)
})
} }
const handleSetRoofBaseList = () => { const handleSetRoofBaseList = () => {
setPopSpinnerStore(true)
getTrestleList({ getTrestleList({
moduleTpCd: trestleState?.moduleTpCd ?? '', moduleTpCd: trestleState?.moduleTpCd ?? '',
roofMatlCd: trestleState?.roofMatlCd ?? '', roofMatlCd: trestleState?.roofMatlCd ?? '',
raftBaseCd: trestleState?.raftBaseCd ?? '', raftBaseCd: trestleState?.raftBaseCd ?? '',
trestleMkrCd: trestleState?.trestleMkrCd ?? '', trestleMkrCd: trestleState?.trestleMkrCd ?? '',
constMthdCd: trestleState?.constMthdCd ?? '', constMthdCd: trestleState?.constMthdCd ?? '',
}).then((res) => {
if (res?.data) setRoofBaseList(res.data)
}) })
.then((res) => {
if (res?.data) setRoofBaseList(res.data)
setPopSpinnerStore(false)
})
.catch((e) => {
setPopSpinnerStore(false)
})
} }
const handleSetConstructionList = () => { const handleSetConstructionList = () => {
setPopSpinnerStore(true)
getConstructionList({ getConstructionList({
moduleTpCd: trestleState?.moduleTpCd ?? '', moduleTpCd: trestleState?.moduleTpCd ?? '',
roofMatlCd: trestleState?.roofMatlCd ?? '', roofMatlCd: trestleState?.roofMatlCd ?? '',
@ -166,12 +187,18 @@ export function useModuleTrestle(props) {
inclCd: trestleState.inclCd ?? '', inclCd: trestleState.inclCd ?? '',
raftBaseCd: trestleState.raftBaseCd ?? '', raftBaseCd: trestleState.raftBaseCd ?? '',
roofPitch: Math.round(trestleState.roofPitch) ?? '', roofPitch: Math.round(trestleState.roofPitch) ?? '',
}).then((res) => {
if (res?.data) setConstructionList(res.data)
}) })
.then((res) => {
if (res?.data) setConstructionList(res.data)
setPopSpinnerStore(false)
})
.catch((e) => {
setPopSpinnerStore(false)
})
} }
const handleSetTrestleDetailData = () => { const handleSetTrestleDetailData = () => {
setPopSpinnerStore(true)
getTrestleDetailList([ getTrestleDetailList([
{ {
moduleTpCd: trestleState.moduleTpCd ?? '', moduleTpCd: trestleState.moduleTpCd ?? '',
@ -189,24 +216,29 @@ export function useModuleTrestle(props) {
roofPitch: trestleState.roofPitch ?? '', roofPitch: trestleState.roofPitch ?? '',
workingWidth: trestleState.workingWidth ?? '', workingWidth: trestleState.workingWidth ?? '',
}, },
]).then((res) => { ])
if (res.length > 0) { .then((res) => {
if (!res[0].data) return if (res.length > 0) {
setEavesMargin(res[0].data.eaveIntvl) if (!res[0].data) return
setRidgeMargin(res[0].data.ridgeIntvl) setEavesMargin(res[0].data.eaveIntvl)
setKerabaMargin(res[0].data.kerabaIntvl) setRidgeMargin(res[0].data.ridgeIntvl)
setTrestleDetail(res[0].data) setKerabaMargin(res[0].data.kerabaIntvl)
// dispatch({ setTrestleDetail(res[0].data)
// type: 'SET_TRESTLE_DETAIL', // dispatch({
// roof: { // type: 'SET_TRESTLE_DETAIL',
// ...trestleState, // roof: {
// eavesMargin: res[0].data.eaveIntvl, // ...trestleState,
// ridgeMargin: res[0].data.ridgeIntvl, // eavesMargin: res[0].data.eaveIntvl,
// kerabaMargin: res[0].data.kerabaIntvl, // ridgeMargin: res[0].data.ridgeIntvl,
// }, // kerabaMargin: res[0].data.kerabaIntvl,
// }) // },
} // })
}) }
setPopSpinnerStore(false)
})
.catch((e) => {
setPopSpinnerStore(false)
})
} }
return { return {

View File

@ -31,7 +31,7 @@ export function useCircuitTrestle(executeEffect = false) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
useEffect(() => { useEffect(() => {
if (Object.keys(selectedModules).length > 0 && executeEffect) setModuleStatisticsData() if (selectedModules && Object.keys(selectedModules).length > 0 && executeEffect) setModuleStatisticsData()
}, [selectedModules]) }, [selectedModules])
const getOptYn = () => { const getOptYn = () => {

View File

@ -2,7 +2,7 @@ import { atom } from 'recoil'
export const selectedModuleState = atom({ export const selectedModuleState = atom({
key: 'selectedModuleState', key: 'selectedModuleState',
default: [], default: null,
dangerouslyAllowMutability: true, dangerouslyAllowMutability: true,
}) })