feat:仪表盘预览

This commit is contained in:
wangjiahao 2021-04-01 11:38:30 +08:00
parent 79d37827a4
commit c87a6f132c
8 changed files with 45 additions and 62 deletions

View File

@ -1,6 +1,5 @@
<template> <template>
<div v-if="show" class="bg"> <div class="bg">
<el-button class="close" @click="close">关闭</el-button>
<div class="canvas-container"> <div class="canvas-container">
<div <div
class="canvas" class="canvas"
@ -57,33 +56,14 @@ export default {
.bg { .bg {
width: 100%; width: 100%;
height: 100%; height: 100%;
top: 0;
left: 0;
position: fixed;
background: rgb(0, 0, 0, .5);
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
overflow: auto;
padding: 20px;
.canvas-container { .canvas-container {
width: calc(100% - 40px); width: 100%;
height: calc(100% - 120px); height: 100%;
overflow: auto; overflow: auto;
.canvas { .canvas {
background: #fff;
position: relative; position: relative;
margin: auto; margin: auto;
} }
} }
.close {
position: absolute;
right: 20px;
top: 100px;
}
} }
</style> </style>

View File

@ -34,7 +34,7 @@
</div> </div>
<!-- 预览 --> <!-- 预览 -->
<Preview v-model="isShowPreview" @change="handlePreviewChange" /> <!-- <Preview v-model="isShowPreview" @change="handlePreviewChange" />-->
</div> </div>
</template> </template>

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="rect-shape"> <div class="rect-shape">
<chart-component :ref="element.propValue.id" class="chart-class" :chart-id="element.propValue.id" :chart="chart" /> <chart-component :ref="element.propValue.id" class="chart-class" :chart="chart" />
</div> </div>
</template> </template>
@ -8,6 +8,7 @@
import { post } from '@/api/panel/panel' import { post } from '@/api/panel/panel'
import ChartComponent from '@/views/chart/components/ChartComponent.vue' import ChartComponent from '@/views/chart/components/ChartComponent.vue'
export default { export default {
name: 'UserView', name: 'UserView',
components: { ChartComponent }, components: { ChartComponent },
@ -22,12 +23,7 @@ export default {
} }
}, },
created() { created() {
const id = this.element.propValue.viewId this.getData(this.element.propValue.viewId)
debugger
this.$nextTick(() => {
// eChar
this.getData(id)
})
}, },
mounted() { mounted() {

View File

@ -12,6 +12,7 @@ import { basePieOption } from '../chart/pie/pie'
import { baseFunnelOption } from '../chart/funnel/funnel' import { baseFunnelOption } from '../chart/funnel/funnel'
import { baseRadarOption } from '../chart/radar/radar' import { baseRadarOption } from '../chart/radar/radar'
import eventBus from '@/components/canvas/utils/eventBus' import eventBus from '@/components/canvas/utils/eventBus'
import { uuid } from 'vue-uuid'
export default { export default {
name: 'ChartComponent', name: 'ChartComponent',
@ -19,15 +20,12 @@ export default {
chart: { chart: {
type: Object, type: Object,
required: true required: true
},
chartId: {
type: String,
required: false
} }
}, },
data() { data() {
return { return {
myChart: {} myChart: {},
chartId: uuid.v1()
} }
}, },
watch: { watch: {
@ -41,8 +39,15 @@ export default {
mounted() { mounted() {
// domecharts // domecharts
console.log('chartId:' + this.chartId) console.log('chartId:' + this.chartId)
// echartdom,idechart id
new Promise((resolve) => { resolve() }).then(() => {
// domechartsdom
this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId))
if (!this.myChart) {
this.myChart = this.$echarts.init(document.getElementById(this.chartId)) this.myChart = this.$echarts.init(document.getElementById(this.chartId))
}
this.drawEcharts() this.drawEcharts()
})
// //
eventBus.$on('resizing', (componentId) => { eventBus.$on('resizing', (componentId) => {

View File

@ -199,12 +199,6 @@ export default {
body.insertBefore(elx, body.firstChild) body.insertBefore(elx, body.firstChild)
}) })
}, },
saveDrawing() {
bus.$emit('panel-drawing-save')
},
preViewShow() {
bus.$emit('panel-drawing-preview')
},
// //
restore() { restore() {
@ -230,7 +224,6 @@ export default {
e.stopPropagation() e.stopPropagation()
let component let component
const newComponentId = uuid.v1() const newComponentId = uuid.v1()
console.log('handleDrop123')
const componentInfo = JSON.parse(e.dataTransfer.getData('componentInfo')) const componentInfo = JSON.parse(e.dataTransfer.getData('componentInfo'))
// //

View File

@ -21,7 +21,6 @@
</de-aside-container> </de-aside-container>
<de-main-container> <de-main-container>
<!--<router-view/>-->
<component :is="component" :param="param" /> <component :is="component" :param="param" />
</de-main-container> </de-main-container>
</de-container> </de-container>

View File

@ -123,10 +123,6 @@
custom-class="de-dialog" custom-class="de-dialog"
> >
<grant-auth v-if="authVisible" :resource-id="authResourceId" @close-grant="closeGrant" /> <grant-auth v-if="authVisible" :resource-id="authResourceId" @close-grant="closeGrant" />
<!-- <span slot="footer" class="dialog-footer">
<el-button @click="authVisible = false"> </el-button>
<el-button type="primary" @click="authVisible = false"> </el-button>
</span> -->
</el-dialog> </el-dialog>
<el-dialog <el-dialog
@ -147,6 +143,8 @@
<script> <script>
import GrantAuth from '../GrantAuth' import GrantAuth from '../GrantAuth'
import LinkGenerate from '@/views/link/generate' import LinkGenerate from '@/views/link/generate'
import { uuid } from 'vue-uuid'
import bus from '@/utils/bus'
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, defaultTree, get } from '@/api/panel/panel' import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, defaultTree, get } from '@/api/panel/panel'
export default { export default {
@ -236,7 +234,6 @@ export default {
this.groupForm = JSON.parse(JSON.stringify(param.data)) this.groupForm = JSON.parse(JSON.stringify(param.data))
break break
case 'move': case 'move':
break break
case 'delete': case 'delete':
this.delete(param.data) this.delete(param.data)
@ -421,7 +418,15 @@ export default {
nodeClick(data, node) { nodeClick(data, node) {
if (data.nodeType === 'panel') { if (data.nodeType === 'panel') {
this.currGroup = data this.currGroup = data
// this.$store.dispatch('panel/setPanelInfo', data) //
this.$nextTick(() => {
localStorage.setItem('canvasData', null)
localStorage.setItem('canvasStyle', null)
get('panel/group/findOne/' + data.id).then(response => {
this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))
this.$store.commit('setCanvasStyle', JSON.parse(response.data.panelStyle))
})
})
} }
if (node.expanded) { if (node.expanded) {
this.expandedArray.push(data.id) this.expandedArray.push(data.id)
@ -523,6 +528,13 @@ export default {
removeLink() { removeLink() {
this.linkVisible = false this.linkVisible = false
this.linkResourceId = null this.linkResourceId = null
},
resetID(data) {
data.forEach(item => {
item.id = uuid.v1()
})
return data
} }
} }
} }

View File

@ -10,18 +10,19 @@
</span> </span>
<span style="float: right;line-height: 40px;"> <span style="float: right;line-height: 40px;">
<el-tooltip content="预览"> <el-tooltip content="预览">
<el-button class="el-icon-view" size="mini" circle @click="preViewShow" /> <el-button class="el-icon-view" size="mini" circle />
</el-tooltip> </el-tooltip>
</span> </span>
</el-row> </el-row>
<!--TODO 仪表盘预览区域--> <!--TODO 仪表盘预览区域-->
<!-- <Preview />--> <section>
<Preview />
</section>
</el-col> </el-col>
</el-row> </el-row>
</el-row> </el-row>
</template> </template>
<script> <script>
import bus from '@/utils/bus'
import Preview from '@/components/canvas/components/Editor/Preview' import Preview from '@/components/canvas/components/Editor/Preview'
export default { export default {
@ -36,15 +37,12 @@ export default {
panelInfo() { panelInfo() {
return this.$store.state.panel.panelInfo return this.$store.state.panel.panelInfo
} }
},
mounted() {
}, },
methods: { methods: {
preViewShow() {
bus.$emit('panel-drawing-preview')
},
savePanel() {
bus.$emit('panel-drawing-save')
}
} }
} }
</script> </script>