Merge pull request #7785 from dataease/pr@dev@refactor_view-dialog

refactor(仪表板): 视图导出支持选择分辨率
This commit is contained in:
王嘉豪 2024-01-24 11:56:17 +08:00 committed by GitHub
commit 3ca32d8d8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 101 additions and 16 deletions

View File

@ -154,15 +154,39 @@
v-if="chartDetailsVisible" v-if="chartDetailsVisible"
style="position: absolute;right: 70px;top:15px" style="position: absolute;right: 70px;top:15px"
> >
<el-button <span v-if="showChartInfoType==='enlarge' && hasDataPermission('export',panelInfo.privileges)&& showChartInfo && !equalsAny(showChartInfo.type, 'symbol-map', 'flow-map')">
v-if="showChartInfoType==='enlarge' && hasDataPermission('export',panelInfo.privileges)&& showChartInfo && !equalsAny(showChartInfo.type, 'symbol-map', 'flow-map')" <span style="font-size: 12px">
class="el-icon-picture-outline" 导出分辨率
size="mini" </span>
:disabled="imageDownloading" <el-select
@click="exportViewImg" v-model="pixel"
> style="width: 120px; margin-right: 8px; margin-top: -1px"
{{ $t('chart.export_img') }} :popper-append-to-body="false"
</el-button> size="mini"
>
<el-option-group
v-for="group in pixelOptions"
:key="group.label"
:label="group.label"
>
<el-option
v-for="item in group.options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-option-group>
</el-select>
<el-button
class="el-icon-picture-outline"
size="mini"
:disabled="imageDownloading"
@click="exportViewImg"
>
{{ $t('chart.export_img') }}
</el-button>
</span>
<el-button <el-button
v-if="showChartInfoType==='details' && hasDataPermission('export',panelInfo.privileges)" v-if="showChartInfoType==='details' && hasDataPermission('export',panelInfo.privileges)"
size="mini" size="mini"
@ -367,7 +391,44 @@ export default {
show: 0 show: 0
}, },
view: {}, view: {},
cancelTime: null cancelTime: null,
pixelOptions: [
{
label: 'Windows(16:9)',
options: [
{
value: '1920 * 1080',
label: '1920 * 1080'
},
{
value: '1600 * 900',
label: '1600 * 900'
},
{
value: '1280 * 720',
label: '1280 * 720'
}
]
},
{
label: 'MacOS(16:10)',
options: [
{
value: '2560 * 1600',
label: '2560 * 1600'
},
{
value: '1920 * 1200',
label: '1920 * 1200'
},
{
value: '1680 * 1050',
label: '1680 * 1050'
}
]
}
],
pixel: '1280 * 720'
} }
}, },
@ -685,7 +746,7 @@ export default {
}, },
exportViewImg() { exportViewImg() {
this.imageDownloading = true this.imageDownloading = true
this.$refs['userViewDialog'].exportViewImg(() => { this.$refs['userViewDialog'].exportViewImg(this.pixel,() => {
this.imageDownloading = false this.imageDownloading = false
}) })
}, },

View File

