Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
njgzx
dataease
Commits
547801ce
提交
547801ce
authored
4月 07, 2021
作者:
wangjiahao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:预览增加自适应屏幕尺寸功能
上级
f8f504f3
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
161 行增加
和
121 行删除
+161
-121
PreviewEject.vue
.../src/components/canvas/components/Editor/PreviewEject.vue
+77
-43
translate.js
frontend/src/components/canvas/utils/translate.js
+79
-75
index.js
frontend/src/router/index.js
+2
-2
PanelList.vue
frontend/src/views/panel/list/PanelList.vue
+1
-0
PanelViewShow.vue
frontend/src/views/panel/list/PanelViewShow.vue
+2
-1
没有找到文件。
frontend/src/components/canvas/components/Editor/PreviewEject.vue
浏览文件 @
547801ce
<
template
>
<
template
>
<div
v-if=
"show"
class=
"bg"
>
<div
ref=
"element"
class=
"bg"
>
<el-button
class=
"close"
@
click=
"close"
>
关闭
</el-button>
<ComponentWrapper
<div
class=
"canvas-container"
>
v-for=
"(item, index) in componentDataInfo"
<div
:key=
"index"
class=
"canvas"
:config=
"item"
:style=
"
{
/>
width: changeStyleWithScale(canvasStyleData.width) + 'px',
height: changeStyleWithScale(canvasStyleData.height) + 'px',
}"
>
<ComponentWrapper
v-for=
"(item, index) in componentData"
:key=
"index"
:config=
"item"
/>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
...
@@ -25,6 +14,9 @@ import { mapState } from 'vuex'
...
@@ -25,6 +14,9 @@ import { mapState } from 'vuex'
import
ComponentWrapper
from
'./ComponentWrapper'
import
ComponentWrapper
from
'./ComponentWrapper'
import
{
changeStyleWithScale
}
from
'@/components/canvas/utils/translate'
import
{
changeStyleWithScale
}
from
'@/components/canvas/utils/translate'
import
{
uuid
}
from
'vue-uuid'
import
{
uuid
}
from
'vue-uuid'
import
{
deepCopy
}
from
'@/components/canvas/utils/utils'
import
eventBus
from
'@/components/canvas/utils/eventBus'
import
{
get
}
from
'@/api/panel/panel'
export
default
{
export
default
{
components
:
{
ComponentWrapper
},
components
:
{
ComponentWrapper
},
...
@@ -38,39 +30,87 @@ export default {
...
@@ -38,39 +30,87 @@ export default {
default
:
false
default
:
false
}
}
},
},
created
()
{
data
()
{
return
{
isShowPreview
:
false
,
panelId
:
''
,
needToChangeHeight
:
[
'top'
,
'height'
,
'fontSize'
,
'borderWidth'
],
needToChangeWidth
:
[
'left'
,
'width'
],
scaleWidth
:
'100'
,
scaleHeight
:
'100'
,
timer
:
null
,
componentData
:
{},
canvasStyleData
:
{}
}
},
computed
:
{
componentDataInfo
()
{
return
this
.
componentData
}
},
mounted
()
{
// 加载数据
this
.
restore
()
this
.
restore
()
window
.
onresize
=
()
=>
{
debugger
this
.
resize
()
}
// this.resize()
},
},
computed
:
mapState
([
'componentData'
,
'canvasStyleData'
]),
methods
:
{
methods
:
{
changeStyleWithScale
,
changeStyleWithScale
,
getStyle
,
getStyle
,
close
()
{
close
()
{
this
.
$emit
(
'change'
,
false
)
this
.
$emit
(
'change'
,
false
)
},
},
resize
()
{
this
.
scaleWidth
=
window
.
innerWidth
*
100
/
parseInt
(
this
.
canvasStyleData
.
width
)
// 获取宽度比
this
.
scaleHeight
=
window
.
innerHeight
*
100
/
parseInt
(
this
.
canvasStyleData
.
height
)
// 获取高度比
this
.
handleScaleChange
()
},
restore
()
{
restore
()
{
debugger
debugger
// 用保存的数据恢复画布
this
.
panelId
=
this
.
$route
.
path
.
split
(
'/'
)[
2
]
if
(
localStorage
.
getItem
(
'canvasData'
))
{
// 加载视图数据
this
.
componentData
=
this
.
resetID
(
JSON
.
parse
(
localStorage
.
getItem
(
'canvasData'
)))
get
(
'panel/group/findOne/'
+
this
.
panelId
).
then
(
response
=>
{
}
this
.
componentData
=
this
.
resetID
(
JSON
.
parse
(
response
.
data
.
panelData
))
this
.
canvasStyleData
=
JSON
.
parse
(
response
.
data
.
panelStyle
)
if
(
localStorage
.
getItem
(
'canvasStyle'
))
{
this
.
resize
()
this
.
canvasStyleData
=
JSON
.
parse
(
localStorage
.
getItem
(
'canvasStyle'
))
})
this
.
$store
.
commit
(
'setCanvasStyle'
,
JSON
.
parse
(
localStorage
.
getItem
(
'canvasStyle'
)))
}
},
},
resetID
(
data
)
{
resetID
(
data
)
{
data
.
forEach
(
item
=>
{
data
.
forEach
(
item
=>
{
item
.
id
=
uuid
.
v1
()
item
.
id
=
uuid
.
v1
()
})
})
return
data
return
data
},
format
(
value
,
scale
)
{
return
value
*
parseInt
(
scale
)
/
100
},
handleScaleChange
()
{
const
componentData
=
deepCopy
(
this
.
componentData
)
componentData
.
forEach
(
component
=>
{
Object
.
keys
(
component
.
style
).
forEach
(
key
=>
{
if
(
this
.
needToChangeHeight
.
includes
(
key
))
{
component
.
style
[
key
]
=
this
.
format
(
component
.
style
[
key
],
this
.
scaleHeight
)
}
if
(
this
.
needToChangeWidth
.
includes
(
key
))
{
component
.
style
[
key
]
=
this
.
format
(
component
.
style
[
key
],
this
.
scaleWidth
)
}
})
})
this
.
componentData
=
componentData
eventBus
.
$emit
(
'resizing'
,
''
)
}
}
}
}
}
}
...
@@ -80,14 +120,8 @@ export default {
...
@@ -80,14 +120,8 @@ export default {
.bg
{
.bg
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
.canvas-container
{
overflow
:
auto
;
width
:
100%
;
position
:
relative
;
height
:
100%
;
margin
:
0
;
overflow
:
auto
;
.canvas
{
position
:
relative
;
margin
:
auto
;
}
}
}
}
</
style
>
</
style
>
frontend/src/components/canvas/utils/translate.js
浏览文件 @
547801ce
...
@@ -3,7 +3,7 @@ import store from '@/store'
...
@@ -3,7 +3,7 @@ import store from '@/store'
// 角度转弧度
// 角度转弧度
// Math.PI = 180 度
// Math.PI = 180 度
function
angleToRadian
(
angle
)
{
function
angleToRadian
(
angle
)
{
return
angle
*
Math
.
PI
/
180
return
angle
*
Math
.
PI
/
180
}
}
/**
/**
...
@@ -15,7 +15,7 @@ function angleToRadian(angle) {
...
@@ -15,7 +15,7 @@ function angleToRadian(angle) {
* https://www.zhihu.com/question/67425734/answer/252724399 旋转矩阵公式
* https://www.zhihu.com/question/67425734/answer/252724399 旋转矩阵公式
*/
*/
export
function
calculateRotatedPointCoordinate
(
point
,
center
,
rotate
)
{
export
function
calculateRotatedPointCoordinate
(
point
,
center
,
rotate
)
{
/**
/**
* 旋转公式:
* 旋转公式:
* 点a(x, y)
* 点a(x, y)
* 旋转中心c(x, y)
* 旋转中心c(x, y)
...
@@ -25,10 +25,10 @@ export function calculateRotatedPointCoordinate(point, center, rotate) {
...
@@ -25,10 +25,10 @@ export function calculateRotatedPointCoordinate(point, center, rotate) {
* ny = sinθ * (ax - cx) + cosθ * (ay - cy) + cy
* ny = sinθ * (ax - cx) + cosθ * (ay - cy) + cy
*/
*/
return
{
return
{
x
:
(
point
.
x
-
center
.
x
)
*
Math
.
cos
(
angleToRadian
(
rotate
))
-
(
point
.
y
-
center
.
y
)
*
Math
.
sin
(
angleToRadian
(
rotate
))
+
center
.
x
,
x
:
(
point
.
x
-
center
.
x
)
*
Math
.
cos
(
angleToRadian
(
rotate
))
-
(
point
.
y
-
center
.
y
)
*
Math
.
sin
(
angleToRadian
(
rotate
))
+
center
.
x
,
y
:
(
point
.
x
-
center
.
x
)
*
Math
.
sin
(
angleToRadian
(
rotate
))
+
(
point
.
y
-
center
.
y
)
*
Math
.
cos
(
angleToRadian
(
rotate
))
+
center
.
y
,
y
:
(
point
.
x
-
center
.
x
)
*
Math
.
sin
(
angleToRadian
(
rotate
))
+
(
point
.
y
-
center
.
y
)
*
Math
.
cos
(
angleToRadian
(
rotate
))
+
center
.
y
}
}
}
}
/**
/**
...
@@ -39,89 +39,93 @@ export function calculateRotatedPointCoordinate(point, center, rotate) {
...
@@ -39,89 +39,93 @@ export function calculateRotatedPointCoordinate(point, center, rotate) {
* @return {Object} 旋转后的点坐标
* @return {Object} 旋转后的点坐标
*/
*/
export
function
getRotatedPointCoordinate
(
style
,
center
,
name
)
{
export
function
getRotatedPointCoordinate
(
style
,
center
,
name
)
{
let
point
// point 是未旋转前的坐标
let
point
// point 是未旋转前的坐标
switch
(
name
)
{
switch
(
name
)
{
case
't'
:
case
't'
:
point
=
{
point
=
{
x
:
style
.
left
+
(
style
.
width
/
2
),
x
:
style
.
left
+
(
style
.
width
/
2
),
y
:
style
.
top
,
y
:
style
.
top
}
}
break
break
case
'b'
:
case
'b'
:
point
=
{
point
=
{
x
:
style
.
left
+
(
style
.
width
/
2
),
x
:
style
.
left
+
(
style
.
width
/
2
),
y
:
style
.
top
+
style
.
height
,
y
:
style
.
top
+
style
.
height
}
}
break
break
case
'l'
:
case
'l'
:
point
=
{
point
=
{
x
:
style
.
left
,
x
:
style
.
left
,
y
:
style
.
top
+
style
.
height
/
2
,
y
:
style
.
top
+
style
.
height
/
2
}
}
break
break
case
'r'
:
case
'r'
:
point
=
{
point
=
{
x
:
style
.
left
+
style
.
width
,
x
:
style
.
left
+
style
.
width
,
y
:
style
.
top
+
style
.
height
/
2
,
y
:
style
.
top
+
style
.
height
/
2
}
}
break
break
case
'lt'
:
case
'lt'
:
point
=
{
point
=
{
x
:
style
.
left
,
x
:
style
.
left
,
y
:
style
.
top
,
y
:
style
.
top
}
}
break
break
case
'rt'
:
case
'rt'
:
point
=
{
point
=
{
x
:
style
.
left
+
style
.
width
,
x
:
style
.
left
+
style
.
width
,
y
:
style
.
top
,
y
:
style
.
top
}
}
break
break
case
'lb'
:
case
'lb'
:
point
=
{
point
=
{
x
:
style
.
left
,
x
:
style
.
left
,
y
:
style
.
top
+
style
.
height
,
y
:
style
.
top
+
style
.
height
}
}
break
break
default
:
// rb
default
:
// rb
point
=
{
point
=
{
x
:
style
.
left
+
style
.
width
,
x
:
style
.
left
+
style
.
width
,
y
:
style
.
top
+
style
.
height
,
y
:
style
.
top
+
style
.
height
}
}
break
break
}
}
return
calculateRotatedPointCoordinate
(
point
,
center
,
style
.
rotate
)
return
calculateRotatedPointCoordinate
(
point
,
center
,
style
.
rotate
)
}
}
// 求两点之间的中点坐标
// 求两点之间的中点坐标
export
function
getCenterPoint
(
p1
,
p2
)
{
export
function
getCenterPoint
(
p1
,
p2
)
{
return
{
return
{
x
:
p1
.
x
+
((
p2
.
x
-
p1
.
x
)
/
2
),
x
:
p1
.
x
+
((
p2
.
x
-
p1
.
x
)
/
2
),
y
:
p1
.
y
+
((
p2
.
y
-
p1
.
y
)
/
2
),
y
:
p1
.
y
+
((
p2
.
y
-
p1
.
y
)
/
2
)
}
}
}
}
export
function
sin
(
rotate
)
{
export
function
sin
(
rotate
)
{
return
Math
.
abs
(
Math
.
sin
(
angleToRadian
(
rotate
)))
return
Math
.
abs
(
Math
.
sin
(
angleToRadian
(
rotate
)))
}
}
export
function
cos
(
rotate
)
{
export
function
cos
(
rotate
)
{
return
Math
.
abs
(
Math
.
cos
(
angleToRadian
(
rotate
)))
return
Math
.
abs
(
Math
.
cos
(
angleToRadian
(
rotate
)))
}
}
export
function
mod360
(
deg
)
{
export
function
mod360
(
deg
)
{
return
(
deg
+
360
)
%
360
return
(
deg
+
360
)
%
360
}
}
export
function
changeStyleWithScale
(
value
)
{
export
function
changeStyleWithScale
(
value
)
{
return
value
*
parseInt
(
store
.
state
.
canvasStyleData
.
scale
)
/
100
return
value
*
parseInt
(
store
.
state
.
canvasStyleData
.
scale
)
/
100
}
export
function
changeStyleWithScaleIn
(
value
,
scale
)
{
return
value
*
parseInt
(
scale
)
/
100
}
}
frontend/src/router/index.js
浏览文件 @
547801ce
...
@@ -72,8 +72,8 @@ export const constantRoutes = [
...
@@ -72,8 +72,8 @@ export const constantRoutes = [
]
]
},
},
{
{
path
:
'/preview'
,
path
:
'/preview
/:reportId
'
,
component
:
()
=>
import
(
'@/components/canvas/components/Editor/Preview
FullScreen
'
),
component
:
()
=>
import
(
'@/components/canvas/components/Editor/Preview
Eject
'
),
hidden
:
true
hidden
:
true
},
},
...
...
frontend/src/views/panel/list/PanelList.vue
浏览文件 @
547801ce
...
@@ -417,6 +417,7 @@ export default {
...
@@ -417,6 +417,7 @@ export default {
nodeClick
(
data
,
node
)
{
nodeClick
(
data
,
node
)
{
if
(
data
.
nodeType
===
'panel'
)
{
if
(
data
.
nodeType
===
'panel'
)
{
this
.
$store
.
dispatch
(
'panel/setPanelInfo'
,
data
)
this
.
currGroup
=
data
this
.
currGroup
=
data
// 加载视图数据
// 加载视图数据
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
...
...
frontend/src/views/panel/list/PanelViewShow.vue
浏览文件 @
547801ce
...
@@ -48,9 +48,10 @@ export default {
...
@@ -48,9 +48,10 @@ export default {
},
},
methods
:
{
methods
:
{
clickPreview
()
{
clickPreview
()
{
debugger
localStorage
.
setItem
(
'canvasData'
,
JSON
.
stringify
(
this
.
componentData
))
localStorage
.
setItem
(
'canvasData'
,
JSON
.
stringify
(
this
.
componentData
))
localStorage
.
setItem
(
'canvasStyle'
,
JSON
.
stringify
(
this
.
canvasStyleData
))
localStorage
.
setItem
(
'canvasStyle'
,
JSON
.
stringify
(
this
.
canvasStyleData
))
const
url
=
'#/preview
'
const
url
=
'#/preview
/'
+
this
.
$store
.
state
.
panel
.
panelInfo
.
id
window
.
open
(
url
,
'_blank'
)
window
.
open
(
url
,
'_blank'
)
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论