- 다국어 적용 및 할당 검증 로직 수정
This commit is contained in:
parent
f621a9e7bb
commit
48401a06df
@ -1,5 +1,5 @@
|
|||||||
import WithDraggable from '@/components/common/draggable/WithDraggable'
|
import WithDraggable from '@/components/common/draggable/WithDraggable'
|
||||||
import { useState, useEffect, useContext } from 'react'
|
import { useState, useEffect, useContext, useRef } from 'react'
|
||||||
import PowerConditionalSelect from '@/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect'
|
import PowerConditionalSelect from '@/components/floor-plan/modal/circuitTrestle/step/PowerConditionalSelect'
|
||||||
import StepUp from '@/components/floor-plan/modal/circuitTrestle/step/StepUp'
|
import StepUp from '@/components/floor-plan/modal/circuitTrestle/step/StepUp'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
@ -43,7 +43,7 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
const [circuitAllocationType, setCircuitAllocationType] = useState(1)
|
const [circuitAllocationType, setCircuitAllocationType] = useState(1)
|
||||||
const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext)
|
const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext)
|
||||||
const selectedModules = useRecoilValue(selectedModuleState)
|
const selectedModules = useRecoilValue(selectedModuleState)
|
||||||
const { getPcsAutoRecommendList, getPcsVoltageChk, getPcsVoltageStepUpList } = useMasterController()
|
const { getPcsAutoRecommendList, getPcsVoltageChk, getPcsVoltageStepUpList, getPcsManualConfChk } = useMasterController()
|
||||||
|
|
||||||
// 회로할당(승합설정)에서 선택된 값들을 저장할 상태 추가
|
// 회로할당(승합설정)에서 선택된 값들을 저장할 상태 추가
|
||||||
const [selectedStepUpValues, setSelectedStepUpValues] = useState({})
|
const [selectedStepUpValues, setSelectedStepUpValues] = useState({})
|
||||||
@ -53,10 +53,9 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
const [stepUpListData, setStepUpListData] = useState([])
|
const [stepUpListData, setStepUpListData] = useState([])
|
||||||
const [seletedOption, setSeletedOption] = useState(null)
|
const [seletedOption, setSeletedOption] = useState(null)
|
||||||
const { setModuleStatisticsData } = useCircuitTrestle()
|
const { setModuleStatisticsData } = useCircuitTrestle()
|
||||||
|
|
||||||
const { handleCanvasToPng } = useImgLoader()
|
const { handleCanvasToPng } = useImgLoader()
|
||||||
const { saveCanvas } = usePlan()
|
const { saveCanvas } = usePlan()
|
||||||
|
const passivityCircuitAllocationRef = useRef()
|
||||||
const { setIsGlobalLoading } = useContext(QcastContext)
|
const { setIsGlobalLoading } = useContext(QcastContext)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -385,6 +384,7 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
obj.pcsItemId = null
|
obj.pcsItemId = null
|
||||||
obj.circuitNumber = null
|
obj.circuitNumber = null
|
||||||
})
|
})
|
||||||
|
setSelectedModels(JSON.parse(JSON.stringify(selectedModels)).map((model) => (model.isUsed = false)))
|
||||||
|
|
||||||
if (allocationType === ALLOCATION_TYPE.PASSIVITY) {
|
if (allocationType === ALLOCATION_TYPE.PASSIVITY) {
|
||||||
setAllocationType(ALLOCATION_TYPE.AUTO)
|
setAllocationType(ALLOCATION_TYPE.AUTO)
|
||||||
@ -479,16 +479,18 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleStepUp = () => {
|
const handleStepUp = () => {
|
||||||
const notAllocationModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE && !obj.circuit)
|
handlePassivityAllocationCkeck()
|
||||||
if (notAllocationModules.length > 0) {
|
// const notAllocationModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE && !obj.circuit)
|
||||||
swalFire({
|
// if (notAllocationModules.length > 0) {
|
||||||
title: getMessage('not.allocation.exist.module'),
|
// swalFire({
|
||||||
type: 'alert',
|
// title: getMessage('not.allocation.exist.module'),
|
||||||
})
|
// type: 'alert',
|
||||||
return
|
// })
|
||||||
} else {
|
// return
|
||||||
setTabNum(2)
|
// } else {
|
||||||
}
|
// passivityCircuitAllocationRef.current.onApply()
|
||||||
|
// setTabNum(2)
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 닫기 버튼 클릭 시 처리하는 함수 추가
|
// 닫기 버튼 클릭 시 처리하는 함수 추가
|
||||||
@ -510,6 +512,83 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
closePopup(id)
|
closePopup(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handlePassivityAllocationCkeck = () => {
|
||||||
|
let pcsCount = {}
|
||||||
|
let result = {}
|
||||||
|
canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => obj.name === POLYGON_TYPE.MODULE)
|
||||||
|
.forEach((module) => {
|
||||||
|
const circuitNumber = module.circuitNumber.replace(/[()]/g, '')
|
||||||
|
pcsCount[circuitNumber] = (pcsCount[circuitNumber] || 0) + 1
|
||||||
|
})
|
||||||
|
for (const key in pcsCount) {
|
||||||
|
const firstPart = key.split('-')[0] // '-' 기준으로 첫 번째 부분을 추출
|
||||||
|
const value = pcsCount[key]
|
||||||
|
|
||||||
|
// 그룹이 없으면 초기화
|
||||||
|
if (!result[firstPart]) {
|
||||||
|
result[firstPart] = { maxValue: value, count: 1 }
|
||||||
|
} else {
|
||||||
|
// 이미 그룹이 있으면 큰 값으로 갱신, count는 증가
|
||||||
|
result[firstPart].maxValue = Math.max(result[firstPart].maxValue, value)
|
||||||
|
result[firstPart].count += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const params = {
|
||||||
|
...getOptYn(),
|
||||||
|
useModuleItemList: getUseModuleItemList(),
|
||||||
|
roofSurfaceList: getRoofSurfaceList(),
|
||||||
|
pcsItemList: selectedModels.map((model, index) => {
|
||||||
|
return {
|
||||||
|
pcsMkrCd: model.pcsMkrCd,
|
||||||
|
pcsSerCd: model.pcsSerCd,
|
||||||
|
itemId: model.itemId,
|
||||||
|
itemNm: model.itemNm,
|
||||||
|
goodsNo: model.goodsNo,
|
||||||
|
serQtyList: [
|
||||||
|
{
|
||||||
|
serQty: result[index + 1].maxValue,
|
||||||
|
paralQty: result[index + 1].count,
|
||||||
|
rmdYn: 'Y',
|
||||||
|
usePossYn: 'Y',
|
||||||
|
roofSurfaceList: canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => POLYGON_TYPE.MODULE_SETUP_SURFACE === obj.name && obj?.modules.length > 0)
|
||||||
|
.map((surface) => {
|
||||||
|
return {
|
||||||
|
roofSurfaceId: surface.id,
|
||||||
|
roofSurface: surface.direction,
|
||||||
|
roofSurfaceIncl: +canvas.getObjects().filter((obj) => obj.id === surface.parentId)[0].pitch,
|
||||||
|
moduleList: surface.modules.map((module) => {
|
||||||
|
return {
|
||||||
|
itemId: module.moduleInfo.itemId,
|
||||||
|
circuit: module.circuitNumber,
|
||||||
|
pcsItemId: module.pcsItemId,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
getPcsManualConfChk(params).then((res) => {
|
||||||
|
if (res?.resultCode === 'E') {
|
||||||
|
swalFire({
|
||||||
|
text: res.resultMsg,
|
||||||
|
type: 'alert',
|
||||||
|
icon: 'warning',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
setTabNum(2)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WithDraggable isShow={true} pos={{ x: 50, y: 230 }}>
|
<WithDraggable isShow={true} pos={{ x: 50, y: 230 }}>
|
||||||
<div className={`modal-pop-wrap l-2`}>
|
<div className={`modal-pop-wrap l-2`}>
|
||||||
@ -531,7 +610,9 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{tabNum === 1 && allocationType === ALLOCATION_TYPE.AUTO && <PowerConditionalSelect {...powerConditionalSelectProps} />}
|
{tabNum === 1 && allocationType === ALLOCATION_TYPE.AUTO && <PowerConditionalSelect {...powerConditionalSelectProps} />}
|
||||||
{tabNum === 1 && allocationType === ALLOCATION_TYPE.PASSIVITY && <PassivityCircuitAllocation {...passivityProps} />}
|
{tabNum === 1 && allocationType === ALLOCATION_TYPE.PASSIVITY && (
|
||||||
|
<PassivityCircuitAllocation {...passivityProps} ref={passivityCircuitAllocationRef} />
|
||||||
|
)}
|
||||||
{tabNum === 2 && <StepUp {...stepUpProps} onInitialize={handleStepUpInitialize} />}
|
{tabNum === 2 && <StepUp {...stepUpProps} onInitialize={handleStepUpInitialize} />}
|
||||||
{tabNum === 1 && allocationType === ALLOCATION_TYPE.AUTO && (
|
{tabNum === 1 && allocationType === ALLOCATION_TYPE.AUTO && (
|
||||||
<div className="grid-btn-wrap">
|
<div className="grid-btn-wrap">
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import { useRecoilState, useRecoilValue } from 'recoil'
|
|||||||
|
|
||||||
export default function PassivityCircuitAllocation(props) {
|
export default function PassivityCircuitAllocation(props) {
|
||||||
const {
|
const {
|
||||||
|
setTabNum,
|
||||||
selectedModels,
|
selectedModels,
|
||||||
setSelectedModels,
|
setSelectedModels,
|
||||||
getOptYn: getApiProps,
|
getOptYn: getApiProps,
|
||||||
@ -88,14 +89,14 @@ export default function PassivityCircuitAllocation(props) {
|
|||||||
]
|
]
|
||||||
if (!circuitNumber || circuitNumber === 0) {
|
if (!circuitNumber || circuitNumber === 0) {
|
||||||
swalFire({
|
swalFire({
|
||||||
text: '회로번호를 1 이상입력해주세요.',
|
text: getMessage('module.circuit.minimun.error'),
|
||||||
type: 'alert',
|
type: 'alert',
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
} else if (targetModules.length === 0) {
|
} else if (targetModules.length === 0) {
|
||||||
swalFire({
|
swalFire({
|
||||||
text: '모듈을 선택해주세요.',
|
text: getMessage('module.not.found'),
|
||||||
type: 'alert',
|
type: 'alert',
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
})
|
})
|
||||||
@ -113,7 +114,7 @@ export default function PassivityCircuitAllocation(props) {
|
|||||||
})
|
})
|
||||||
if (result) {
|
if (result) {
|
||||||
swalFire({
|
swalFire({
|
||||||
text: '회로 번호가 같은 다른 파워 컨디셔너 모듈이 있습니다. 다른 회로 번호를 설정하십시오.',
|
text: getMessage('module.already.exist.error'),
|
||||||
type: 'alert',
|
type: 'alert',
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
})
|
})
|
||||||
@ -185,7 +186,30 @@ export default function PassivityCircuitAllocation(props) {
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
let pcsCount = {}
|
||||||
|
let result = {}
|
||||||
|
canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => obj.name === POLYGON_TYPE.MODULE)
|
||||||
|
.forEach((module) => {
|
||||||
|
if (module.circuitNumber) {
|
||||||
|
const circuitNumber = module.circuitNumber.replace(/[()]/g, '')
|
||||||
|
pcsCount[circuitNumber] = (pcsCount[circuitNumber] || 0) + 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
for (const key in pcsCount) {
|
||||||
|
const firstPart = key.split('-')[0] // '-' 기준으로 첫 번째 부분을 추출
|
||||||
|
const value = pcsCount[key]
|
||||||
|
|
||||||
|
// 그룹이 없으면 초기화
|
||||||
|
if (!result[firstPart]) {
|
||||||
|
result[firstPart] = { maxValue: value, count: 1 }
|
||||||
|
} else {
|
||||||
|
// 이미 그룹이 있으면 큰 값으로 갱신, count는 증가
|
||||||
|
result[firstPart].maxValue = Math.max(result[firstPart].maxValue, value)
|
||||||
|
result[firstPart].count += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
const usedPcses = pcsList.filter((model) => model.isUsed)
|
const usedPcses = pcsList.filter((model) => model.isUsed)
|
||||||
const pcsItemList = usedPcses.map((model, index) => {
|
const pcsItemList = usedPcses.map((model, index) => {
|
||||||
return {
|
return {
|
||||||
@ -196,8 +220,8 @@ export default function PassivityCircuitAllocation(props) {
|
|||||||
goodsNo: model.goodsNo,
|
goodsNo: model.goodsNo,
|
||||||
serQtyList: [
|
serQtyList: [
|
||||||
{
|
{
|
||||||
serQty: targetModules.length,
|
serQty: result[index + 1].maxValue,
|
||||||
paralQty: uniqueCircuitNumbers.length,
|
paralQty: result[index + 1].count,
|
||||||
rmdYn: 'Y',
|
rmdYn: 'Y',
|
||||||
usePossYn: 'Y',
|
usePossYn: 'Y',
|
||||||
roofSurfaceList: roofSurfaceList,
|
roofSurfaceList: roofSurfaceList,
|
||||||
@ -305,6 +329,173 @@ export default function PassivityCircuitAllocation(props) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onApply = () => {
|
||||||
|
let uniqueCircuitNumbers = [
|
||||||
|
...new Set(
|
||||||
|
canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => obj.name === POLYGON_TYPE.MODULE && obj.circuitNumber)
|
||||||
|
.map((obj) => obj.circuitNumber),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
if (!circuitNumber || circuitNumber === 0) {
|
||||||
|
swalFire({
|
||||||
|
text: getMessage('module.circuit.minimun.error'),
|
||||||
|
type: 'alert',
|
||||||
|
icon: 'warning',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
} else if (targetModules.length === 0) {
|
||||||
|
swalFire({
|
||||||
|
text: getMessage('module.not.found'),
|
||||||
|
type: 'alert',
|
||||||
|
icon: 'warning',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
} else if (selectedModels.length > 1) {
|
||||||
|
let result = false
|
||||||
|
|
||||||
|
uniqueCircuitNumbers.forEach((number) => {
|
||||||
|
if (
|
||||||
|
number.split('-')[1] === circuitNumber + ')' &&
|
||||||
|
number.split('-')[0] !== '(' + (selectedModels.findIndex((model) => model.id === selectedPcs.id) + 1)
|
||||||
|
) {
|
||||||
|
result = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (result) {
|
||||||
|
swalFire({
|
||||||
|
text: getMessage('module.already.exist.error'),
|
||||||
|
type: 'alert',
|
||||||
|
icon: 'warning',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let tempSelectedPcs = { ...selectedPcs }
|
||||||
|
canvas.discardActiveObject()
|
||||||
|
canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => targetModules.includes(obj.id))
|
||||||
|
.forEach((obj) => {
|
||||||
|
if (obj.circuit) {
|
||||||
|
canvas.remove(obj.circuit)
|
||||||
|
}
|
||||||
|
const moduleCircuitText = new fabric.Text(getCircuitNumber(), {
|
||||||
|
left: obj.left + obj.width / 2,
|
||||||
|
top: obj.top + obj.height / 2,
|
||||||
|
fontFamily: circuitNumberText.fontFamily.value,
|
||||||
|
fontWeight: circuitNumberText.fontWeight.value.toLowerCase().includes('bold') ? 'bold' : 'normal',
|
||||||
|
fontStyle: circuitNumberText.fontWeight.value.toLowerCase().includes('italic') ? 'italic' : 'normal',
|
||||||
|
fontSize: circuitNumberText.fontSize.value,
|
||||||
|
fill: circuitNumberText.fontColor.value,
|
||||||
|
width: obj.width,
|
||||||
|
height: obj.height,
|
||||||
|
textAlign: 'center',
|
||||||
|
originX: 'center',
|
||||||
|
originY: 'center',
|
||||||
|
name: 'circuitNumber',
|
||||||
|
selectable: false,
|
||||||
|
parentId: obj.id,
|
||||||
|
circuitInfo: selectedPcs,
|
||||||
|
visible: isDisplayCircuitNumber,
|
||||||
|
})
|
||||||
|
obj.set({
|
||||||
|
strokeWidth: 0.3,
|
||||||
|
})
|
||||||
|
obj.pcsItemId = selectedPcs.itemId
|
||||||
|
obj.pcsItemCode = selectedPcs.id
|
||||||
|
obj.circuit = moduleCircuitText
|
||||||
|
obj.circuitNumber = getCircuitNumber()
|
||||||
|
tempSelectedPcs.used = true
|
||||||
|
setSelectedPcs(tempSelectedPcs)
|
||||||
|
canvas.add(moduleCircuitText)
|
||||||
|
})
|
||||||
|
|
||||||
|
let pcsList = JSON.parse(JSON.stringify(selectedModels)).map((model) => {
|
||||||
|
if (model.id === selectedPcs.id) {
|
||||||
|
model.isUsed = true
|
||||||
|
}
|
||||||
|
return model
|
||||||
|
})
|
||||||
|
|
||||||
|
const roofSurfaceList = canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => POLYGON_TYPE.MODULE_SETUP_SURFACE === obj.name && obj?.modules.length > 0)
|
||||||
|
.map((surface) => {
|
||||||
|
return {
|
||||||
|
roofSurfaceId: surface.id,
|
||||||
|
roofSurface: surface.direction,
|
||||||
|
roofSurfaceIncl: +canvas.getObjects().filter((obj) => obj.id === surface.parentId)[0].pitch,
|
||||||
|
moduleList: surface.modules.map((module) => {
|
||||||
|
return {
|
||||||
|
itemId: module.moduleInfo.itemId,
|
||||||
|
circuit: module.circuitNumber,
|
||||||
|
pcsItemId: module.pcsItemId,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
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(),
|
||||||
|
useModuleItemList: getSelectedModuleList(),
|
||||||
|
pcsItemList: pcsItemList,
|
||||||
|
}
|
||||||
|
|
||||||
|
getPcsManualConfChk(params).then((res) => {
|
||||||
|
if (res?.resultCode === 'E') {
|
||||||
|
swalFire({
|
||||||
|
text: res.resultMsg,
|
||||||
|
type: 'alert',
|
||||||
|
icon: 'warning',
|
||||||
|
confirmFn: () => {
|
||||||
|
const circuitNumbers = canvas.getObjects().filter((obj) => obj.name === 'circuitNumber' && targetModules.includes(obj.parentId))
|
||||||
|
canvas.remove(...circuitNumbers)
|
||||||
|
canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => obj.name === 'module' && targetModules.includes(obj.id))
|
||||||
|
.forEach((obj) => {
|
||||||
|
obj.pcsItemId = null
|
||||||
|
obj.circuit = null
|
||||||
|
obj.circuitNumber = null
|
||||||
|
})
|
||||||
|
canvas.renderAll()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
setSelectedPcs({ ...selectedPcs, used: false })
|
||||||
|
setTargetModules([])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectedModels(pcsList)
|
||||||
|
|
||||||
|
setTargetModules([])
|
||||||
|
setModuleStatisticsData()
|
||||||
|
setTabNum(2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="properties-setting-wrap outer">
|
<div className="properties-setting-wrap outer">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user