refactor(仪表板): 视图放大导出支持显示水印
This commit is contained in:
parent
6623fe7411
commit
e7335768b5
@ -149,6 +149,10 @@ export default {
|
|||||||
isRelation: {
|
isRelation: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: String,
|
||||||
|
require: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|||||||
@ -164,6 +164,7 @@
|
|||||||
<user-view-dialog
|
<user-view-dialog
|
||||||
v-if="chartDetailsVisible"
|
v-if="chartDetailsVisible"
|
||||||
ref="userViewDialog-canvas-main"
|
ref="userViewDialog-canvas-main"
|
||||||
|
:user-id="userId"
|
||||||
:chart="showChartInfo"
|
:chart="showChartInfo"
|
||||||
:chart-table="showChartTableInfo"
|
:chart-table="showChartTableInfo"
|
||||||
:canvas-style-data="canvasStyleData"
|
:canvas-style-data="canvasStyleData"
|
||||||
|
|||||||
@ -206,6 +206,7 @@
|
|||||||
:chart-table="showChartTableInfo"
|
:chart-table="showChartTableInfo"
|
||||||
:canvas-style-data="canvasStyleData"
|
:canvas-style-data="canvasStyleData"
|
||||||
:open-type="showChartInfoType"
|
:open-type="showChartInfoType"
|
||||||
|
:user-id="userId"
|
||||||
/>
|
/>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
@ -342,6 +343,10 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
require: false,
|
require: false,
|
||||||
default: 'preview'
|
default: 'preview'
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: String,
|
||||||
|
require: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -746,7 +751,7 @@ export default {
|
|||||||
},
|
},
|
||||||
exportViewImg() {
|
exportViewImg() {
|
||||||
this.imageDownloading = true
|
this.imageDownloading = true
|
||||||
this.$refs['userViewDialog'].exportViewImg(this.pixel,() => {
|
this.$refs['userViewDialog'].exportViewImg(this.pixel, () => {
|
||||||
this.imageDownloading = false
|
this.imageDownloading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@ -31,39 +31,39 @@
|
|||||||
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'"
|
||||||
|
:ref="element.propValue.id"
|
||||||
: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'"
|
||||||
|
:ref="element.propValue.id"
|
||||||
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'"
|
||||||
|
:ref="element.propValue.id"
|
||||||
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')"
|
||||||
|
:ref="element.propValue.id"
|
||||||
: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'"
|
||||||
|
:ref="element.propValue.id"
|
||||||
: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'"
|
||||||
|
:ref="element.propValue.id"
|
||||||
:chart="chart"
|
:chart="chart"
|
||||||
class="table-class"
|
class="table-class"
|
||||||
/>
|
/>
|
||||||
@ -96,6 +96,8 @@ import LabelNormalText from '@/views/chart/components/normal/LabelNormalText'
|
|||||||
import html2canvas from 'html2canvasde'
|
import html2canvas from 'html2canvasde'
|
||||||
import { hexColorToRGBA } from '@/views/chart/chart/util'
|
import { hexColorToRGBA } from '@/views/chart/chart/util'
|
||||||
import { deepCopy, exportExcelDownload, exportImg, imgUrlTrans } from '@/components/canvas/utils/utils'
|
import { deepCopy, exportExcelDownload, exportImg, imgUrlTrans } from '@/components/canvas/utils/utils'
|
||||||
|
import { activeWatermark } from '@/components/canvas/tools/watermark'
|
||||||
|
import { proxyUserLoginInfo, userLoginInfo } from '@/api/systemInfo/userLogin'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UserViewDialog',
|
name: 'UserViewDialog',
|
||||||
@ -122,6 +124,10 @@ export default {
|
|||||||
openType: {
|
openType: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'details'
|
default: 'details'
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: String,
|
||||||
|
require: false
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -258,8 +264,22 @@ export default {
|
|||||||
this.element = deepCopy(this.curComponent)
|
this.element = deepCopy(this.curComponent)
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.initWatermark()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
initWatermark(waterDomId = 'chartCanvas') {
|
||||||
|
if (this.panelInfo.watermarkInfo) {
|
||||||
|
if (this.userInfo) {
|
||||||
|
activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, 'canvas-main', this.panelInfo.watermarkOpen, 'de-watermark-view')
|
||||||
|
} else {
|
||||||
|
const method = this.userId ? proxyUserLoginInfo : userLoginInfo
|
||||||
|
method().then(res => {
|
||||||
|
this.userInfo = res.data
|
||||||
|
activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, 'canvas-main', this.panelInfo.watermarkOpen, 'de-watermark-view')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
exportExcel(callBack) {
|
exportExcel(callBack) {
|
||||||
const _this = this
|
const _this = this
|
||||||
if (this.isOnlyDetails) {
|
if (this.isOnlyDetails) {
|
||||||
@ -282,6 +302,7 @@ export default {
|
|||||||
this.exporting = true
|
this.exporting = true
|
||||||
this.resizeChart()
|
this.resizeChart()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
this.initWatermark()
|
||||||
exportImg(this.chart.name, (params) => {
|
exportImg(this.chart.name, (params) => {
|
||||||
this.exporting = false
|
this.exporting = false
|
||||||
this.resizeChart()
|
this.resizeChart()
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
class="full-div"
|
class="full-div"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
id="chartCanvas"
|
||||||
class="canvas-class"
|
class="canvas-class"
|
||||||
:style="commonStyle"
|
:style="commonStyle"
|
||||||
>
|
>
|
||||||
@ -70,6 +71,8 @@ import ChartComponentS2 from '@/views/chart/components/ChartComponentS2'
|
|||||||
import PluginCom from '@/views/system/plugin/PluginCom'
|
import PluginCom from '@/views/system/plugin/PluginCom'
|
||||||
import { deepCopy, imgUrlTrans } from '@/components/canvas/utils/utils'
|
import { deepCopy, imgUrlTrans } from '@/components/canvas/utils/utils'
|
||||||
import { hexColorToRGBA } from '@/views/chart/chart/util'
|
import { hexColorToRGBA } from '@/views/chart/chart/util'
|
||||||
|
import {activeWatermark} from "@/components/canvas/tools/watermark";
|
||||||
|
import {proxyUserLoginInfo, userLoginInfo} from "@/api/systemInfo/userLogin";
|
||||||
export default {
|
export default {
|
||||||
name: 'UserViewMobileDialog',
|
name: 'UserViewMobileDialog',
|
||||||
components: { ChartComponentS2, LabelNormalText, DeContainer, DeMainContainer, ChartComponentG2, ChartComponent, TableNormal, LabelNormal, PluginCom },
|
components: { ChartComponentS2, LabelNormalText, DeContainer, DeMainContainer, ChartComponentG2, ChartComponent, TableNormal, LabelNormal, PluginCom },
|
||||||
@ -81,6 +84,10 @@ export default {
|
|||||||
chartTable: {
|
chartTable: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: String,
|
||||||
|
require: false
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -180,6 +187,19 @@ export default {
|
|||||||
this.element = deepCopy(this.curComponent)
|
this.element = deepCopy(this.curComponent)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
initWatermark(waterDomId = 'chartCanvas') {
|
||||||
|
if (this.panelInfo.watermarkInfo) {
|
||||||
|
if (this.userInfo) {
|
||||||
|
activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, 'canvas-main', this.panelInfo.watermarkOpen, 'de-watermark-view')
|
||||||
|
} else {
|
||||||
|
const method = this.userId ? proxyUserLoginInfo : userLoginInfo
|
||||||
|
method().then(res => {
|
||||||
|
this.userInfo = res.data
|
||||||
|
activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, 'canvas-main', this.panelInfo.watermarkOpen, 'de-watermark-view')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
renderComponent() {
|
renderComponent() {
|
||||||
return this.chart.render
|
return this.chart.render
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// 动态创建水印元素的封装函数
|
// 动态创建水印元素的封装函数
|
||||||
|
|
||||||
export function watermark(settings, domId) {
|
export function watermark(settings, domId, watermarkDomId = 'de-watermark-server') {
|
||||||
const watermarkDom = document.getElementById(domId)
|
const watermarkDom = document.getElementById(domId)
|
||||||
// 默认设置
|
// 默认设置
|
||||||
const defaultSettings = {
|
const defaultSettings = {
|
||||||
@ -85,7 +85,7 @@ export function watermark(settings, domId) {
|
|||||||
oTemp.appendChild(mask_div)
|
oTemp.appendChild(mask_div)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
oTemp.setAttribute('id', 'de-watermark-server')
|
oTemp.setAttribute('id', watermarkDomId)
|
||||||
watermarkDom.appendChild(oTemp)
|
watermarkDom.appendChild(oTemp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,9 +109,9 @@ export function getNow() {
|
|||||||
return time
|
return time
|
||||||
}
|
}
|
||||||
|
|
||||||
export function activeWatermark(watermarkForm, userLoginInfo, domId, canvasId, watermarkOpen) {
|
export function activeWatermark(watermarkForm, userLoginInfo, domId, canvasId, watermarkOpen, watermarkDomId = 'de-watermark-server') {
|
||||||
// 清理历史水印
|
// 清理历史水印
|
||||||
const historyWatermarkDom = document.getElementById('de-watermark-server')
|
const historyWatermarkDom = document.getElementById(watermarkDomId)
|
||||||
if (historyWatermarkDom) {
|
if (historyWatermarkDom) {
|
||||||
historyWatermarkDom.remove()
|
historyWatermarkDom.remove()
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ export function activeWatermark(watermarkForm, userLoginInfo, domId, canvasId, w
|
|||||||
watermark_y_space: watermarkForm.watermark_y_space,
|
watermark_y_space: watermarkForm.watermark_y_space,
|
||||||
watermark_fontsize: watermarkForm.watermark_fontsize + 'px'
|
watermark_fontsize: watermarkForm.watermark_fontsize + 'px'
|
||||||
}
|
}
|
||||||
watermark(settings, domId)
|
watermark(settings, domId, watermarkDomId)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default { watermark, getNow, activeWatermark }
|
export default { watermark, getNow, activeWatermark }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user