diff --git a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx index fa4abd4c..2881ec2c 100644 --- a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx @@ -62,17 +62,10 @@ export default function CircuitTrestleSetting({ id }) { const passivityProps = { tabNum, setTabNum, + pcsCheck, selectedModels, setSelectedModels, } - const stepUpProps = { - tabNum, - setTabNum, - models, - setModels, - circuitAllocationType, - setCircuitAllocationType, - } useEffect(() => { if (!managementState) { @@ -88,7 +81,58 @@ export default function CircuitTrestleSetting({ id }) { }) return } - const roofSurfaceList = canvas + + console.log('๐Ÿš€ ~ onAutoRecommend ~ selectedModules:', selectedModules) + + const params = { + ...getApiProps(), + useModuleItemList: getSelectedModuleList(), + roofSurfaceList: getRoofSurfaceList(), + pcsItemList: getModelList(), + } + + getPcsAutoRecommendList(params).then((res) => { + if (res.data?.pcsItemList) { + setModels(res.data.pcsItemList) + setTabNum(2) + } else { + swalFire({ + title: 'ํŒŒ์›Œ์ปจ๋””์…”๋„ˆ๋ฅผ ์ถ”๊ฐ€ํ•ด ์ฃผ์„ธ์š”.', + type: 'alert', + }) + } + }) + } + + const getApiProps = () => { + return { + maxConnYn: pcsCheck.max ? 'Y' : 'N', + smpCirYn: pcsCheck.division ? 'Y' : 'N', + coldZoneYn: managementState?.coldRegionFlg === '1' ? 'Y' : 'N', + } + } + + const getModelList = () => { + return models.map((model) => { + return { + itemId: model.itemId, + pcsMkrCd: model.pcsMkrCd, + pcsSerCd: model.pcsSerCd, + } + }) + } + + const getSelectedModuleList = () => { + return selectedModules.itemList.map((m) => { + return { + itemId: m.itemId, + mixMatlNo: m.mixMatlNo, + } + }) + } + + const getRoofSurfaceList = () => { + return canvas .getObjects() .filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) .map((obj) => { @@ -106,37 +150,6 @@ export default function CircuitTrestleSetting({ id }) { }), } }) - - const params = { - maxConnYn: pcsCheck.max ? 'Y' : 'N', - smpCirYn: pcsCheck.division ? 'Y' : 'N', - coldZoneYn: managementState?.coldRegionFlg === '1' ? 'Y' : 'N', - useModuleItemList: selectedModules.itemList.map((m) => { - return { - itemId: m.itemId, - mixMatlNo: m.mixMatlNo, - } - }), - roofSurfaceList: roofSurfaceList, - pcsItemList: models.map((model) => { - return { - itemId: model.itemId, - pcsMkrCd: model.pcsMkrCd, - pcsSerCd: model.pcsSerCd, - } - }), - } - getPcsAutoRecommendList(params).then((res) => { - if (res.data?.pcsItemList) { - setModels(res.data.pcsItemList) - setTabNum(2) - } else { - swalFire({ - title: 'ํŒŒ์›Œ์ปจ๋””์…”๋„ˆ๋ฅผ ์ถ”๊ฐ€ํ•ด ์ฃผ์„ธ์š”.', - type: 'alert', - }) - } - }) } const onAutoAllocation = () => { @@ -199,6 +212,19 @@ export default function CircuitTrestleSetting({ id }) { setAllocationType(ALLOCATION_TYPE.PASSIVITY) } + const stepUpProps = { + tabNum, + setTabNum, + models, + setModels, + circuitAllocationType, + setCircuitAllocationType, + getApiProps, + getSelectedModuleList, + getRoofSurfaceList, + getModelList, + } + return (
diff --git a/src/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect.jsx b/src/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect.jsx index fbaef41a..3c581e6f 100644 --- a/src/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect.jsx @@ -141,7 +141,7 @@ export default function PowerConditionalSelect(props) { return } - setSelectedModels([...selectedModels, selectedRow]) + setSelectedModels([...selectedModels, { ...selectedRow, id: uuidv4() }]) setSelectedRow(null) } diff --git a/src/components/floor-plan/modal/circuitTrestle/step/StepUp.jsx b/src/components/floor-plan/modal/circuitTrestle/step/StepUp.jsx index 19a701dc..721e6dff 100644 --- a/src/components/floor-plan/modal/circuitTrestle/step/StepUp.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/step/StepUp.jsx @@ -24,9 +24,16 @@ export default function StepUp(props) { const [stepUpListData, setStepUpListData] = useState([]) const [optCodes, setOptCodes] = useState([]) + useCanvasPopupStatusController(6) + const canvasPopupStatusState = useRecoilValue(canvasPopupStatusStore) + if (Object.keys(canvasPopupStatusState[6]).length !== 0) { + console.log('๐Ÿš€ ~ useEffect ~ canvasPopupStatusState :', canvasPopupStatusState) + } + useEffect(() => { + console.log('๐Ÿš€ ~ useEffect ~ >>>>>>>>>>>> props:', props) + if (!managementState) { - console.log('๐Ÿš€ ~ useEffect ~ managementState:', managementState) setManagementState(managementStateLoaded) } @@ -73,48 +80,86 @@ export default function StepUp(props) { } //getPcsVoltageStepUpList(null) - getPcsVoltageStepUpList().then((res) => { + // PCS ์Šน์••์„ค์ • ์ •๋ณด ์กฐํšŒ + fetchStepUpData() + }, []) + + const fetchStepUpData = async () => { + try { + const res = await getPcsVoltageStepUpList() if (res?.result.code === 200 && res?.data) { const dataArray = Array.isArray(res.data) ? res.data : [res.data] - const stepUpListData = dataArray.map((stepUps) => ({ - ...stepUps, - optionList: (stepUps.optionList || []).map((option) => ({ - pcsOptCd: option.pcsOptCd, - pcsOptNm: option.pcsOptNm, - pcsOptNmJp: option.pcsOptNmJp, - })), - pcsItemList: (stepUps.pcsItemList || []).map((item) => ({ - goodsNo: item.goodsNo, - itemId: item.itemId, - itemNm: item.itemNm, - pcsMkrCd: item.pcsMkrCd, - pcsSerCd: item.pcsSerCd, - connList: (item.connList || []).map((conn) => ({ - connAllowCur: conn.connAllowCur, - connMaxParalCnt: conn.connMaxParalCnt, - goodsNo: conn.goodsNo, - itemId: conn.itemId, - itemNm: conn.itemNm, - vstuParalCnt: conn.vstuParalCnt, - })), - serQtyList: (item.serQtyList || []).map((qty) => ({ - serQty: qty.serQty, - paralQty: qty.paralQty, - })), - })), - })) + const stepUpListData = formatStepUpListData(dataArray) console.log('๐Ÿš€ ~ useEffect ~ getPcsVoltageStepUpList ~ stepUpListData:', stepUpListData) setStepUpListData(stepUpListData) - setOptCodes(res.data.optionList.map((opt) => ({ ...opt, code: opt.pcsOptCd, name: opt.pcsOptNm, nameJp: opt.pcsOptNmJp }))) + // PCS ์˜ต์…˜ ์กฐํšŒ + const formattedOptCodes = formatOptionCodes(res.data.optionList) + setOptCodes(formattedOptCodes) } - }) - }, []) + } catch (error) { + console.error('Error fetching step up data:', error) + } + } - useCanvasPopupStatusController(6) - const canvasPopupStatusState = useRecoilValue(canvasPopupStatusStore) - if (Object.keys(canvasPopupStatusState[6]).length !== 0) { - console.log('๐Ÿš€ ~ useEffect ~ canvasPopupStatusState :', canvasPopupStatusState) + // PCS ์˜ต์…˜ ์กฐํšŒ + const formatOptionCodes = (optionList = []) => { + return optionList.map((opt) => ({ + code: opt.pcsOptCd, + name: opt.pcsOptNm, + nameJp: opt.pcsOptNmJp, + })) + } + + // PCS ์Šน์••์„ค์ • ์ •๋ณด ํฌ๋งท + const formatStepUpListData = (dataArray = []) => { + return dataArray.map((stepUps) => ({ + ...stepUps, + optionList: formatOptionList(stepUps.optionList), + pcsItemList: formatPcsItemList(stepUps.pcsItemList), + })) + } + + // PCS ์˜ต์…˜ ํฌ๋งท + const formatOptionList = (optionList = []) => { + return optionList.map((option) => ({ + pcsOptCd: option.pcsOptCd, + pcsOptNm: option.pcsOptNm, + pcsOptNmJp: option.pcsOptNmJp, + })) + } + + // PCS ์•„์ดํ…œ ํฌ๋งท + const formatPcsItemList = (pcsItemList = []) => { + return pcsItemList.map((item) => ({ + goodsNo: item.goodsNo, + itemId: item.itemId, + itemNm: item.itemNm, + pcsMkrCd: item.pcsMkrCd, + pcsSerCd: item.pcsSerCd, + connList: formatConnList(item.connList), + serQtyList: formatSerQtyList(item.serQtyList), + })) + } + + // PCS ์—ฐ๊ฒฐ ํฌ๋งท + const formatConnList = (connList = []) => { + return connList.map((conn) => ({ + connAllowCur: conn.connAllowCur, + connMaxParalCnt: conn.connMaxParalCnt, + goodsNo: conn.goodsNo, + itemId: conn.itemId, + itemNm: conn.itemNm, + vstuParalCnt: conn.vstuParalCnt, + })) + } + + // PCS ์‹œ๋ฆฌ์ฆˆ ํฌ๋งท + const formatSerQtyList = (serQtyList = []) => { + return serQtyList.map((qty) => ({ + serQty: qty.serQty, + paralQty: qty.paralQty, + })) } // ๊ฐ ๋ชจ๋“ˆ์˜ ํƒญ์„ ๋ณ€๊ฒฝํ•˜๋Š” ํ•จ์ˆ˜ diff --git a/src/components/floor-plan/modal/circuitTrestle/step/type/PassivityCircuitAllocation.jsx b/src/components/floor-plan/modal/circuitTrestle/step/type/PassivityCircuitAllocation.jsx index 62e54ec1..e1c2b29b 100644 --- a/src/components/floor-plan/modal/circuitTrestle/step/type/PassivityCircuitAllocation.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/step/type/PassivityCircuitAllocation.jsx @@ -1,5 +1,6 @@ import { GlobalDataContext } from '@/app/GlobalDataProvider' import { POLYGON_TYPE } from '@/common/common' +import { useMasterController } from '@/hooks/common/useMasterController' import { useMessage } from '@/hooks/useMessage' import { canvasState } from '@/store/canvasAtom' import { moduleStatisticsState } from '@/store/circuitTrestleAtom' @@ -8,7 +9,7 @@ import { useContext, useEffect, useState } from 'react' import { useRecoilValue } from 'recoil' export default function PassivityCircuitAllocation(props) { - const { tabNum, setTabNum, selectedModels } = props + const { tabNum, setTabNum, selectedModels, pcsCheck } = props const { getMessage } = useMessage() const canvas = useRecoilValue(canvasState) const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext) @@ -22,6 +23,7 @@ export default function PassivityCircuitAllocation(props) { const [footer, setFooter] = useState(['ํ•ฉ๊ณ„']) const [circuitNumber, setCircuitNumber] = useState(1) const [targetModules, setTargetModules] = useState([]) + const { pcsMaualConfChk } = useMasterController() useEffect(() => { console.log('๐Ÿš€ ~ PassivityCircuitAllocation ~ targetModules:', targetModules) @@ -145,15 +147,752 @@ export default function PassivityCircuitAllocation(props) { const handleCircuitNumberFix = () => { console.log('๐Ÿš€ ~ handleCircuitNumberFix ~ circuitNumber:', circuitNumber) + console.log('๐Ÿš€ ~ handleCircuitNumberFix ~ selectedPcs:', selectedPcs) + // const params = { + // maxConnYn: pcsCheck.max ? 'Y' : 'N', + // smpCirYn: 'Y', + // coldZoneYn: 'Y', + // useModuleItemList: [{ itemId: '107077', mixMatlNo: '0' }], + // pcsItemList: [ + // { + // pcsMkrCd: 'MKR001', + // pcsSerCd: 'SER001', + // itemId: '106857', + // itemNm: 'HQJP-KA55-5 ๏พŠ๏พŸ๏พœ๏ฝฐ๏ฝบ๏พ๏พƒ๏พž๏ฝจ๏ฝผ๏ฝฎ๏พ…5.5kWๅฑ‹ๅ†…', + // goodsNo: 'HQJP-KA55-5', + // serQtyList: [ + // { + // serQty: 5, + // paralQty: 3, + // rmdYn: 'Y', + // usePossYn: 'Y', + // roofSurfaceList: [ + // { + // roofSurfaceId: '1', + // roofSurface: '๋‚จ์„œ', + // roofSurfaceIncl: '5', + // moduleList: [ + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-4', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-4', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-4', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-4', + // pcsItemId: '106856', + // }, + // ], + // cirLastIdx: 5, + // isCirLastDupCircuit: true, + // roofSurfacePossibleModuleCnt: 0, + // totCirModuleWpOut: 0, + // roofSurfaceCirModuleWpOut: 3960, + // }, + // { + // roofSurfaceId: '2', + // roofSurface: '๋‚จ์„œ', + // roofSurfaceIncl: '5', + // moduleList: [ + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: null, + // pcsItemId: null, + // }, + // ], + // cirLastIdx: 3, + // isCirLastDupCircuit: true, + // roofSurfacePossibleModuleCnt: 1, + // totCirModuleWpOut: 0, + // roofSurfaceCirModuleWpOut: 2200, + // }, + // { + // roofSurfaceId: '3', + // roofSurface: '๋‚จ', + // roofSurfaceIncl: '3', + // moduleList: [ + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-5', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-5', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-5', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-5', + // pcsItemId: '106856', + // }, + // ], + // cirLastIdx: 6, + // isCirLastDupCircuit: true, + // roofSurfacePossibleModuleCnt: 0, + // totCirModuleWpOut: 0, + // roofSurfaceCirModuleWpOut: 3960, + // }, + // ], + // }, + // ], + // }, + // { + // pcsMkrCd: 'MKR001', + // pcsSerCd: 'SER001', + // itemId: '106856', + // itemNm: 'HQJP-KA40-5 ๏พŠ๏พŸ๏พœ๏ฝฐ๏ฝบ๏พ๏พƒ๏พž๏ฝจ๏ฝผ๏ฝฎ๏พ…4.0kWๅฑ‹ๅ†…', + // goodsNo: 'HQJP-KA40-5', + // circuitCfg: '4, 4', + // serQtyList: [ + // { + // pcsTpCd: 'INDFCS', + // serQty: 4, + // paralQty: 2, + // rmdYn: 'Y', + // usePossYn: 'Y', + // cirModuleWpOutSum: 3520, + // roofSurfaceList: [ + // { + // roofSurfaceId: '1', + // roofSurface: '๋‚จ์„œ', + // roofSurfaceIncl: '5', + // moduleList: [ + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-1', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-4', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-4', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-4', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-4', + // pcsItemId: '106856', + // }, + // ], + // cirLastIdx: 5, + // isCirLastDupCircuit: true, + // roofSurfacePossibleModuleCnt: 0, + // totCirModuleWpOut: 0, + // roofSurfaceCirModuleWpOut: 3960, + // }, + // { + // roofSurfaceId: '2', + // roofSurface: '๋‚จ์„œ', + // roofSurfaceIncl: '5', + // moduleList: [ + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-2', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: null, + // pcsItemId: null, + // }, + // ], + // }, + // { + // roofSurfaceId: '3', + // roofSurface: '๋‚จ', + // roofSurfaceIncl: '3', + // moduleList: [ + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '1-3', + // pcsItemId: '106857', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-5', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-5', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-5', + // pcsItemId: '106856', + // }, + // { + // pcsMkrCd: null, + // pcsSerCd: null, + // applySerQty: null, + // itemId: '107077', + // itemTp: null, + // wpOut: 440, + // moduleStdVol: 42, + // moduleColdZoneVol: null, + // mixMatlNo: null, + // circuit: '2-5', + // pcsItemId: '106856', + // }, + // ], + // }, + // ], + // }, + // ], + // }, + // ], + // } + // pcsMaualConfChk() + canvas.discardActiveObject() canvas .getObjects() .filter((obj) => targetModules.includes(obj.id)) .forEach((obj) => { obj.set({ circuit: circuitNumber, + strokeWidth: 0.3, }) + obj.pscId = selectedPcs.id + obj.pscIndex = selectedModels.findIndex((model) => model.itemId === selectedPcs.itemId) + 1 canvas.add( - new fabric.Text(`(${circuitNumber})`, { + new fabric.Text(getCircuitNumber(), { left: obj.left + obj.width / 2, top: obj.top + obj.height / 2, fill: 'red', @@ -171,7 +910,29 @@ export default function PassivityCircuitAllocation(props) { console.log(obj) }) setTargetModules([]) - setCircuitNumber(circuitNumber + 1) + setCircuitNumber(+circuitNumber + 1) + canvas.renderAll() + } + + const getCircuitNumber = () => { + if (selectedModels.length === 1) { + return `(${circuitNumber})` + } else { + return `(${selectedModels.findIndex((model) => model.itemId === selectedPcs.itemId) + 1}-${circuitNumber})` + } + } + + const initSelectedPcsCircuitNumber = () => { + const modules = canvas.getObjects().filter((obj) => obj.name === 'circuitNumber' && obj.pscId === selectedPcs.id) + canvas.remove(...modules) + canvas + .getObjects() + .filter((obj) => obj.pscIndex === selectedPcs.id) + .forEach((obj) => { + obj.pscId = null + obj.pscIndex = null + }) + canvas.renderAll() } @@ -280,7 +1041,7 @@ export default function PassivityCircuitAllocation(props) {
-
diff --git a/src/hooks/common/useMasterController.js b/src/hooks/common/useMasterController.js index b0b21b05..e12ac4a5 100644 --- a/src/hooks/common/useMasterController.js +++ b/src/hooks/common/useMasterController.js @@ -168,6 +168,12 @@ export function useMasterController() { }) } + const pcsMaualConfChk = async (params = null) => { + return await post({ url: '/api/v1/master/pcsMaualConfChk', data: params }).then((res) => { + return res + }) + } + /** * PCS ์Šน์••์„ค์ • ์ •๋ณด ์กฐํšŒ * @param {Max์ ‘์†(๊ณผ์ )์—ฌ๋ถ€} maxConnYn @@ -253,6 +259,7 @@ export function useMasterController() { getPcsMakerList, getPcsModelList, getPcsAutoRecommendList, + pcsMaualConfChk, getPcsVoltageStepUpList, } } diff --git a/src/hooks/common/useRoofFn.js b/src/hooks/common/useRoofFn.js index 84416370..dc877788 100644 --- a/src/hooks/common/useRoofFn.js +++ b/src/hooks/common/useRoofFn.js @@ -15,10 +15,19 @@ export function useRoofFn() { const currentObject = useRecoilValue(currentObjectState) //๋ฉดํ˜•์ƒ ์„ ํƒ ํด๋ฆญ์‹œ ์ง€๋ถ• ํŒจํ„ด ์ž…ํžˆ๊ธฐ - function setSurfaceShapePattern(polygon, mode = 'onlyBorder', trestleMode = false, roofMaterial = selectedRoofMaterial) { + function setSurfaceShapePattern(polygon, mode = 'onlyBorder', trestleMode = false, roofMaterial = selectedRoofMaterial, isForceChange = false) { if (!polygon) { return } + if (isForceChange) { + if (polygon.roofMaterial) { + polygon.roofMaterial = null + } + } + + if (polygon.roofMaterial) { + return + } const ratio = window.devicePixelRatio || 1 const layout = roofMaterial.layout diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index 24541d22..5c1d7927 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -19,17 +19,33 @@ export const useTrestle = () => { canvas.remove(obj) } }) - + canvas.getObjects().forEach((obj) => { + if (obj.name === 'bracket') { + canvas.remove(obj) + } + }) surfaces.forEach((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 + const construction = moduleSelectionData?.roofConstructions?.find((construction) => construction.roofIndex === roofMaterialIndex).construction + if (!construction) { + alert('์•ž์—์„œ ์…‹ํŒ… ์•ˆ๋จ') + return + } let isEaveBar = construction.setupCover + let isSnowGuard = construction.setupSnowCover const direction = parent.direction - const rack = surface.trestleDetail.rack - let { rackQty, rackIntvlPct } = surface.trestleDetail + let { rackQty, rackIntvlPct, rackYn, cvrPlvrYn } = surface.trestleDetail + rackYn = 'N' + rackQty = 5 + cvrPlvrYn = 'Y' + + if (!rack) { + //25/01/16 ๊ธฐ์ค€ ๋ž™์ด ์—†๋Š” ๊ฒฝ์šฐ๋Š” ๊ทธ๋ƒฅ ์•ˆ๊ทธ๋ ค์ค€๋‹ค. + return + } const rackInfos = Object.keys(rack).map((key) => { return { key, value: rack[key] } @@ -41,12 +57,16 @@ export const useTrestle = () => { const exposedBottomModules = [] // ์•„๋ž˜ ๋‘๋ฉด์ด ๋ชจ๋‘ ๋…ธ์ถœ ๋˜์–ด์žˆ๋Š” ๊ฒฝ์šฐ const leftExposedHalfBottomModules = [] // ์™ผ์ชฝ ๋ฉด๋งŒ ๋…ธ์ถœ๋˜์–ด์žˆ๋Š” ๊ฒฝ์šฐ const rightExposedHalfBottomPoints = [] // ์˜ค๋ฅธ์ชฝ ๋ฉด๋งŒ ๋…ธ์ถœ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ + const leftExposedHalfTopModules = [] // ์™ผ์ชฝ ๋ฉด๋งŒ ๋…ธ์ถœ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ + const rightExposedHalfTopPoints = [] // ์˜ค๋ฅธ์ชฝ ๋ฉด๋งŒ ๋…ธ์ถœ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ const modules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE) modules.forEach((module) => { const { x, y } = module.getCenterPoint() const isExposedBottom = result.exposedBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2) const isLeftExposedHalfBottom = result.leftExposedHalfBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2) const isRightExposedHalfBottom = result.rightExposedHalfBottomPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2) + const isRightExposedHalfTop = result.rightExposedHalfTopPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2) + const isLeftExposedHalfTop = result.leftExposedHalfTopPoints.some((point) => Math.abs(point.x - x) < 2 && Math.abs(point.y - y) < 2) if (isExposedBottom) { exposedBottomModules.push(module) } @@ -56,11 +76,24 @@ export const useTrestle = () => { if (isRightExposedHalfBottom) { rightExposedHalfBottomPoints.push(module) } + if (isRightExposedHalfTop) { + leftExposedHalfTopModules.push(module) + } + if (isLeftExposedHalfTop) { + rightExposedHalfTopPoints.push(module) + } }) + // 4๊ฐœ์ค‘ ํ•œ๊ฐœ๋ผ๋„ ์žˆ๋Š” ๊ฒฝ์šฐ ์น˜์กฐ๋ฐฐ์น˜๋กœ ๊ฐ„์ฃผํ•œ๋‹ค. + const isChidory = + leftExposedHalfBottomModules.length > 0 || + rightExposedHalfBottomPoints.length > 0 || + leftExposedHalfTopModules.length > 0 || + rightExposedHalfTopPoints.length > 0 + canvas .getObjects() - .filter((obj) => obj.name === 'eaveBar') + .filter((obj) => ['eaveBar', 'halfEaveBar'].includes(obj.name) && obj.parent === surface) .forEach((obj) => { canvas.remove(obj) }) @@ -72,19 +105,84 @@ export const useTrestle = () => { const bottomPoints = findTopTwoPoints([...module.points], direction) if (!bottomPoints) return const eaveBar = new fabric.Line([bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y], { + parent: surface, name: 'eaveBar', stroke: 'blue', strokeWidth: 4, selectable: false, + parentId: module.id, }) canvas.add(eaveBar) canvas.renderAll() }) + + if (isChidory && cvrPlvrYn === 'Y') { + leftExposedHalfBottomModules.forEach((module) => { + const bottomPoints = findTopTwoPoints([...module.points], direction) + let barPoints = [] + //์„ค์น˜ํ•ด์•ผํ•  ๋ฐ˜์ฒ˜๋งˆ์ปค๋ฒ„ ํฌ์ธํŠธ๋ฅผ ๋ฐฉํ–ฅ์— ๋”ฐ๋ผ ์„ค์ • + + if (direction === 'south') { + barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x - module.width / 2, bottomPoints[1].y] + } else if (direction === 'north') { + barPoints = [bottomPoints[0].x + module.width / 2, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y] + } else if (direction === 'east') { + barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[0].y - module.height / 2] + } else if (direction === 'west') { + barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y - module.height / 2] + } + + if (!bottomPoints) return + const halfEaveBar = new fabric.Line(barPoints, { + parent: surface, + name: 'halfEaveBar', + stroke: 'blue', + strokeWidth: 4, + selectable: false, + parentId: module.id, + }) + canvas.add(halfEaveBar) + canvas.renderAll() + }) + + rightExposedHalfBottomPoints.forEach((module) => { + const bottomPoints = findTopTwoPoints([...module.points], direction) + let barPoints = [] + //์„ค์น˜ํ•ด์•ผํ•  ๋ฐ˜์ฒ˜๋งˆ์ปค๋ฒ„ ํฌ์ธํŠธ๋ฅผ ๋ฐฉํ–ฅ์— ๋”ฐ๋ผ ์„ค์ • + + if (direction === 'south') { + barPoints = [bottomPoints[0].x + module.width / 2, bottomPoints[0].y, bottomPoints[1].x, bottomPoints[1].y] + } else if (direction === 'north') { + barPoints = [bottomPoints[0].x, bottomPoints[0].y, bottomPoints[0].x + module.width / 2, bottomPoints[1].y] + } else if (direction === 'east') { + barPoints = [bottomPoints[0].x, bottomPoints[1].y + module.height / 2, bottomPoints[1].x, bottomPoints[1].y] + } else if (direction === 'west') { + barPoints = [bottomPoints[0].x, bottomPoints[1].y - module.height / 2, bottomPoints[1].x, bottomPoints[1].y] + } + + if (!bottomPoints) return + const halfEaveBar = new fabric.Line(barPoints, { + parent: surface, + name: 'halfEaveBar', + stroke: 'blue', + strokeWidth: 4, + selectable: false, + parentId: module.id, + }) + canvas.add(halfEaveBar) + canvas.renderAll() + }) + } } + const horizontal = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlHor : surface.trestleDetail.moduleIntvlVer + + const vertical = ['south', 'north'].includes(direction) ? surface.trestleDetail.moduleIntvlVer : surface.trestleDetail.moduleIntvlHor // ๊ฐ€๋Œ€ ์„ค์น˜๋ฅผ ์œ„ํ•œ ๊ฐ€์žฅ ์•„๋ž˜ ๋ชจ๋“ˆ๋กœ๋ถ€ํ„ฐ ์œ„๋กœ ๋ช‡๋‹จ์ธ์ง€ ๊ณ„์‚ฐ // ์˜ค๋ฅธ์ชฝ,์™ผ์ชฝ ๋‘˜ ๋‹ค ์•„๋ž˜์— ์•„๋ฌด๊ฒƒ๋„ ์—†๋Š”, ์ฒ˜๋งˆ ์ปค๋ฒ„๋ฅผ ํ•„์š”๋กœ ํ•˜๋Š” ๋ชจ๋“ˆ exposedBottomModules.forEach((module) => { - const { width, height } = module + let { width, height } = { ...module } + width = Math.floor(width) + height = Math.floor(height) let { x: startX, y: startY } = { ...module.getCenterPoint() } let { x, y } = { ...module.getCenterPoint() } //TODO : ๋ฐฉํ–ฅ๋ณ„๋กœ ๊ฐ€๋Œ€ ์„ค์น˜ํ•ด์•ผํ•จ @@ -99,7 +197,7 @@ export const useTrestle = () => { //์šฐ์„  ์ ˆ๋ฐ˜์„ ๋‚˜๋ˆˆ ๋’ค ์™ผ์ชฝ๋ถ€ํ„ฐ ์ฐพ๋Š”๋‹ค. while (hasNextModule) { //๋ฐ”๋กœ ์œ„์— ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. - let nextModule = findNextModule({ x, y, width, height }, centerPoints, direction) + let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) if (nextModule) { // ๋ฐ”๋กœ ์œ„ ๋ชจ๋“ˆ์„ ์ฐพ๋Š”๋‹ค. @@ -109,10 +207,10 @@ export const useTrestle = () => { } else { // ๋ฐ”๋กœ ์œ„๊ฐ€ ์—†์„ ๊ฒฝ์šฐ ๋จผ์ € ์™ผ์ชฝ์œ„๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ ํ•œ๋‹ค. if (findLeft) { - nextModule = findNextLeftModule({ x, y, width, height }, centerPoints, direction) + nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) findLeft = false } else { - nextModule = findNextRightModule({ x, y, width, height }, centerPoints, direction) + nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) findLeft = true } @@ -134,7 +232,7 @@ export const useTrestle = () => { // ์˜ค๋ฅธ์ชฝ ์ฐพ๋Š”๋‹ค. while (hasNextModule) { //๋ฐ”๋กœ ์œ„์— ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. - let nextModule = findNextModule({ x, y, width, height }, centerPoints, direction) + let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) if (nextModule) { // ๋ฐ”๋กœ ์œ„ ๋ชจ๋“ˆ์„ ์ฐพ๋Š”๋‹ค. @@ -144,10 +242,10 @@ export const useTrestle = () => { } else { // ๋ฐ”๋กœ ์œ„๊ฐ€ ์—†์„ ๊ฒฝ์šฐ ๋จผ์ € ์™ผ์ชฝ์œ„๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ ํ•œ๋‹ค. if (findRight) { - nextModule = findNextRightModule({ x, y, width, height }, centerPoints, direction) + nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) findRight = false } else { - nextModule = findNextLeftModule({ x, y, width, height }, centerPoints, direction) + nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) findRight = true } @@ -169,7 +267,7 @@ export const useTrestle = () => { // ์„ผํ„ฐ ์ฐพ๋Š”๋‹ค. while (hasNextModule) { //๋ฐ”๋กœ ์œ„์— ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. - let nextModule = findNextModule({ x, y, width, height }, centerPoints, direction) + let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) if (nextModule) { // ๋ฐ”๋กœ ์œ„ ๋ชจ๋“ˆ์„ ์ฐพ๋Š”๋‹ค. @@ -196,13 +294,19 @@ export const useTrestle = () => { return rack.value.moduleRows === centerRows })?.value.racks - drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L') - drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R') + if (rackYn === 'Y') { + drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn) + drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn) - if (rackQty === 3) { - //rack ๊ฐฏ์ˆ˜๊ฐ€ 3๊ฐœ์ธ ๊ฒฝ์šฐ๋Š” ์ค‘๊ฐ„๋ ‰๋„ ์ถ”๊ฐ€ํ•ด์ค˜์•ผํ•จ - drawRacks(centerRacks, rackQty, rackIntvlPct, module, direction, 'C') + if (rackQty === 3) { + //rack ๊ฐฏ์ˆ˜๊ฐ€ 3๊ฐœ์ธ ๊ฒฝ์šฐ๋Š” ์ค‘๊ฐ„๋ ‰๋„ ์ถ”๊ฐ€ํ•ด์ค˜์•ผํ•จ + drawRacks(centerRacks, rackQty, rackIntvlPct, module, direction, 'C', rackYn) + } else if (rackQty === 4) { + drawRacks(leftRacks, rackQty, rackIntvlPct / 3, module, direction, 'L', rackYn) + drawRacks(rightRacks, rackQty, rackIntvlPct / 3, module, direction, 'R', rackYn) + } } + module.set({ leftRows, rightRows, centerRows }) }) // ์™ผ์ชฝ์•„๋ž˜์— ๋ชจ๋“ˆ์ด ์—†๋Š” ๋ชจ๋“ˆ๋“ค leftExposedHalfBottomModules.forEach((module) => { @@ -218,7 +322,7 @@ export const useTrestle = () => { //์šฐ์„  ์ ˆ๋ฐ˜์„ ๋‚˜๋ˆˆ ๋’ค ์™ผ์ชฝ๋ถ€ํ„ฐ ์ฐพ๋Š”๋‹ค. while (hasNextModule) { //๋ฐ”๋กœ ์œ„์— ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. - let nextModule = findNextModule({ x, y, width, height }, centerPoints, direction) + let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) if (nextModule) { // ๋ฐ”๋กœ ์œ„ ๋ชจ๋“ˆ์„ ์ฐพ๋Š”๋‹ค. @@ -228,10 +332,10 @@ export const useTrestle = () => { } else { // ๋ฐ”๋กœ ์œ„๊ฐ€ ์—†์„ ๊ฒฝ์šฐ ๋จผ์ € ์™ผ์ชฝ์œ„๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ ํ•œ๋‹ค. if (findLeft) { - nextModule = findNextLeftModule({ x, y, width, height }, centerPoints, direction) + nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) findLeft = false } else { - nextModule = nextModule = findNextRightModule({ x, y, width, height }, centerPoints, direction) + nextModule = nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) findLeft = true } @@ -251,7 +355,11 @@ export const useTrestle = () => { return rack.value.moduleRows === leftRows })?.value.racks - drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L') + if (rackYn === 'Y') { + drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn) + } + + module.set({ leftRows }) }) // ์˜ค๋ฅธ์ชฝ ์•„๋ž˜์— ๋ชจ๋“ˆ์ด ์—†๋Š” ๋ชจ๋“ˆ๋“ค rightExposedHalfBottomPoints.forEach((module) => { @@ -267,7 +375,7 @@ export const useTrestle = () => { // ์˜ค๋ฅธ์ชฝ ์ฐพ๋Š”๋‹ค. while (hasNextModule) { //๋ฐ”๋กœ ์œ„์— ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. - let nextModule = findNextModule({ x, y, width, height }, centerPoints, direction) + let nextModule = findNextModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) if (nextModule) { // ๋ฐ”๋กœ ์œ„ ๋ชจ๋“ˆ์„ ์ฐพ๋Š”๋‹ค. @@ -277,10 +385,10 @@ export const useTrestle = () => { } else { // ๋ฐ”๋กœ ์œ„๊ฐ€ ์—†์„ ๊ฒฝ์šฐ ๋จผ์ € ์™ผ์ชฝ์œ„๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ ํ•œ๋‹ค. if (findRight) { - nextModule = findNextRightModule({ x, y, width, height }, centerPoints, direction) + nextModule = findNextRightModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) findRight = false } else { - nextModule = findNextLeftModule({ x, y, width, height }, centerPoints, direction) + nextModule = findNextLeftModule({ x, y, width, height, horizontal, vertical }, centerPoints, direction) findRight = true } @@ -300,46 +408,46 @@ export const useTrestle = () => { return rack.value.moduleRows === rightRows })?.value.racks // ํ•ด๋‹น rack์œผ๋กœ ๊ทธ๋ ค์ค€๋‹ค. + if (rackYn === 'Y') { + drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn) + } - drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R') + module.set({ rightRows }) }) + + if (rackYn === 'N') { + // rack์ด ์—†์„๊ฒฝ์šฐ + installBracketWithOutRack(surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory) + } else if (rackYn === 'Y') { + installBracket(surface) + } }) - - /*switch (rackYn) { - case 'Y': { - // rack์ด Y์ผ ๊ฒฝ์šฐ rackQty๊ฐ€ ํ•„์š”ํ•จ - - break - } - case 'N': { - break - } - }*/ - // ์ง€์ง€๊ธˆ๊ตฌ ์„ค์น˜ - installBracket() } const findNextModule = (currentPoint, centerPoints, direction) => { - let { x, y, width, height } = currentPoint - width = Math.floor(width) - height = Math.floor(height) + let { x, y, width, height, horizontal, vertical } = { ...currentPoint } + width = width + horizontal + height = height + vertical + + let maxX = 2 + horizontal * 3 + let maxY = 2 + vertical * 3 let result switch (direction) { case 'south': { - result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < 2 && Math.abs(centerPoint.y - (y - height)) < 2) + result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY) break } case 'north': { - result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < 2 && Math.abs(centerPoint.y - (y + height)) < 2) + result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY) break } case 'east': { - result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < 2 && Math.abs(centerPoint.y - y) < 2) + result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY) break } case 'west': { - result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < 2 && Math.abs(centerPoint.y - y) < 2) + result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY) break } } @@ -348,16 +456,23 @@ export const useTrestle = () => { } const findNextLeftModule = (currentPoint, centerPoints, direction) => { - const { x, y, width, height } = currentPoint + let { x, y, width, height, horizontal, vertical } = { ...currentPoint } + let result let topLeftPoint + let maxX = 2 + horizontal * 3 + let maxY = 2 + vertical * 3 switch (direction) { case 'south': { + width = width + horizontal + height = height + vertical topLeftPoint = { x: x - width / 2, y: y - height } break } case 'north': { + width = width + horizontal + height = height + vertical topLeftPoint = { x: x + width / 2, y: y + height } break } @@ -371,15 +486,20 @@ export const useTrestle = () => { } } - result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < 2 && Math.abs(centerPoint.y - topLeftPoint.y) < 2) + result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY) return result } const findNextRightModule = (currentPoint, centerPoints, direction) => { - const { x, y, width, height } = currentPoint + let { x, y, width, height, horizontal, vertical } = { ...currentPoint } + width = width + horizontal + height = height + vertical let result let topRightPoint + let maxX = 2 + horizontal * 3 + let maxY = 2 + vertical * 3 + switch (direction) { case 'south': { topRightPoint = { x: x + width / 2, y: y - height } @@ -399,13 +519,16 @@ export const useTrestle = () => { } } - result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < 2 && Math.abs(centerPoint.y - topRightPoint.y) < 2) + result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY) return result } - const drawRacks = (rackInfos, rackQty, rackIntvlPct, module, direction, l) => { - const { width, height } = module + const drawRacks = (rackInfos, rackQty, rackIntvlPct, module, direction, l, rackYn) => { + const { width, height, left, top, lastX, lastY } = module + + const moduleLeft = lastX ?? left + const moduleTop = lastY ?? top let startPointX, startPointY @@ -500,6 +623,7 @@ export const useTrestle = () => { offsetX: 0, offsetY: 0, }, + parentId: module.id, supFitQty, supFitIntvlPct, rackLen, @@ -530,11 +654,13 @@ export const useTrestle = () => { offsetX: 0, offsetY: 0, }, + parentId: module.id, strokeWidth: 4, selectable: false, supFitQty, supFitIntvlPct, rackLen, + rackYn, rackId: itemId, direction: 'left', }) @@ -562,6 +688,7 @@ export const useTrestle = () => { offsetX: 0, offsetY: 0, }, + parentId: module.id, strokeWidth: 4, selectable: false, supFitQty, @@ -593,6 +720,7 @@ export const useTrestle = () => { offsetX: 0, offsetY: 0, }, + parentId: module.id, strokeWidth: 4, selectable: false, supFitQty, @@ -612,32 +740,40 @@ export const useTrestle = () => { } } - const installBracket = () => { - const racks = canvas.getObjects().filter((obj) => obj.name === 'rack') - // name์ด bracket์ธ ๊ฐ์ฒด๋ฅผ ์ฐพ์•„์„œ ์‚ญ์ œ - canvas.getObjects().forEach((obj) => { - if (obj.name === 'bracket') { - canvas.remove(obj) - } + const installBracket = (surface) => { + const modules = surface.modules + const racks = [] + modules.forEach((module) => { + canvas + .getObjects() + .filter((obj) => obj.name === 'rack') + .forEach((rack) => { + if (rack.parentId === module.id) { + canvas.remove(canvas.getObjects().filter((obj) => obj.name === 'bracket' && obj.parentId === rack.id)) + racks.push(rack) + } + }) }) + canvas.renderAll() racks.forEach((rack) => { const { x1, y1, x2, y2, direction, supFitQty, supFitIntvlPct, rackLen } = rack - const moduleLength = 10 + const bracketLength = 10 if (direction === 'top') { const result = getBracketPoints(supFitQty, supFitIntvlPct) result.forEach((percent) => { const bracket = new fabric.Rect({ - left: x2 - moduleLength / 3, + left: x2 - bracketLength / 3, top: y2 + (rackLen / 10) * percent, fill: 'green', name: 'bracket', - width: moduleLength, - height: moduleLength, + parentId: rack.parentId, + width: bracketLength, + height: bracketLength, selectable: false, }) @@ -650,11 +786,12 @@ export const useTrestle = () => { result.forEach((percent) => { const bracket = new fabric.Rect({ left: x2 + (rackLen / 10) * percent, - top: y2 - moduleLength / 3, + top: y2 - bracketLength / 3, fill: 'green', name: 'bracket', - width: moduleLength, - height: moduleLength, + parentId: rack.parentId, + width: bracketLength, + height: bracketLength, selectable: false, }) @@ -667,11 +804,12 @@ export const useTrestle = () => { result.forEach((percent) => { const bracket = new fabric.Rect({ left: x2 - (rackLen / 10) * percent, - top: y2 - moduleLength / 3, + top: y2 - bracketLength / 3, fill: 'green', + parentId: rack.parentId, name: 'bracket', - width: moduleLength, - height: moduleLength, + width: bracketLength, + height: bracketLength, selectable: false, }) @@ -683,12 +821,13 @@ export const useTrestle = () => { result.forEach((percent) => { const bracket = new fabric.Rect({ - left: x2 - moduleLength / 3, + left: x2 - bracketLength / 3, top: y2 - (rackLen / 10) * percent, fill: 'green', name: 'bracket', - width: moduleLength, - height: moduleLength, + parentId: rack.parentId, + width: bracketLength, + height: bracketLength, selectable: false, }) @@ -699,6 +838,153 @@ export const useTrestle = () => { }) } + //๋ž™ ์—†์Œ ์ธ ๊ฒฝ์šฐ ์ง€์ง€๊ธˆ๊ตฌ ์„ค์น˜ + const installBracketWithOutRack = (surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory) => { + let { rackQty, rackIntvlPct, moduleIntvlHor, moduleIntvlVer } = surface.trestleDetail + rackQty = 3 + + canvas.renderAll() + exposedBottomModules.forEach((module) => { + canvas.renderAll() + drawBracketWithOutRack(module, rackIntvlPct, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer) + drawBracketWithOutRack(module, rackIntvlPct, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) + if (!isChidory && rackQty === 3) { + // ์น˜๋„๋ฆฌ๊ฐ€ ์•„๋‹ˆ๋ฉด์„œ ๊ฐฏ์ˆ˜๊ฐ€ 3๊ฐœ์ธ ๊ฒฝ์šฐ ์„ผํ„ฐ๋„ ์„ค์น˜ ํ•„์š”ํ•จ + drawBracketWithOutRack(module, rackIntvlPct, module.centerRows + 1, 'C', surface.direction, moduleIntvlHor, moduleIntvlVer) + } + + if (isChidory && rackQty === 3) { + 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) + drawBracketWithOutRack(module, rackIntvlPct / 3, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) + } + + if (rackQty === 5) { + drawBracketWithOutRack(module, rackIntvlPct / 3, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer) + drawBracketWithOutRack(module, rackIntvlPct / 3, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) + drawBracketWithOutRack(module, rackIntvlPct / 3, module.rightRows + 1, 'C', surface.direction, moduleIntvlHor, moduleIntvlVer) + } + }) + + leftExposedHalfBottomModules.forEach((module) => { + drawBracketWithOutRack(module, rackIntvlPct, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer) + if (rackQty === 4) { + drawBracketWithOutRack(module, rackIntvlPct / 3, module.leftRows + 1, 'L', surface.direction, moduleIntvlHor, moduleIntvlVer) + } + }) + + rightExposedHalfBottomPoints.forEach((module) => { + drawBracketWithOutRack(module, rackIntvlPct, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) + if (rackQty === 4) { + drawBracketWithOutRack(module, rackIntvlPct / 3, module.rightRows + 1, 'R', surface.direction, moduleIntvlHor, moduleIntvlVer) + } + }) + } + + const drawBracketWithOutRack = (module, rackIntvlPct, count, l, direction, moduleIntvlHor, moduleIntvlVer) => { + let { width, height, left, top } = module + let startPointX + let startPointY + + switch (l) { + case 'L': { + // ์™ผ์ชฝ๋ถ€๋ถ„ ์‹œ์ž‘ ์  + if (direction === 'south') { + startPointX = left + width / rackIntvlPct + startPointY = top + height + break + } else if (direction === 'east') { + startPointX = left + width + startPointY = top + height - height / rackIntvlPct + break + } else if (direction === 'west') { + startPointX = left + startPointY = top + height / rackIntvlPct + break + } else if (direction === 'north') { + startPointX = left + width - width / rackIntvlPct + startPointY = top + break + } + } + + case 'R': { + // ์˜ค๋ฅธ์ชฝ๋ถ€๋ถ„ ์‹œ์ž‘ ์  + if (direction === 'south') { + startPointX = left + width - width / rackIntvlPct + startPointY = top + height / 2 + height / 2 + break + } else if (direction === 'east') { + startPointX = left + width + startPointY = top + height / rackIntvlPct + break + } else if (direction === 'west') { + startPointX = left + startPointY = top + height - height / rackIntvlPct + break + } else if (direction === 'north') { + startPointX = left + width / rackIntvlPct + startPointY = top + break + } + } + case 'C': { + // ์ค‘๊ฐ„๋ถ€๋ถ„ ์‹œ์ž‘์  + if (direction === 'south') { + const x = left + width / 2 + const y = top + height / 2 + startPointX = x + startPointY = y + height / 2 + break + } else if (direction === 'east') { + const x = left + width + const y = top + height / 2 + startPointX = x + startPointY = y + break + } else if (direction === 'west') { + const x = left + const y = top + height / 2 + startPointX = x + startPointY = y + break + } else if (direction === 'north') { + const x = left + width / 2 + const y = top + startPointX = x + startPointY = y + break + } + } + } + + for (let i = 0; i < count; i++) { + const bracket = new fabric.Rect({ + left: startPointX - 5, + top: startPointY - 5, + fill: 'green', + name: 'bracket', + parentId: module.id, + width: 10, + height: 10, + selectable: false, + }) + canvas.add(bracket) + canvas.renderAll() + if (direction === 'south') { + startPointY -= height + moduleIntvlVer + } else if (direction === 'north') { + startPointY += height + moduleIntvlVer + } else if (direction === 'east') { + startPointX -= width + moduleIntvlHor + } else if (direction === 'west') { + startPointX += width + moduleIntvlHor + } + } + } + const getBracketPoints = (n, percent) => { if (n < 2) { throw new Error('Number of points must be at least 2') @@ -747,10 +1033,18 @@ export const useTrestle = () => { const direction = moduleSurface.direction const modules = moduleSurface.modules + const horizontal = ['south', 'north'].includes(direction) + ? moduleSurface.trestleDetail.moduleIntvlHor + : moduleSurface.trestleDetail.moduleIntvlVer + + const vertical = ['south', 'north'].includes(direction) ? moduleSurface.trestleDetail.moduleIntvlVer : moduleSurface.trestleDetail.moduleIntvlHor + + const maxX = 2 + horizontal * 3 + const maxY = 2 + vertical * 3 modules.forEach((module, index) => { module.tempIndex = index const { x, y } = module.getCenterPoint() - const { width, height } = module + const { width, height } = { ...module } centerPoints.push({ x, y, width: Math.floor(width), height: Math.floor(height), index }) }) @@ -775,9 +1069,11 @@ export const useTrestle = () => { // ๋ฐ˜๋…ธ์ถœ bottom๋ฉด์˜ points let leftExposedHalfBottomPoints = [] let rightExposedHalfBottomPoints = [] + let leftExposedHalfTopPoints = [] + let rightExposedHalfTopPoints = [] centerPoints.forEach((centerPoint, index) => { - const { x, y, width, height } = centerPoint + let { x, y, width, height } = { ...centerPoint } // centerPoints์ค‘์— ํ˜„์žฌ centerPoint์™€ x๊ฐ’์ด ๊ฐ™๊ณ , y๊ฐ’์ด y-height๊ฐ’๊ณผ ๊ฐ™์€ centerPoint๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ let bottomCell let bottomLeftPoint @@ -787,22 +1083,28 @@ export const useTrestle = () => { switch (direction) { case 'south': - bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < 2 && Math.abs(centerPoint.y - (y + height)) < 2) + width = width + horizontal + height = height + vertical + bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY) bottomLeftPoint = { x: x - width / 2, y: y + height } bottomRightPoint = { x: x + width / 2, y: y + height } break case 'north': - bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < 2 && Math.abs(centerPoint.y - (y - height)) < 2) + width = width + horizontal + height = height + vertical + bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY) bottomLeftPoint = { x: x + width / 2, y: y - height } bottomRightPoint = { x: x - width / 2, y: y - height } break case 'east': - bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x + width)) < 2 && Math.abs(centerPoint.y - y) < 2) + bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY) + width = width + horizontal bottomLeftPoint = { x: x + width, y: y + height / 2 } bottomRightPoint = { x: x + width, y: y - height / 2 } break case 'west': - bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x - width)) < 2 && Math.abs(centerPoint.y - y) < 2) + bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY) + width = width + horizontal bottomLeftPoint = { x: x - width, y: y - height / 2 } bottomRightPoint = { x: x - width, y: y + height / 2 } break @@ -814,10 +1116,10 @@ export const useTrestle = () => { // ๋ฐ”๋กœ ์•„๋ž˜์— ์…€์ด ์—†๋Š” ๊ฒฝ์šฐ ๋ฌผ๋–ผ์„ธ ๋ฐฐ์น˜๊ฐ€ ์™ผ์ชฝ ๋˜์–ด์žˆ๋Š” ์…€์„ ์ฐพ๋Š”๋‹ค. leftBottomCnt = centerPoints.filter( - (centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < 2 && Math.abs(centerPoint.y - bottomLeftPoint.y) < 2, + (centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY, ).length rightBottomCnt = centerPoints.filter( - (centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < 2 && Math.abs(centerPoint.y - bottomRightPoint.y) < 2, + (centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY, ).length if (leftBottomCnt + rightBottomCnt === 1) { @@ -835,7 +1137,7 @@ export const useTrestle = () => { // ๋…ธ์ถœ์ƒ๋ฉด ๋ฐ ์ ‘๋ฉด ์ฒดํฌ centerPoints.forEach((centerPoint, index) => { - const { x, y, width, height } = centerPoint + let { x, y, width, height } = { ...centerPoint } let topCell let topLeftPoint @@ -845,22 +1147,27 @@ export const useTrestle = () => { switch (direction) { case 'south': - topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < 2 && Math.abs(centerPoint.y - (y - height)) < 2) + width = width + horizontal + height = height + vertical + topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY) topLeftPoint = { x: x - width / 2, y: y - height } topRightPoint = { x: x + width / 2, y: y - height } break case 'north': - topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < 2 && Math.abs(centerPoint.y - (y + height)) < 2) + height = height + vertical + topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY) topLeftPoint = { x: x + width / 2, y: y + height } topRightPoint = { x: x - width / 2, y: y + height } break case 'east': - topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x - width)) < 2 && Math.abs(centerPoint.y - y) < 2) + width = width + horizontal + topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY) topLeftPoint = { x: x - width, y: y + height / 2 } topRightPoint = { x: x - width, y: y - height / 2 } break case 'west': - topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x + width)) < 2 && Math.abs(centerPoint.y - y) < 2) + width = width + horizontal + topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY) topLeftPoint = { x: x + width, y: y - height / 2 } topRightPoint = { x: x + width, y: y + height / 2 } break @@ -872,10 +1179,10 @@ export const useTrestle = () => { } leftTopCnt = centerPoints.filter( - (centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < 2 && Math.abs(centerPoint.y - topLeftPoint.y) < 2, + (centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY, ).length rightTopCnt = centerPoints.filter( - (centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < 2 && Math.abs(centerPoint.y - topRightPoint.y) < 2, + (centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY, ).length if (leftTopCnt + rightTopCnt === 2) { @@ -886,6 +1193,12 @@ export const useTrestle = () => { if (leftTopCnt + rightTopCnt === 1) { exposedHalfTop++ halfTouchDimension++ + if (leftTopCnt === 1) { + rightExposedHalfTopPoints.push(centerPoint) + } + if (rightTopCnt === 1) { + leftExposedHalfTopPoints.push(centerPoint) + } return } if (leftTopCnt + rightTopCnt === 0) { @@ -894,10 +1207,6 @@ export const useTrestle = () => { }) // ์™„์ „ ๋…ธ์ถœ ํ•˜๋ฉด ๊ณ„์‚ฐ - /*const cells = canvas.getObjects().filter((obj) => polygon.id === obj.parentId) - const points = cells.map((cell) => { - return cell.getCenterPoint() - })*/ const groupPoints = groupCoordinates(centerPoints, modules[0], direction) groupPoints.forEach((group) => { @@ -937,6 +1246,8 @@ export const useTrestle = () => { exposedBottomPoints, leftExposedHalfBottomPoints, rightExposedHalfBottomPoints, + leftExposedHalfTopPoints, + rightExposedHalfTopPoints, centerPoints, } } diff --git a/src/styles/_canvasside.scss b/src/styles/_canvasside.scss index ca9dee61..b49087ed 100644 --- a/src/styles/_canvasside.scss +++ b/src/styles/_canvasside.scss @@ -3,7 +3,7 @@ position: fixed; top: 200px; left: 50px; - z-index: 999999; + z-index: 100000; display: flex; width: 237px; height: 40px; diff --git a/src/styles/_reset.scss b/src/styles/_reset.scss index a77b35e2..106a50e7 100644 --- a/src/styles/_reset.scss +++ b/src/styles/_reset.scss @@ -912,9 +912,22 @@ input[type=text]{ font-size: 13px; padding: 7px 10px; color: #45576F; + } .custom__option--is-selected{ - color: #fff; + background-color: #2684FF; + color: #fff !important; + &.custom__option--is-focused{ + background-color: #2684FF; + color: #fff; + } + } + .custom__option--is-focused{ + background-color: #DEEBFF; + color: #45576F; + } + .special-option{ + color: red; } // disable &.custom--is-disabled{ @@ -925,6 +938,7 @@ input[type=text]{ color: #999999; } } + } // toggle