Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
03cb1f06
提交
03cb1f06
authored
12月 20, 2021
作者:
wangjiahao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 仪表板支持高清PDF导出
上级
e59d5b80
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
88 行增加
和
39 行删除
+88
-39
Preview.vue
frontend/src/components/canvas/components/Editor/Preview.vue
+1
-1
index.vue
frontend/src/components/canvas/components/Editor/index.vue
+1
-1
UserView.vue
frontend/src/components/canvas/custom-component/UserView.vue
+1
-0
style.js
frontend/src/components/canvas/utils/style.js
+0
-2
index.js
frontend/src/store/index.js
+5
-5
PDFPreExport.vue
frontend/src/views/panel/export/PDFPreExport.vue
+41
-17
PanelViewShow.vue
frontend/src/views/panel/list/PanelViewShow.vue
+39
-13
没有找到文件。
frontend/src/components/canvas/components/Editor/Preview.vue
浏览文件 @
03cb1f06
...
...
@@ -229,7 +229,7 @@ export default {
const
canvasWidth
=
document
.
getElementById
(
'canvasInfoMain'
).
offsetWidth
this
.
scaleWidth
=
(
canvasWidth
)
*
100
/
this
.
canvasStyleData
.
width
// 获取宽度比
this
.
scaleHeight
=
canvasHeight
*
100
/
this
.
canvasStyleData
.
height
// 获取高度比
this
.
$store
.
commit
(
'setPreviewCanvasScale'
,
(
this
.
scaleWidth
/
100
),
(
this
.
scaleHeight
/
100
)
)
this
.
$store
.
commit
(
'setPreviewCanvasScale'
,
{
scaleWidth
:
(
this
.
scaleWidth
/
100
),
scaleHeight
:
(
this
.
scaleHeight
/
100
)
}
)
this
.
handleScaleChange
()
},
resetID
(
data
)
{
...
...
frontend/src/components/canvas/components/Editor/index.vue
浏览文件 @
03cb1f06
...
...
@@ -1195,7 +1195,7 @@ export default {
matrixStyleOriginWidth
:
this
.
matrixStyle
.
originWidth
,
matrixStyleOriginHeight
:
this
.
matrixStyle
.
originHeight
})
this
.
$store
.
commit
(
'setPreviewCanvasScale'
,
this
.
scalePointWidth
,
this
.
scalePointHeight
)
this
.
$store
.
commit
(
'setPreviewCanvasScale'
,
{
scaleWidth
:
this
.
scalePointWidth
,
scaleHeight
:
this
.
scalePointHeight
}
)
}
},
getShapeStyleIntDeDrag
(
style
,
prop
)
{
...
...
frontend/src/components/canvas/custom-component/UserView.vue
浏览文件 @
03cb1f06
...
...
@@ -316,6 +316,7 @@ export default {
// 根据仪表板的缩放比例,修改视图内部参数
mergeScale
()
{
const
scale
=
Math
.
min
(
this
.
previewCanvasScale
.
scalePointWidth
,
this
.
previewCanvasScale
.
scalePointHeight
)
*
this
.
scaleCoefficient
console
.
log
(
'scale:'
+
scale
+
';this.previewCanvasScale:'
+
JSON
.
stringify
(
this
.
previewCanvasScale
))
const
customAttrChart
=
JSON
.
parse
(
this
.
sourceCustomAttrStr
)
const
customStyleChart
=
JSON
.
parse
(
this
.
sourceCustomStyleStr
)
recursionTransObj
(
customAttrTrans
,
customAttrChart
,
scale
,
this
.
scaleCoefficientType
)
...
...
frontend/src/components/canvas/utils/style.js
浏览文件 @
03cb1f06
...
...
@@ -94,8 +94,6 @@ export const customAttrTrans = {
'barWidth'
,
'lineWidth'
,
'lineSymbolSize'
,
'pieInnerRadius'
,
'pieOuterRadius'
,
'funnelWidth'
,
// 漏斗图 最大宽度
'tableTitleFontSize'
,
'tableItemFontSize'
,
...
...
frontend/src/store/index.js
浏览文件 @
03cb1f06
...
...
@@ -140,12 +140,12 @@ const data = {
setCurCanvasScale
(
state
,
curCanvasScale
)
{
state
.
curCanvasScale
=
curCanvasScale
},
setPreviewCanvasScale
(
state
,
scale
Width
,
scaleHeight
)
{
if
(
scaleWidth
)
{
state
.
previewCanvasScale
.
scalePointWidth
=
scaleWidth
setPreviewCanvasScale
(
state
,
scale
)
{
if
(
scale
.
scale
Width
)
{
state
.
previewCanvasScale
.
scalePointWidth
=
scale
.
scale
Width
}
if
(
scaleHeight
)
{
state
.
previewCanvasScale
.
scalePointHeight
=
scaleHeight
if
(
scale
.
scale
Height
)
{
state
.
previewCanvasScale
.
scalePointHeight
=
scale
.
scale
Height
}
},
setShapeStyle
({
curComponent
,
canvasStyleData
,
curCanvasScale
},
{
top
,
left
,
width
,
height
,
rotate
})
{
...
...
frontend/src/views/panel/export/PDFPreExport.vue
浏览文件 @
03cb1f06
...
...
@@ -4,11 +4,11 @@
style=
"height: 100%;width: 100%;"
:element-loading-text=
"$t('panel.export_loading')"
element-loading-spinner=
"el-icon-loading"
element-loading-background=
"rgba(0, 0, 0,
0.8
)"
element-loading-background=
"rgba(0, 0, 0,
1
)"
>
<el-row
class=
"export_body_class"
>
<div
id=
"exportPdf"
ref=
"exportPdf"
>
<div
class=
"export_body_inner_class"
v-html=
"templateContentChange"
/>
<div
id=
"exportPdf"
ref=
"exportPdf"
:style=
"mainCanvasStyle"
>
<div
class=
"export_body_inner_class"
:style=
"templateHtmlStyle"
v-html=
"templateContentChange"
/>
</div>
</el-row>
<el-row
class=
"root_class"
>
...
...
@@ -26,6 +26,7 @@ import { pdfTemplateReplaceAll } from '@/utils/StringUtils.js'
export
default
{
name
:
'PDFPreExport'
,
components
:
{
},
props
:
{
// eslint-disable-next-line vue/require-default-prop
panelName
:
{
...
...
@@ -43,6 +44,7 @@ export default {
},
data
()
{
return
{
toExport
:
false
,
exportLoading
:
false
,
activeName
:
''
,
templateContentChange
:
''
,
...
...
@@ -60,7 +62,26 @@ export default {
}
},
computed
:
{
mainCanvasStyle
()
{
if
(
this
.
toExport
)
{
return
{
width
:
'4096px'
}
}
else
{
return
{
width
:
'100%'
}
}
},
templateHtmlStyle
()
{
if
(
this
.
toExport
)
{
return
{
fontSize
:
'48px!important'
}
}
else
{
return
{}
}
}
},
watch
:
{
templateContent
(
newVal
,
oldVla
)
{
...
...
@@ -92,19 +113,22 @@ export default {
const
_this
=
this
_this
.
exportLoading
=
true
setTimeout
(()
=>
{
html2canvas
(
document
.
getElementById
(
'exportPdf'
)).
then
(
function
(
canvas
)
{
_this
.
exportLoading
=
false
const
contentWidth
=
canvas
.
width
const
contentHeight
=
canvas
.
height
const
pageData
=
canvas
.
toDataURL
(
'image/jpeg'
,
1.0
)
const
lp
=
contentWidth
>
contentHeight
?
'l'
:
'p'
const
PDF
=
new
JsPDF
(
lp
,
'pt'
,
[
contentWidth
,
contentHeight
])
PDF
.
addImage
(
pageData
,
'JPEG'
,
0
,
0
,
contentWidth
,
contentHeight
)
PDF
.
save
(
_this
.
panelName
+
'.pdf'
)
_this
.
$emit
(
'closePreExport'
)
}
)
},
50
)
_this
.
toExport
=
true
setTimeout
(()
=>
{
html2canvas
(
document
.
getElementById
(
'exportPdf'
)).
then
(
function
(
canvas
)
{
_this
.
exportLoading
=
false
const
contentWidth
=
canvas
.
width
const
contentHeight
=
canvas
.
height
const
pageData
=
canvas
.
toDataURL
(
'image/jpeg'
,
1.0
)
const
lp
=
contentWidth
>
contentHeight
?
'l'
:
'p'
const
PDF
=
new
JsPDF
(
lp
,
'pt'
,
[
contentWidth
,
contentHeight
])
PDF
.
addImage
(
pageData
,
'JPEG'
,
0
,
0
,
contentWidth
,
contentHeight
)
PDF
.
save
(
_this
.
panelName
+
'.pdf'
)
_this
.
$emit
(
'closePreExport'
)
}
)
},
1500
)
},
500
)
}
}
...
...
frontend/src/views/panel/list/PanelViewShow.vue
浏览文件 @
03cb1f06
...
...
@@ -4,7 +4,7 @@
style=
"height: 100%;width: 100%;"
:element-loading-text=
"$t('panel.data_loading')"
element-loading-spinner=
"el-icon-loading"
element-loading-background=
"rgba(0, 0, 0,
0.8
)"
element-loading-background=
"rgba(0, 0, 0,
1
)"
>
<el-col
v-if=
"panelInfo.name.length>0"
class=
"panel-design"
>
...
...
@@ -73,9 +73,10 @@
</el-row>
<!-- 仪表板预览区域-->
<el-row
class=
"panel-design-preview"
>
<div
id=
"imageWrapper"
ref=
"imageWrapper"
style=
"width: 100%;height: 100%"
>
<!--
<div
id=
"imageWrapper"
ref=
"imageWrapper"
style=
"width: 4096px;height: 2160px"
>
-->
<div
id=
"imageWrapper"
ref=
"imageWrapper"
:style=
"imageWrapperStyle"
>
<fullscreen
style=
"height: 100%;background: #f7f8fa;overflow-y: auto"
:fullscreen
.
sync=
"fullscreen"
>
<Preview
v-if=
"showMain"
:in-screen=
"!fullscreen"
:show-type=
"'width'"
:screen-shot=
"dataLoading"
/>
<Preview
v-if=
"showMain
Flag
"
:in-screen=
"!fullscreen"
:show-type=
"'width'"
:screen-shot=
"dataLoading"
/>
</fullscreen>
</div>
</el-row>
...
...
@@ -129,6 +130,7 @@ import { starStatus, saveEnshrine, deleteEnshrine } from '@/api/panel/enshrine'
import
bus
from
'@/utils/bus'
import
{
queryAll
}
from
'@/api/panel/pdfTemplate'
import
ShareHead
from
'@/views/panel/GrantAuth/ShareHead'
import
JsPDF
from
'jspdf'
export
default
{
name
:
'PanelViewShow'
,
...
...
@@ -154,10 +156,27 @@ export default {
pdfExportShow
:
false
,
snapshotInfo
:
''
,
showType
:
0
,
dataLoading
:
false
dataLoading
:
false
,
exporting
:
false
}
},
computed
:
{
imageWrapperStyle
()
{
if
(
this
.
exporting
)
{
return
{
width
:
'4096px'
,
height
:
'2160px'
}
}
else
{
return
{
width
:
'100%'
,
height
:
'100%'
}
}
},
showMainFlag
()
{
return
this
.
showMain
},
panelInfo
()
{
return
this
.
$store
.
state
.
panel
.
panelInfo
},
...
...
@@ -252,17 +271,24 @@ export default {
},
downloadAsPDF
()
{
// this.pdfExportShow = true
//
this
.
dataLoading
=
true
setTimeout
(()
=>
{
html2canvas
(
document
.
getElementById
(
'canvasInfoTemp'
)).
then
(
canvas
=>
{
const
snapshot
=
canvas
.
toDataURL
(
'image/jpeg'
,
1
)
// 是图片质量
this
.
dataLoading
=
false
if
(
snapshot
!==
''
)
{
this
.
snapshotInfo
=
snapshot
this
.
pdfExportShow
=
true
}
})
},
50
)
this
.
exporting
=
true
setTimeout
(()
=>
{
html2canvas
(
document
.
getElementById
(
'canvasInfoTemp'
)).
then
(
canvas
=>
{
const
snapshot
=
canvas
.
toDataURL
(
'image/jpeg'
,
1
)
// 是图片质量
this
.
dataLoading
=
false
this
.
exporting
=
false
if
(
snapshot
!==
''
)
{
this
.
snapshotInfo
=
snapshot
this
.
pdfExportShow
=
true
}
})
},
1500
)
},
500
)
},
refreshTemplateInfo
()
{
this
.
templateInfo
=
{}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论