Merge branch 'qcast-pub' into dev
This commit is contained in:
commit
74d3cd5462
@ -52,7 +52,7 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
// const [stepUpListData, setStepUpListData] = useRecoilState(stepUpListDataState)
|
// const [stepUpListData, setStepUpListData] = useRecoilState(stepUpListDataState)
|
||||||
const [stepUpListData, setStepUpListData] = useState([])
|
const [stepUpListData, setStepUpListData] = useState([])
|
||||||
const [seletedOption, setSeletedOption] = useState(null)
|
const [seletedOption, setSeletedOption] = useState(null)
|
||||||
const { setModuleStatisticsData } = useCircuitTrestle()
|
const { setModuleStatisticsData, resetCircuits } = useCircuitTrestle()
|
||||||
const { handleCanvasToPng } = useImgLoader()
|
const { handleCanvasToPng } = useImgLoader()
|
||||||
|
|
||||||
const passivityCircuitAllocationRef = useRef()
|
const passivityCircuitAllocationRef = useRef()
|
||||||
@ -92,6 +92,17 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
// selectedModels,
|
// selectedModels,
|
||||||
// pcsCheck,
|
// pcsCheck,
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (
|
||||||
|
canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
|
.some((surface) => !surface.isComplete)
|
||||||
|
) {
|
||||||
|
resetCircuits()
|
||||||
|
}
|
||||||
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// 수동할당 시 모듈 삭제
|
// 수동할당 시 모듈 삭제
|
||||||
|
|||||||
@ -33,7 +33,6 @@ export default function PanelEdit(props) {
|
|||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
const { swalFire } = useSwal()
|
const { swalFire } = useSwal()
|
||||||
const { moduleMove, moduleCopy, moduleMultiMove, moduleMultiCopy, moduleMoveAll, moduleCopyAll } = useModule()
|
const { moduleMove, moduleCopy, moduleMultiMove, moduleMultiCopy, moduleMoveAll, moduleCopyAll } = useModule()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!canvas) {
|
if (!canvas) {
|
||||||
const isSetupModules = canvas.getObjects().filter((obj) => obj.name === 'module') // selectedObj에 없는 객체만 필터링
|
const isSetupModules = canvas.getObjects().filter((obj) => obj.name === 'module') // selectedObj에 없는 객체만 필터링
|
||||||
|
|||||||
@ -108,13 +108,18 @@ export function useModule() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
||||||
|
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
if (activeModule.circuit) {
|
if (activeModule.circuit) {
|
||||||
swalFire({
|
if (surfaces.some((surface) => surface.isComplete)) {
|
||||||
title: getMessage('can.not.move.module'),
|
swalFire({
|
||||||
icon: 'error',
|
title: getMessage('can.not.move.module'),
|
||||||
type: 'alert',
|
icon: 'error',
|
||||||
})
|
type: 'alert',
|
||||||
return
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
removeTrestleMaterials()
|
||||||
}
|
}
|
||||||
const modules = type === 'row' ? getRowModules(activeModule) : getColumnModules(activeModule)
|
const modules = type === 'row' ? getRowModules(activeModule) : getColumnModules(activeModule)
|
||||||
const otherModules = getOtherModules(modules)
|
const otherModules = getOtherModules(modules)
|
||||||
@ -224,7 +229,7 @@ export function useModule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modules.forEach((module) => {
|
modules.forEach((module) => {
|
||||||
const { top, left } = getPosotion(module, direction, Number(length) + Number(moduleLength), true)
|
const { top, left } = getPosotion(module, direction, Number(length) + Number(moduleLength) * 10, false)
|
||||||
module.clone((obj) => {
|
module.clone((obj) => {
|
||||||
obj.set({
|
obj.set({
|
||||||
parentId: module.parentId,
|
parentId: module.parentId,
|
||||||
@ -263,8 +268,12 @@ export function useModule() {
|
|||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
surface.set({ modules: [...surface.modules, ...copyModules] })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setModuleStatisticsData()
|
||||||
}
|
}
|
||||||
|
|
||||||
const moduleCopy = (length, direction) => {
|
const moduleCopy = (length, direction) => {
|
||||||
@ -342,12 +351,17 @@ export function useModule() {
|
|||||||
}
|
}
|
||||||
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
||||||
if (activeModule.circuit) {
|
if (activeModule.circuit) {
|
||||||
swalFire({
|
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
title: getMessage('can.not.copy.module'),
|
if (surfaces.some((surface) => surface.isComplete)) {
|
||||||
icon: 'error',
|
swalFire({
|
||||||
type: 'alert',
|
title: getMessage('can.not.copy.module'),
|
||||||
})
|
icon: 'error',
|
||||||
return
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
removeTrestleMaterials()
|
||||||
}
|
}
|
||||||
const modules = type === 'row' ? getRowModules(activeModule) : getColumnModules(activeModule)
|
const modules = type === 'row' ? getRowModules(activeModule) : getColumnModules(activeModule)
|
||||||
const otherModules = canvas.getObjects().filter((obj) => obj.surfaceId === modules[0].surfaceId && obj.name === POLYGON_TYPE.MODULE)
|
const otherModules = canvas.getObjects().filter((obj) => obj.surfaceId === modules[0].surfaceId && obj.name === POLYGON_TYPE.MODULE)
|
||||||
@ -364,7 +378,7 @@ export function useModule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modules.forEach((module) => {
|
modules.forEach((module) => {
|
||||||
const { top, left } = getPosotion(module, direction, Number(length) + Number(moduleLength), true)
|
const { top, left } = getPosotion(module, direction, Number(length), true)
|
||||||
module.clone((obj) => {
|
module.clone((obj) => {
|
||||||
obj.set({
|
obj.set({
|
||||||
parentId: module.parentId,
|
parentId: module.parentId,
|
||||||
@ -385,6 +399,7 @@ export function useModule() {
|
|||||||
canvas.add(obj)
|
canvas.add(obj)
|
||||||
copyModules.push(obj)
|
copyModules.push(obj)
|
||||||
obj.setCoords()
|
obj.setCoords()
|
||||||
|
console.log(obj)
|
||||||
})
|
})
|
||||||
if (
|
if (
|
||||||
isOverlapOtherModules(copyModule, otherModules) ||
|
isOverlapOtherModules(copyModule, otherModules) ||
|
||||||
@ -430,6 +445,10 @@ export function useModule() {
|
|||||||
if (moduleSetupSurface.isComplete) {
|
if (moduleSetupSurface.isComplete) {
|
||||||
resetSurface()
|
resetSurface()
|
||||||
}
|
}
|
||||||
|
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
|
if (surfaces.some((surface) => surface.isComplete)) {
|
||||||
|
removeTrestleMaterials()
|
||||||
|
}
|
||||||
canvas.discardActiveObject()
|
canvas.discardActiveObject()
|
||||||
moduleSetupSurface.set({ modules: otherModules })
|
moduleSetupSurface.set({ modules: otherModules })
|
||||||
canvas.remove(...columnModules)
|
canvas.remove(...columnModules)
|
||||||
@ -528,14 +547,13 @@ export function useModule() {
|
|||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
surfaces.modules = surfaces.modules.filter((module) => !columnModules.map((copyModule) => copyModule.id).includes(module.id))
|
||||||
}
|
}
|
||||||
setModuleStatisticsData()
|
setModuleStatisticsData()
|
||||||
}
|
}
|
||||||
|
|
||||||
const moduleRowRemove = (type) => {
|
const moduleRowRemove = (type) => {
|
||||||
// if (isFixedModule()) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
||||||
const rowModules = getRowModules(activeModule)
|
const rowModules = getRowModules(activeModule)
|
||||||
const otherModules = getOtherModules(rowModules)
|
const otherModules = getOtherModules(rowModules)
|
||||||
@ -546,8 +564,9 @@ export function useModule() {
|
|||||||
let height = -1
|
let height = -1
|
||||||
const moduleSetupSurface = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)
|
const moduleSetupSurface = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)
|
||||||
let isWarning = false
|
let isWarning = false
|
||||||
if (moduleSetupSurface.isComplete) {
|
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
resetSurface()
|
if (surfaces.some((surface) => surface.isComplete)) {
|
||||||
|
removeTrestleMaterials()
|
||||||
}
|
}
|
||||||
canvas.discardActiveObject()
|
canvas.discardActiveObject()
|
||||||
moduleSetupSurface.set({ modules: otherModules })
|
moduleSetupSurface.set({ modules: otherModules })
|
||||||
@ -652,9 +671,6 @@ export function useModule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const moduleColumnInsert = (type) => {
|
const moduleColumnInsert = (type) => {
|
||||||
if (isFixedModule()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
||||||
const columnModules = getColumnModules(activeModule)
|
const columnModules = getColumnModules(activeModule)
|
||||||
let otherModules = getOtherModules(columnModules)
|
let otherModules = getOtherModules(columnModules)
|
||||||
@ -665,25 +681,11 @@ export function useModule() {
|
|||||||
const objects = getObjects()
|
const objects = getObjects()
|
||||||
const copyModules = []
|
const copyModules = []
|
||||||
const moduleSetupSurface = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)
|
const moduleSetupSurface = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)
|
||||||
if (moduleSetupSurface.isComplete) {
|
|
||||||
resetSurface()
|
|
||||||
}
|
|
||||||
let width = -1
|
|
||||||
let isWarning = false
|
let isWarning = false
|
||||||
const { moduleIntvlHor, moduleIntvlVer } = moduleSetupSurface.trestleDetail
|
const { moduleIntvlHor, moduleIntvlVer } = moduleSetupSurface.trestleDetail
|
||||||
if (targetModules.length === 0) {
|
|
||||||
swalFire({
|
|
||||||
title: '마지막 모듈입니다.',
|
|
||||||
icon: 'error',
|
|
||||||
type: 'alert',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
canvas.discardActiveObject()
|
canvas.discardActiveObject()
|
||||||
targetModules.forEach((module) => {
|
targetModules.forEach((module) => {
|
||||||
if (width === -1)
|
const { top, left } = getPosotion(module, type, moduleIntvlHor, true)
|
||||||
width = type === MODULE_INSERT_TYPE.LEFT ? Number(activeModule.left) - Number(module.left) : Number(module.left) - Number(activeModule.left)
|
|
||||||
const { top, left } = getPosotion(module, type, module.width, true)
|
|
||||||
module.originPos = {
|
module.originPos = {
|
||||||
left: module.left,
|
left: module.left,
|
||||||
top: module.top,
|
top: module.top,
|
||||||
@ -700,7 +702,7 @@ export function useModule() {
|
|||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
otherModules = getOtherModules(columnModules)
|
otherModules = getOtherModules(columnModules)
|
||||||
columnModules.forEach((module) => {
|
columnModules.forEach((module) => {
|
||||||
const { top, left } = getPosotion(module, type, module.width + moduleIntvlHor, true)
|
const { top, left } = getPosotion(module, type, moduleIntvlHor, true)
|
||||||
let copyModule = null
|
let copyModule = null
|
||||||
module.clone((obj) => {
|
module.clone((obj) => {
|
||||||
obj.set({
|
obj.set({
|
||||||
@ -749,6 +751,8 @@ export function useModule() {
|
|||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
moduleSetupSurface.modules = [...surface.modules, ...copyModules]
|
||||||
}
|
}
|
||||||
setModuleStatisticsData()
|
setModuleStatisticsData()
|
||||||
}
|
}
|
||||||
@ -779,29 +783,14 @@ export function useModule() {
|
|||||||
type === MODULE_INSERT_TYPE.TOP
|
type === MODULE_INSERT_TYPE.TOP
|
||||||
? otherModules.filter((module) => module.top < activeModule.top).sort((a, b) => a.top - b.top)
|
? otherModules.filter((module) => module.top < activeModule.top).sort((a, b) => a.top - b.top)
|
||||||
: otherModules.filter((module) => module.top > activeModule.top).sort((a, b) => a.top - b.top)
|
: otherModules.filter((module) => module.top > activeModule.top).sort((a, b) => a.top - b.top)
|
||||||
if (targetModules.length === 0) {
|
|
||||||
swalFire({
|
|
||||||
title: '마지막 모듈입니다.',
|
|
||||||
icon: 'error',
|
|
||||||
type: 'alert',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const objects = getObjects()
|
const objects = getObjects()
|
||||||
const copyModules = []
|
const copyModules = []
|
||||||
const moduleSetupSurface = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)
|
const moduleSetupSurface = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)
|
||||||
let height = -1
|
|
||||||
let isWarning = false
|
let isWarning = false
|
||||||
const { moduleIntvlHor, moduleIntvlVer } = moduleSetupSurface.trestleDetail
|
const { moduleIntvlHor, moduleIntvlVer } = moduleSetupSurface.trestleDetail
|
||||||
|
|
||||||
if (surface.isComplete) {
|
|
||||||
resetSurface()
|
|
||||||
}
|
|
||||||
canvas.discardActiveObject()
|
canvas.discardActiveObject()
|
||||||
targetModules.forEach((module) => {
|
targetModules.forEach((module) => {
|
||||||
if (height === -1)
|
const { top, left } = getPosotion(module, type, moduleIntvlVer, true)
|
||||||
height = type === MODULE_INSERT_TYPE.TOP ? Number(activeModule.top) - Number(module.top) : Number(module.top) - Number(activeModule.top)
|
|
||||||
const { top, left } = getPosotion(module, type, activeModule.height + moduleIntvlVer, true)
|
|
||||||
module.originPos = {
|
module.originPos = {
|
||||||
left: module.left,
|
left: module.left,
|
||||||
top: module.top,
|
top: module.top,
|
||||||
@ -817,7 +806,7 @@ export function useModule() {
|
|||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
otherModules = getOtherModules(rowModules)
|
otherModules = getOtherModules(rowModules)
|
||||||
rowModules.forEach((module) => {
|
rowModules.forEach((module) => {
|
||||||
const { top, left } = getPosotion(module, type, activeModule.height + moduleIntvlVer, true)
|
const { top, left } = getPosotion(module, type, moduleIntvlVer, true)
|
||||||
let copyModule = null
|
let copyModule = null
|
||||||
module.clone((obj) => {
|
module.clone((obj) => {
|
||||||
obj.set({
|
obj.set({
|
||||||
@ -869,6 +858,8 @@ export function useModule() {
|
|||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
moduleSetupSurface.modules = [...surface.modules, ...copyModules]
|
||||||
}
|
}
|
||||||
setModuleStatisticsData()
|
setModuleStatisticsData()
|
||||||
}
|
}
|
||||||
@ -931,14 +922,20 @@ export function useModule() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 회로가 없을때만 삭제 가능
|
||||||
const modulesRemove = () => {
|
const modulesRemove = () => {
|
||||||
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
const activeModule = canvas.getObjects().find((obj) => canvas.getActiveObjects()[0].id === obj.id)
|
||||||
const modules = canvas
|
const modules = canvas
|
||||||
.getObjects()
|
.getObjects()
|
||||||
.filter((obj) => obj.surfaceId === activeModule.surfaceId && obj.name === POLYGON_TYPE.MODULE && activeModule.id !== obj.id)
|
.filter((obj) => obj.surfaceId === activeModule.surfaceId && obj.name === POLYGON_TYPE.MODULE && activeModule.id !== obj.id)
|
||||||
const surface = canvas.getObjects().find((obj) => obj.id === activeModule.surfaceId && obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
const surface = canvas.getObjects().find((obj) => obj.id === activeModule.surfaceId && obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
if (surface.isComplete) {
|
if (activeModule.circuit) {
|
||||||
resetSurface()
|
swalFire({
|
||||||
|
title: getMessage('can.not.remove.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
surface.set({ modules: modules })
|
surface.set({ modules: modules })
|
||||||
|
|||||||
@ -2799,5 +2799,11 @@ export const useTrestle = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return { apply, getTrestleParams, clear, setViewCircuitNumberTexts, getEstimateData, setAllModuleSurfaceIsComplete }
|
// 배치면 전체에 가대 설치 여부
|
||||||
|
const isAllComplete = () => {
|
||||||
|
const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
|
||||||
|
return surfaces.every((surface) => surface.isComplete)
|
||||||
|
}
|
||||||
|
|
||||||
|
return { apply, getTrestleParams, clear, setViewCircuitNumberTexts, getEstimateData, setAllModuleSurfaceIsComplete, isAllComplete }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -176,8 +176,6 @@ export function useCircuitTrestle() {
|
|||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
const setPowerConditionerData = () => {}
|
|
||||||
|
|
||||||
const setModuleStatisticsData = () => {
|
const setModuleStatisticsData = () => {
|
||||||
console.log('selectedModules', selectedModules)
|
console.log('selectedModules', selectedModules)
|
||||||
if (!selectedModules || !selectedModules?.itemList || selectedModules?.itemList?.length === 0) return
|
if (!selectedModules || !selectedModules?.itemList || selectedModules?.itemList?.length === 0) return
|
||||||
@ -302,6 +300,13 @@ export function useCircuitTrestle() {
|
|||||||
})
|
})
|
||||||
if (circuitTexts.length > 0) canvas.remove(...circuitTexts)
|
if (circuitTexts.length > 0) canvas.remove(...circuitTexts)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
|
|
||||||
|
setModuleStatisticsData()
|
||||||
|
}
|
||||||
|
|
||||||
|
const isExistCircuit = () => {
|
||||||
|
const circuits = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE && obj.circuit)
|
||||||
|
return circuits.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -326,5 +331,6 @@ export function useCircuitTrestle() {
|
|||||||
removeNotAllocationModules,
|
removeNotAllocationModules,
|
||||||
setModuleStatisticsData,
|
setModuleStatisticsData,
|
||||||
resetCircuits,
|
resetCircuits,
|
||||||
|
isExistCircuit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,8 @@ import { useRoofFn } from '@/hooks/common/useRoofFn'
|
|||||||
import { MODULE_ALIGN_TYPE, useModule } from './module/useModule'
|
import { MODULE_ALIGN_TYPE, useModule } from './module/useModule'
|
||||||
import PlacementSurfaceLineProperty from '@/components/floor-plan/modal/placementShape/PlacementSurfaceLineProperty'
|
import PlacementSurfaceLineProperty from '@/components/floor-plan/modal/placementShape/PlacementSurfaceLineProperty'
|
||||||
import { selectedMenuState } from '@/store/menuAtom'
|
import { selectedMenuState } from '@/store/menuAtom'
|
||||||
|
import { useTrestle } from './module/useTrestle'
|
||||||
|
import { useCircuitTrestle } from './useCirCuitTrestle'
|
||||||
|
|
||||||
export function useContextMenu() {
|
export function useContextMenu() {
|
||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
@ -73,7 +75,8 @@ export function useContextMenu() {
|
|||||||
const { alignModule, modulesRemove, moduleRoofRemove } = useModule()
|
const { alignModule, modulesRemove, moduleRoofRemove } = useModule()
|
||||||
const { removeRoofMaterial, removeAllRoofMaterial, moveRoofMaterial, removeOuterLines } = useRoofFn()
|
const { removeRoofMaterial, removeAllRoofMaterial, moveRoofMaterial, removeOuterLines } = useRoofFn()
|
||||||
const selectedMenu = useRecoilValue(selectedMenuState)
|
const selectedMenu = useRecoilValue(selectedMenuState)
|
||||||
|
const { isAllComplete, clear: resetModule } = useTrestle()
|
||||||
|
const { isExistCircuit } = useCircuitTrestle()
|
||||||
const currentMenuSetting = () => {
|
const currentMenuSetting = () => {
|
||||||
switch (selectedMenu) {
|
switch (selectedMenu) {
|
||||||
case 'outline':
|
case 'outline':
|
||||||
@ -602,56 +605,154 @@ export function useContextMenu() {
|
|||||||
{
|
{
|
||||||
id: 'move',
|
id: 'move',
|
||||||
name: getMessage('contextmenu.move'),
|
name: getMessage('contextmenu.move'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.MOVE} />,
|
fn: () => {
|
||||||
|
if (currentObject.circuit) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.move.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.MOVE} />)
|
||||||
|
},
|
||||||
|
// component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.MOVE} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'copy',
|
id: 'copy',
|
||||||
name: getMessage('contextmenu.copy'),
|
name: getMessage('contextmenu.copy'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COPY} />,
|
fn: () => {
|
||||||
|
if (currentObject.circuit) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.copy.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COPY} />)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
id: 'columnMove',
|
id: 'columnMove',
|
||||||
name: getMessage('contextmenu.column.move'),
|
name: getMessage('contextmenu.column.move'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COLUMN_MOVE} />,
|
fn: () => {
|
||||||
|
if (isAllComplete()) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.move.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COLUMN_MOVE} />)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'columnCopy',
|
id: 'columnCopy',
|
||||||
name: getMessage('contextmenu.column.copy'),
|
name: getMessage('contextmenu.column.copy'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COLUMN_COPY} />,
|
fn: () => {
|
||||||
|
if (isAllComplete()) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.copy.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COLUMN_COPY} />)
|
||||||
|
},
|
||||||
|
// component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COLUMN_COPY} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'columnRemove',
|
id: 'columnRemove',
|
||||||
name: getMessage('contextmenu.column.remove'),
|
name: getMessage('contextmenu.column.remove'),
|
||||||
component: <ColumnRemove id={popupId} />,
|
fn: () => {
|
||||||
|
if (isExistCircuit()) {
|
||||||
|
resetModule()
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <ColumnRemove id={popupId} />)
|
||||||
|
},
|
||||||
|
// component: <ColumnRemove id={popupId} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'columnInsert',
|
id: 'columnInsert',
|
||||||
name: getMessage('contextmenu.column.insert'),
|
name: getMessage('contextmenu.column.insert'),
|
||||||
component: <ColumnInsert id={popupId} />,
|
fn: () => {
|
||||||
|
if (isExistCircuit()) {
|
||||||
|
resetModule()
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <ColumnInsert id={popupId} />)
|
||||||
|
},
|
||||||
|
// component: <ColumnInsert id={popupId} />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
id: 'rowMove',
|
id: 'rowMove',
|
||||||
name: getMessage('contextmenu.row.move'),
|
name: getMessage('contextmenu.row.move'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.ROW_MOVE} />,
|
fn: () => {
|
||||||
|
if (isAllComplete()) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.move.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.ROW_MOVE} />)
|
||||||
|
},
|
||||||
|
// component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.ROW_MOVE} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'rowCopy',
|
id: 'rowCopy',
|
||||||
name: getMessage('contextmenu.row.copy'),
|
name: getMessage('contextmenu.row.copy'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.ROW_COPY} />,
|
fn: () => {
|
||||||
|
if (isAllComplete()) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.copy.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.ROW_COPY} />)
|
||||||
|
},
|
||||||
|
// component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.ROW_COPY} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'rowRemove',
|
id: 'rowRemove',
|
||||||
name: getMessage('contextmenu.row.remove'),
|
name: getMessage('contextmenu.row.remove'),
|
||||||
component: <RowRemove id={popupId} />,
|
fn: () => {
|
||||||
|
if (isExistCircuit()) {
|
||||||
|
resetModule()
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <RowRemove id={popupId} />)
|
||||||
|
},
|
||||||
|
// component: <RowRemove id={popupId} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'rowInsert',
|
id: 'rowInsert',
|
||||||
name: getMessage('contextmenu.row.insert'),
|
name: getMessage('contextmenu.row.insert'),
|
||||||
component: <RowInsert id={popupId} />,
|
fn: () => {
|
||||||
|
if (isExistCircuit()) {
|
||||||
|
resetModule()
|
||||||
|
}
|
||||||
|
|
||||||
|
addPopup(popupId, 1, <RowInsert id={popupId} />)
|
||||||
|
},
|
||||||
|
// component: <RowInsert id={popupId} />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
@ -663,32 +764,16 @@ export function useContextMenu() {
|
|||||||
id: 'moduleVerticalCenterAlign',
|
id: 'moduleVerticalCenterAlign',
|
||||||
name: getMessage('contextmenu.module.vertical.align'),
|
name: getMessage('contextmenu.module.vertical.align'),
|
||||||
fn: () => {
|
fn: () => {
|
||||||
if (currentObject.arrayData) {
|
if (isAllComplete()) {
|
||||||
let existCircuit = false
|
swalFire({
|
||||||
currentObject.arrayData.forEach((surface) => {
|
title: getMessage('can.not.move.module'),
|
||||||
surface.modules.forEach((module) => {
|
icon: 'error',
|
||||||
if (module.circuit) existCircuit = true
|
type: 'alert',
|
||||||
})
|
|
||||||
})
|
})
|
||||||
if (existCircuit) {
|
return
|
||||||
swalFire({
|
|
||||||
title: getMessage('can.not.move.module'),
|
|
||||||
icon: 'error',
|
|
||||||
type: 'alert',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const allocatedModules = currentObject.modules.filter((module) => module.circuit !== null)
|
|
||||||
if (allocatedModules.length > 0) {
|
|
||||||
swalFire({
|
|
||||||
title: getMessage('can.not.move.module'),
|
|
||||||
icon: 'error',
|
|
||||||
type: 'alert',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetModule()
|
||||||
alignModule(MODULE_ALIGN_TYPE.VERTICAL, currentObject.arrayData ?? [currentObject])
|
alignModule(MODULE_ALIGN_TYPE.VERTICAL, currentObject.arrayData ?? [currentObject])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -696,32 +781,15 @@ export function useContextMenu() {
|
|||||||
id: 'moduleHorizonCenterAlign',
|
id: 'moduleHorizonCenterAlign',
|
||||||
name: getMessage('contextmenu.module.horizon.align'),
|
name: getMessage('contextmenu.module.horizon.align'),
|
||||||
fn: () => {
|
fn: () => {
|
||||||
if (currentObject.arrayData) {
|
if (isAllComplete()) {
|
||||||
let existCircuit = false
|
swalFire({
|
||||||
currentObject.arrayData.forEach((surface) => {
|
title: getMessage('can.not.move.module'),
|
||||||
surface.modules.forEach((module) => {
|
icon: 'error',
|
||||||
if (module.circuit) existCircuit = true
|
type: 'alert',
|
||||||
})
|
|
||||||
})
|
})
|
||||||
if (existCircuit) {
|
return
|
||||||
swalFire({
|
|
||||||
title: getMessage('can.not.move.module'),
|
|
||||||
icon: 'error',
|
|
||||||
type: 'alert',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const allocatedModules = currentObject.modules.filter((module) => module.circuit !== null)
|
|
||||||
if (allocatedModules.length > 0) {
|
|
||||||
swalFire({
|
|
||||||
title: getMessage('can.not.move.module'),
|
|
||||||
icon: 'error',
|
|
||||||
type: 'alert',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
alignModule(MODULE_ALIGN_TYPE.HORIZONTAL, currentObject.arrayData ?? [currentObject])
|
alignModule(MODULE_ALIGN_TYPE.HORIZONTAL, currentObject.arrayData ?? [currentObject])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -740,12 +808,45 @@ export function useContextMenu() {
|
|||||||
{
|
{
|
||||||
id: 'moduleMove',
|
id: 'moduleMove',
|
||||||
name: getMessage('contextmenu.module.move'),
|
name: getMessage('contextmenu.module.move'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.MOVE_ALL} arrayData={currentObject.arrayData ?? [currentObject]} />,
|
fn: () => {
|
||||||
|
if (isAllComplete()) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.move.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resetModule()
|
||||||
|
addPopup(
|
||||||
|
popupId,
|
||||||
|
1,
|
||||||
|
<PanelEdit id={popupId} type={PANEL_EDIT_TYPE.MOVE_ALL} arrayData={currentObject.arrayData ?? [currentObject]} />,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
// component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.MOVE_ALL} arrayData={currentObject.arrayData ?? [currentObject]} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'moduleCopy',
|
id: 'moduleCopy',
|
||||||
name: getMessage('contextmenu.module.copy'),
|
name: getMessage('contextmenu.module.copy'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COPY_ALL} arrayData={currentObject.arrayData ?? [currentObject]} />,
|
fn: () => {
|
||||||
|
if (isAllComplete()) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.move.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resetModule()
|
||||||
|
addPopup(
|
||||||
|
popupId,
|
||||||
|
1,
|
||||||
|
<PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COPY_ALL} arrayData={currentObject.arrayData ?? [currentObject]} />,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
// component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COPY_ALL} arrayData={currentObject.arrayData ?? [currentObject]} />,
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// id: 'moduleCircuitNumberEdit',
|
// id: 'moduleCircuitNumberEdit',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user