견적서 데이터 만들기 작업중
This commit is contained in:
parent
1edcdb84dc
commit
d0126343b9
@ -1,16 +1,18 @@
|
||||
import { useRecoilValue } from 'recoil'
|
||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||
import { canvasState } 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 apply = () => {
|
||||
//처마력바가 체크되어 있는 경우 exposedBottomPoints를 이용해 처마력바 그려줘야함.
|
||||
@ -54,6 +56,10 @@ export const useTrestle = () => {
|
||||
})
|
||||
|
||||
const result = calculateForApi(surface)
|
||||
|
||||
if (!result) {
|
||||
return
|
||||
}
|
||||
const centerPoints = result.centerPoints
|
||||
|
||||
const exposedBottomModules = [] // 아래 두면이 모두 노출 되어있는 경우
|
||||
@ -439,16 +445,50 @@ export const useTrestle = () => {
|
||||
const quotationParam = getTrestleParams(surface)
|
||||
|
||||
surface.set({ quotationParam })
|
||||
getQuoationItems()
|
||||
})
|
||||
setQuoationItem()
|
||||
}
|
||||
|
||||
// itemList 조회 후 estimateParam에 저장
|
||||
const setQuoationItem = () => {
|
||||
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||
//surfaces.pcses들을 배열로 묶는다
|
||||
const pcses = surfaces[0].pcses
|
||||
surfaces.forEach((surface, index) => {
|
||||
if (index !== 0) {
|
||||
pcses.concat(surface.pcses)
|
||||
}
|
||||
})
|
||||
const params = { trestles: surfaces.map((surface) => surface.quotationParam), pcses }
|
||||
//견적서 itemList 조회
|
||||
getQuotationItem(params).then((res) => {
|
||||
if (!res.data) {
|
||||
return
|
||||
}
|
||||
const itemList = res.data
|
||||
//northArrangement 북면 설치 여부
|
||||
const northArrangement = getNorthArrangement()
|
||||
|
||||
setEstimateParam({ ...estimateParam, itemList, northArrangement })
|
||||
})
|
||||
}
|
||||
|
||||
const getQuoationItems = () => {
|
||||
const getNorthArrangement = () => {
|
||||
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||
const params = { trestles: surfaces.map((surface) => surface.quotationParam), pcses: surfaces[0].pcses ?? [] }
|
||||
getQuotationItem(params).then((res) => {
|
||||
console.log('res', res)
|
||||
let northArrangement = '0'
|
||||
|
||||
surfaces.forEach((surface) => {
|
||||
const parent = canvas.getObjects().find((obj) => obj.id === surface.parentId)
|
||||
const directionText = parent.directionText
|
||||
// ['西北西','東北東'] 의 경우를 제외하고는 北이 들어간 경우 전부 북면으로 간주
|
||||
if (directionText.includes('北') && !directionText.includes('西北西') && !directionText.includes('東北東')) {
|
||||
if (surface.modules.length > 0) {
|
||||
northArrangement = '1'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return northArrangement
|
||||
}
|
||||
|
||||
const findNextModule = (currentPoint, centerPoints, direction) => {
|
||||
|
||||
23
src/store/estimateAtom.js
Normal file
23
src/store/estimateAtom.js
Normal file
@ -0,0 +1,23 @@
|
||||
import { atom } from 'recoil'
|
||||
|
||||
export const estimateParamAtom = atom({
|
||||
// 견적서 post parameter
|
||||
key: 'estimateParamAtom',
|
||||
default: {
|
||||
saleStoreId: '',
|
||||
objectNo: '',
|
||||
planNo: '',
|
||||
slope: '',
|
||||
angle: '',
|
||||
surfaceType: '',
|
||||
setupHeight: '',
|
||||
standardWindSpeedId: '',
|
||||
snowfall: '',
|
||||
northArrangement: '',
|
||||
drawingFlg: '',
|
||||
userId: '',
|
||||
roofSurfaceList: [],
|
||||
circuitItemList: [],
|
||||
itemList: [],
|
||||
},
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user