2020-06-01 19:10:45 +08:00
|
|
|
<style lang="scss">
|
|
|
|
|
@import './chart.scss';
|
2020-04-14 21:46:38 +08:00
|
|
|
</style>
|
|
|
|
|
<template>
|
2020-05-31 22:33:16 +08:00
|
|
|
<div class="nz-chart-resize">
|
|
|
|
|
<div class="resize-shadow" ref="resizeShadow"></div>
|
|
|
|
|
<div class="resize-box resize-box-url" ref="resizeBox">
|
2020-06-05 17:09:27 +08:00
|
|
|
<div class="chart-url" :id="'chartUrlDiv'+chartIndex" @mouseenter="caretShow=true" @mouseleave="caretShow=false" >
|
2020-04-14 21:46:38 +08:00
|
|
|
<loading :ref="'localLoading'+chartIndex"></loading>
|
|
|
|
|
<div class="clearfix chartTitle" :class="{'dragTitle':dragTitleShow}" :id="'chartTitle'+chartIndex">
|
2020-12-15 18:47:30 +08:00
|
|
|
<el-dropdown trigger="click" class="nz-chart-top" :key="'chartDropdown'+chartIndex" v-clickoutside="clickos" :class="{'move-able':!isLock}">
|
2020-04-21 19:28:01 +08:00
|
|
|
<el-dropdown-menu style="display: none"></el-dropdown-menu>
|
2021-04-07 19:18:22 +08:00
|
|
|
<span class="el-dropdown-link chart-title">
|
2021-04-07 16:41:11 +08:00
|
|
|
<span class="chart-title-text">{{chartData.name}}</span>
|
2021-05-17 20:31:32 +08:00
|
|
|
<span class="chart-title-icon" :class="{'visible':caretShow,'hidden':!caretShow}">
|
2021-04-20 14:38:24 +08:00
|
|
|
<span v-if="chartData.remark">
|
2021-04-08 18:45:58 +08:00
|
|
|
<el-tooltip :content="chartData.remark" placement="top" effect="light">
|
|
|
|
|
<i class="nz-icon nz-icon-info-normal"></i>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
</span>
|
2021-04-14 18:46:58 +08:00
|
|
|
<span v-has="'panel_chart_edit'" :title="$t('dashboard.refresh')" class="" @click="refreshChart">
|
2021-04-07 19:18:22 +08:00
|
|
|
<i class="nz-icon nz-icon-replay"></i>
|
|
|
|
|
</span>
|
2021-05-17 20:31:32 +08:00
|
|
|
<span @click="showAllScreen" v-if="from !== 'chartTemp'" class="" :title="$t('dashboard.screen')">
|
2021-04-07 19:18:22 +08:00
|
|
|
<i class="nz-icon nz-icon-maxview"></i>
|
|
|
|
|
</span>
|
|
|
|
|
<span><i class="el-icon-more" @click.stop="dropdownMenuShow=!dropdownMenuShow"></i></span>
|
|
|
|
|
</span>
|
2020-04-14 21:46:38 +08:00
|
|
|
</span>
|
2021-04-07 19:18:22 +08:00
|
|
|
<ul slot="dropdown" v-show="dropdownMenuShow" :id="'dropdownUl'+chartIndex" class="el-dropdown-menu nz-chart-dropdown" style="" >
|
|
|
|
|
<li @click="editChart" class="el-dropdown-menu__item">
|
|
|
|
|
<i class="nz-icon nz-icon-edit" style="font-size: 16px;"></i><span>{{$t('dashboard.edit')}}</span></li>
|
2021-04-14 18:46:58 +08:00
|
|
|
<li v-has="'panel_chart_delete'" class="el-dropdown-menu__item" @click="removeChart">
|
2020-09-10 17:00:32 +08:00
|
|
|
<i class="nz-icon nz-icon-delete" style="font-size: 16px;"></i>{{$t('dashboard.delete')}}</li>
|
2021-04-14 18:46:58 +08:00
|
|
|
<li v-has="'panel_chart_add'" class="el-dropdown-menu__item" @click="duplicate">
|
2020-05-18 14:28:14 +08:00
|
|
|
<i class="el-icon-copy-document" style="font-size: 16px;"></i>{{$t('dashboard.duplicate')}}</li>
|
2020-04-14 21:46:38 +08:00
|
|
|
</ul>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<div :id="'chartUrl'+chartIndex" class="mt-10 url-container" v-show="firstShow" >
|
2020-05-31 22:33:16 +08:00
|
|
|
<iframe :id="'urlContainer'+chartIndex" frameborder="0" width="100%" height="100%" name="showHere" scrolling=auto v-if="!showStatic"
|
|
|
|
|
style="z-index:5000;padding-bottom:6px;"
|
2020-12-14 20:25:24 +08:00
|
|
|
></iframe>
|
2020-05-31 22:33:16 +08:00
|
|
|
</div>
|
2020-06-02 13:06:42 +08:00
|
|
|
<div style="position: absolute;width: 100%; top:calc(50% - 50px);text-align: center;" v-if="showStatic">
|
2020-05-31 22:33:16 +08:00
|
|
|
<div :id="'staticContainer'+chartIndex" class="center-content"></div>
|
2020-04-14 21:46:38 +08:00
|
|
|
</div>
|
|
|
|
|
<!--全屏-->
|
2020-05-31 22:33:16 +08:00
|
|
|
<el-dialog class="nz-dialog table-chart-dialog" :title="$t('dashboard.panel.view')" :visible.sync="screenModal" width="96%" @opened="initDialog" @close="screenModal = false" >
|
|
|
|
|
<div slot="title">
|
2021-04-07 16:41:11 +08:00
|
|
|
<span class="nz-dialog-title">{{chartData.name}}</span>
|
2020-05-31 22:33:16 +08:00
|
|
|
</div>
|
|
|
|
|
<iframe :id="'urlContainerFull'+chartIndex" frameborder="0" width="100%" height="100%" name="showHereFull" scrolling=auto v-if="!showStatic"
|
|
|
|
|
style="z-index:5000;padding-bottom:6px;"
|
2020-12-14 20:25:24 +08:00
|
|
|
></iframe>
|
2020-06-02 13:06:42 +08:00
|
|
|
<div style="position: absolute;width: 100%; top:calc(50% - 100px);text-align: center;" v-if="showStatic">
|
2020-05-31 22:33:16 +08:00
|
|
|
<div :id="'staticContainerFull'+chartIndex" class="center-content"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<loading :ref="'localLoadingScreen'+chartIndex"></loading>
|
2020-04-14 21:46:38 +08:00
|
|
|
</el-dialog>
|
2020-05-31 22:33:16 +08:00
|
|
|
</div>
|
2020-12-15 18:47:30 +08:00
|
|
|
<span class="vue-resizable-handle" @mousedown="startResize" v-if="!isLock"></span>
|
2020-04-14 21:46:38 +08:00
|
|
|
</div>
|
2020-05-31 22:33:16 +08:00
|
|
|
</div>
|
2020-04-14 21:46:38 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
import loading from '../common/loading'
|
2020-04-14 21:46:38 +08:00
|
|
|
|
|
|
|
|
export default {
|
2020-05-31 22:33:16 +08:00
|
|
|
name: 'chartUrl',
|
2020-04-14 21:46:38 +08:00
|
|
|
components: {
|
2021-03-19 18:52:19 +08:00
|
|
|
loading: loading
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2020-05-31 22:33:16 +08:00
|
|
|
props: {
|
|
|
|
|
chartData: {
|
|
|
|
|
type: Object
|
|
|
|
|
},
|
|
|
|
|
// 看板id
|
|
|
|
|
panelId: {
|
|
|
|
|
type: Number,
|
2021-03-19 18:52:19 +08:00
|
|
|
default: 0
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
|
|
|
|
editChartId: {
|
|
|
|
|
type: String,
|
2021-03-19 18:52:19 +08:00
|
|
|
default: 'editChartId'
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
chartIndex: {
|
2020-05-31 22:33:16 +08:00
|
|
|
type: Number,
|
2021-03-19 18:52:19 +08:00
|
|
|
default: 0
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
from: { type: String },
|
|
|
|
|
isLock: { type: Boolean, default: false }
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
data () {
|
2020-05-31 22:33:16 +08:00
|
|
|
return {
|
|
|
|
|
data: {}, // 该图表信息,chartItem
|
2021-03-19 18:52:19 +08:00
|
|
|
unit: {},
|
2020-05-31 22:33:16 +08:00
|
|
|
|
|
|
|
|
images: '',
|
2021-03-19 18:52:19 +08:00
|
|
|
loading: Object,
|
2020-05-31 22:33:16 +08:00
|
|
|
panelIdInner: '', // 看板id=panelId,原写作chart,由set_data获取
|
|
|
|
|
firstLoad: false, // 是否第一次加载
|
|
|
|
|
screenModal: false,
|
|
|
|
|
firstShow: false, // 默认不显示操作按钮,
|
2021-03-19 18:52:19 +08:00
|
|
|
caretShow: false,
|
|
|
|
|
dragTitleShow: false,
|
|
|
|
|
dropdownMenuShow: false,
|
|
|
|
|
minHeight: 200,
|
|
|
|
|
chartSpaceHeight: 5, // top-border: 1,bottom-border: 1,padding-bottome:3
|
|
|
|
|
titleHeight: 38, // title-height:28,magrin-bottom:10
|
|
|
|
|
paddingBottom: 6,
|
|
|
|
|
divFirstShow: false,
|
|
|
|
|
showStatic: false
|
|
|
|
|
}
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2021-03-19 18:52:19 +08:00
|
|
|
startResize (e) {
|
|
|
|
|
const vm = this
|
|
|
|
|
this.$chartResizeTool.start(vm, this.chartData, e)
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
resize (chartItem) {
|
|
|
|
|
const chartBox = document.getElementById('chartUrlDiv' + this.chartIndex)
|
|
|
|
|
chartBox.querySelector('.url-container').style.height = `calc(100% - ${this.$chartResizeTool.titleHeight}px)`
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
showLoad (chartItem) {
|
|
|
|
|
this.data = chartItem
|
|
|
|
|
this.panelIdInner = this.panelId
|
|
|
|
|
// 设置高度
|
2020-05-31 22:33:16 +08:00
|
|
|
this.$nextTick(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
this.resize(chartItem)
|
|
|
|
|
})
|
|
|
|
|
this.startLoading()
|
2020-05-29 15:21:04 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
if (/\{\{.*?\}\}/g.test(this.data.param.url)) {
|
|
|
|
|
this.showStatic = true
|
|
|
|
|
this.setStaticContent()
|
|
|
|
|
} else {
|
|
|
|
|
this.showStatic = false
|
|
|
|
|
this.setLoadFrame()
|
2020-05-31 22:33:16 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
this.divFirstShow = true
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
setStaticContent: function () {
|
|
|
|
|
const that = this
|
2020-05-31 22:33:16 +08:00
|
|
|
this.$nextTick(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
const staticDiv = document.querySelector('#staticContainer' + this.chartIndex)
|
|
|
|
|
staticDiv.innerHTML = `<div class="content-static-url">${that.data.param.url}</div><div class="content-static-tip">${that.$t('dashboard.panel.chartForm.typeVal.url.staticTip')}</div>`
|
|
|
|
|
that.firstShow = true
|
|
|
|
|
that.endLoading()
|
|
|
|
|
})
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
setLoadFrame () {
|
|
|
|
|
const that = this
|
2020-05-31 22:33:16 +08:00
|
|
|
this.$nextTick(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
const iframe = document.querySelector('#urlContainer' + this.chartIndex)
|
2020-05-31 22:33:16 +08:00
|
|
|
// 处理兼容行问题
|
|
|
|
|
if (iframe.attachEvent) {
|
|
|
|
|
iframe.attachEvent('onload', function () {
|
|
|
|
|
// iframe加载完毕以后执行操作
|
2021-03-19 18:52:19 +08:00
|
|
|
that.firstShow = true
|
2020-10-30 16:26:36 +08:00
|
|
|
// console.log('iframe已加载完毕');
|
2021-03-19 18:52:19 +08:00
|
|
|
that.endLoading()
|
2020-05-31 22:33:16 +08:00
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
iframe.onload = function () {
|
|
|
|
|
// iframe加载完毕以后执行操作
|
2021-03-19 18:52:19 +08:00
|
|
|
that.firstShow = true
|
2020-10-30 16:26:36 +08:00
|
|
|
// console.log('iframe已加载完毕');
|
2021-03-19 18:52:19 +08:00
|
|
|
that.endLoading()
|
2020-04-14 21:46:38 +08:00
|
|
|
}
|
2020-05-29 15:21:04 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
iframe.src = that.data.param.url
|
|
|
|
|
})
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
initDialog () {
|
|
|
|
|
this.startLoading('screen')
|
|
|
|
|
if (/\{\{.*?\}\}/g.test(this.data.param.url)) {
|
|
|
|
|
this.showStatic = true
|
|
|
|
|
this.setStaticContentFull()
|
|
|
|
|
} else {
|
|
|
|
|
this.showStatic = false
|
|
|
|
|
this.setLoadFrameFull()
|
2020-05-31 22:33:16 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
startLoading (area) {
|
|
|
|
|
if (area === 'screen') {
|
|
|
|
|
this.$refs['localLoadingScreen' + this.chartIndex].startLoading()
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs['localLoading' + this.chartIndex].startLoading()
|
2020-05-31 22:33:16 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
endLoading (area) {
|
|
|
|
|
if (area === 'screen') {
|
|
|
|
|
this.$refs['localLoadingScreen' + this.chartIndex].endLoading()
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs['localLoading' + this.chartIndex].endLoading()
|
2020-06-01 19:10:45 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
clearChart () {
|
|
|
|
|
this.data = {}
|
2020-06-01 19:10:45 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
screenRefreshChart () {
|
|
|
|
|
('urlContainerFull' + this.chartIndex).window.location.reload()
|
2020-12-01 10:55:39 +08:00
|
|
|
},
|
2020-06-01 19:10:45 +08:00
|
|
|
// 重新请求数据 刷新操作-local
|
2021-03-19 18:52:19 +08:00
|
|
|
refreshChart () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
this.startLoading()
|
|
|
|
|
this.firstShow = false
|
|
|
|
|
const iframe = document.querySelector('#urlContainer' + this.chartIndex)
|
|
|
|
|
iframe.src = ''
|
|
|
|
|
iframe.src = this.data.param.url
|
2020-06-01 19:10:45 +08:00
|
|
|
},
|
|
|
|
|
// 编辑图表
|
2021-03-19 18:52:19 +08:00
|
|
|
editChart () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
this.$emit('on-edit-chart-block', this.data.id)
|
2020-06-01 19:10:45 +08:00
|
|
|
},
|
|
|
|
|
// 删除该图表
|
2021-03-19 18:52:19 +08:00
|
|
|
removeChart () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
this.$emit('on-remove-chart-block', this.data.id)
|
2020-06-01 19:10:45 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
clickos () {
|
|
|
|
|
this.dropdownMenuShow = false
|
2020-06-01 19:10:45 +08:00
|
|
|
},
|
|
|
|
|
// 全屏查看
|
2021-03-19 18:52:19 +08:00
|
|
|
showAllScreen () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
this.screenModal = true
|
2020-06-01 19:10:45 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
duplicate () {
|
|
|
|
|
this.dropdownMenuShow = false
|
2021-04-07 19:18:22 +08:00
|
|
|
this.$emit('on-duplicate-chart-block', this.data.id)
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
setLoadFrameFull () {
|
|
|
|
|
const that = this
|
2020-05-31 22:33:16 +08:00
|
|
|
this.$nextTick(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
const iframe = document.querySelector('#urlContainerFull' + this.chartIndex)
|
2020-05-31 22:33:16 +08:00
|
|
|
|
|
|
|
|
// 处理兼容行问题
|
|
|
|
|
if (iframe.attachEvent) {
|
|
|
|
|
iframe.attachEvent('onload', function () {
|
|
|
|
|
// iframe加载完毕以后执行操作
|
2021-03-19 18:52:19 +08:00
|
|
|
that.firstShow = true
|
2020-10-30 16:26:36 +08:00
|
|
|
// console.log('iframe已加载完毕');
|
2021-03-19 18:52:19 +08:00
|
|
|
that.endLoading('screen')
|
2020-05-31 22:33:16 +08:00
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
iframe.onload = function () {
|
|
|
|
|
// iframe加载完毕以后执行操作
|
2021-03-19 18:52:19 +08:00
|
|
|
that.firstShow = true
|
2020-10-30 16:26:36 +08:00
|
|
|
// console.log('iframe已加载完毕');
|
2021-03-19 18:52:19 +08:00
|
|
|
that.endLoading('screen')
|
2020-05-31 22:33:16 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
iframe.src = this.data.param.url
|
|
|
|
|
})
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
setStaticContentFull: function () {
|
|
|
|
|
const that = this
|
2020-05-31 22:33:16 +08:00
|
|
|
this.$nextTick(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
const staticDiv = document.querySelector('#staticContainerFull' + this.chartIndex)
|
|
|
|
|
staticDiv.innerHTML = `<div class="content-static-url">${that.data.param.url}</div><div class="content-static-tip">${that.$t('dashboard.panel.chartForm.typeVal.url.staticTip')}</div>`
|
|
|
|
|
that.firstShow = true
|
|
|
|
|
that.endLoading('screen')
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
2021-01-18 19:47:21 +08:00
|
|
|
watch: {
|
2021-03-19 18:52:19 +08:00
|
|
|
dropdownMenuShow (n) {
|
|
|
|
|
this.$emit('dropmenu-change', n)
|
2021-01-18 19:47:21 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
mounted () {
|
|
|
|
|
this.firstLoad = false
|
2020-05-31 22:33:16 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
beforeDestroy () {
|
|
|
|
|
this.clearChart()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
</script>
|
2020-05-29 15:21:04 +08:00
|
|
|
<style>
|
|
|
|
|
.center-content .content-static-url{
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
}
|
|
|
|
|
.center-content .content-static-tip{
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
color: lightgrey;
|
|
|
|
|
}
|
|
|
|
|
</style>
|