2020-10-20 20:53:21 +08:00
|
|
|
<style lang="scss">
|
|
|
|
|
@import './chart.scss';
|
|
|
|
|
</style>
|
|
|
|
|
<template>
|
|
|
|
|
<div class="nz-chart-resize">
|
|
|
|
|
<div class="resize-shadow" ref="resizeShadow"></div>
|
|
|
|
|
<div class="resize-box resize-box-single" ref="resizeBox">
|
|
|
|
|
<div class="chart-text" :id="'chartSingleStatDiv'+chartIndex" @mouseenter="caretShow=true" @mouseleave="caretShow=false">
|
|
|
|
|
<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-10-20 20:53:21 +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-10-20 20:53:21 +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-10-20 20:53:21 +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-10-20 20:53:21 +08:00
|
|
|
<i class="el-icon-copy-document" style="font-size: 16px;"></i>{{$t('dashboard.duplicate')}}</li>
|
2021-05-20 15:04:11 +08:00
|
|
|
<li v-has="'panel_chart_edit'" v-if="from !== 'chartTemp'&&chartData.pid" class="el-dropdown-menu__item" @click="$emit('sync')">
|
|
|
|
|
<i class="nz-icon nz-icon-sync" style="font-size: 16px;"></i>{{$t('overall.syncChart')}}</li>
|
2020-10-20 20:53:21 +08:00
|
|
|
</ul>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mt-10 rich-text-container" v-cloak v-show="firstShow" >
|
|
|
|
|
<div :id="'chartContainer'+chartIndex" ref="chartContainer" class="text-content" >
|
|
|
|
|
<el-scrollbar style="height: 100%;" class="el-scrollbar-normal">
|
2020-10-21 09:58:31 +08:00
|
|
|
<div style="height: 100%;" v-html="text" ></div>
|
2020-10-20 20:53:21 +08:00
|
|
|
</el-scrollbar>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!--全屏-->
|
|
|
|
|
<el-dialog class="nz-dialog table-chart-dialog" :title="$t('dashboard.panel.view')"
|
|
|
|
|
:visible.sync="screenModal"
|
2021-05-18 10:19:54 +08:00
|
|
|
width="96%" @close="screenModal = false" :modal-append-to-body="false">
|
2020-10-20 20:53:21 +08:00
|
|
|
<div slot="title">
|
2021-04-07 16:41:11 +08:00
|
|
|
<span class="nz-dialog-title">{{data.name}}</span>
|
2020-10-20 20:53:21 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="rich-text-screen-container" >
|
2020-10-21 09:58:31 +08:00
|
|
|
<div id="chartScreenContainer" ref="chartScreenContainer" class="text-content" >
|
|
|
|
|
<el-scrollbar style="height: 100%;" class="el-scrollbar-normal">
|
|
|
|
|
<div style="height: 100%;" v-html="screenText" ></div>
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
</div>
|
2020-10-20 20:53:21 +08:00
|
|
|
</div>
|
|
|
|
|
<loading :ref="'localLoadingScreen'+chartIndex"></loading>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
2020-12-15 18:47:30 +08:00
|
|
|
<span class="vue-resizable-handle" @mousedown="startResize" v-if="!isLock"></span>
|
2020-10-20 20:53:21 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
import loading from '../common/loading'
|
|
|
|
|
import 'quill/dist/quill.snow.css'
|
|
|
|
|
export default {
|
|
|
|
|
name: 'chartSingleStat',
|
|
|
|
|
components: {
|
|
|
|
|
loading: loading
|
|
|
|
|
},
|
|
|
|
|
props: {
|
|
|
|
|
chartData: {
|
|
|
|
|
type: Object
|
|
|
|
|
},
|
|
|
|
|
// 看板id
|
|
|
|
|
panelId: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 0
|
|
|
|
|
},
|
|
|
|
|
editChartId: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'editChartId'
|
|
|
|
|
},
|
|
|
|
|
chartIndex: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 0
|
|
|
|
|
},
|
|
|
|
|
from: { type: String },
|
|
|
|
|
isLock: { type: Boolean, default: false }
|
|
|
|
|
},
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
data: {}, // 该图表信息,chartItem
|
|
|
|
|
noData: false,
|
|
|
|
|
unit: {},
|
|
|
|
|
text: '', // 保存信息
|
|
|
|
|
screenText: '', // 全屏数据
|
|
|
|
|
loading: Object,
|
|
|
|
|
panelIdInner: '', // 看板id=panelId,原写作chart,由set_data获取
|
|
|
|
|
firstLoad: false, // 是否第一次加载
|
|
|
|
|
screenModal: false,
|
|
|
|
|
firstShow: false, // 默认不显示操作按钮,
|
|
|
|
|
caretShow: false,
|
|
|
|
|
dragTitleShow: false,
|
|
|
|
|
dropdownMenuShow: false,
|
|
|
|
|
divFirstShow: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created () {
|
|
|
|
|
},
|
|
|
|
|
computed: {},
|
|
|
|
|
watch: {
|
|
|
|
|
dropdownMenuShow (n) {
|
|
|
|
|
this.$emit('dropmenu-change', n)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
startResize (e) {
|
|
|
|
|
const vm = this
|
|
|
|
|
this.$chartResizeTool.start(vm, this.data, e)
|
|
|
|
|
},
|
|
|
|
|
startLoading (area) {
|
|
|
|
|
if (area === 'screen') {
|
|
|
|
|
this.$refs['localLoadingScreen' + this.chartIndex].startLoading()
|
|
|
|
|
} else {
|
|
|
|
|
// this.showLoading = true;
|
|
|
|
|
this.$refs['localLoading' + this.chartIndex].startLoading()
|
2021-01-18 19:47:21 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
endLoading (area) {
|
|
|
|
|
if (area === 'screen') {
|
|
|
|
|
// this.showLoadingScreen = false;
|
|
|
|
|
this.$refs['localLoadingScreen' + this.chartIndex].endLoading()
|
|
|
|
|
} else {
|
|
|
|
|
// this.showLoading = false;
|
|
|
|
|
this.$refs['localLoading' + this.chartIndex].endLoading()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
showLoad (chartItem) {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
const chartBox = document.getElementById('chartSingleStatDiv' + this.chartIndex)
|
|
|
|
|
let height = Math.floor(chartItem.height / 10) * 10// 图表高度四舍五入
|
|
|
|
|
if (height < this.minHeight) {
|
|
|
|
|
height = this.minHeight
|
2020-10-20 20:53:21 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
chartBox.style.height = `${height - this.chartSpaceHeight}px`
|
|
|
|
|
const singleStatBox = document.getElementById('chartContainer' + this.chartIndex)
|
|
|
|
|
singleStatBox.style.height = `${height - this.chartSpaceHeight - this.titleHeight}px`// -75-32
|
|
|
|
|
})
|
|
|
|
|
this.startLoading()
|
|
|
|
|
this.divFirstShow = true
|
|
|
|
|
},
|
|
|
|
|
// 重新请求数据 刷新操作-local
|
|
|
|
|
refreshChart () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
this.startLoading()
|
|
|
|
|
this.firstShow = false
|
|
|
|
|
this.$emit('on-refresh-data', this.data.id)
|
|
|
|
|
},
|
|
|
|
|
// 编辑图表
|
|
|
|
|
editChart () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
this.$emit('on-edit-chart-block', this.data.id)
|
|
|
|
|
},
|
|
|
|
|
// 删除该图表
|
|
|
|
|
removeChart () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
this.$emit('on-remove-chart-block', this.data.id)
|
|
|
|
|
},
|
|
|
|
|
clickos () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
},
|
|
|
|
|
clearChart () {
|
|
|
|
|
this.data = {}
|
|
|
|
|
},
|
|
|
|
|
duplicate () {
|
|
|
|
|
this.dropdownMenuShow = false
|
2021-04-07 19:18:22 +08:00
|
|
|
this.$emit('on-duplicate-chart-block', this.data.id)
|
2020-10-20 20:53:21 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
// 全屏查看
|
|
|
|
|
showAllScreen () {
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
this.screenModal = true
|
2020-10-20 20:53:21 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
resize (chartItem) {
|
|
|
|
|
document.querySelector('#chartSingleStatDiv' + this.chartIndex + ' .rich-text-container').style.height = `calc(100% - ${this.$chartResizeTool.titleHeight}px)`
|
2020-10-20 20:53:21 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
// 设置数据, filter区分
|
|
|
|
|
setData (chartItem, seriesItem, panelId, filter, area) {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.resize(chartItem)
|
|
|
|
|
})
|
|
|
|
|
this.divFirstShow = true
|
|
|
|
|
|
|
|
|
|
this.firstShow = true // 展示操作按键
|
|
|
|
|
|
|
|
|
|
this.panelIdInner = panelId
|
|
|
|
|
this.data = chartItem
|
|
|
|
|
this.text = chartItem.param.text
|
|
|
|
|
this.screenText = chartItem.param.text
|
|
|
|
|
this.endLoading()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted () {
|
|
|
|
|
this.firstLoad = false
|
|
|
|
|
},
|
|
|
|
|
beforeDestroy () {
|
|
|
|
|
this.clearChart()
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-20 20:53:21 +08:00
|
|
|
</script>
|