Merge remote-tracking branch 'origin/qcast-pub' into dev
# Conflicts: # src/components/floor-plan/modal/circuitTrestle/CircuitTrestleSetting.jsx
This commit is contained in:
commit
757f5ed194
@ -18,6 +18,7 @@ import { canvasState } from '@/store/canvasAtom'
|
||||
|
||||
import { useTrestle } from '@/hooks/module/useTrestle'
|
||||
import { selectedModuleState } from '@/store/selectedModuleOptions'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
const ALLOCATION_TYPE = {
|
||||
AUTO: 'auto',
|
||||
@ -43,29 +44,6 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext)
|
||||
const selectedModules = useRecoilValue(selectedModuleState)
|
||||
const { getPcsAutoRecommendList } = useMasterController()
|
||||
const powerConditionalSelectProps = {
|
||||
tabNum,
|
||||
setTabNum,
|
||||
makers,
|
||||
setMakers,
|
||||
selectedMaker,
|
||||
setSelectedMaker,
|
||||
series,
|
||||
setSeries,
|
||||
models,
|
||||
setModels,
|
||||
selectedModels,
|
||||
setSelectedModels,
|
||||
managementState,
|
||||
}
|
||||
|
||||
const passivityProps = {
|
||||
tabNum,
|
||||
setTabNum,
|
||||
pcsCheck,
|
||||
selectedModels,
|
||||
setSelectedModels,
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!managementState) {
|
||||
@ -73,6 +51,14 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (allocationType === ALLOCATION_TYPE.PASSIVITY && tabNum === 2) {
|
||||
const notAllocationModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE && !obj.circuit)
|
||||
canvas.remove(...notAllocationModules)
|
||||
canvas.renderAll()
|
||||
}
|
||||
}, [tabNum])
|
||||
|
||||
const onAutoRecommend = () => {
|
||||
if (series.filter((s) => s.selected).length === 0) {
|
||||
swalFire({
|
||||
@ -91,7 +77,14 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
|
||||
getPcsAutoRecommendList(params).then((res) => {
|
||||
if (res.data?.pcsItemList) {
|
||||
setModels(res.data.pcsItemList)
|
||||
setModels(
|
||||
res.data.pcsItemList.map((model) => {
|
||||
return {
|
||||
...model,
|
||||
id: uuidv4(),
|
||||
}
|
||||
}),
|
||||
)
|
||||
setTabNum(2)
|
||||
} else {
|
||||
// 데이터가 없는 경우 오류 메시지 확인 필요
|
||||
@ -152,6 +145,8 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
moduleList: obj.modules.map((module) => {
|
||||
return {
|
||||
itemId: module.moduleInfo.itemId,
|
||||
circuit: module.circuitNumber ? module.circuitNumber : null,
|
||||
pcsItemId: module.circuit ? module.circuit?.pcsItemId : null,
|
||||
}
|
||||
}),
|
||||
}
|
||||
@ -190,11 +185,33 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
|
||||
const onPassivityAllocation = () => {
|
||||
if (selectedModels.length === 0) {
|
||||
swalFire({
|
||||
title: '파워 컨디셔너를 추가해 주세요.',
|
||||
type: 'alert',
|
||||
const params = {
|
||||
...getOptYn(),
|
||||
useModuleItemList: getUseModuleItemList(),
|
||||
roofSurfaceList: getRoofSurfaceList(),
|
||||
pcsItemList: getPcsItemList(),
|
||||
}
|
||||
|
||||
getPcsAutoRecommendList(params).then((res) => {
|
||||
if (res.data?.pcsItemList) {
|
||||
const itemList = models.filter((model) => {
|
||||
return res.data?.pcsItemList.map((item) => item.itemId).includes(model.itemId)
|
||||
})
|
||||
setSelectedModels(
|
||||
itemList.map((model) => {
|
||||
return {
|
||||
...model,
|
||||
id: uuidv4(),
|
||||
}
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
swalFire({
|
||||
title: '파워컨디셔너를 추가해 주세요.',
|
||||
type: 'alert',
|
||||
})
|
||||
}
|
||||
})
|
||||
return
|
||||
} else if (pcsCheck.max) {
|
||||
const moduleStdQty = selectedModels.reduce((acc, model) => {
|
||||
return acc + parseInt(model.moduleStdQty)
|
||||
@ -218,6 +235,52 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
setAllocationType(ALLOCATION_TYPE.PASSIVITY)
|
||||
}
|
||||
|
||||
const onClickPrev = () => {
|
||||
setAllocationType(ALLOCATION_TYPE.AUTO)
|
||||
swalFire({
|
||||
text: '할당한 회로 번호가 초기화됩니다.',
|
||||
type: 'alert',
|
||||
icon: 'warning',
|
||||
confirmFn: () => {
|
||||
const circuitModules = canvas
|
||||
.getObjects()
|
||||
.filter((obj) => obj.name === 'module' && selectedModels.map((model) => model.id).includes(obj.circuit?.circuitInfo?.id))
|
||||
canvas.remove(...circuitModules.map((module) => module.circuit))
|
||||
circuitModules.forEach((obj) => {
|
||||
obj.circuit = null
|
||||
obj.pcsItemId = null
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const powerConditionalSelectProps = {
|
||||
tabNum,
|
||||
setTabNum,
|
||||
makers,
|
||||
setMakers,
|
||||
selectedMaker,
|
||||
setSelectedMaker,
|
||||
series,
|
||||
setSeries,
|
||||
models,
|
||||
setModels,
|
||||
selectedModels,
|
||||
setSelectedModels,
|
||||
managementState,
|
||||
}
|
||||
|
||||
const passivityProps = {
|
||||
tabNum,
|
||||
setTabNum,
|
||||
pcsCheck,
|
||||
selectedModels,
|
||||
setSelectedModels,
|
||||
getOptYn,
|
||||
getUseModuleItemList,
|
||||
getRoofSurfaceList,
|
||||
}
|
||||
|
||||
const stepUpProps = {
|
||||
tabNum,
|
||||
setTabNum,
|
||||
@ -231,8 +294,6 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
getPcsItemList, // PCS 아이템 목록
|
||||
}
|
||||
|
||||
console.log('🚀 ~ stepUpProps ~ stepUpProps:', stepUpProps)
|
||||
|
||||
return (
|
||||
<WithDraggable isShow={true} pos={{ x: 50, y: 230 }}>
|
||||
<div className={`modal-pop-wrap l-2`}>
|
||||
|
||||
@ -64,6 +64,7 @@ export default function PowerConditionalSelect(props) {
|
||||
useEffect(() => {
|
||||
if (makers.length === 0) {
|
||||
getPcsMakerList().then((res) => {
|
||||
console.log('getPcsMakerList', res.data)
|
||||
setMakers(res.data)
|
||||
})
|
||||
}
|
||||
@ -90,6 +91,7 @@ export default function PowerConditionalSelect(props) {
|
||||
}
|
||||
|
||||
const onCheckSeries = (data) => {
|
||||
console.log('data', data)
|
||||
const copySeries = series.map((s) => {
|
||||
return {
|
||||
...s,
|
||||
@ -97,12 +99,19 @@ export default function PowerConditionalSelect(props) {
|
||||
}
|
||||
})
|
||||
setSeries(copySeries)
|
||||
console.log('copySeries', copySeries)
|
||||
handleSetmodels(copySeries.filter((s) => s.selected))
|
||||
}
|
||||
|
||||
const handleSetmodels = (series) => {
|
||||
const pcsMkrCd = series[0]?.pcsMkrCd
|
||||
const pcsSerList = series.map((series) => {
|
||||
const handleSetmodels = (selectedSeries) => {
|
||||
console.log('series', selectedSeries)
|
||||
if (selectedSeries.length === 0) {
|
||||
setModels([])
|
||||
setSelectedModels([])
|
||||
return
|
||||
}
|
||||
const pcsMkrCd = selectedSeries[0]?.pcsMkrCd
|
||||
const pcsSerList = selectedSeries.map((series) => {
|
||||
return { pcsSerCd: series.pcsSerCd }
|
||||
})
|
||||
const moduleItemList = selectedModules.itemList?.map((module) => {
|
||||
@ -123,11 +132,10 @@ export default function PowerConditionalSelect(props) {
|
||||
}
|
||||
}),
|
||||
)
|
||||
return
|
||||
} else {
|
||||
setModels([])
|
||||
setSelectedModels([])
|
||||
}
|
||||
|
||||
setModels([])
|
||||
setSelectedModels([])
|
||||
})
|
||||
}
|
||||
|
||||
@ -146,15 +154,16 @@ export default function PowerConditionalSelect(props) {
|
||||
}
|
||||
|
||||
const onRemoveSelectedModel = (model) => {
|
||||
setModels(models.map((m) => ({ ...m, selected: m.code !== model.code ? m.selected : false })))
|
||||
setSelectedModels(selectedModels.filter((m) => m.id !== model.id))
|
||||
}
|
||||
|
||||
const onChangeMaker = (option) => {
|
||||
if (option) {
|
||||
setModels(null)
|
||||
setModels([])
|
||||
setSelectedMaker(option)
|
||||
|
||||
getPcsMakerList(option).then((res) => {
|
||||
console.log('getPcsMakerList(series)', res.data)
|
||||
setSeries(
|
||||
res.data.map((series) => {
|
||||
return { ...series, selected: false }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -147,7 +147,7 @@ export function useMasterController() {
|
||||
],
|
||||
}
|
||||
|
||||
return await post({ url: '/api/v1/master/getPcsSeriesItemList', data: test }).then((res) => {
|
||||
return await post({ url: '/api/v1/master/getPcsSeriesItemList', data: params }).then((res) => {
|
||||
return res
|
||||
})
|
||||
}
|
||||
@ -163,13 +163,12 @@ export function useMasterController() {
|
||||
*/
|
||||
const getPcsAutoRecommendList = async (params = null) => {
|
||||
return await post({ url: '/api/v1/master/getPcsAutoRecommendList', data: params }).then((res) => {
|
||||
console.log('🚀🚀 ~ getPcsAutoRecommendList ~ res:', res)
|
||||
return res
|
||||
})
|
||||
}
|
||||
|
||||
const pcsMaualConfChk = async (params = null) => {
|
||||
return await post({ url: '/api/v1/master/pcsMaualConfChk', data: params }).then((res) => {
|
||||
const getPcsManualConfChk = async (params = null) => {
|
||||
return await post({ url: '/api/v1/master/getPcsMenualConfChk', data: params }).then((res) => {
|
||||
return res
|
||||
})
|
||||
}
|
||||
@ -213,7 +212,7 @@ export function useMasterController() {
|
||||
getPcsMakerList,
|
||||
getPcsModelList,
|
||||
getPcsAutoRecommendList,
|
||||
pcsMaualConfChk,
|
||||
getPcsManualConfChk,
|
||||
getPcsVoltageStepUpList,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user