Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
ce4d20b8
提交
ce4d20b8
authored
6月 24, 2021
作者:
junjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:代码规范
上级
09aaaede
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
95 行增加
和
95 行删除
+95
-95
Group.vue
frontend/src/components/canvas/custom-component/Group.vue
+42
-42
copy.js
frontend/src/components/canvas/store/copy.js
+52
-52
PanelList.vue
frontend/src/views/panel/list/PanelList.vue
+1
-1
没有找到文件。
frontend/src/components/canvas/custom-component/Group.vue
浏览文件 @
ce4d20b8
<
template
>
<div
class=
"group"
>
<div>
<template
v-for=
"item in propValue"
>
<component
class=
"component"
:is=
"item.component"
:style=
"item.groupStyle"
:propValue=
"item.propValue"
:key=
"item.id"
:id=
"'component' + item.id"
:element=
"item"
/>
</
template
>
</div>
<div
class=
"group"
>
<div>
<template
v-for=
"item in propValue"
>
<component
:is=
"item.component"
:id=
"'component' + item.id"
:key=
"item.id"
class=
"component"
:style=
"item.groupStyle"
:prop-value=
"item.propValue"
:element=
"item"
/>
</
template
>
</div>
</div>
</template>
<
script
>
import
{
getStyle
}
from
'@/components/canvas/utils/style'
export
default
{
props
:
{
propValue
:
{
type
:
Array
,
default
:
()
=>
[],
},
element
:
{
type
:
Object
,
},
},
created
()
{
const
parentStyle
=
this
.
element
.
style
this
.
propValue
.
forEach
(
component
=>
{
// component.groupStyle 的 top left 是相对于 group 组件的位置
// 如果已存在 component.groupStyle,说明已经计算过一次了。不需要再次计算
if
(
!
Object
.
keys
(
component
.
groupStyle
).
length
)
{
const
style
=
{
...
component
.
style
}
component
.
groupStyle
=
getStyle
(
style
)
component
.
groupStyle
.
left
=
this
.
toPercent
((
style
.
left
-
parentStyle
.
left
)
/
parentStyle
.
width
)
component
.
groupStyle
.
top
=
this
.
toPercent
((
style
.
top
-
parentStyle
.
top
)
/
parentStyle
.
height
)
component
.
groupStyle
.
width
=
this
.
toPercent
(
style
.
width
/
parentStyle
.
width
)
component
.
groupStyle
.
height
=
this
.
toPercent
(
style
.
height
/
parentStyle
.
height
)
}
})
},
methods
:
{
toPercent
(
val
)
{
return
val
*
100
+
'%'
},
props
:
{
propValue
:
{
type
:
Array
,
default
:
()
=>
[]
},
element
:
{
type
:
Object
}
},
created
()
{
const
parentStyle
=
this
.
element
.
style
this
.
propValue
.
forEach
(
component
=>
{
// component.groupStyle 的 top left 是相对于 group 组件的位置
// 如果已存在 component.groupStyle,说明已经计算过一次了。不需要再次计算
if
(
!
Object
.
keys
(
component
.
groupStyle
).
length
)
{
const
style
=
{
...
component
.
style
}
component
.
groupStyle
=
getStyle
(
style
)
component
.
groupStyle
.
left
=
this
.
toPercent
((
style
.
left
-
parentStyle
.
left
)
/
parentStyle
.
width
)
component
.
groupStyle
.
top
=
this
.
toPercent
((
style
.
top
-
parentStyle
.
top
)
/
parentStyle
.
height
)
component
.
groupStyle
.
width
=
this
.
toPercent
(
style
.
width
/
parentStyle
.
width
)
component
.
groupStyle
.
height
=
this
.
toPercent
(
style
.
height
/
parentStyle
.
height
)
}
})
},
methods
:
{
toPercent
(
val
)
{
return
val
*
100
+
'%'
}
}
}
</
script
>
...
...
frontend/src/components/canvas/store/copy.js
浏览文件 @
ce4d20b8
...
...
@@ -4,64 +4,64 @@ import generateID from '@/components/canvas/utils/generateID'
import
{
deepCopy
}
from
'@/components/canvas/utils/utils'
export
default
{
state
:
{
copyData
:
null
,
// 复制粘贴剪切
isCut
:
false
,
},
mutations
:
{
copy
(
state
)
{
if
(
!
state
.
curComponent
)
return
state
.
copyData
=
{
data
:
deepCopy
(
state
.
curComponent
),
index
:
state
.
curComponentIndex
,
}
state
:
{
copyData
:
null
,
// 复制粘贴剪切
isCut
:
false
},
mutations
:
{
copy
(
state
)
{
if
(
!
state
.
curComponent
)
return
state
.
copyData
=
{
data
:
deepCopy
(
state
.
curComponent
),
index
:
state
.
curComponentIndex
}
state
.
isCut
=
false
},
state
.
isCut
=
false
},
paste
(
state
,
isMouse
)
{
if
(
!
state
.
copyData
)
{
toast
(
'请选择组件'
)
return
}
paste
(
state
,
isMouse
)
{
if
(
!
state
.
copyData
)
{
toast
(
'请选择组件'
)
return
}
const
data
=
state
.
copyData
.
data
const
data
=
state
.
copyData
.
data
if
(
isMouse
)
{
data
.
style
.
top
=
state
.
menuTop
data
.
style
.
left
=
state
.
menuLeft
}
else
{
data
.
style
.
top
+=
10
data
.
style
.
left
+=
10
}
if
(
isMouse
)
{
data
.
style
.
top
=
state
.
menuTop
data
.
style
.
left
=
state
.
menuLeft
}
else
{
data
.
style
.
top
+=
10
data
.
style
.
left
+=
10
}
data
.
id
=
generateID
()
store
.
commit
(
'addComponent'
,
{
component
:
deepCopy
(
data
)
})
if
(
state
.
isCut
)
{
state
.
copyData
=
null
}
},
data
.
id
=
generateID
()
store
.
commit
(
'addComponent'
,
{
component
:
deepCopy
(
data
)
})
if
(
state
.
isCut
)
{
state
.
copyData
=
null
}
},
cut
(
state
)
{
if
(
!
state
.
curComponent
)
{
toast
(
'请选择组件'
)
return
}
cut
(
state
)
{
if
(
!
state
.
curComponent
)
{
toast
(
'请选择组件'
)
return
}
if
(
state
.
copyData
)
{
const
data
=
deepCopy
(
state
.
copyData
.
data
)
const
index
=
state
.
copyData
.
index
data
.
id
=
generateID
()
store
.
commit
(
'addComponent'
,
{
component
:
data
,
index
})
if
(
state
.
curComponentIndex
>=
index
)
{
// 如果当前组件索引大于等于插入索引,需要加一,因为当前组件往后移了一位
state
.
curComponentIndex
++
}
}
if
(
state
.
copyData
)
{
const
data
=
deepCopy
(
state
.
copyData
.
data
)
const
index
=
state
.
copyData
.
index
data
.
id
=
generateID
()
store
.
commit
(
'addComponent'
,
{
component
:
data
,
index
})
if
(
state
.
curComponentIndex
>=
index
)
{
// 如果当前组件索引大于等于插入索引,需要加一,因为当前组件往后移了一位
state
.
curComponentIndex
++
}
}
store
.
commit
(
'copy'
)
store
.
commit
(
'deleteComponent'
)
state
.
isCut
=
true
},
},
store
.
commit
(
'copy'
)
store
.
commit
(
'deleteComponent'
)
state
.
isCut
=
true
}
}
}
frontend/src/views/panel/list/PanelList.vue
浏览文件 @
ce4d20b8
...
...
@@ -178,7 +178,7 @@ import bus from '@/utils/bus'
import
EditPanel
from
'./EditPanel'
import
{
addGroup
,
delGroup
,
groupTree
,
defaultTree
,
findOne
}
from
'@/api/panel/panel'
import
{
DEFAULT_COMMON_CANVAS_STYLE_STRING
DEFAULT_COMMON_CANVAS_STYLE_STRING
}
from
'@/views/panel/panel'
export
default
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论