diff --git a/src/components/floor-plan/CanvasMenu.jsx b/src/components/floor-plan/CanvasMenu.jsx index 44c22d4b..517e2c35 100644 --- a/src/components/floor-plan/CanvasMenu.jsx +++ b/src/components/floor-plan/CanvasMenu.jsx @@ -359,7 +359,7 @@ export default function CanvasMenu(props) { }, [basicSetting])*/ const checkMenuState = (menu) => { - return (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.index === 2) || (menuNumber === 4 && menu.index === 2) + return (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.index === 2) || (menuNumber === 4 && [1, 2].includes(menu.index)) } const checkMenuAndCanvasState = () => { @@ -493,7 +493,7 @@ export default function CanvasMenu(props) { className={`canvas-menu-item ${menuNumber === menu.index ? 'active' : ''}`} onClick={() => { if (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.index === 2) return - if (menuNumber === 4 && menu.index === 2) return + if (menuNumber === 4 && [1, 2].includes(menu.index)) return onClickNav(menu) }} > diff --git a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx index 98d96ace..62f6769e 100644 --- a/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx @@ -94,14 +94,14 @@ export default function CircuitTrestleSetting({ id }) { // 시리즈중 자동으로 추천 PCS 정보 조회 getPcsAutoRecommendList(params).then((res) => { if (res.data?.pcsItemList) { - const itemList = models.filter((model) => { - return res.data?.pcsItemList.map((item) => item.itemId).includes(model.itemId) - }) - const selectedModels = itemList.map((model) => { - return { - ...model, - id: uuidv4(), - isUsed: false, + let pcsItemList = [] + res.data?.pcsItemList.forEach((item) => { + if (models.map((model) => model.itemId).includes(item.itemId)) { + pcsItemList.push({ + ...item, + id: uuidv4(), + isUsed: false, + }) } }) // 회로 구성 가능 여부 체크 요청 파라미터 @@ -112,7 +112,7 @@ export default function CircuitTrestleSetting({ id }) { pcsItemList: getPcsItemList(), } // 추천 목록 선택 - setSelectedModels(selectedModels) + setSelectedModels(pcsItemList) // 회로 구성 가능 여부 체크 getPcsVoltageChk(pcsVoltageChkParams).then((res) => { if (res.resultCode === 'S') { @@ -205,24 +205,26 @@ export default function CircuitTrestleSetting({ id }) { const getRoofSurfaceList = () => { const roofSurfaceList = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) roofSurfaceList.sort((a, b) => a.left - b.left || b.top - a.top) - return roofSurfaceList.map((obj) => { - return { - roofSurfaceId: obj.id, - roofSurface: canvas - .getObjects() - .filter((o) => o.id === obj.parentId)[0] - .directionText.replace(/[0-9]/g, ''), - roofSurfaceIncl: canvas.getObjects().filter((o) => o.id === obj.parentId)[0].roofMaterial.pitch, - moduleList: getModuleList(obj).map((module) => { - return { - itemId: module.moduleInfo.itemId, - circuit: module.circuitNumber ? module.circuitNumber : null, - pcsItemId: module.circuit ? module.circuit?.pcsItemId : null, - uniqueId: module.id ? module.id : null, - } - }), - } - }) + return roofSurfaceList + .map((obj) => { + return { + roofSurfaceId: obj.id, + roofSurface: canvas + .getObjects() + .filter((o) => o.id === obj.parentId)[0] + .directionText.replace(/[0-9]/g, ''), + roofSurfaceIncl: canvas.getObjects().filter((o) => o.id === obj.parentId)[0].roofMaterial.pitch, + moduleList: getModuleList(obj).map((module) => { + return { + itemId: module.moduleInfo.itemId, + circuit: module.circuitNumber ? module.circuitNumber : null, + pcsItemId: module.circuit ? module.circuit?.pcsItemId : null, + uniqueId: module.id ? module.id : null, + } + }), + } + }) + .filter((surface) => surface.moduleList.length > 0) } // 모듈 목록 @@ -338,7 +340,18 @@ export default function CircuitTrestleSetting({ id }) { const params = { ...getOptYn(), useModuleItemList: getUseModuleItemList(), - roofSurfaceList: getRoofSurfaceList(), + roofSurfaceList: getRoofSurfaceList().map((surface) => { + console.log(surface.moduleList) + return { + ...surface, + moduleList: surface.moduleList.map((module) => { + return { + itemId: module.itemId, + uniqueId: module.uniqueId, + } + }), + } + }), pcsItemList: getPcsItemList(), } @@ -348,19 +361,34 @@ export default function CircuitTrestleSetting({ id }) { const itemList = models.filter((model) => { return res.data?.pcsItemList.map((item) => item.itemId).includes(model.itemId) }) - const selectedModels = itemList.map((model) => { - return { - ...model, - id: uuidv4(), + + let pcsItemList = [] + let pcsObj = {} + models.forEach((model) => { + pcsObj[model.itemId] = model + }) + res.data?.pcsItemList.forEach((item) => { + if (pcsObj[item.itemId]) { + pcsItemList.push({ + ...pcsObj[item.itemId], + isUsed: false, + id: uuidv4(), + }) } }) const pcsVoltageChkParams = { ...getOptYn(), useModuleItemList: getUseModuleItemList(), roofSurfaceList: getRoofSurfaceList(), - pcsItemList: getPcsItemList(), + pcsItemList: pcsItemList.map((item) => { + return { + itemId: item.itemId, + pcsMkrCd: item.pcsMkrCd, + pcsSerCd: item.pcsSerCd, + } + }), } - setSelectedModels(selectedModels) + setSelectedModels(pcsItemList) getPcsVoltageChk(pcsVoltageChkParams).then((res) => { setAllocationType(ALLOCATION_TYPE.PASSIVITY) }) @@ -536,37 +564,21 @@ export default function CircuitTrestleSetting({ id }) { // 닫기 버튼 클릭 시 처리하는 함수 추가 const handleClose = () => { - swalFire({ - title: '변경사항을 저장하시겠습니까?', - //text: '저장하지 않은 변경사항은 모두 사라집니다.', - type: 'confirm', - confirmButtonText: '저장', - cancelButtonText: '취소', - icon: 'warning', - confirmFn: async () => { - // 저장 로직 실행 - await onApply() - closePopup(id) - }, - denyFn: () => { - // 회로 번호 텍스트 제거 - const circuitTexts = canvas.getObjects().filter((obj) => obj.name === 'circuitNumber') - canvas.remove(...circuitTexts) + // // 회로 번호 텍스트 제거 + const circuitTexts = canvas.getObjects().filter((obj) => obj.name === 'circuitNumber') + canvas.remove(...circuitTexts) + // 모듈의 회로 정보 초기화 + canvas + .getObjects() + .filter((obj) => obj.name === POLYGON_TYPE.MODULE) + .forEach((obj) => { + obj.circuit = null + obj.pcsItemId = null + obj.circuitNumber = null + }) - // 모듈의 회로 정보 초기화 - canvas - .getObjects() - .filter((obj) => obj.name === POLYGON_TYPE.MODULE) - .forEach((obj) => { - obj.circuit = null - obj.pcsItemId = null - obj.circuitNumber = null - }) - - canvas.renderAll() - closePopup(id) - }, - }) + canvas.renderAll() + closePopup(id) } return ( diff --git a/src/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect.jsx b/src/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect.jsx index 5496a0d5..ee56d4c4 100644 --- a/src/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect.jsx @@ -91,7 +91,6 @@ export default function PowerConditionalSelect(props) { } const onCheckSeries = (data) => { - console.log('data', data) const copySeries = series.map((s) => { return { ...s, @@ -99,12 +98,10 @@ export default function PowerConditionalSelect(props) { } }) setSeries(copySeries) - console.log('copySeries', copySeries) handleSetmodels(copySeries.filter((s) => s.selected)) } const handleSetmodels = (selectedSeries) => { - console.log('series', selectedSeries) if (selectedSeries.length === 0) { setModels([]) setSelectedModels([]) @@ -149,7 +146,7 @@ export default function PowerConditionalSelect(props) { return } - setSelectedModels([...selectedModels, { ...selectedRow, id: uuidv4() }]) + setSelectedModels([...selectedModels, { ...selectedRow, id: uuidv4(), isUsed: false }]) setSelectedRow(null) } @@ -163,7 +160,6 @@ export default function PowerConditionalSelect(props) { setSelectedMaker(option) getPcsMakerList(option).then((res) => { - console.log('getPcsMakerList(series)', res.data) setSeries( res.data.map((series) => { return { ...series, selected: false } 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 aa151d9c..ff1e7cb8 100644 --- a/src/components/floor-plan/modal/circuitTrestle/step/type/PassivityCircuitAllocation.jsx +++ b/src/components/floor-plan/modal/circuitTrestle/step/type/PassivityCircuitAllocation.jsx @@ -79,36 +79,36 @@ export default function PassivityCircuitAllocation(props) { const setSurfaceInfo = () => { const surfaces = canvas.getObjects().filter((obj) => POLYGON_TYPE.MODULE_SETUP_SURFACE === obj.name) // setHeaders([header[0], { name: '회로', prop: 'circuit' }, ...header.slice(1)]) - setRows( - rows.map((row) => { - return { - ...row, - circuit: '', - } - }), - ) - let totals = {} + // setRows( + // rows.map((row) => { + // return { + // ...row, + // circuit: '', + // } + // }), + // ) + // let totals = {} - rows.forEach((row) => { - if (header.length === 4) { - if (!totals[header[2].prop]) totals[header[2].prop] = 0 - totals[header[2].prop] += +row[header[2].prop] - } else if (header.length === 5) { - if (!totals[header[2].prop]) totals[header[2].prop] = 0 - totals[header[2].prop] += +row[header[2].prop] - if (!totals[header[3].prop]) totals[header[3].prop] = 0 - totals[header[3]] += +row[header[3]] - } - }) - setFooter([ - ...['합계', ''], - ...Object.keys(totals).map((key) => { - return totals[key] - }), - Object.keys(totals).reduce((acc, key) => { - return acc + totals[key] - }, 0), - ]) + // rows.forEach((row) => { + // if (header.length === 4) { + // if (!totals[header[2].prop]) totals[header[2].prop] = 0 + // totals[header[2].prop] += +row[header[2].prop] + // } else if (header.length === 5) { + // if (!totals[header[2].prop]) totals[header[2].prop] = 0 + // totals[header[2].prop] += +row[header[2].prop] + // if (!totals[header[3].prop]) totals[header[3].prop] = 0 + // totals[header[3]] += +row[header[3]] + // } + // }) + // setFooter([ + // ...['합계', ''], + // ...Object.keys(totals).map((key) => { + // return totals[key] + // }), + // Object.keys(totals).reduce((acc, key) => { + // return acc + totals[key] + // }, 0), + // ]) // let totalWpout = 0 // const rows = surfaces.map((surface) => { // let wpOut = 0 @@ -226,10 +226,23 @@ export default function PassivityCircuitAllocation(props) { setSelectedPcs(tempSelectedPcs) canvas.add(moduleCircuitText) }) + console.log('🚀 ~ handleCircuitNumberFix ~ selectedModels:', selectedModels) + + // let pcsList = [...selectedModels.map((model) => ({ ...model }))] + let pcsList = JSON.parse(JSON.stringify(selectedModels)) + pcsList = pcsList.map((model) => { + console.log('🚀 ~ handleCircuitNumberFix ~ pcsList:', pcsList) + if (model.id === selectedPcs.id) { + model.isUsed = true + } + return model + }) + + console.log('🚀 ~ handleCircuitNumberFix ~ pcsList:', pcsList) const roofSurfaceList = canvas .getObjects() - .filter((obj) => POLYGON_TYPE.MODULE_SETUP_SURFACE === obj.name) + .filter((obj) => POLYGON_TYPE.MODULE_SETUP_SURFACE === obj.name && obj?.modules.length > 0) .map((surface) => { return { roofSurfaceId: surface.id, @@ -246,45 +259,25 @@ export default function PassivityCircuitAllocation(props) { }) console.log('uniqueCircuitNumbers', uniqueCircuitNumbers) - const usedPcses = selectedModels.filter((model) => model.isUsed) - const pcsItemList = - usedPcses.length === 0 - ? [ - { - pcsMkrCd: selectedPcs.pcsMkrCd, - pcsSerCd: selectedPcs.pcsSerCd, - itemId: selectedPcs.itemId, - itemNm: selectedPcs.itemNm, - goodsNo: selectedPcs.goodsNo, - serQtyList: [ - { - serQty: targetModules.length, - paralQty: uniqueCircuitNumbers.length, - rmdYn: 'Y', - usePossYn: 'Y', - roofSurfaceList: roofSurfaceList, - }, - ], - }, - ] - : selectedModels.map((model, index) => { - return { - pcsMkrCd: model.pcsMkrCd, - pcsSerCd: model.pcsSerCd, - itemId: model.itemId, - itemNm: model.itemNm, - goodsNo: model.goodsNo, - serQtyList: [ - { - serQty: targetModules.length, - paralQty: uniqueCircuitNumbers.length, - rmdYn: 'Y', - usePossYn: 'Y', - roofSurfaceList: roofSurfaceList, - }, - ], - } - }) + const usedPcses = pcsList.filter((model) => model.isUsed) + const pcsItemList = usedPcses.map((model, index) => { + return { + pcsMkrCd: model.pcsMkrCd, + pcsSerCd: model.pcsSerCd, + itemId: model.itemId, + itemNm: model.itemNm, + goodsNo: model.goodsNo, + serQtyList: [ + { + serQty: targetModules.length, + paralQty: uniqueCircuitNumbers.length, + rmdYn: 'Y', + usePossYn: 'Y', + roofSurfaceList: roofSurfaceList, + }, + ], + } + }) const params = { ...getApiProps(), @@ -318,17 +311,15 @@ export default function PassivityCircuitAllocation(props) { return } - setSelectedModels( - selectedModels.map((model) => { - return { ...model, isUsed: model.id === selectedPcs.id ? true : model.isUsed } - }), - ) + setSelectedModels(pcsList) setTargetModules([]) setCircuitNumber(+circuitNumber + 1) setModuleStatisticsData() }) } + console.log('🚀 ~ handleCircuitNumberFix ~ selectedModels:', selectedModels) + console.log('🚀 ~ handleCircuitNumberFix ~ selectedModels:', selectedModels) const getCircuitNumber = () => { if (selectedModels.length === 1) { diff --git a/src/components/floor-plan/modal/roofAllocation/ContextRoofAllocationSetting.jsx b/src/components/floor-plan/modal/roofAllocation/ContextRoofAllocationSetting.jsx index dde3e468..bcd3dfe4 100644 --- a/src/components/floor-plan/modal/roofAllocation/ContextRoofAllocationSetting.jsx +++ b/src/components/floor-plan/modal/roofAllocation/ContextRoofAllocationSetting.jsx @@ -116,22 +116,25 @@ export default function ContextRoofAllocationSetting(props) { )} -
-
- {getMessage('slope')} -
- { - handleChangePitch(e, index) - }} - defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle} - /> + {roof.raftAuth && ( +
+
+ {getMessage('modal.placement.initial.setting.rafter')} + {raftCodes.length > 0 && ( +
+ +
+ )}
- {pitchText}
-
+ )} + {(roof.widAuth || roof.lenAuth) && ( <> {roof.widAuth && ( @@ -156,43 +159,37 @@ export default function ContextRoofAllocationSetting(props) { )} )} - {(roof.raftAuth || roof.roofPchAuth) && ( - <> - {roof.raftAuth && ( -
-
- {getMessage('modal.placement.initial.setting.rafter')} - {raftCodes.length > 0 && ( -
- -
- )} -
+ {roof.roofPchAuth && ( +
+
+ {getMessage('hajebichi')} +
+
- )} - {roof.roofPchAuth && ( -
-
- {getMessage('hajebichi')} -
- -
-
-
- )} - +
+
)} +
+
+ {getMessage('slope')} +
+ { + handleChangeInput(e, currentAngleType === 'slope' ? 'pitch' : 'angle', index) + }} + defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle} + /> +
+ {pitchText} +
+
-
-
- {getMessage('slope')} -
- { - handleChangePitch(e, index) - }} - defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle} - /> + + {roof.raftAuth && ( +
+
+ {getMessage('modal.placement.initial.setting.rafter')} + {raftCodes.length > 0 && ( +
+ handleChangeRaft(e, index)} + /> +
+ )}
- {pitchText}
-
+ )} + {(roof.widAuth || roof.lenAuth) && ( <> {roof.widAuth && ( @@ -170,45 +174,38 @@ export default function RoofAllocationSetting(props) { )} )} - {(roof.raftAuth || roof.roofPchAuth) && ( - <> - {roof.raftAuth && ( -
-
- {getMessage('modal.placement.initial.setting.rafter')} - {raftCodes.length > 0 && ( -
- handleChangeRaft(e, index)} - /> -
- )} -
+ {roof.roofPchAuth && ( +
+
+ {getMessage('hajebichi')} +
+ handleChangeInput(e, 'hajebichi', index)} + value={parseInt(roof.hajebichi)} + readOnly={roof.roofPchAuth === 'R'} + />
- )} - {roof.roofPchAuth && ( -
-
- {getMessage('hajebichi')} -
- handleChangeInput(e, 'hajebichi', index)} - value={parseInt(roof.hajebichi)} - readOnly={roof.roofPchAuth === 'R'} - /> -
-
-
- )} - +
+
)} +
+
+ {getMessage('slope')} +
+ { + handleChangePitch(e, index) + }} + defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle} + /> +
+ {pitchText} +
+