diff --git a/src/hooks/common/useMasterController.js b/src/hooks/common/useMasterController.js index 21220726..dae68c69 100644 --- a/src/hooks/common/useMasterController.js +++ b/src/hooks/common/useMasterController.js @@ -212,9 +212,14 @@ export function useMasterController() { } const getQuotationItem = async (params) => { - return await post({ url: '/api/v1/master/getQuotationItem', data: params }).then((res) => { - return res - }) + return await post({ url: '/api/v1/master/getQuotationItem', data: params }) + .then((res) => { + return res + }) + .catch((error) => { + console.log('๐Ÿš€ ~ getQuotationItem ~ error:', error) + setIsGlobalLoading(false) + }) } /** diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index 0aea8bfc..643b8e03 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -53,6 +53,7 @@ export const useTrestle = () => { } }) surfaces.forEach((surface) => { + getSameLineModules(surface) const parent = canvas.getObjects().find((obj) => obj.id === surface.parentId) const roofMaterialIndex = parent.roofMaterial.index if (+roofSizeSet === 3) { @@ -67,6 +68,7 @@ export const useTrestle = () => { let moduleRowsTotCnt = 0 let isEaveBar = construction.setupCover let isSnowGuard = construction.setupSnowCover + let cvrLmtRow = construction.cvrLmtRow const direction = parent.direction const rack = surface.trestleDetail.rack let { rackQty, rackIntvlPct, rackYn, cvrPlvrYn, lessSupFitIntvlPct, lessSupFitQty } = surface.trestleDetail @@ -149,6 +151,10 @@ export const useTrestle = () => { if (isEaveBar) { // ์ฒ˜๋งˆ๋ ฅ๋ฐ”์„ค์น˜ true์ธ ๊ฒฝ์šฐ ์„ค์น˜ exposedBottomModules.forEach((module) => { + const level = module.level + if (level > cvrLmtRow) { + return + } const bottomPoints = findTopTwoPoints([...module.getCurrentPoints()], direction) if (!bottomPoints) return const eaveBar = new fabric.Line([bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y], { @@ -167,6 +173,10 @@ export const useTrestle = () => { if (isChidory && cvrPlvrYn === 'Y') { leftExposedHalfBottomModules.forEach((module) => { + const level = module.level + if (level > cvrLmtRow) { + return + } const bottomPoints = findTopTwoPoints([...module.getCurrentPoints()], direction) let barPoints = [] //์„ค์น˜ํ•ด์•ผํ•  ๋ฐ˜์ฒ˜๋งˆ์ปค๋ฒ„ ํฌ์ธํŠธ๋ฅผ ๋ฐฉํ–ฅ์— ๋”ฐ๋ผ ์„ค์ • @@ -197,6 +207,10 @@ export const useTrestle = () => { }) rightExposedHalfBottomPoints.forEach((module) => { + const level = module.level + if (level > cvrLmtRow) { + return + } const bottomPoints = findTopTwoPoints([...module.points], direction) let barPoints = [] //์„ค์น˜ํ•ด์•ผํ•  ๋ฐ˜์ฒ˜๋งˆ์ปค๋ฒ„ ํฌ์ธํŠธ๋ฅผ ๋ฐฉํ–ฅ์— ๋”ฐ๋ผ ์„ค์ • @@ -1059,7 +1073,8 @@ export const useTrestle = () => { const roof = canvas.getObjects().find((obj) => obj.id === surface.parentId) const degree = getDegreeByChon(roof.roofMaterial.pitch) - + rackIntvlPct = rackIntvlPct === 0 ? 1 : rackIntvlPct // 0์ธ ๊ฒฝ์šฐ 1๋กœ ๋ณ€๊ฒฝ + rackIntvlPct = 100 / rackIntvlPct // ํผ์„ผํŠธ๋กœ ๋ณ€๊ฒฝ const moduleLeft = lastX ?? left const moduleTop = lastY ?? top @@ -1573,7 +1588,9 @@ export const useTrestle = () => { drawBracketWithOutRack(module, rackIntvlPct, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer) if (rackQty === 3 && !findSamePointInBottom(exposedBottomModules, module)) { // ํ•ด๋‹น ๋ชจ๋“ˆ๊ณผ ๊ฐ™์€ ์œ„์น˜ ๋งจ ์•„๋ž˜์— ๋ชจ๋“ˆ์ด ์—†๋Š” ๊ฒฝ์šฐ ํ•˜๋‚˜ ๋” ์„ค์น˜ ํ•„์š” - drawBracketWithOutRack(module, rackIntvlPct / 3, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer) + if (module.level % 2 !== 0) { + drawBracketWithOutRack(module, rackIntvlPct / 3, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer) + } } if (rackQty === 4) { drawBracketWithOutRack(module, rackIntvlPct / 3, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer) @@ -1581,10 +1598,13 @@ export const useTrestle = () => { }) rightExposedHalfBottomPoints.forEach((module) => { + console.log('rightmodule.level', module.level) drawBracketWithOutRack(module, rackIntvlPct, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) if (rackQty === 3 && !findSamePointInBottom(exposedBottomModules, module, direction)) { // ํ•ด๋‹น ๋ชจ๋“ˆ๊ณผ ๊ฐ™์€ ์œ„์น˜ ๋งจ ์•„๋ž˜์— ๋ชจ๋“ˆ์ด ์—†๋Š” ๊ฒฝ์šฐ ํ•˜๋‚˜ ๋” ์„ค์น˜ ํ•„์š” - drawBracketWithOutRack(module, rackIntvlPct / 3, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) + if (module.level % 2 === 0) { + drawBracketWithOutRack(module, rackIntvlPct / 3, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) + } } if (rackQty === 4) { drawBracketWithOutRack(module, rackIntvlPct / 3, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) @@ -2545,23 +2565,11 @@ export const useTrestle = () => { return result } - // ๊ฐ€์žฅ ์™ผ์ชฝ์— ์žˆ๋Š” ๋ชจ๋“ˆ์„ ๊ธฐ์ค€์œผ๋กœ ๊ฐ™์€ ๋‹จ์— ์žˆ๋Š” ๋ชจ๋“ˆ๋“ค ํŒŒ๋ผ๋ฏธํ„ฐ ์ƒ์„ฑ - const getMostLeftModules = (surface, exposedBottomModules) => { + const getSameLineModules = (surface) => { const { direction, modules, isChidory } = surface - const parent = canvas.getObjects().find((obj) => obj.id === surface.parentId) - const roofMaterialIndex = parent.roofMaterial.index - const construction = moduleSelectionData?.roofConstructions?.find((construction) => construction.roofIndex === roofMaterialIndex).construction - let isEaveBar = construction.setupCover - let isSnowGuard = construction.setupSnowCover - let { rackYn, cvrPlvrYn, moduleIntvlHor, moduleIntvlVer, rackQty, lessSupFitQty } = surface.trestleDetail - - if (rackYn === 'N') { - rackQty = lessSupFitQty - } // ๊ฐ™์€ ๋‹จ์— ์žˆ๋Š” ๋ชจ๋“ˆ๋“ค์˜ ๋ฆฌ์ŠคํŠธ let sameLineModuleList = [] - let result = [] if (direction === 'south') { // ๋ชจ๋“ˆ์˜ top์œผ๋กœ groupBy @@ -2612,9 +2620,34 @@ export const useTrestle = () => { sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => a[0].left - b[0].left) } + sameLineModuleList.forEach((modules, index) => { + modules.forEach((module) => { + module.set({ level: index + 1 }) // ๊ฐ ๋ชจ๋“ˆ์— level ์†์„ฑ ์ถ”๊ฐ€ + }) + }) + + return sameLineModuleList + } + + // ๊ฐ€์žฅ ์™ผ์ชฝ์— ์žˆ๋Š” ๋ชจ๋“ˆ์„ ๊ธฐ์ค€์œผ๋กœ ๊ฐ™์€ ๋‹จ์— ์žˆ๋Š” ๋ชจ๋“ˆ๋“ค ํŒŒ๋ผ๋ฏธํ„ฐ ์ƒ์„ฑ + const getMostLeftModules = (surface, exposedBottomModules) => { + const { direction, modules, isChidory } = surface + const parent = canvas.getObjects().find((obj) => obj.id === surface.parentId) + const roofMaterialIndex = parent.roofMaterial.index + const construction = moduleSelectionData?.roofConstructions?.find((construction) => construction.roofIndex === roofMaterialIndex).construction + let isEaveBar = construction.setupCover + let isSnowGuard = construction.setupSnowCover + let cvrLmtRow = construction.cvrLmtRow + let { rackYn, cvrPlvrYn, moduleIntvlHor, moduleIntvlVer, rackQty, lessSupFitQty } = surface.trestleDetail + let result = [] + if (rackYn === 'N') { + rackQty = lessSupFitQty + } + const sameLineModuleList = getSameLineModules(surface, exposedBottomModules) + sameLineModuleList.forEach((modules, index) => { const moduleRowResultData = { - seq: index, + seq: index + 1, moduleItemId: modules[0].moduleInfo.itemId, moduleTpCd: modules[0].moduleInfo.itemTp, moduleCnt: modules.length, @@ -2646,6 +2679,7 @@ export const useTrestle = () => { } // ๋ชจ๋“ˆ ํ•˜๋ฉด,์ตœํ•˜๋ฉด ๋“ฑ ๊ตฌํ•ด์•ผํ•จ modules.forEach((module, index) => { + const level = module.level // ํ•ด๋‹น ๋ชจ๋“ˆ ์ฃผ๋ณ€์— ๋‹ค๋ฅธ ๋ชจ๋“ˆ์ด ์žˆ๋Š”์ง€ ํ™•์ธ let { bottomModule, @@ -2659,6 +2693,7 @@ export const useTrestle = () => { bottomLeftModule, bottomRightModule, } = findSideModule(module, surface) + if (bottomModule) { moduleRowResultData.touchedSurfaceCnt++ if (rackYn === 'N') { @@ -2702,10 +2737,12 @@ export const useTrestle = () => { } if (cvrPlvrYn === 'Y') { - moduleRowResultData.eavesHalfCnt++ - if (bottomLeftModule || bottomRightModule || halfBottomLeftModule || halfBottomRightModule) { - //์ฒ˜๋งˆ์ปค๋ฒ„ ํ•œ๊ฐœ ๋…ธ์ถœ ์ถ”๊ฐ€ - moduleRowResultData.exposedSideEavesCnt++ + if (level <= cvrLmtRow) { + moduleRowResultData.eavesHalfCnt++ + if (bottomLeftModule || bottomRightModule || halfBottomLeftModule || halfBottomRightModule) { + //์ฒ˜๋งˆ์ปค๋ฒ„ ํ•œ๊ฐœ ๋…ธ์ถœ ์ถ”๊ฐ€ + moduleRowResultData.exposedSideEavesCnt++ + } } } } else { @@ -2714,13 +2751,15 @@ export const useTrestle = () => { moduleRowResultData.exposedBottomBracketCnt += rackQty } if (isEaveBar) { - moduleRowResultData.eavesCnt++ - if ((rightModule && !leftModule) || (!rightModule && leftModule)) { - // ๋‘˜์ค‘ ํ•˜๋‚˜๊ฐ€ ์—†๋Š”๊ฒฝ์šฐ๋Š” ์ฒ˜๋งˆ์ปค๋ฒ„ ๋…ธ์ถœ ์ถ”๊ฐ€ - moduleRowResultData.exposedSideEavesCnt++ - } else if (!rightModule && !leftModule) { - // ์–‘์ชฝ ๋‘˜๋‹ค ์—†๋Š”๊ฒฝ์šฐ๋Š” ์ฒ˜๋งˆ์ปค๋ฒ„ ๋…ธ์ถœ 2๊ฐœ ์ถ”๊ฐ€ - moduleRowResultData.exposedSideEavesCnt += 2 + if (level <= cvrLmtRow) { + moduleRowResultData.eavesCnt++ + if ((rightModule && !leftModule) || (!rightModule && leftModule)) { + // ๋‘˜์ค‘ ํ•˜๋‚˜๊ฐ€ ์—†๋Š”๊ฒฝ์šฐ๋Š” ์ฒ˜๋งˆ์ปค๋ฒ„ ๋…ธ์ถœ ์ถ”๊ฐ€ + moduleRowResultData.exposedSideEavesCnt++ + } else if (!rightModule && !leftModule) { + // ์–‘์ชฝ ๋‘˜๋‹ค ์—†๋Š”๊ฒฝ์šฐ๋Š” ์ฒ˜๋งˆ์ปค๋ฒ„ ๋…ธ์ถœ 2๊ฐœ ์ถ”๊ฐ€ + moduleRowResultData.exposedSideEavesCnt += 2 + } } } } diff --git a/src/hooks/usePlan.js b/src/hooks/usePlan.js index 52c60f80..ba8776d4 100644 --- a/src/hooks/usePlan.js +++ b/src/hooks/usePlan.js @@ -343,6 +343,7 @@ export function usePlan(params = {}) { }) .catch((error) => { swalFire({ text: error.message, icon: 'error' }) + setIsGlobalLoading(false) }) return rtn }