提交 01eb4abc authored 作者: wangjiahao's avatar wangjiahao

feat:增加预览背景设置 解决改变窗口大小 echart 有滚动条的问题

上级 9ba7aeae
<template> <template>
<div id="canvasInfo" class="bg"> <div id="canvasInfo" :style="customStyle" class="bg">
<ComponentWrapper <ComponentWrapper
v-for="(item, index) in componentDataInfo" v-for="(item, index) in componentDataInfo"
:key="index" :key="index"
...@@ -51,6 +51,25 @@ export default { ...@@ -51,6 +51,25 @@ export default {
} }
}, },
computed: { computed: {
customStyle() {
let style = {}
if (this.canvasStyleData.openCommonStyle) {
if (this.canvasStyleData.panel.backgroundType === 'image') {
style = {
width: '100%',
height: '100%',
background: `url(${this.canvasStyleData.panel.imageUrl}) no-repeat`
}
} else {
style = {
width: '100%',
height: '100%',
background: this.canvasStyleData.panel.color
}
}
}
return style
},
// 此处单独计算componentData的值 不放入全局mapState中 // 此处单独计算componentData的值 不放入全局mapState中
componentDataInfo() { componentDataInfo() {
return this.componentDataShow return this.componentDataShow
...@@ -81,7 +100,7 @@ export default { ...@@ -81,7 +100,7 @@ export default {
this.handleScaleChange() this.handleScaleChange()
}, },
resetID(data) { resetID(data) {
if( data ) { if (data) {
data.forEach(item => { data.forEach(item => {
item.id = uuid.v1() item.id = uuid.v1()
}) })
...@@ -104,7 +123,7 @@ export default { ...@@ -104,7 +123,7 @@ export default {
}) })
}) })
this.componentDataShow = componentData this.componentDataShow = componentData
eventBus.$emit('resizing', '') this.$nextTick(() => (eventBus.$emit('resizing', '')))
} }
} }
} }
...@@ -117,6 +136,7 @@ export default { ...@@ -117,6 +136,7 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
border: 1px solid #E6E6E6; border: 1px solid #E6E6E6;
background-size: 100% !important;
.canvas-container { .canvas-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
......
<template> <template>
<div id="canvasInfo" class="bg"> <div id="canvasInfo" :style="customStyle" class="bg">
<ComponentWrapper <ComponentWrapper
v-for="(item, index) in componentDataInfo" v-for="(item, index) in componentDataInfo"
:key="index" :key="index"
...@@ -47,13 +47,32 @@ export default { ...@@ -47,13 +47,32 @@ export default {
scaleWidth: '100', scaleWidth: '100',
scaleHeight: '100', scaleHeight: '100',
timer: null, timer: null,
componentDataSource: {}, componentDataSource: [],
componentData: {}, componentData: [],
canvasStyleData: {} canvasStyleData: {}
} }
}, },
computed: { computed: {
customStyle() {
let style = {}
if (this.canvasStyleData.openCommonStyle) {
if (this.canvasStyleData.panel.backgroundType === 'image') {
style = {
width: '100%',
height: '100%',
background: `url(${this.canvasStyleData.panel.imageUrl}) no-repeat`
}
} else {
style = {
width: '100%',
height: '100%',
background: this.canvasStyleData.panel.color
}
}
}
return style
},
componentDataInfo() { componentDataInfo() {
return this.componentData return this.componentData
} }
...@@ -70,9 +89,6 @@ export default { ...@@ -70,9 +89,6 @@ export default {
_this.resize() _this.resize()
}) })
}) })
window.onresize = () => {
this.resize()
}
// this.resize() // this.resize()
}, },
methods: { methods: {
...@@ -96,7 +112,7 @@ export default { ...@@ -96,7 +112,7 @@ export default {
}) })
}, },
resetID(data) { resetID(data) {
if( data ) { if (data) {
data.forEach(item => { data.forEach(item => {
item.id = uuid.v1() item.id = uuid.v1()
}) })
...@@ -120,7 +136,7 @@ export default { ...@@ -120,7 +136,7 @@ export default {
}) })
}) })
this.componentData = componentData this.componentData = componentData
eventBus.$emit('resizing', '') this.$nextTick(() => (eventBus.$emit('resizing', '')))
} }
} }
} }
...@@ -132,6 +148,7 @@ export default { ...@@ -132,6 +148,7 @@ export default {
min-height: 600px; min-height: 600px;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-size: 100% !important;
overflow: auto; overflow: auto;
position: relative; position: relative;
margin: 0; margin: 0;
......
<template> <template>
<div style="width: 100%;height: 100%;background-color: #f7f8fa"> <div style="width: 100%;height: 100%;">
<span style="line-height: 35px; position: absolute; top:10px;right: 20px;z-index:100000"> <span style="line-height: 35px; position: absolute; top:10px;right: 20px;z-index:100000">
<el-button size="mini" @click="toDir"> <el-button size="mini" @click="toDir">
关闭 关闭
......
...@@ -121,7 +121,7 @@ export default { ...@@ -121,7 +121,7 @@ export default {
...this.canvasStyleData, ...this.canvasStyleData,
scale: this.scale scale: this.scale
}) })
eventBus.$emit('resizing', '') this.$nextTick(() => (eventBus.$emit('resizing', '')))
}, 1000) }, 1000)
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论