2021-03-12 16:08:55 +08:00
|
|
|
<template>
|
2021-04-09 18:19:45 +08:00
|
|
|
<el-row style="height: 100%;width: 100%;">
|
2021-04-08 16:54:37 +08:00
|
|
|
<el-col v-if="panelInfo.name.length>0" class="panel-design">
|
|
|
|
<el-row class="panel-design-head">
|
|
|
|
<!--TODO 仪表盘头部区域-->
|
|
|
|
<span>{{ panelInfo.name || '测试仪表板' }}</span>
|
2021-04-13 18:43:17 +08:00
|
|
|
<span style="float: right;margin-right: 10px">
|
|
|
|
<el-tooltip content="导出为模板">
|
|
|
|
<el-button class="el-icon-download" size="mini" circle @click="saveToTemplate" />
|
|
|
|
</el-tooltip>
|
|
|
|
</span>
|
|
|
|
<span style="float: right;margin-right: 10px">
|
2021-04-08 16:54:37 +08:00
|
|
|
<el-tooltip content="预览">
|
|
|
|
<el-button class="el-icon-view" size="mini" circle @click="clickPreview" />
|
|
|
|
</el-tooltip>
|
|
|
|
</span>
|
|
|
|
</el-row>
|
|
|
|
<!--TODO 仪表盘预览区域-->
|
|
|
|
<el-row class="panel-design-preview">
|
2021-04-13 18:43:17 +08:00
|
|
|
<div ref="imageWrapper" style="width: 100%;height: 100%">
|
|
|
|
<Preview v-if="showMain" />
|
|
|
|
</div>
|
2021-04-08 16:54:37 +08:00
|
|
|
</el-row>
|
|
|
|
</el-col>
|
|
|
|
<el-col v-if="panelInfo.name.length===0" style="height: 100%;">
|
|
|
|
<el-row style="height: 100%;" class="custom-position">
|
|
|
|
请从左侧选择仪表盘
|
|
|
|
</el-row>
|
|
|
|
</el-col>
|
2021-03-12 16:08:55 +08:00
|
|
|
</el-row>
|
|
|
|
</template>
|
|
|
|
<script>
|
2021-03-30 15:38:32 +08:00
|
|
|
import Preview from '@/components/canvas/components/Editor/Preview'
|
2021-04-06 15:07:13 +08:00
|
|
|
import { mapState } from 'vuex'
|
2021-04-13 18:43:17 +08:00
|
|
|
import html2canvas from 'html2canvas'
|
|
|
|
import FileSaver from 'file-saver'
|
2021-03-19 17:06:52 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PanelViewShow',
|
2021-03-29 14:57:04 +08:00
|
|
|
components: { Preview },
|
2021-03-19 17:06:52 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 18:19:45 +08:00
|
|
|
showMain: true
|
2021-03-23 17:16:51 +08:00
|
|
|
|
2021-03-19 17:06:52 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
panelInfo() {
|
|
|
|
return this.$store.state.panel.panelInfo
|
2021-04-06 15:07:13 +08:00
|
|
|
},
|
|
|
|
...mapState([
|
|
|
|
'componentData',
|
|
|
|
'canvasStyleData'
|
|
|
|
])
|
2021-04-01 11:38:30 +08:00
|
|
|
},
|
2021-04-09 18:19:45 +08:00
|
|
|
watch: {
|
|
|
|
panelInfo(newVal, oldVla) {
|
|
|
|
// 刷新 进行重新渲染
|
2021-04-09 13:53:04 +08:00
|
|
|
this.showMain = false
|
2021-04-09 18:19:45 +08:00
|
|
|
this.$nextTick(() => { this.showMain = true })
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-03-19 17:06:52 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2021-04-06 15:07:13 +08:00
|
|
|
clickPreview() {
|
2021-04-07 11:12:02 +08:00
|
|
|
const url = '#/preview/' + this.$store.state.panel.panelInfo.id
|
2021-04-06 15:07:13 +08:00
|
|
|
window.open(url, '_blank')
|
2021-04-13 18:43:17 +08:00
|
|
|
},
|
|
|
|
saveToTemplate() {
|
|
|
|
html2canvas(this.$refs.imageWrapper).then(canvas => {
|
|
|
|
debugger
|
|
|
|
const snapShot = canvas.toDataURL('image/jpeg', 0.5) // 0.5是图片质量
|
|
|
|
if (snapShot !== '') {
|
|
|
|
const templateInfo = {
|
|
|
|
snapShot: snapShot,
|
|
|
|
panelStyle: JSON.stringify(this.canvasStyleData),
|
|
|
|
panelData: JSON.stringify(this.componentData),
|
|
|
|
dynamicData: ''
|
|
|
|
}
|
|
|
|
const blob = new Blob([JSON.stringify(templateInfo)], { type: '' })
|
|
|
|
FileSaver.saveAs(blob, this.$store.state.panel.panelInfo.name + '-TEMPLATE.DE')
|
|
|
|
}
|
|
|
|
})
|
2021-04-06 15:07:13 +08:00
|
|
|
}
|
2021-03-19 17:06:52 +08:00
|
|
|
|
2021-03-12 16:08:55 +08:00
|
|
|
}
|
2021-03-19 17:06:52 +08:00
|
|
|
}
|
2021-03-12 16:08:55 +08:00
|
|
|
</script>
|
|
|
|
|
2021-04-08 16:54:37 +08:00
|
|
|
<style>
|
2021-03-12 16:08:55 +08:00
|
|
|
.view-list {
|
|
|
|
height: 100%;
|
|
|
|
width: 20%;
|
|
|
|
min-width: 180px;
|
2021-03-16 11:38:20 +08:00
|
|
|
max-width: 220px;
|
2021-03-12 16:08:55 +08:00
|
|
|
border: 1px solid #E6E6E6;
|
|
|
|
border-left: 0 solid;
|
2021-03-16 11:38:20 +08:00
|
|
|
overflow-y: auto;
|
2021-03-12 16:08:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.view-list-thumbnails-outline {
|
|
|
|
height: 100%;
|
|
|
|
overflow-y: auto;
|
|
|
|
}
|
2021-03-16 11:38:20 +08:00
|
|
|
|
2021-03-12 16:08:55 +08:00
|
|
|
.view-list-thumbnails {
|
|
|
|
width: 100%;
|
|
|
|
padding: 0px 15px 15px 0px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.panel-design {
|
2021-04-08 16:54:37 +08:00
|
|
|
min-height: 400px;
|
2021-03-12 16:08:55 +08:00
|
|
|
height: 100%;
|
|
|
|
min-width: 500px;
|
2021-04-08 16:54:37 +08:00
|
|
|
overflow-y: auto;
|
2021-03-12 16:08:55 +08:00
|
|
|
border-top: 1px solid #E6E6E6;
|
|
|
|
}
|
|
|
|
|
|
|
|
.panel-design-head {
|
|
|
|
height: 40px;
|
2021-04-08 16:54:37 +08:00
|
|
|
background-color: white;
|
|
|
|
padding: 0 6px;
|
|
|
|
line-height: 40px;
|
2021-03-12 16:08:55 +08:00
|
|
|
}
|
|
|
|
|
2021-04-08 16:54:37 +08:00
|
|
|
.panel-design-preview {
|
2021-03-12 16:08:55 +08:00
|
|
|
width: 100%;
|
2021-04-08 16:54:37 +08:00
|
|
|
height: calc(100% - 40px);
|
|
|
|
overflow-x: hidden;
|
|
|
|
overflow-y: auto;
|
|
|
|
padding: 5px;
|
2021-03-12 16:08:55 +08:00
|
|
|
border-top: 1px solid #E6E6E6;
|
|
|
|
}
|
|
|
|
|
2021-04-08 16:54:37 +08:00
|
|
|
.custom-position {
|
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
font-size: 14px;
|
|
|
|
flex-flow: row nowrap;
|
|
|
|
color: #9ea6b2;
|
|
|
|
}
|
2021-03-12 16:08:55 +08:00
|
|
|
</style>
|