일괄 복사, 이동 기능 추가
This commit is contained in:
parent
6010b4023a
commit
65fd3d348f
@ -57,13 +57,13 @@ export default function PanelEdit(props) {
|
|||||||
moduleMove(length, direction)
|
moduleMove(length, direction)
|
||||||
break
|
break
|
||||||
case PANEL_EDIT_TYPE.MOVE_ALL:
|
case PANEL_EDIT_TYPE.MOVE_ALL:
|
||||||
moduleMoveAll(length, direction)
|
moduleMoveAll(length, direction, props.arrayData)
|
||||||
break
|
break
|
||||||
case PANEL_EDIT_TYPE.COPY:
|
case PANEL_EDIT_TYPE.COPY:
|
||||||
moduleCopy(length, direction)
|
moduleCopy(length, direction)
|
||||||
break
|
break
|
||||||
case PANEL_EDIT_TYPE.COPY_ALL:
|
case PANEL_EDIT_TYPE.COPY_ALL:
|
||||||
moduleCopyAll(length, direction)
|
moduleCopyAll(length, direction, props.arrayData)
|
||||||
break
|
break
|
||||||
case PANEL_EDIT_TYPE.COLUMN_MOVE:
|
case PANEL_EDIT_TYPE.COLUMN_MOVE:
|
||||||
moduleMultiMove('column', length, direction)
|
moduleMultiMove('column', length, direction)
|
||||||
|
|||||||
@ -145,104 +145,113 @@ export function useModule() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const moduleMoveAll = (length, direction) => {
|
const moduleMoveAll = (length, direction, surfaceArray) => {
|
||||||
const moduleSetupSurface = canvas.getObjects().filter((obj) => canvas.getActiveObjects()[0].id === obj.id)[0]
|
surfaceArray.forEach((surface) => {
|
||||||
const modules = canvas.getObjects().filter((obj) => obj.surfaceId === moduleSetupSurface.id && obj.name === POLYGON_TYPE.MODULE)
|
const modules = canvas
|
||||||
const objects = getObjects()
|
.getObjects()
|
||||||
|
.filter((module) => module.name === POLYGON_TYPE.MODULE)
|
||||||
|
.filter((module) => module.surfaceId === surface.id)
|
||||||
|
const objects = getObjects()
|
||||||
|
|
||||||
let isWarning = false
|
let isWarning = false
|
||||||
|
|
||||||
modules.forEach((module) => {
|
modules.forEach((module) => {
|
||||||
const { top, left } = getPosotion(module, direction, length, false)
|
const { top, left } = getPosotion(module, direction, length, false)
|
||||||
module.originPos = {
|
module.originPos = {
|
||||||
top: module.top,
|
top: module.top,
|
||||||
left: module.left,
|
left: module.left,
|
||||||
fill: module.fill,
|
fill: module.fill,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.set({ top, left })
|
||||||
|
module.setCoords()
|
||||||
|
canvas.renderAll()
|
||||||
|
|
||||||
|
if (isOverlapObjects(module, objects) || isOutsideSurface(module, surface)) {
|
||||||
|
isWarning = true
|
||||||
|
module.set({ fill: 'red' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
module.set({ top, left })
|
|
||||||
module.setCoords()
|
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
|
if (isWarning) {
|
||||||
if (isOverlapObjects(module, objects) || isOutsideSurface(module, moduleSetupSurface)) {
|
swalFire({
|
||||||
isWarning = true
|
title: getMessage('can.not.move.module'),
|
||||||
module.set({ fill: 'red' })
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
confirmFn: () => {
|
||||||
|
modules.forEach((module) => {
|
||||||
|
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
|
||||||
|
module.setCoords()
|
||||||
|
})
|
||||||
|
canvas.renderAll()
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
canvas.renderAll()
|
|
||||||
if (isWarning) {
|
|
||||||
swalFire({
|
|
||||||
title: getMessage('can.not.move.module'),
|
|
||||||
icon: 'error',
|
|
||||||
type: 'alert',
|
|
||||||
confirmFn: () => {
|
|
||||||
modules.forEach((module) => {
|
|
||||||
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
|
|
||||||
module.setCoords()
|
|
||||||
})
|
|
||||||
canvas.renderAll()
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const moduleCopyAll = (length, direction) => {
|
const moduleCopyAll = (length, direction, surfaceArray) => {
|
||||||
const moduleSetupSurface = canvas.getObjects().filter((obj) => canvas.getActiveObjects()[0].id === obj.id)[0]
|
surfaceArray.forEach((surface) => {
|
||||||
const modules = canvas.getObjects().filter((obj) => obj.surfaceId === moduleSetupSurface.id && obj.name === POLYGON_TYPE.MODULE)
|
const modules = canvas
|
||||||
const objects = getObjects()
|
.getObjects()
|
||||||
const copyModules = []
|
.filter((module) => module.name === POLYGON_TYPE.MODULE)
|
||||||
let copyModule = null
|
.filter((module) => module.surfaceId === surface.id)
|
||||||
let isWarning = false
|
const objects = getObjects()
|
||||||
let moduleLength = 0
|
const copyModules = []
|
||||||
if (['up', 'down'].includes(direction)) {
|
|
||||||
modules.sort((a, b) => a.top - b.top)
|
|
||||||
moduleLength = Number(modules[modules.length - 1].top) + Number(modules[modules.length - 1].height) - Number(modules[0].top)
|
|
||||||
} else if (['left', 'right'].includes(direction)) {
|
|
||||||
modules.sort((a, b) => a.left - b.left)
|
|
||||||
moduleLength = Number(modules[modules.length - 1].left) + Number(modules[modules.length - 1].width) - Number(modules[0].left)
|
|
||||||
}
|
|
||||||
|
|
||||||
modules.forEach((module) => {
|
let copyModule = null
|
||||||
const { top, left } = getPosotion(module, direction, Number(length) + Number(moduleLength), false)
|
let isWarning = false
|
||||||
module.clone((obj) => {
|
let moduleLength = 0
|
||||||
obj.set({
|
if (['up', 'down'].includes(direction)) {
|
||||||
parentId: module.parentId,
|
modules.sort((a, b) => a.top - b.top)
|
||||||
initOptions: module.initOptions,
|
moduleLength = Number(modules[modules.length - 1].top) + Number(modules[modules.length - 1].height) - Number(modules[0].top)
|
||||||
direction: module.direction,
|
} else if (['left', 'right'].includes(direction)) {
|
||||||
arrow: module.arrow,
|
modules.sort((a, b) => a.left - b.left)
|
||||||
name: module.name,
|
moduleLength = Number(modules[modules.length - 1].left) + Number(modules[modules.length - 1].width) - Number(modules[0].left)
|
||||||
type: module.type,
|
|
||||||
length: module.length,
|
|
||||||
points: module.points,
|
|
||||||
surfaceId: module.surfaceId,
|
|
||||||
left,
|
|
||||||
top,
|
|
||||||
id: uuidv4(),
|
|
||||||
})
|
|
||||||
copyModule = obj
|
|
||||||
canvas.add(obj)
|
|
||||||
copyModules.push(obj)
|
|
||||||
obj.setCoords()
|
|
||||||
})
|
|
||||||
if (isOverlapObjects(copyModule, objects) || isOutsideSurface(copyModule, moduleSetupSurface)) {
|
|
||||||
isWarning = true
|
|
||||||
copyModule.set({ fill: 'red' })
|
|
||||||
}
|
}
|
||||||
canvas.renderAll()
|
|
||||||
})
|
|
||||||
|
|
||||||
if (isWarning) {
|
modules.forEach((module) => {
|
||||||
swalFire({
|
const { top, left } = getPosotion(module, direction, Number(length) + Number(moduleLength), false)
|
||||||
title: getMessage('can.not.copy.module'),
|
module.clone((obj) => {
|
||||||
icon: 'error',
|
obj.set({
|
||||||
type: 'alert',
|
parentId: module.parentId,
|
||||||
confirmFn: () => {
|
initOptions: module.initOptions,
|
||||||
canvas.remove(...copyModules)
|
direction: module.direction,
|
||||||
canvas.renderAll()
|
arrow: module.arrow,
|
||||||
},
|
name: module.name,
|
||||||
|
type: module.type,
|
||||||
|
length: module.length,
|
||||||
|
points: module.points,
|
||||||
|
surfaceId: module.surfaceId,
|
||||||
|
left,
|
||||||
|
top,
|
||||||
|
id: uuidv4(),
|
||||||
|
})
|
||||||
|
copyModule = obj
|
||||||
|
canvas.add(obj)
|
||||||
|
copyModules.push(obj)
|
||||||
|
obj.setCoords()
|
||||||
|
})
|
||||||
|
if (isOverlapObjects(copyModule, objects) || isOutsideSurface(copyModule, surface)) {
|
||||||
|
isWarning = true
|
||||||
|
copyModule.set({ fill: 'red' })
|
||||||
|
}
|
||||||
|
canvas.renderAll()
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
if (isWarning) {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('can.not.copy.module'),
|
||||||
|
icon: 'error',
|
||||||
|
type: 'alert',
|
||||||
|
confirmFn: () => {
|
||||||
|
canvas.remove(...copyModules)
|
||||||
|
canvas.renderAll()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const moduleCopy = (length, direction) => {
|
const moduleCopy = (length, direction) => {
|
||||||
|
|||||||
@ -123,7 +123,7 @@ export function useModuleBasicSetting(tabNum) {
|
|||||||
makeModuleInstArea(roof, detail.data)
|
makeModuleInstArea(roof, detail.data)
|
||||||
//surface에 상세 데이터 추가
|
//surface에 상세 데이터 추가
|
||||||
} else {
|
} else {
|
||||||
console.log('가대 데이터가 없네요...')
|
swalFire({ text: getMessage('module.roof.not.exist'), icon: 'warning' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -747,18 +747,18 @@ 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} />,
|
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.MOVE_ALL} arrayData={currentObject.arrayData} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'moduleCopy',
|
id: 'moduleCopy',
|
||||||
name: getMessage('contextmenu.module.copy'),
|
name: getMessage('contextmenu.module.copy'),
|
||||||
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COPY_ALL} />,
|
component: <PanelEdit id={popupId} type={PANEL_EDIT_TYPE.COPY_ALL} arrayData={currentObject.arrayData} />,
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'moduleCircuitNumberEdit',
|
|
||||||
name: getMessage('contextmenu.module.circuit.number.edit'),
|
|
||||||
component: <CircuitNumberEdit id={popupId} />,
|
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// id: 'moduleCircuitNumberEdit',
|
||||||
|
// name: getMessage('contextmenu.module.circuit.number.edit'),
|
||||||
|
// component: <CircuitNumberEdit id={popupId} />,
|
||||||
|
// },
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
break
|
break
|
||||||
|
|||||||
@ -998,5 +998,6 @@
|
|||||||
"menu.validation.canvas.roof": "패널을 배치하려면 지붕면을 입력해야 합니다.",
|
"menu.validation.canvas.roof": "패널을 배치하려면 지붕면을 입력해야 합니다.",
|
||||||
"batch.object.outside.roof": "오브젝트는 지붕내에 설치해야 합니다.",
|
"batch.object.outside.roof": "오브젝트는 지붕내에 설치해야 합니다.",
|
||||||
"batch.object.notinstall.cross": "오브젝트는 겹쳐서 설치 할 수 없습니다.",
|
"batch.object.notinstall.cross": "오브젝트는 겹쳐서 설치 할 수 없습니다.",
|
||||||
"module.not.batch.north": "북쪽에는 모듈을 배치할 수 없습니다."
|
"module.not.batch.north": "북쪽에는 모듈을 배치할 수 없습니다.",
|
||||||
|
"module.trestleDetail.not.exist": "가대 상세 정보가 없습니다."
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user