@ -13,7 +13,6 @@
> >
<div <div
id="chartCanvas" id="chartCanvas"
:class="{'canvas-class-exporting':exporting}"
class="canvas-class" class="canvas-class"
:style="customStyle" :style="customStyle"
> >
@ -23,6 +22,7 @@
> >
<plugin-com <plugin-com
v-if="chart.isPlugin" v-if="chart.isPlugin"
:ref="element.propValue.id"
:component-name="chart.type + '-view'" :component-name="chart.type + '-view'"
:obj="{chart: mapChart || chart}" :obj="{chart: mapChart || chart}"
:chart="mapChart || chart" :chart="mapChart || chart"
@ -31,32 +31,38 @@
class="chart-class" class="chart-class"
/> />
<chart-component <chart-component
:ref="element.propValue.id"
v-else-if="!chart.type.includes('text') && chart.type !== 'label' && !chart.type.includes('table') && renderComponent() === 'echarts'" v-else-if="!chart.type.includes('text') && chart.type !== 'label' && !chart.type.includes('table') && renderComponent() === 'echarts'"
:theme-style="element.commonBackground" :theme-style="element.commonBackground"
class="chart-class" class="chart-class"
:chart="mapChart || chart" :chart="mapChart || chart"
/> />
<chart-component-g2 <chart-component-g2
:ref="element.propValue.id"
v-else-if="!chart.type.includes('text') && chart.type !== 'label' && !chart.type.includes('table') && renderComponent() === 'antv'" v-else-if="!chart.type.includes('text') && chart.type !== 'label' && !chart.type.includes('table') && renderComponent() === 'antv'"
class="chart-class show-in-dialog" class="chart-class show-in-dialog"
:chart="chart" :chart="chart"
/> />
<chart-component-s2 <chart-component-s2
:ref="element.propValue.id"
v-else-if="chart.type.includes('table') && renderComponent() === 'antv'" v-else-if="chart.type.includes('table') && renderComponent() === 'antv'"
class="chart-class" class="chart-class"
:chart="chart" :chart="chart"
/> />
<label-normal <label-normal
:ref="element.propValue.id"
v-else-if="chart.type.includes('text')" v-else-if="chart.type.includes('text')"
:chart="chart" :chart="chart"
class="table-class" class="table-class"
/> />
<label-normal-text <label-normal-text
:ref="element.propValue.id"
v-else-if="chart.type === 'label'" v-else-if="chart.type === 'label'"
:chart="chart" :chart="chart"
class="table-class" class="table-class"
/> />
<table-normal <table-normal
:ref="element.propValue.id"
v-else-if="chart.type.includes('table') && renderComponent() === 'echarts'" v-else-if="chart.type.includes('table') && renderComponent() === 'echarts'"
:chart="chart" :chart="chart"
class="table-class" class="table-class"
@ -126,7 +132,8 @@ export default {
lastMapChart: null, lastMapChart: null,
linkLoading: false, linkLoading: false,
exporting: false, exporting: false,
exportLoading: false exportLoading: false,
pixel: '1280 * 720'
} }
}, },
computed: { computed: {
@ -144,6 +151,13 @@ export default {
}, },
customStyle() { customStyle() {
let style = {} let style = {}
if (this.exporting) {
const bashStyle = this.pixel.split(' * ')
style = {
width: bashStyle[0] + 'px!important',
height: bashStyle[1] + 'px!important'
}
}
if (this.canvasStyleData.openCommonStyle) { if (this.canvasStyleData.openCommonStyle) {
if (this.canvasStyleData.panel.backgroundType === 'image' && this.canvasStyleData.panel.imageUrl) { if (this.canvasStyleData.panel.backgroundType === 'image' && this.canvasStyleData.panel.imageUrl) {
style = { style = {
@ -261,13 +275,16 @@ export default {
} }
} }
}, },
exportViewImg(callback) { exportViewImg(pixel, callback) {
this.pixel = pixel
this.exportLoading = true this.exportLoading = true
this.$nextTick(() => { this.$nextTick(() => {
this.exporting = true this.exporting = true
this.resizeChart()
setTimeout(() => { setTimeout(() => {
exportImg(this.chart.name, (params) => { exportImg(this.chart.name, (params) => {
this.exporting = false this.exporting = false
this.resizeChart()
setTimeout(() => { setTimeout(() => {
this.exportLoading = false this.exportLoading = false
}, 500) }, 500)
@ -286,6 +303,13 @@ export default {
renderComponent() { renderComponent() {
return this.chart.render return this.chart.render
},
resizeChart() {
if (this.$refs[this.element.propValue.id]) {
this.chart.isPlugin
? this.$refs[this.element.propValue.id].callPluginInner({ methodName: 'chartResize' })
: this.$refs[this.element.propValue.id].chartResize()
}
} }
} }
} }
@ -320,8 +344,8 @@ export default {
background-size: 100% 100% !important; background-size: 100% 100% !important;
} }
.canvas-class-exporting { .canvas-class-exporting {
width: 1080px!important; width: 1980px!important;
height: 560px!important; height: 860px!important;
} }
.abs-container { .abs-container {