2020-05-31 17:40:55 +08:00
|
|
|
|
<style lang="scss">
|
2020-06-01 19:10:45 +08:00
|
|
|
|
@import './chart.scss';
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</style>
|
|
|
|
|
|
<template>
|
2020-05-31 17:40:55 +08:00
|
|
|
|
<div class="nz-chart-resize">
|
|
|
|
|
|
<div class="resize-shadow" ref="resizeShadow"></div>
|
|
|
|
|
|
<div class="resize-box resize-box-single" ref="resizeBox">
|
2020-06-05 17:09:27 +08:00
|
|
|
|
<div class="chart-single-stat" :id="'chartSingleStatDiv'+chartIndex" @mouseenter="caretShow=true" @mouseleave="caretShow=false">
|
2020-05-07 21:02:09 +08:00
|
|
|
|
<loading :ref="'localLoading'+chartIndex"></loading>
|
|
|
|
|
|
<div class="clearfix chartTitle" :class="{'dragTitle':dragTitleShow}" :id="'chartTitle'+chartIndex">
|
|
|
|
|
|
<el-popover
|
|
|
|
|
|
v-if="isError"
|
|
|
|
|
|
:close-delay=10
|
|
|
|
|
|
placement="top-start"
|
|
|
|
|
|
trigger="hover"
|
|
|
|
|
|
popper-class="chart-error-popper">
|
|
|
|
|
|
<div >{{errorContent}}</div>
|
|
|
|
|
|
<span slot="reference" style="" class="panel-info-corner panel-info-corner--error">
|
2020-05-31 17:40:55 +08:00
|
|
|
|
<i class="nz-icon nz-icon-warning fa"></i>
|
|
|
|
|
|
<span class="panel-info-corner-inner"></span>
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</el-popover>
|
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-05-07 21:02:09 +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-04-07 19:18:22 +08:00
|
|
|
|
<span class="chart-title-icon" :class="{'visible':caretShow,'hidden':!caretShow}">
|
2021-04-12 10:53:21 +08:00
|
|
|
|
<span>
|
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>
|
|
|
|
|
|
<span @click="showAllScreen" class="" :title="$t('dashboard.screen')">
|
|
|
|
|
|
<i class="nz-icon nz-icon-maxview"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span><i class="el-icon-more" @click.stop="dropdownMenuShow=!dropdownMenuShow"></i></span>
|
|
|
|
|
|
</span>
|
2020-05-07 21:02:09 +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-05-07 21:02:09 +08:00
|
|
|
|
</ul>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="mt-10 single-stat-container" v-cloak v-show="firstShow" >
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<div :id="'chartContainer'+chartIndex" :style="{color:mapping?mapping.color.text:'#000',background:mapping?mapping.color.bac:'#fff'}" class="single-stat-content" ref="chartContainer">
|
2020-05-07 21:02:09 +08:00
|
|
|
|
{{serieSingleStat}}
|
2020-06-08 15:22:26 +08:00
|
|
|
|
<div class="chart-no-data" v-show="noData">No Data</div>
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--全屏-->
|
2020-05-31 17:40:55 +08:00
|
|
|
|
<el-dialog class="nz-dialog table-chart-dialog" :title="$t('dashboard.panel.view')"
|
|
|
|
|
|
:visible.sync="screenModal"
|
|
|
|
|
|
width="96%" @close="screenModal = false" >
|
|
|
|
|
|
<div slot="title">
|
2021-04-07 16:41:11 +08:00
|
|
|
|
<span class="nz-dialog-title">{{data.name}}</span>
|
2020-05-31 17:40:55 +08:00
|
|
|
|
<div class="float-right panel-calendar dialog-tool">
|
2020-12-15 18:47:30 +08:00
|
|
|
|
<!-- <time-picker ref="calendarPanel" class="nz-dashboard-picker" style="margin-top: -12px;" @change="dateChange"></time-picker>-->
|
2021-02-04 11:21:00 +08:00
|
|
|
|
<pick-time :refresh-data-func="dateChange" v-model="searchTime" :use-chart-unit="false" ref="pickTime" style="height: 28px;" id="single-chart"></pick-time>
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</div>
|
2020-12-15 18:47:30 +08:00
|
|
|
|
<!-- <span class="float-right dialog-tool" @click="screenRefreshChart" style="margin-right: 15px"><i class="global-active-color nz-icon nz-icon-refresh"/></span>-->
|
2020-05-31 17:40:55 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="single-stat-screen-container" >
|
2020-12-08 22:14:52 +08:00
|
|
|
|
<div :style="{color:mapping?mapping.color.text:'#000',background:mapping?mapping.color.bac:'#fff'}" class="single-stat-content" id="chartScreenContainer" ref="chartScreenContainer">
|
2020-05-31 17:40:55 +08:00
|
|
|
|
{{serieSingleStat}}
|
2020-06-08 15:22:26 +08:00
|
|
|
|
<div class="chart-no-data" v-show="noData">No Data</div>
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</div>
|
2020-05-31 17:40:55 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<loading :ref="'localLoadingScreen'+chartIndex"></loading>
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</el-dialog>
|
2020-05-31 17:40:55 +08:00
|
|
|
|
</div>
|
2020-12-15 18:47:30 +08:00
|
|
|
|
<span class="vue-resizable-handle" @mousedown="startResize" v-if="!isLock"></span>
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</div>
|
2020-05-31 17:40:55 +08:00
|
|
|
|
</div>
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import chartDataFormat from './chartDataFormat'
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
2020-05-31 17:40:55 +08:00
|
|
|
|
name: 'chartSingleStat',
|
|
|
|
|
|
props: {
|
2020-06-05 17:09:27 +08:00
|
|
|
|
chartData: {
|
|
|
|
|
|
type: Object
|
|
|
|
|
|
},
|
2020-05-31 17:40:55 +08:00
|
|
|
|
// 看板id
|
|
|
|
|
|
panelId: {
|
|
|
|
|
|
type: Number,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
default: 0
|
2020-05-07 21:02:09 +08:00
|
|
|
|
},
|
2020-05-31 17:40:55 +08:00
|
|
|
|
editChartId: {
|
|
|
|
|
|
type: String,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
default: 'editChartId'
|
2020-05-07 21:02:09 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
chartIndex: {
|
2020-05-31 17:40:55 +08:00
|
|
|
|
type: Number,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
default: 0
|
2020-12-15 21:13:07 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
from: { type: String },
|
|
|
|
|
|
isLock: { type: Boolean, default: false }
|
2020-05-31 17:40:55 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
data () {
|
2020-05-31 17:40:55 +08:00
|
|
|
|
return {
|
|
|
|
|
|
data: {}, // 该图表信息,chartItem
|
2021-03-19 18:52:19 +08:00
|
|
|
|
noData: false,
|
|
|
|
|
|
unit: {},
|
|
|
|
|
|
isError: false,
|
|
|
|
|
|
errorContent: '',
|
2020-05-31 17:40:55 +08:00
|
|
|
|
seriesItem: [], // 保存信息
|
2021-03-19 18:52:19 +08:00
|
|
|
|
seriesItemScreen: [], // 全屏数据
|
|
|
|
|
|
serieSingleStat: '',
|
|
|
|
|
|
mapping: '', // 满足valueMapping时 mapping的值
|
2020-05-31 17:40:55 +08:00
|
|
|
|
images: '',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
loading: Object,
|
2020-05-31 17:40:55 +08:00
|
|
|
|
items: {
|
|
|
|
|
|
metric_name: [], // 每条数据列名称
|
|
|
|
|
|
xAxis: [],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
theData: [] // series数据组
|
2020-05-31 17:40:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
panelIdInner: '', // 看板id=panelId,原写作chart,由set_data获取
|
|
|
|
|
|
firstLoad: false, // 是否第一次加载
|
|
|
|
|
|
screenModal: false,
|
|
|
|
|
|
// 查询数据使用
|
|
|
|
|
|
filter: {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
start_time: '',
|
|
|
|
|
|
end_time: ''
|
2020-05-31 17:40:55 +08:00
|
|
|
|
},
|
2021-03-31 11:10:04 +08:00
|
|
|
|
stableFilter: {},
|
2020-05-31 17:40:55 +08:00
|
|
|
|
firstShow: false, // 默认不显示操作按钮,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
caretShow: false,
|
|
|
|
|
|
dragTitleShow: false,
|
|
|
|
|
|
dropdownMenuShow: false,
|
|
|
|
|
|
divFirstShow: false,
|
|
|
|
|
|
searchTime: [new Date().setHours(new Date().getHours() - 1), new Date()], // 全屏显示的时间
|
|
|
|
|
|
oldSearchTime: []
|
|
|
|
|
|
}
|
2020-05-31 17:40:55 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
created () {
|
2020-05-31 17:40:55 +08:00
|
|
|
|
},
|
2020-05-07 21:02:09 +08:00
|
|
|
|
computed: {},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
watch: {
|
|
|
|
|
|
dropdownMenuShow (n) {
|
|
|
|
|
|
this.$emit('dropmenu-change', n)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
startResize (e) {
|
|
|
|
|
|
const vm = this
|
|
|
|
|
|
this.$chartResizeTool.start(vm, this.data, e)
|
2021-01-18 19:47:21 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
dragResize: function (e) {
|
|
|
|
|
|
const diffWidth = 20 // 界面的宽度空白的地方的宽度
|
|
|
|
|
|
const chartBoxPadding = 22
|
|
|
|
|
|
const targetDiv = document.getElementById('chartSingleStatDiv' + this.chartIndex) // e.target.parentNode.parentNode;.children[0]
|
|
|
|
|
|
const targetDivContainer = document.getElementById('listContainer') // e.target.parentNode.parentNode;.children[0]
|
|
|
|
|
|
const maxWidth = targetDivContainer.offsetWidth - diffWidth
|
|
|
|
|
|
const minWidth = maxWidth / 12
|
|
|
|
|
|
const stepWidth = maxWidth / 12
|
|
|
|
|
|
const stepHeight = 10
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 得到点击时该容器的宽高:
|
|
|
|
|
|
const targetDivHeight = targetDiv.offsetHeight
|
|
|
|
|
|
const targetDivWidth = targetDiv.offsetWidth
|
|
|
|
|
|
const startY = e.clientY
|
|
|
|
|
|
const startX = e.clientX
|
|
|
|
|
|
const _this = this
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
document.onmousemove = function (e) {
|
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
// 得到鼠标拖动的宽高距离:取绝对值
|
|
|
|
|
|
const distY = Math.abs(e.clientY - startY)
|
|
|
|
|
|
const distX = Math.abs(e.clientX - startX)
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 往上方拖动:
|
|
|
|
|
|
if (e.clientY < startY) {
|
|
|
|
|
|
targetDiv.style.height = targetDivHeight - distY + 'px'
|
|
|
|
|
|
// heightTmp = targetDivHeight-distY;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.clientX < startX) {
|
|
|
|
|
|
targetDiv.style.width = targetDivWidth - distX + 'px'
|
|
|
|
|
|
// widthTmp = targetDivWidth-distX;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 往下方拖动:
|
|
|
|
|
|
if (e.clientY > startY) {
|
|
|
|
|
|
targetDiv.style.height = (targetDivHeight + distY) + 'px'
|
|
|
|
|
|
// heightTmp = targetDivHeight+distY;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (e.clientX > startX) {
|
|
|
|
|
|
targetDiv.style.width = (targetDivWidth + distX) + 'px'
|
|
|
|
|
|
// widthTmp = targetDivWidth+distX;
|
|
|
|
|
|
}
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (parseInt(targetDiv.style.height) <= _this.minHeight) {
|
|
|
|
|
|
targetDiv.style.height = _this.minHeight + 'px'
|
|
|
|
|
|
// heightTmp = _this.minHeight;
|
|
|
|
|
|
}
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (parseInt(targetDiv.style.width) >= maxWidth) {
|
|
|
|
|
|
targetDiv.style.width = maxWidth + 'px'
|
|
|
|
|
|
// widthTmp = maxWidth;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (parseInt(targetDiv.style.width) <= minWidth) {
|
|
|
|
|
|
targetDiv.style.width = minWidth + 'px'
|
|
|
|
|
|
// widthTmp = minWidth;
|
2020-05-07 21:02:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 调整表格大小
|
|
|
|
|
|
const containerHeight = parseInt(targetDiv.style.height)
|
|
|
|
|
|
const containerWidth = parseInt(targetDiv.style.width)
|
|
|
|
|
|
const chartBox = document.getElementsByClassName('chartBox')
|
|
|
|
|
|
chartBox[_this.chartIndex].style.width = (containerWidth + chartBoxPadding) + 'px'
|
|
|
|
|
|
// chartBox[_this.chartIndex].style.height = `${containerHeight}px`;
|
|
|
|
|
|
// 表格的高度
|
|
|
|
|
|
const chartSingleStatBox = document.getElementById('chartContainer' + _this.chartIndex)
|
|
|
|
|
|
chartSingleStatBox.style.height = `${containerHeight - _this.titleHeight}px`// -75-32+25
|
|
|
|
|
|
}
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
document.onmouseup = function () {
|
|
|
|
|
|
const targetDivHeightNew = parseInt(targetDiv.style.height)
|
|
|
|
|
|
// let targetDivHeightNew = heightTmp
|
|
|
|
|
|
const targetDivWidthNew = parseInt(targetDiv.style.width)
|
|
|
|
|
|
// let targetDivWidthNew = widthTmp;
|
|
|
|
|
|
|
|
|
|
|
|
const diffHeight = Math.abs(targetDivHeight - targetDivHeightNew)
|
|
|
|
|
|
if (targetDivHeight > targetDivHeightNew) {
|
|
|
|
|
|
const finalDiffHeight = Math.floor(diffHeight / stepHeight) * stepHeight
|
|
|
|
|
|
// alert('oldWidth='+targetDivHeight+"===diffHeight+"+diffHeight+"==finalDiffHeight="+finalDiffHeight);
|
|
|
|
|
|
targetDiv.style.height = (targetDivHeight - finalDiffHeight) + 'px'
|
|
|
|
|
|
}
|
|
|
|
|
|
if (targetDivHeight < targetDivHeightNew) {
|
|
|
|
|
|
const finalDiffHeight = Math.ceil(diffHeight / stepHeight) * stepHeight
|
|
|
|
|
|
targetDiv.style.height = (targetDivHeight + finalDiffHeight) + 'px'
|
|
|
|
|
|
}
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
let span = _this.data.span
|
|
|
|
|
|
if (targetDivWidth > targetDivWidthNew) {
|
|
|
|
|
|
span = Math.floor((targetDivWidthNew * 12) / maxWidth)
|
|
|
|
|
|
const finalWidth = Math.floor((targetDivWidthNew * 12) / maxWidth) * stepWidth
|
|
|
|
|
|
if ((finalWidth) < minWidth) {
|
|
|
|
|
|
targetDiv.style.width = minWidth + 'px'
|
|
|
|
|
|
span = 1
|
|
|
|
|
|
} else {
|
|
|
|
|
|
targetDiv.style.width = finalWidth + 'px'
|
2020-05-07 21:02:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (targetDivWidth < targetDivWidthNew) {
|
|
|
|
|
|
span = Math.ceil((targetDivWidthNew * 12) / maxWidth)
|
|
|
|
|
|
const spanUnit = Math.ceil((targetDivWidthNew * 12) / maxWidth)
|
|
|
|
|
|
const finalWidth = spanUnit * stepWidth
|
|
|
|
|
|
if (finalWidth > maxWidth || spanUnit === 12) {
|
|
|
|
|
|
targetDiv.style.width = maxWidth + 'px'
|
|
|
|
|
|
span = 12
|
|
|
|
|
|
} else {
|
|
|
|
|
|
targetDiv.style.width = finalWidth + 'px'
|
2020-05-07 21:02:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 调整表格大小
|
|
|
|
|
|
const containerHeight = parseInt(targetDiv.style.height)
|
|
|
|
|
|
const containerWidth = parseInt(targetDiv.style.width)
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const chartBox = document.getElementsByClassName('chartBox')
|
|
|
|
|
|
chartBox[_this.chartIndex].style.width = (containerWidth + chartBoxPadding) + 'px'
|
|
|
|
|
|
// chartBox[_this.chartIndex].style.height = `${containerHeight}px`;
|
|
|
|
|
|
// 表格的高度
|
|
|
|
|
|
const chartSingleStatBox = document.getElementById('chartContainer' + _this.chartIndex)
|
|
|
|
|
|
chartSingleStatBox.style.height = `${containerHeight - _this.titleHeight}px`
|
|
|
|
|
|
|
|
|
|
|
|
const modifyParams = {
|
|
|
|
|
|
id: _this.data.id,
|
|
|
|
|
|
span: span,
|
|
|
|
|
|
height: (containerHeight + _this.chartSpaceHeight),
|
|
|
|
|
|
prev: parseInt(_this.data.prev),
|
|
|
|
|
|
next: parseInt(_this.data.next)
|
|
|
|
|
|
}
|
|
|
|
|
|
targetDiv.style.height = (Math.floor((containerHeight + _this.chartSpaceHeight) / 10) * 10 - _this.chartSpaceHeight) + 'px'// 图表实际渲染高度,采用个位数字四舍五入
|
|
|
|
|
|
_this.$put('panel/' + _this.panelIdInner + '/charts/modify', modifyParams).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
// 更新当前图表数据
|
|
|
|
|
|
_this.data.span = span
|
|
|
|
|
|
_this.data.height = containerHeight + _this.chartSpaceHeight
|
|
|
|
|
|
_this.$emit('on-drag-chart', _this.data)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (response.msg) {
|
|
|
|
|
|
_this.$message.error(response.msg)
|
|
|
|
|
|
} else if (response.error) {
|
|
|
|
|
|
_this.$message.error(response.error)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
_this.$message.error(response)
|
2020-05-07 21:02:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
document.onmousemove = null
|
|
|
|
|
|
document.onmouseup = null
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
startLoading (area) {
|
|
|
|
|
|
if (area === 'screen') {
|
|
|
|
|
|
this.$refs['localLoadingScreen' + this.chartIndex].startLoading()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// this.showLoading = true;
|
|
|
|
|
|
this.$refs['localLoading' + this.chartIndex].startLoading()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
|
},
|
|
|
|
|
|
screenRefreshChart () {
|
|
|
|
|
|
this.$refs.calendarPanel.timeChange(this.$refs.calendarPanel.nowTimeType, 'chart')
|
|
|
|
|
|
},
|
|
|
|
|
|
// 重新请求数据 刷新操作-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)
|
|
|
|
|
|
},
|
|
|
|
|
|
// 全屏时间条件查询
|
|
|
|
|
|
dateChange (time) {
|
|
|
|
|
|
this.seriesItemScreen = []
|
|
|
|
|
|
this.serieSingleStat = ''
|
|
|
|
|
|
this.startLoading('screen')
|
|
|
|
|
|
this.$emit('on-search-data', this.data.id, this.searchTime)
|
|
|
|
|
|
},
|
|
|
|
|
|
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)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 全屏查看
|
|
|
|
|
|
showAllScreen () {
|
|
|
|
|
|
this.dropdownMenuShow = false
|
|
|
|
|
|
this.searchTime = []
|
|
|
|
|
|
this.$set(this.searchTime, 0, this.oldSearchTime[0])
|
|
|
|
|
|
this.$set(this.searchTime, 1, this.oldSearchTime[1])
|
2021-03-31 11:10:04 +08:00
|
|
|
|
this.$refs.pickTime.$refs.timePicker.setCustomTime(this.stableFilter)
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.seriesItemScreen = this.seriesItem
|
|
|
|
|
|
this.screenModal = true
|
|
|
|
|
|
},
|
|
|
|
|
|
resize (chartItem) {
|
|
|
|
|
|
document.querySelector('#chartSingleStatDiv' + this.chartIndex + ' .single-stat-container').style.height = `calc(100% - ${this.$chartResizeTool.titleHeight}px)`
|
|
|
|
|
|
},
|
|
|
|
|
|
// 设置数据, filter区分
|
|
|
|
|
|
setData (chartItem, seriesItem, panelId, filter, area, errorMsg) {
|
2021-03-31 11:10:04 +08:00
|
|
|
|
if (filter) {
|
|
|
|
|
|
this.stableFilter = filter
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (errorMsg && errorMsg !== '') {
|
|
|
|
|
|
this.isError = true
|
|
|
|
|
|
this.errorContent = errorMsg
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.isError = false
|
|
|
|
|
|
this.errorContent = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
if (seriesItem || (typeof seriesItem === 'number' && seriesItem == 0) || (typeof seriesItem === 'string' && seriesItem != '')) { // 0 为false
|
|
|
|
|
|
this.noData = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.noData = true
|
|
|
|
|
|
}
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (area === 'showFullScreen') { // 全屏按时间查询
|
|
|
|
|
|
this.data = chartItem
|
|
|
|
|
|
this.unit = chartDataFormat.getUnit(this.data.unit)
|
|
|
|
|
|
if (Number(seriesItem)) {
|
|
|
|
|
|
const singleStatTmp = parseFloat(Number(seriesItem).toFixed(2))// parseFloat :如果没有小数点,或者小数点后都是零,parseFloat() 会返回整数。
|
|
|
|
|
|
if (chartItem.param.valueMapping && chartItem.param.valueMapping.type) {
|
|
|
|
|
|
const type = chartItem.param.valueMapping.type
|
|
|
|
|
|
const mappings = chartItem.param.valueMapping.mapping ? chartItem.param.valueMapping.mapping : []
|
|
|
|
|
|
let mapping
|
|
|
|
|
|
if (type == 'value') {
|
|
|
|
|
|
mapping = mappings.find(item => { return item.value == singleStatTmp })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mapping = mappings.find(item => { return item.from <= singleStatTmp && item.to >= singleStatTmp })
|
2020-05-07 21:02:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.mapping = mapping
|
|
|
|
|
|
if (this.mapping && !this.mapping.color) {
|
|
|
|
|
|
this.mapping.color = { bac: '#fff', text: '#000' }
|
|
|
|
|
|
}
|
|
|
|
|
|
this.serieSingleStat = mapping ? mapping.text.replace('{{value}}', singleStatTmp).replace('{{name}}', chartItem.elements[0].legend) : chartDataFormat.getUnit(chartItem.unit ? chartItem.unit : 2).compute(singleStatTmp, null, 2)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.serieSingleStat = chartDataFormat.getUnit(chartItem.unit ? chartItem.unit : 2).compute(singleStatTmp, null, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.serieSingleStat = seriesItem
|
2020-05-31 17:40:55 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.searchTime[0] = filter.start_time// 将列表的查询时间复制给全屏的查询时间
|
|
|
|
|
|
this.searchTime[1] = filter.end_time
|
|
|
|
|
|
this.endLoading('screen')
|
|
|
|
|
|
} else {
|
2020-05-31 17:40:55 +08:00
|
|
|
|
this.$nextTick(() => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.resize(chartItem)
|
|
|
|
|
|
})
|
|
|
|
|
|
this.divFirstShow = true
|
2020-05-07 21:02:09 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.firstShow = true // 展示操作按键
|
2020-06-28 18:48:03 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.panelIdInner = panelId
|
|
|
|
|
|
this.data = chartItem
|
|
|
|
|
|
this.unit = chartDataFormat.getUnit(this.data.unit)
|
|
|
|
|
|
if (Number(seriesItem)) {
|
|
|
|
|
|
const singleStatTmp = parseFloat(Number(seriesItem).toFixed(2))// parseFloat :如果没有小数点,或者小数点后都是零,parseFloat() 会返回整数。
|
|
|
|
|
|
if (chartItem.param.valueMapping && chartItem.param.valueMapping.type) {
|
|
|
|
|
|
const type = chartItem.param.valueMapping.type
|
|
|
|
|
|
const mappings = chartItem.param.valueMapping.mapping ? chartItem.param.valueMapping.mapping : []
|
|
|
|
|
|
let mapping
|
|
|
|
|
|
if (type == 'value') {
|
|
|
|
|
|
mapping = mappings.find(item => { return item.value == singleStatTmp })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
mapping = mappings.find(item => { return item.from <= singleStatTmp && item.to >= singleStatTmp })
|
2020-12-04 15:24:59 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.mapping = mapping
|
|
|
|
|
|
if (this.mapping && !this.mapping.color) {
|
|
|
|
|
|
this.mapping.color = { bac: '#fff', text: '#000' }
|
2020-09-17 10:28:09 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.serieSingleStat = mapping ? mapping.text.replace('{{value}}', singleStatTmp).replace('{{name}}', chartItem.elements[0].legend) : chartDataFormat.getUnit(chartItem.unit ? chartItem.unit : 2).compute(singleStatTmp, null, 2)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.serieSingleStat = chartDataFormat.getUnit(chartItem.unit ? chartItem.unit : 2).compute(singleStatTmp, null, 2)
|
2020-05-31 17:40:55 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.serieSingleStat = seriesItem
|
2020-05-31 17:40:55 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (filter) { // 保存数据,用于同步时间
|
|
|
|
|
|
this.searchTime[0] = filter.start_time// 将列表的查询时间复制给全屏的查询时间
|
|
|
|
|
|
this.searchTime[1] = filter.end_time
|
|
|
|
|
|
this.oldSearchTime[0] = this.searchTime[0]
|
|
|
|
|
|
this.oldSearchTime[1] = this.searchTime[1]
|
|
|
|
|
|
}
|
|
|
|
|
|
this.endLoading()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.firstLoad = false
|
|
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy () {
|
|
|
|
|
|
this.clearChart()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-05-07 21:02:09 +08:00
|
|
|
|
</script>
|