2021-04-22 11:47:24 +08:00
|
|
|
|
<template>
|
2023-03-15 15:39:06 +08:00
|
|
|
|
<div class="full-width-height chart-list dashboard-tab asset-detail" v-my-loading="dashboardLoading">
|
2021-04-22 11:47:24 +08:00
|
|
|
|
<nz-bottom-data-list
|
2021-10-11 14:05:07 +08:00
|
|
|
|
:showTitle='showTitle'
|
2021-11-17 13:51:28 +08:00
|
|
|
|
:obj='obj'
|
2022-10-28 14:07:06 +08:00
|
|
|
|
:tableId="tableId"
|
2021-04-22 11:47:24 +08:00
|
|
|
|
:layout="[]"
|
|
|
|
|
|
:tabs="tabs"
|
|
|
|
|
|
:targetTab="targetTab"
|
|
|
|
|
|
@changeTab="changeTab"
|
|
|
|
|
|
class="full-width-height"
|
2021-04-27 19:24:26 +08:00
|
|
|
|
:showPagination="false"
|
2021-04-22 11:47:24 +08:00
|
|
|
|
>
|
|
|
|
|
|
<template v-slot:title><span :title="obj.name">{{obj.name}}</span></template>
|
2021-05-17 20:31:32 +08:00
|
|
|
|
<template v-slot:top-tool-right>
|
2022-11-22 19:16:59 +08:00
|
|
|
|
<!-- asset -->
|
2021-05-19 23:17:24 +08:00
|
|
|
|
<div v-if="from === fromRoute.asset" style="display: flex">
|
2023-03-15 15:39:06 +08:00
|
|
|
|
<pick-time ref="pickTime" v-model="searchTime" :refresh-data-func="dateChange" :use-chart-unit="false" :sign="'dashboard' + obj.id"></pick-time>
|
2023-01-05 17:53:42 +08:00
|
|
|
|
<button id="panel-add-chart" v-has="'main_add'" :title="$t('overall.createChart')" class="top-tool-btn margin-r-10" type="button" @click="addChartBefore">
|
2021-12-21 18:36:22 +08:00
|
|
|
|
<i class="nz-icon-create-square nz-icon"></i>
|
2021-05-17 20:31:32 +08:00
|
|
|
|
</button>
|
2022-11-22 19:16:59 +08:00
|
|
|
|
<top-tool-more-options
|
2022-05-24 15:04:46 +08:00
|
|
|
|
ref="topTool"
|
|
|
|
|
|
:delete-objs="batchDeleteObjs"
|
2021-05-17 20:31:32 +08:00
|
|
|
|
id="asset-list"
|
|
|
|
|
|
:params="filter"
|
2021-07-19 17:04:46 +08:00
|
|
|
|
:params-type="paramsType"
|
2022-03-25 16:37:24 +08:00
|
|
|
|
:permissions="{import: 'main_add', export: 'main_edit'}"
|
2021-05-17 20:31:32 +08:00
|
|
|
|
class="top-tool-export margin-r-10"
|
|
|
|
|
|
export-file-name="asset-charts"
|
2023-03-15 15:39:06 +08:00
|
|
|
|
export-url="/visual/dashboard/export"
|
2021-05-17 20:31:32 +08:00
|
|
|
|
@afterImport="getTableData"
|
|
|
|
|
|
:link="obj"
|
|
|
|
|
|
:showLock="from === fromRoute.asset"
|
2022-05-24 15:04:46 +08:00
|
|
|
|
@export="exportType"
|
2021-05-17 20:31:32 +08:00
|
|
|
|
@panelLockChange="panelLockChange"
|
|
|
|
|
|
>
|
2021-05-19 23:17:24 +08:00
|
|
|
|
<template v-slot:after>
|
2023-03-15 15:39:06 +08:00
|
|
|
|
<el-dropdown-item v-has="'dashboard_view'">
|
2022-06-06 10:38:57 +08:00
|
|
|
|
<div id="chart-export-html" @click="exportType"><i class="nz-icon nz-icon-kuaizhao"></i>{{ $t('overall.snapshoot') }}</div>
|
2022-05-27 09:29:59 +08:00
|
|
|
|
</el-dropdown-item>
|
2021-05-19 23:17:24 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</top-tool-more-options>
|
|
|
|
|
|
</div>
|
2022-11-22 19:16:59 +08:00
|
|
|
|
<!-- endpoint -->
|
2021-05-19 23:17:24 +08:00
|
|
|
|
<div v-else-if="from === fromRoute.endpoint" style="display: flex">
|
2023-03-15 15:39:06 +08:00
|
|
|
|
<pick-time ref="pickTime" v-model="searchTime" :refresh-data-func="dateChange" :use-chart-unit="false" :sign="'dashboard' + obj.id"></pick-time>
|
2023-02-13 14:37:51 +08:00
|
|
|
|
<button id="endpoint-create-chart" v-has="'main_add'" :title="$t('overall.createChart')" class="top-tool-btn margin-r-10" @click.stop="addChartBefore">
|
2021-05-19 23:17:24 +08:00
|
|
|
|
<i class="nz-icon nz-icon-create-square"></i>
|
|
|
|
|
|
</button>
|
2022-11-22 19:16:59 +08:00
|
|
|
|
<top-tool-more-options
|
2022-05-24 15:04:46 +08:00
|
|
|
|
ref="topTool"
|
|
|
|
|
|
:delete-objs="batchDeleteObjs"
|
2021-05-19 23:17:24 +08:00
|
|
|
|
id="asset-list"
|
|
|
|
|
|
:link="obj"
|
|
|
|
|
|
:params="filter"
|
2022-01-11 17:05:21 +08:00
|
|
|
|
:permissions="{import: 'main_add', export: 'main_edit'}"
|
2021-07-19 17:04:46 +08:00
|
|
|
|
:params-type="paramsType"
|
2021-05-19 23:17:24 +08:00
|
|
|
|
:showLock="from === fromRoute.endpoint"
|
|
|
|
|
|
class="top-tool-export margin-r-10"
|
|
|
|
|
|
export-file-name="endpoint-charts"
|
2023-03-15 15:39:06 +08:00
|
|
|
|
export-url="/visual/dashboard/export"
|
2021-05-19 23:17:24 +08:00
|
|
|
|
@afterImport="getTableData"
|
2022-05-24 15:04:46 +08:00
|
|
|
|
@export="exportType"
|
2021-05-19 23:17:24 +08:00
|
|
|
|
@panelLockChange="panelLockChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template v-slot:after>
|
2023-03-15 15:39:06 +08:00
|
|
|
|
<el-dropdown-item v-has="'dashboard_view'">
|
2022-06-06 10:38:57 +08:00
|
|
|
|
<div id="chart-export-html" @click="exportType"><i class="nz-icon nz-icon-kuaizhao"></i>{{ $t('overall.snapshoot') }}</div>
|
2022-05-27 09:29:59 +08:00
|
|
|
|
</el-dropdown-item>
|
2021-05-19 23:17:24 +08:00
|
|
|
|
</template>
|
2021-05-17 20:31:32 +08:00
|
|
|
|
</top-tool-more-options>
|
2021-05-18 10:12:47 +08:00
|
|
|
|
</div>
|
2022-11-22 19:16:59 +08:00
|
|
|
|
<!-- dashboardTemp -->
|
|
|
|
|
|
<div v-else-if="from === fromRoute.dashboardTemp">
|
2023-02-13 14:37:51 +08:00
|
|
|
|
<button v-has="'main_add'" id="endpoint-create-chart" :title="$t('overall.createChart')" class="top-tool-btn margin-r-10" @click.stop="addChartBefore">
|
2022-11-22 19:16:59 +08:00
|
|
|
|
<i class="nz-icon nz-icon-create-square"></i>
|
|
|
|
|
|
</button>
|
2022-12-27 16:17:50 +08:00
|
|
|
|
<button v-has="'main_edit'" id="panel-lock" :title='panelLock ? $t("overall.unlocked") : $t("overall.locked")' class="top-tool-btn margin-r-10" @click="panelLockChange(!panelLock)" type="button">
|
2022-11-22 19:16:59 +08:00
|
|
|
|
<i :class="{'nz-icon nz-icon-lock':!panelLock,'nz-icon nz-icon-unlock':panelLock}"></i>
|
|
|
|
|
|
</button>
|
2022-12-27 16:17:50 +08:00
|
|
|
|
<button v-has="'main_edit'" @click="chartBySync" id="chart-sync" :title="$t('overall.syncChart')" class="top-tool-btn margin-r-10" type="button">
|
2021-05-20 14:07:58 +08:00
|
|
|
|
<i class="nz-icon nz-icon-sync"></i>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2021-04-26 21:42:15 +08:00
|
|
|
|
</template>
|
2021-12-16 18:15:52 +08:00
|
|
|
|
<!--图表-->
|
2021-12-31 14:06:02 +08:00
|
|
|
|
<div id="tableList" class="table-list" style="padding-top: 0;overflow: hidden">
|
|
|
|
|
|
<div id="dashboardScrollbar" class="table-list-box">
|
2022-07-18 16:15:54 +08:00
|
|
|
|
<div class="box-content" ref="dashboardScrollbar" v-my-loading="chartListLoading" style="overflow-y: auto;display: flex;flex-direction: column;overflow-x: hidden">
|
2022-07-08 18:06:31 +08:00
|
|
|
|
<panel-variables :labelArrs="variables" :time-range="searchTime" @getPanelData="getPanelData"></panel-variables>
|
2021-12-16 18:15:52 +08:00
|
|
|
|
<chart-list
|
|
|
|
|
|
ref="chartList"
|
|
|
|
|
|
name="panel"
|
2023-03-15 15:39:06 +08:00
|
|
|
|
:dashboardId="showPanel.id"
|
2021-12-16 18:15:52 +08:00
|
|
|
|
:class="{'show-top':showTopBtn}"
|
|
|
|
|
|
:data-list="dataList"
|
|
|
|
|
|
:nowTimeType="nowTimeType"
|
2021-12-16 19:50:23 +08:00
|
|
|
|
:from="from"
|
2021-12-16 18:15:52 +08:00
|
|
|
|
:time-range="searchTime"
|
|
|
|
|
|
@edit-chart="editChart"
|
|
|
|
|
|
@on-refresh-time="refreshTime"
|
|
|
|
|
|
@on-remove-chart="delChart"
|
|
|
|
|
|
@on-add-group-item-chart="addGroupItem"
|
2022-03-10 11:31:48 +08:00
|
|
|
|
@refreshPanel="refreshPanel"
|
2022-07-08 18:06:31 +08:00
|
|
|
|
:variablesInit="variablesInit"
|
2021-12-16 18:15:52 +08:00
|
|
|
|
:loading="chartListLoading"
|
|
|
|
|
|
:chart-detail-info="chartDetailInfo"
|
|
|
|
|
|
></chart-list>
|
2021-04-22 11:47:24 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2021-12-16 18:15:52 +08:00
|
|
|
|
</div>
|
2021-04-22 11:47:24 +08:00
|
|
|
|
</nz-bottom-data-list>
|
2022-11-22 19:16:59 +08:00
|
|
|
|
|
2021-05-19 23:17:24 +08:00
|
|
|
|
<transition name="right-box">
|
2021-12-16 19:50:23 +08:00
|
|
|
|
<chart-right-box
|
|
|
|
|
|
v-if="chartRightBoxShow"
|
2022-03-25 15:40:05 +08:00
|
|
|
|
v-my-loading="rightBox.loading"
|
2021-12-16 19:50:23 +08:00
|
|
|
|
ref="addChartModal"
|
|
|
|
|
|
:chart="chart"
|
|
|
|
|
|
:from="from"
|
|
|
|
|
|
:panel-data="panelData"
|
|
|
|
|
|
:show-panel="showPanel"
|
|
|
|
|
|
@close="closeRightBox"
|
|
|
|
|
|
@reload="panelReload"
|
|
|
|
|
|
@reloadOnlyPanel="panelReloadOnlyPanel"
|
|
|
|
|
|
@on-create-success="createSuccess"
|
|
|
|
|
|
></chart-right-box>
|
2021-05-19 23:17:24 +08:00
|
|
|
|
</transition>
|
|
|
|
|
|
<transition name="right-box">
|
|
|
|
|
|
<chart-temp-box v-if="rightBox.chartTemp.show" :from="from" :obj="chart" :panel-data="panelData" :show-panel="showPanel" @close="closeRightBox" @on-create-success="createSuccess"></chart-temp-box>
|
|
|
|
|
|
</transition>
|
2023-03-08 17:56:28 +08:00
|
|
|
|
<!-- 快照进度 -->
|
|
|
|
|
|
<snapshotProgress v-if="snapshotVisible" :showPanel="showPanel" :searchTime="searchTime" :snapshotVisible.sync="snapshotVisible"></snapshotProgress>
|
2021-04-22 11:47:24 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-12-16 19:50:23 +08:00
|
|
|
|
// import chartBox from '../../../page/dashboard/chartBox'
|
2022-11-22 19:16:59 +08:00
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
|
|
import { chartCache } from '@/components/common/js/common'
|
2021-12-16 19:50:23 +08:00
|
|
|
|
import chartRightBox from '@/components/common/rightBox/chart/chartRightBox'
|
2021-12-16 18:15:52 +08:00
|
|
|
|
import chartList from '@/components/chart/chartList'
|
2021-04-22 11:47:24 +08:00
|
|
|
|
import bus from '../../../../libs/bus'
|
|
|
|
|
|
import subDataListMixin from '@/components/common/mixin/subDataList'
|
|
|
|
|
|
import nzBottomDataList from '@/components/common/bottomBox/nzBottomDataList'
|
2021-04-26 21:42:15 +08:00
|
|
|
|
import { fromRoute } from '@/components/common/js/constants'
|
2021-05-19 23:17:24 +08:00
|
|
|
|
import chartTempBox from '@/components/common/rightBox/chartTempBox'
|
2021-04-27 16:26:22 +08:00
|
|
|
|
import topToolMoreOptions from '@/components/common/popBox/topToolMoreOptions'
|
2021-10-11 14:05:07 +08:00
|
|
|
|
import detailViewRightMixin from '@/components/common/mixin/detailViewRightMixin'
|
2021-12-21 18:42:17 +08:00
|
|
|
|
import { randomcolor } from '@/components/common/js/radomcolor/randomcolor'
|
2022-04-11 17:54:38 +08:00
|
|
|
|
import htmlToPdfMixin from '@/components/common/mixin/htmlToPdfMixin'
|
2022-05-24 15:04:46 +08:00
|
|
|
|
import exportHtmlMixin from '@/components/common/mixin/exportHtml'
|
2022-09-02 14:41:14 +08:00
|
|
|
|
import panelVariables from '@/components/common/panel/panelVariables'
|
2023-03-08 17:56:28 +08:00
|
|
|
|
import snapshotProgress from '@/components/common/snapshotProgress/snapshotProgress.vue'
|
|
|
|
|
|
|
2021-04-22 11:47:24 +08:00
|
|
|
|
export default {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
name: 'dashboardTab',
|
2022-05-24 15:04:46 +08:00
|
|
|
|
mixins: [subDataListMixin, detailViewRightMixin, htmlToPdfMixin, exportHtmlMixin],
|
2021-04-22 11:47:24 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
from: String,
|
|
|
|
|
|
obj: Object,
|
2021-07-19 17:04:46 +08:00
|
|
|
|
draggable: { type: Boolean, default: true },
|
|
|
|
|
|
paramsType: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: 'dashboard'
|
2022-04-13 17:09:59 +08:00
|
|
|
|
},
|
2022-09-02 14:41:14 +08:00
|
|
|
|
sign: [Number, String]
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
2021-12-16 19:50:23 +08:00
|
|
|
|
computed: {
|
|
|
|
|
|
chartRightBoxShow () {
|
|
|
|
|
|
return this.$store.getters.getShowRightBox
|
|
|
|
|
|
},
|
|
|
|
|
|
delChartFlag () {
|
|
|
|
|
|
return this.$store.getters.getDelChart
|
2022-02-14 17:46:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
panelLock () {
|
|
|
|
|
|
return this.$store.getters.getPanelLock
|
2021-12-16 19:50:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-22 11:47:24 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
fromRoute,
|
2023-03-15 15:39:06 +08:00
|
|
|
|
tableId: 'dashboardTab',
|
2022-04-11 17:54:38 +08:00
|
|
|
|
pdfId: 'pdfDom',
|
2023-03-15 15:39:06 +08:00
|
|
|
|
htmlTitle: 'dashboard',
|
|
|
|
|
|
dashboardLoading: false,
|
2021-04-22 11:47:24 +08:00
|
|
|
|
showTopBtn: false, // top按钮
|
|
|
|
|
|
visible: false,
|
2021-12-16 18:15:52 +08:00
|
|
|
|
chartListLoading: true,
|
2021-04-22 11:47:24 +08:00
|
|
|
|
rightBox: { // 面板弹出框相关
|
2021-05-19 23:17:24 +08:00
|
|
|
|
chart: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
},
|
|
|
|
|
|
chartTemp: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
tableHover: false,
|
|
|
|
|
|
searchTime: bus.getTimezontDateRange(),
|
|
|
|
|
|
intervalTimer: null,
|
|
|
|
|
|
interval: 0,
|
|
|
|
|
|
panel: { // 新增panel
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
name: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
chart: {},
|
|
|
|
|
|
blankChart: {
|
|
|
|
|
|
id: '',
|
2021-12-21 18:42:17 +08:00
|
|
|
|
name: '',
|
2021-04-22 11:47:24 +08:00
|
|
|
|
type: 'line',
|
2021-12-21 18:42:17 +08:00
|
|
|
|
span: 4,
|
|
|
|
|
|
datasource: 'metrics',
|
|
|
|
|
|
height: 4,
|
2021-04-22 11:47:24 +08:00
|
|
|
|
unit: 2,
|
|
|
|
|
|
param: {
|
2021-12-21 18:42:17 +08:00
|
|
|
|
stack: 0,
|
|
|
|
|
|
nullType: 'null',
|
|
|
|
|
|
legend: { placement: 'bottom', values: [], show: true },
|
|
|
|
|
|
enable: {
|
|
|
|
|
|
legend: true,
|
|
|
|
|
|
valueMapping: false,
|
2023-01-05 17:53:42 +08:00
|
|
|
|
thresholds: false,
|
2023-02-21 14:34:11 +08:00
|
|
|
|
visibility: false,
|
|
|
|
|
|
rightYAxis: false
|
2021-12-21 18:42:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
thresholdShow: true,
|
2023-01-05 17:53:42 +08:00
|
|
|
|
thresholds: [{ value: undefined, color: randomcolor() }],
|
|
|
|
|
|
showHeader: 1,
|
|
|
|
|
|
visibility: {
|
|
|
|
|
|
varName: '',
|
|
|
|
|
|
operator: 'equal',
|
|
|
|
|
|
varValue: '',
|
|
|
|
|
|
result: 'show'
|
2023-02-21 14:34:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
rightYAxis: {
|
|
|
|
|
|
elementNames: [],
|
|
|
|
|
|
style: 'line',
|
|
|
|
|
|
unit: 2,
|
|
|
|
|
|
label: '',
|
|
|
|
|
|
min: undefined,
|
|
|
|
|
|
max: undefined
|
2023-01-05 17:53:42 +08:00
|
|
|
|
}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
2023-01-05 17:53:42 +08:00
|
|
|
|
elements: [{ expression: '', legend: '', type: 'expert', id: '', name: 'A', state: 1, orderNum: 0 }],
|
2021-04-22 11:47:24 +08:00
|
|
|
|
panel: '',
|
2021-04-26 21:42:15 +08:00
|
|
|
|
sync: 0,
|
2021-12-21 18:42:17 +08:00
|
|
|
|
remark: '',
|
2023-01-05 17:53:42 +08:00
|
|
|
|
groupId: '',
|
|
|
|
|
|
varType: ''
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
pageObj: {
|
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
|
pageSize: -1, // 此处获取所有数据,所以设置一个较大的值
|
|
|
|
|
|
total: 0
|
|
|
|
|
|
},
|
|
|
|
|
|
chartsData: [], // 中间部分图表相关数据
|
|
|
|
|
|
panelData: [],
|
|
|
|
|
|
searchMsg: { // 给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
searchLabel: {}, // 搜索参数
|
|
|
|
|
|
// ---图表相关参数--start
|
|
|
|
|
|
dataList: [], // 数据列表
|
|
|
|
|
|
filter: { // 过滤条件
|
|
|
|
|
|
// productId: 0,
|
2023-03-15 15:39:06 +08:00
|
|
|
|
dashboardId: 0,
|
2023-03-28 09:16:24 +08:00
|
|
|
|
from: this.from
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
showPanel: {
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
type: this.from,
|
2021-05-19 23:17:24 +08:00
|
|
|
|
id: null
|
|
|
|
|
|
},
|
|
|
|
|
|
blankChartTemp: {
|
|
|
|
|
|
varType: 1,
|
|
|
|
|
|
pid: '',
|
2023-03-15 15:39:06 +08:00
|
|
|
|
dashboardId: null,
|
2021-05-19 23:17:24 +08:00
|
|
|
|
varIds: []
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
// removeModal: false, // 删除弹出
|
|
|
|
|
|
// deleteObj: {}, // 删除对象
|
|
|
|
|
|
// ---图表相关参数--end
|
2021-04-26 19:46:40 +08:00
|
|
|
|
scrollbarWrap: null,
|
2021-11-02 17:01:13 +08:00
|
|
|
|
panelDataList: [],
|
2021-11-24 09:41:48 +08:00
|
|
|
|
batchDeleteObjs: [],
|
2021-12-16 18:15:52 +08:00
|
|
|
|
nowTimeType: {},
|
2022-07-08 18:06:31 +08:00
|
|
|
|
chartDetailInfo: {},
|
|
|
|
|
|
variables: [],
|
2023-03-08 17:56:28 +08:00
|
|
|
|
variablesInit: false,
|
2023-03-28 09:16:24 +08:00
|
|
|
|
snapshotVisible: false,
|
|
|
|
|
|
timeData: [
|
|
|
|
|
|
{ id: 1, text: this.$t('dashboard.dashboard.lastFiveMin'), type: 'minute', value: 5 },
|
|
|
|
|
|
{ id: 2, text: this.$t('dashboard.dashboard.lastFifteenMin'), type: 'minute', value: 15 },
|
|
|
|
|
|
{ id: 3, text: this.$t('dashboard.dashboard.lastThirtyMin'), type: 'minute', value: 30 },
|
|
|
|
|
|
{ id: 4, text: this.$t('dashboard.dashboard.lastOneHour'), type: 'hour', value: 1 },
|
|
|
|
|
|
{ id: 5, text: this.$t('dashboard.dashboard.lastThreeHour'), type: 'hour', value: 3 },
|
|
|
|
|
|
{ id: 6, text: this.$t('dashboard.dashboard.lastSixHour'), type: 'hour', value: 6 },
|
|
|
|
|
|
{ id: 7, text: this.$t('dashboard.dashboard.lastTwelveHour'), type: 'hour', value: 12 },
|
|
|
|
|
|
{ id: 8, text: this.$t('dashboard.dashboard.lastTwentyFourHour'), type: 'hour', value: 24 },
|
|
|
|
|
|
{ id: 9, text: this.$t('dashboard.dashboard.lastTwoDay'), type: 'date', value: 2 },
|
|
|
|
|
|
{ id: 10, text: this.$t('dashboard.dashboard.lastSevenDay'), type: 'date', value: 7 },
|
|
|
|
|
|
{ id: 11, text: this.$t('dashboard.dashboard.lastThirtyDay'), type: 'date', value: 30 }
|
|
|
|
|
|
],
|
|
|
|
|
|
intervalList: [
|
|
|
|
|
|
{ value: 0, label: this.$t('dashboard.dashboard.chartForm.lockList.off') },
|
|
|
|
|
|
{ value: 30, label: '30s' },
|
|
|
|
|
|
{ value: 60, label: '1m' },
|
|
|
|
|
|
{ value: 300, label: '5m' },
|
|
|
|
|
|
{ value: 900, label: '15m' },
|
|
|
|
|
|
{ value: 1800, label: '30m' }
|
|
|
|
|
|
]
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
2021-12-16 19:50:23 +08:00
|
|
|
|
chartRightBox,
|
2021-04-26 21:42:15 +08:00
|
|
|
|
chartList,
|
|
|
|
|
|
nzBottomDataList,
|
2021-05-19 23:17:24 +08:00
|
|
|
|
topToolMoreOptions,
|
2022-07-08 18:06:31 +08:00
|
|
|
|
chartTempBox,
|
2023-03-08 17:56:28 +08:00
|
|
|
|
panelVariables, // 处理panel变量的组件
|
|
|
|
|
|
snapshotProgress // 快照进度
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
// 刷新
|
|
|
|
|
|
refresh () {
|
|
|
|
|
|
this.getTableData(this.obj.id)
|
|
|
|
|
|
},
|
2022-03-10 11:31:48 +08:00
|
|
|
|
refreshPanel () {
|
|
|
|
|
|
this.getData(this.filter)
|
|
|
|
|
|
},
|
2021-04-22 11:47:24 +08:00
|
|
|
|
refreshTime (st, et) {
|
2022-04-22 10:04:59 +08:00
|
|
|
|
const startTime = bus.timeFormate(st)
|
|
|
|
|
|
const endTime = bus.timeFormate(et)
|
2021-04-22 11:47:24 +08:00
|
|
|
|
this.searchTime = [startTime, endTime]
|
|
|
|
|
|
},
|
|
|
|
|
|
panelReloadForDel () {
|
|
|
|
|
|
this.getTableData(this.obj.id)
|
|
|
|
|
|
},
|
2021-12-16 19:50:23 +08:00
|
|
|
|
panelReload (clearShowPanel) {
|
|
|
|
|
|
this.getTableData(clearShowPanel)
|
|
|
|
|
|
},
|
|
|
|
|
|
panelReloadOnlyPanel () { // 仅刷新panel数据
|
2023-03-15 15:39:06 +08:00
|
|
|
|
if (!this.hasButton('dashboard_view')) {
|
2021-12-16 19:50:23 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.$get('visual/dashboard?pageSize=-1').then(response => {
|
2021-12-16 19:50:23 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.panelData = response.data.list
|
|
|
|
|
|
for (let i = 0; i < this.panelData.length; i++) {
|
|
|
|
|
|
if (this.panelData[i].id == this.showPanel.id) {
|
|
|
|
|
|
this.showPanel = this.panelData[i]
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-04-22 11:47:24 +08:00
|
|
|
|
/* 图表相关操作--start */
|
|
|
|
|
|
addChart () {
|
|
|
|
|
|
this.chart = this.newChart()
|
2023-01-05 17:53:42 +08:00
|
|
|
|
this.chart.param.thresholds = [{ value: undefined, color: randomcolor() }]
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.chart.dashboardId = this.showPanel.id
|
2023-01-05 17:53:42 +08:00
|
|
|
|
this.chart.panelName = this.showPanel.name
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.addChartModal.isStable = 'stable'
|
2021-12-21 18:36:22 +08:00
|
|
|
|
})
|
2021-05-19 23:17:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
addChartByTemp () {
|
2021-12-08 15:15:18 +08:00
|
|
|
|
this.chart = JSON.parse(JSON.stringify(this.blankChartTemp))
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.chart.dashboardId = this.showPanel.id
|
2021-05-19 23:17:24 +08:00
|
|
|
|
if (this.from === fromRoute.endpoint) {
|
|
|
|
|
|
this.chart.varType = 2
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.from === fromRoute.asset || this.from === fromRoute.endpoint) {
|
|
|
|
|
|
this.chart.varIds.push(this.obj.id)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.rightBox.chartTemp.show = true
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
newChart () {
|
|
|
|
|
|
return JSON.parse(JSON.stringify(this.blankChart))
|
|
|
|
|
|
},
|
2021-12-16 19:50:23 +08:00
|
|
|
|
|
2021-04-22 11:47:24 +08:00
|
|
|
|
// 切换tab
|
|
|
|
|
|
changeTab (tab) {
|
|
|
|
|
|
this.$emit('changeTab', tab)
|
|
|
|
|
|
},
|
|
|
|
|
|
closeRightBox (refresh) {
|
2021-05-19 23:17:24 +08:00
|
|
|
|
this.rightBox.chart.show = false
|
|
|
|
|
|
this.rightBox.chartTemp.show = false
|
2021-12-16 19:50:23 +08:00
|
|
|
|
this.$store.dispatch('clearPanel')
|
2022-01-04 16:26:43 +08:00
|
|
|
|
this.chart = {}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.refresh()
|
2021-05-17 20:31:32 +08:00
|
|
|
|
if (this.from === fromRoute.chartTemp) {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.$get('/visual/dashboard/chart', { ids: this.obj.id }).then(res => {
|
2021-05-17 20:31:32 +08:00
|
|
|
|
res.data.list.forEach(item => {
|
|
|
|
|
|
if (!item.children) {
|
|
|
|
|
|
item.children = []
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.panelDataList = res.data.list
|
|
|
|
|
|
if (this.panelDataList.length > 0) {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.showPanel.id = this.filter.dashboardId = 0
|
2021-05-17 20:31:32 +08:00
|
|
|
|
this.getData(this.filter)
|
2022-06-17 13:58:36 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.chartListLoading = false
|
|
|
|
|
|
this.dataList = this.panelDataList
|
2022-06-17 14:02:55 +08:00
|
|
|
|
this.$emit('exit')
|
2021-05-17 20:31:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-07-29 16:23:15 +08:00
|
|
|
|
this.$emit('getTableData')
|
2021-05-17 20:31:32 +08:00
|
|
|
|
}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 编辑图表信息,打开编辑弹窗
|
2021-12-29 16:18:46 +08:00
|
|
|
|
editChart (data, copy) {
|
|
|
|
|
|
if (copy) {
|
|
|
|
|
|
this.chart = JSON.parse(JSON.stringify(data))
|
|
|
|
|
|
this.chart.x = 0
|
|
|
|
|
|
this.chart.y = 0
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.chart.dashboardId = this.showPanel.id
|
2021-12-29 16:18:46 +08:00
|
|
|
|
this.chart.panelName = this.showPanel.name
|
|
|
|
|
|
this.chart.id = ''
|
|
|
|
|
|
this.chart.elements.forEach((item) => {
|
|
|
|
|
|
item.id = ''
|
|
|
|
|
|
item.chartId = ''
|
|
|
|
|
|
delete item.seq
|
|
|
|
|
|
})
|
|
|
|
|
|
if (this.chart.datasource !== 'metrics' && this.chart.datasource !== 'log') {
|
|
|
|
|
|
delete this.chart.elements
|
|
|
|
|
|
}
|
2021-12-29 18:12:40 +08:00
|
|
|
|
if (!this.chart.groupId || this.chart.groupId == -1) {
|
|
|
|
|
|
this.chart.groupId = ''
|
|
|
|
|
|
}
|
2021-12-29 16:18:46 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.rightBox.loading = true
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.$get('visual/dashboard/chart/' + data.id).then(res => {
|
2021-12-29 16:18:46 +08:00
|
|
|
|
this.rightBox.loading = false
|
|
|
|
|
|
if (res.code === 200) {
|
2022-03-02 10:46:57 +08:00
|
|
|
|
const chartData = res.data
|
2021-12-29 16:18:46 +08:00
|
|
|
|
this.chart = JSON.parse(JSON.stringify(chartData))
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.chart.dashboardId = this.showPanel.id
|
2021-12-29 16:18:46 +08:00
|
|
|
|
this.chart.panelName = this.showPanel.name
|
2023-02-17 11:23:41 +08:00
|
|
|
|
if (this.chart.param) {
|
|
|
|
|
|
this.chart.param = JSON.parse(this.chart.param)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.chart.param = {}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!this.chart.param.rightYAxis) {
|
|
|
|
|
|
this.chart.param.rightYAxis = {
|
|
|
|
|
|
elementNames: [],
|
|
|
|
|
|
style: 'line',
|
|
|
|
|
|
unit: 2,
|
|
|
|
|
|
label: '',
|
|
|
|
|
|
min: undefined,
|
|
|
|
|
|
max: undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-12-29 16:18:46 +08:00
|
|
|
|
if (!this.chart.groupId || this.chart.groupId == -1) {
|
|
|
|
|
|
this.chart.groupId = ''
|
|
|
|
|
|
}
|
2023-03-21 16:53:15 +08:00
|
|
|
|
if (this.chart.type === 'stat') {
|
|
|
|
|
|
if (!this.chart.param.sparklineMode) { this.chart.param.sparklineMode = 'none' }
|
|
|
|
|
|
if (!this.chart.param.comparison) { this.chart.param.comparison = 'none' }
|
2023-02-28 14:15:52 +08:00
|
|
|
|
}
|
2021-12-29 16:18:46 +08:00
|
|
|
|
if (this.chart.type == 'table') {
|
|
|
|
|
|
const arr = this.chart.param.indexs ? this.chart.param.indexs.split(',') : []
|
|
|
|
|
|
this.chart.param.tags = arr.map((item) => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
text: item,
|
|
|
|
|
|
tiClasses: ['ti-valid']
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2023-01-05 17:53:42 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.addChartModal.isStable = 'stable'
|
|
|
|
|
|
})
|
2021-12-29 16:18:46 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 移除图表:弹出确认框询问
|
|
|
|
|
|
delChart (data, from) {
|
|
|
|
|
|
this.$confirm(this.$t('tip.confirmDelete'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
|
type: 'warning'
|
2021-05-17 20:31:32 +08:00
|
|
|
|
}).then(() => {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.$delete('visual/dashboard/chart?ids=' + data.id).then(response => {
|
2021-05-17 20:31:32 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
duration: 2000,
|
|
|
|
|
|
type: 'success',
|
|
|
|
|
|
message: this.$t('tip.deleteSuccess')
|
|
|
|
|
|
})
|
|
|
|
|
|
this.closeRightBox(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg)
|
2022-03-22 15:42:50 +08:00
|
|
|
|
this.$store.dispatch('clearPanel')
|
2021-05-17 20:31:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2022-03-23 15:06:36 +08:00
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
this.$store.dispatch('clearPanel')
|
2021-05-17 20:31:32 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
addGroupItem (groupId) {
|
|
|
|
|
|
this.chart = this.newChart()
|
|
|
|
|
|
this.chart.groupId = groupId
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.chart.dashboardId = this.showPanel.id
|
2021-05-17 20:31:32 +08:00
|
|
|
|
this.chart.panelName = this.showPanel.name
|
|
|
|
|
|
this.chart.isGroup = true
|
2023-02-22 18:32:54 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.addChartModal.isStable = 'stable'
|
|
|
|
|
|
})
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 图表创建成功,回调panel页面,进行图表的刷新
|
|
|
|
|
|
createSuccess (msg, data, params) {
|
|
|
|
|
|
this.getData(this.filter)
|
|
|
|
|
|
},
|
|
|
|
|
|
// 获取数据,用在子页面
|
|
|
|
|
|
getData (params) {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
if (!this.hasButton('dashboard_view')) {
|
2021-12-16 18:15:52 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.chartListLoading = true
|
2021-12-16 19:50:23 +08:00
|
|
|
|
if (this.from !== 'chartTemp') {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.$get('visual/dashboard/chart?dashboardId=' + params.dashboardId + '&groupId=0' + '&pageSize=-1').then(response => {
|
2021-12-16 19:50:23 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.chartListLoading = false
|
|
|
|
|
|
this.dataList = response.data.list.map(item => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
...item,
|
|
|
|
|
|
loaded: false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.chartListLoading = false
|
|
|
|
|
|
this.dataList = this.panelDataList
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/* 图表相关操作--end */
|
|
|
|
|
|
/* 时间条件查询--start */
|
|
|
|
|
|
// 选择日期变化
|
|
|
|
|
|
dateChange (val) {
|
2021-05-25 19:47:22 +08:00
|
|
|
|
if (this.$refs.pickTime) {
|
|
|
|
|
|
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
|
2021-11-24 09:41:48 +08:00
|
|
|
|
this.nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
|
2021-05-25 19:47:22 +08:00
|
|
|
|
this.setSearchTime(nowTimeType.type, nowTimeType.value)
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.filter.dashboardId = this.showPanel.id
|
2021-05-25 19:47:22 +08:00
|
|
|
|
this.getData(this.filter)
|
2022-02-15 11:23:10 +08:00
|
|
|
|
this.$store.dispatch('dispatchPanelTime', {
|
|
|
|
|
|
time: this.searchTime,
|
|
|
|
|
|
nowTimeType: this.nowTimeType
|
|
|
|
|
|
})
|
2021-05-25 19:47:22 +08:00
|
|
|
|
}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
/* 时间条件查询--end */
|
|
|
|
|
|
setSearchTime (type, val) { // 设置searchTime
|
|
|
|
|
|
if (type === 'minute') {
|
2022-04-22 10:04:59 +08:00
|
|
|
|
const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val))
|
|
|
|
|
|
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
|
2021-04-22 11:47:24 +08:00
|
|
|
|
this.$set(this.searchTime, 0, startTime)
|
|
|
|
|
|
this.$set(this.searchTime, 1, endTime)
|
|
|
|
|
|
this.$set(this.searchTime, 2, val + 'm')
|
|
|
|
|
|
} else if (type === 'hour') {
|
2022-04-22 10:04:59 +08:00
|
|
|
|
const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val))
|
|
|
|
|
|
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
|
2021-04-22 11:47:24 +08:00
|
|
|
|
this.$set(this.searchTime, 0, startTime)
|
|
|
|
|
|
this.$set(this.searchTime, 1, endTime)
|
|
|
|
|
|
this.$set(this.searchTime, 2, val + 'h')
|
|
|
|
|
|
} else if (type === 'date') {
|
2022-04-22 10:04:59 +08:00
|
|
|
|
const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val))
|
|
|
|
|
|
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
|
2021-04-22 11:47:24 +08:00
|
|
|
|
this.$set(this.searchTime, 0, startTime)
|
|
|
|
|
|
this.$set(this.searchTime, 1, endTime)
|
|
|
|
|
|
this.$set(this.searchTime, 2, val + 'd')
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.pickTime.$refs.timePicker.searchTime = this.searchTime
|
|
|
|
|
|
},
|
2021-04-26 21:42:15 +08:00
|
|
|
|
getVarType (from) {
|
|
|
|
|
|
if (from === this.fromRoute.asset) {
|
|
|
|
|
|
return 1
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-22 11:47:24 +08:00
|
|
|
|
// 公用操作
|
2023-03-28 09:16:24 +08:00
|
|
|
|
async getTableData (linkId) {
|
2021-05-19 23:17:24 +08:00
|
|
|
|
if (this.from === this.fromRoute.alertRule) {
|
2021-04-22 11:47:24 +08:00
|
|
|
|
this.getData(this.filter)
|
|
|
|
|
|
} else {
|
2023-03-28 09:16:24 +08:00
|
|
|
|
if (this.from === this.fromRoute.dashboardTemp) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await this.$get('visual/dashboard', { type: 'template', ids: this.obj.id })
|
2022-11-22 19:16:59 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.panelData = response.data.list
|
|
|
|
|
|
if (this.panelData.length > 0) {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.filter.dashboardId = this.panelData[0].id
|
2022-11-22 19:16:59 +08:00
|
|
|
|
this.showPanel = this.$loadsh.cloneDeep(this.panelData[0])
|
2023-03-16 11:11:53 +08:00
|
|
|
|
this.variables = this.$loadsh.cloneDeep(this.$loadsh.get(this, 'showPanel.param.variables', []) || [])
|
2022-11-22 19:16:59 +08:00
|
|
|
|
this.getData(this.filter)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-28 09:16:24 +08:00
|
|
|
|
} catch (error) {
|
2022-11-22 19:16:59 +08:00
|
|
|
|
if (error) {
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
this.$message.error(error.toString())
|
|
|
|
|
|
}
|
2023-03-28 09:16:24 +08:00
|
|
|
|
}
|
2021-04-25 14:58:03 +08:00
|
|
|
|
} else {
|
2023-03-28 09:16:24 +08:00
|
|
|
|
try {
|
|
|
|
|
|
const response = await this.$get('visual/dashboard', { type: this.from, link: linkId || this.obj.id })
|
2021-04-25 14:58:03 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.panelData = response.data.list
|
|
|
|
|
|
if (this.panelData.length > 0) {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.filter.dashboardId = this.panelData[0].id
|
2022-11-22 19:16:59 +08:00
|
|
|
|
this.showPanel = this.$loadsh.cloneDeep(this.panelData[0])
|
2023-03-16 11:11:53 +08:00
|
|
|
|
this.variables = this.$loadsh.cloneDeep(this.$loadsh.get(this, 'showPanel.param.variables', []) || [])
|
2021-04-25 14:58:03 +08:00
|
|
|
|
this.getData(this.filter)
|
2022-12-27 16:17:50 +08:00
|
|
|
|
} else {
|
2022-12-23 16:27:09 +08:00
|
|
|
|
this.chartListLoading = false
|
2021-04-25 14:58:03 +08:00
|
|
|
|
}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
} else {
|
2022-12-23 16:27:09 +08:00
|
|
|
|
this.chartListLoading = false
|
2021-04-25 14:58:03 +08:00
|
|
|
|
if (response.msg) {
|
|
|
|
|
|
console.error(response.msg)
|
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
|
} else if (response.error) {
|
|
|
|
|
|
console.error(response.error)
|
|
|
|
|
|
this.$message.error(response.error)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error(response)
|
|
|
|
|
|
this.$message.error(response)
|
|
|
|
|
|
}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
2023-03-28 09:16:24 +08:00
|
|
|
|
} catch (error) {
|
2021-04-25 14:58:03 +08:00
|
|
|
|
if (error) {
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
this.$message.error(error.toString())
|
|
|
|
|
|
}
|
2023-03-28 09:16:24 +08:00
|
|
|
|
}
|
2021-04-25 14:58:03 +08:00
|
|
|
|
}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 定期刷新
|
|
|
|
|
|
selectInterval (val) {
|
|
|
|
|
|
this.visible = false
|
|
|
|
|
|
clearInterval(this.intervalTimer)
|
|
|
|
|
|
if (val) {
|
|
|
|
|
|
this.interval = val
|
|
|
|
|
|
const start = new Date(this.searchTime[1])
|
|
|
|
|
|
const now = new Date()
|
|
|
|
|
|
const interval = Math.floor((now.getTime() - start.getTime()) / 1000) // 计算当前结束时间到现在的间隔(秒)
|
|
|
|
|
|
if (interval >= 60) { // 如果结束时间到现在超过1分钟,则
|
|
|
|
|
|
this.getIntervalData(interval)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.intervalTimer = setInterval(() => {
|
|
|
|
|
|
this.getIntervalData(this.interval)
|
|
|
|
|
|
}, val * 1000)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
getIntervalData (interval) { // interval:结束时间到现在的秒数
|
|
|
|
|
|
const start = new Date(this.searchTime[0])
|
|
|
|
|
|
const end = new Date(this.searchTime[1])
|
|
|
|
|
|
start.setSeconds(start.getSeconds() + interval)
|
|
|
|
|
|
end.setSeconds(end.getSeconds() + interval)
|
|
|
|
|
|
const startTime = bus.timeFormate(start, 'yyyy-MM-dd hh:mm')
|
|
|
|
|
|
const endTime = bus.timeFormate(end, 'yyyy-MM-dd hh:mm')
|
|
|
|
|
|
this.searchTime = [startTime, endTime]
|
|
|
|
|
|
// 刷新数据
|
|
|
|
|
|
this.dateChange()
|
|
|
|
|
|
},
|
|
|
|
|
|
// 滚动事件触发下拉加载
|
|
|
|
|
|
onScroll () {
|
|
|
|
|
|
const _self = this
|
|
|
|
|
|
this.scrollbarWrap.addEventListener('scroll', bus.debounce(function () {
|
|
|
|
|
|
_self.showTopBtn = _self.scrollbarWrap.scrollTop > 50
|
2021-12-31 14:06:02 +08:00
|
|
|
|
// _self.$refs.chartList.loadChartData(_self.scrollbarWrap.scrollTop)
|
|
|
|
|
|
_self.$refs.chartList.onScroll(_self.scrollbarWrap.scrollTop)
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}, 300))
|
|
|
|
|
|
},
|
2021-04-27 16:26:22 +08:00
|
|
|
|
syncChart () {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
if (this.from == this.fromRoute.asset || this.from == this.fromRoute.model) {
|
2021-04-22 11:47:24 +08:00
|
|
|
|
this.$confirm(this.$t('tip.syncTip'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
const param = {
|
2021-04-26 21:42:15 +08:00
|
|
|
|
modelId: this.from == this.fromRoute.model ? this.obj.id : null,
|
|
|
|
|
|
assetId: this.from == this.fromRoute.asset ? this.obj.id : null
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.$put('/model/syncChart', param).then(response => {
|
|
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.syncSuccess') })
|
2021-04-26 21:42:15 +08:00
|
|
|
|
if (this.from == this.fromRoute.asset) {
|
2021-04-22 11:47:24 +08:00
|
|
|
|
this.refresh()
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error(response.msg)
|
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
toTop (wrap) {
|
|
|
|
|
|
let currentTop = wrap.scrollTop
|
|
|
|
|
|
const interval = currentTop / 10
|
|
|
|
|
|
const intervalFunc = setInterval(function () { // 花200ms分10次回到顶部,模拟动画效果
|
|
|
|
|
|
if (currentTop === 0) {
|
|
|
|
|
|
clearInterval(intervalFunc)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
currentTop = (currentTop - interval) < interval * 0.5 ? 0 : currentTop - interval
|
|
|
|
|
|
wrap.scrollTop = currentTop
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 20)
|
|
|
|
|
|
},
|
|
|
|
|
|
tableListEnter () {
|
|
|
|
|
|
this.tableHover = true
|
|
|
|
|
|
},
|
|
|
|
|
|
tableListLeave () {
|
|
|
|
|
|
this.tableHover = false
|
2021-05-13 19:02:23 +08:00
|
|
|
|
},
|
|
|
|
|
|
panelLockChange (boolean) {
|
2022-02-14 17:46:54 +08:00
|
|
|
|
this.$store.dispatch('dispatchPanelLock', { flag: boolean })
|
2021-05-20 14:07:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
chartBySync () {
|
2022-10-20 16:25:03 +08:00
|
|
|
|
this.$store.dispatch('dispatchHomeLoading', true)
|
2022-03-10 15:27:01 +08:00
|
|
|
|
const params = {}
|
2023-03-02 10:35:56 +08:00
|
|
|
|
params.tmplId = this.showPanel.id
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.$post('visual/dashboard/syncTmpl', params).then(res => {
|
2022-10-20 16:25:03 +08:00
|
|
|
|
this.$store.dispatch('dispatchHomeLoading', false)
|
2021-05-20 14:07:58 +08:00
|
|
|
|
if (res.code === 200) {
|
2021-11-16 17:30:01 +08:00
|
|
|
|
this.getTableData(this.obj.id)
|
2021-05-20 14:07:58 +08:00
|
|
|
|
this.$message.success(this.$t('tip.syncSuccess'))
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(res.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-12-16 19:50:23 +08:00
|
|
|
|
},
|
2023-01-05 17:53:42 +08:00
|
|
|
|
addChartBefore () {
|
|
|
|
|
|
this.$store.dispatch('dispatchEditChart', {
|
|
|
|
|
|
chart: '',
|
|
|
|
|
|
type: 'add'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-12-16 19:50:23 +08:00
|
|
|
|
disposeChart () {
|
|
|
|
|
|
const chartInfo = this.$store.getters.getChart
|
|
|
|
|
|
const groupId = this.$store.getters.getGroupId
|
|
|
|
|
|
const type = this.$store.getters.getType
|
|
|
|
|
|
if (type === 'add') {
|
|
|
|
|
|
this.addChart()
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type === 'edit') {
|
|
|
|
|
|
this.editChart(chartInfo)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type === 'addGroupItem') {
|
|
|
|
|
|
this.addGroupItem(groupId)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type === 'delete') {
|
|
|
|
|
|
this.delChart(chartInfo)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type === 'duplicate') {
|
|
|
|
|
|
this.editChart(chartInfo, true)
|
|
|
|
|
|
}
|
2022-04-11 17:54:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
htmlToPdf () {
|
|
|
|
|
|
const dom = document.getElementsByClassName(this.pdfId)[0]
|
2022-04-12 10:30:33 +08:00
|
|
|
|
this.htmlTitle = this.obj.name || 'pdf'
|
2022-04-11 17:54:38 +08:00
|
|
|
|
if (dom) {
|
|
|
|
|
|
// dom = dom.getElementsByClassName('vue-grid-layout')[0]
|
|
|
|
|
|
this.scrollbarWrap.scrollTop = this.scrollbarWrap.scrollHeight
|
|
|
|
|
|
this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop)
|
|
|
|
|
|
let flag = true
|
|
|
|
|
|
this.showScreenLoading(true)
|
|
|
|
|
|
let timer = setInterval(() => {
|
|
|
|
|
|
flag = true
|
|
|
|
|
|
this.$refs.chartList.copyDataList.forEach(chart => {
|
|
|
|
|
|
if (chart.type !== 'group') {
|
|
|
|
|
|
flag = flag && chart.loaded
|
|
|
|
|
|
} else if (chart.collapse) {
|
|
|
|
|
|
chart.children.forEach(groupChart => {
|
|
|
|
|
|
flag = flag && groupChart.loaded
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
|
clearInterval(timer)
|
|
|
|
|
|
timer = null
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
document.body.style.height = 'auto'
|
|
|
|
|
|
// document.getElementsByTagName('html')[0].style.overflow = 'visible'
|
|
|
|
|
|
const position = dom.getBoundingClientRect()
|
2022-07-14 09:55:10 +08:00
|
|
|
|
this.getPdf(dom, -1 * position.left, -1 * position.top, this.searchTime)
|
2022-04-11 17:54:38 +08:00
|
|
|
|
// this.getPdf(dom, 0, 0)
|
|
|
|
|
|
}, 2000)
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 200)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.showScreenLoading(false)
|
|
|
|
|
|
}
|
2022-05-24 15:04:46 +08:00
|
|
|
|
this.$refs.topTool.closeDialog()
|
|
|
|
|
|
},
|
|
|
|
|
|
exportType (type) {
|
|
|
|
|
|
if (type === 'PDF') {
|
|
|
|
|
|
this.htmlToPdf()
|
|
|
|
|
|
} else {
|
2023-03-08 17:56:28 +08:00
|
|
|
|
this.snapshotVisible = true
|
2022-05-24 15:04:46 +08:00
|
|
|
|
}
|
2022-07-08 18:06:31 +08:00
|
|
|
|
},
|
|
|
|
|
|
getPanelData () {
|
|
|
|
|
|
this.variablesInit = true
|
2023-02-15 17:46:15 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop)
|
|
|
|
|
|
})
|
2023-03-28 09:16:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 时间选择器设置默认时间范围
|
|
|
|
|
|
setDefaultTimeRange () {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
let nowTimeType = this.$loadsh.cloneDeep(this.timeData[3])
|
|
|
|
|
|
const defaultTimeRange = this.$loadsh.get(this.showPanel, 'param.defaultTimeRange')
|
|
|
|
|
|
if (defaultTimeRange) {
|
|
|
|
|
|
nowTimeType = this.timeData.find(item => item.id == defaultTimeRange)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.nowTimeType = this.$loadsh.cloneDeep(nowTimeType)
|
|
|
|
|
|
// 刷新时间范围
|
|
|
|
|
|
this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType)
|
|
|
|
|
|
this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType)
|
|
|
|
|
|
this.$store.dispatch('dispatchPanelTime', {
|
|
|
|
|
|
time: this.searchTime,
|
|
|
|
|
|
nowTimeType: this.nowTimeType
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 设置默认刷新
|
|
|
|
|
|
setDefaultRefresh () {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
let refresh = this.$loadsh.cloneDeep(this.intervalList[0])
|
|
|
|
|
|
const defaultRefresh = this.$loadsh.get(this.showPanel, 'param.refresh')
|
|
|
|
|
|
if (defaultRefresh) {
|
|
|
|
|
|
refresh = this.intervalList.find(item => item.value == defaultRefresh)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.pickTime.selectInterval(refresh)
|
|
|
|
|
|
})
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-27 16:26:22 +08:00
|
|
|
|
mounted () {
|
2022-03-10 16:51:51 +08:00
|
|
|
|
bus.$on('refreshPanel', this.refreshPanel)
|
2021-04-22 11:47:24 +08:00
|
|
|
|
this.scrollbarWrap = this.$refs.dashboardScrollbar
|
|
|
|
|
|
this.onScroll()
|
|
|
|
|
|
document.querySelector('#tableList').addEventListener('mouseenter', this.tableListEnter)
|
|
|
|
|
|
document.querySelector('#tableList').addEventListener('mouseleave', this.tableListLeave)
|
2022-02-15 11:23:10 +08:00
|
|
|
|
this.$store.dispatch('dispatchPanelTime', {
|
|
|
|
|
|
time: this.searchTime,
|
|
|
|
|
|
nowTimeType: this.nowTimeType
|
|
|
|
|
|
})
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
obj: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n, o) {
|
2023-03-28 09:16:24 +08:00
|
|
|
|
setTimeout(async () => {
|
2021-04-22 11:47:24 +08:00
|
|
|
|
if (n && n.id) {
|
2022-06-15 14:04:03 +08:00
|
|
|
|
this.searchLabel = {}
|
2021-05-17 20:31:32 +08:00
|
|
|
|
if (this.from === fromRoute.asset) {
|
2021-05-17 19:31:36 +08:00
|
|
|
|
this.searchLabel.assetIds = n.id
|
|
|
|
|
|
}
|
2023-03-28 09:16:24 +08:00
|
|
|
|
this.getTableData(n.id)
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
2021-12-16 18:15:52 +08:00
|
|
|
|
this.chartDetailInfo = n
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}, 500)
|
|
|
|
|
|
}
|
2021-12-16 19:50:23 +08:00
|
|
|
|
},
|
2023-03-28 09:16:24 +08:00
|
|
|
|
showPanel: {
|
|
|
|
|
|
handler () {
|
|
|
|
|
|
this.setDefaultTimeRange()
|
|
|
|
|
|
this.setDefaultRefresh()
|
2021-12-16 19:50:23 +08:00
|
|
|
|
}
|
2022-11-22 19:16:59 +08:00
|
|
|
|
},
|
2023-03-15 15:39:06 +08:00
|
|
|
|
// 监听图表联动配置
|
2022-11-22 19:16:59 +08:00
|
|
|
|
'showPanel.param.chartShare': {
|
|
|
|
|
|
handler (value) {
|
|
|
|
|
|
// 每次切换联动模式 tooltip设置显示
|
|
|
|
|
|
const option = {
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
className: 'chart-time-series'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (const key in chartCache) {
|
|
|
|
|
|
if (!chartCache[key] || chartCache[key].group !== 'timeSeriesGroup') {
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
|
|
|
|
|
chartCache[key].setOption(option)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$store.commit('setCurrentMousemove', 0)
|
|
|
|
|
|
if (value && value !== 'none') {
|
|
|
|
|
|
this.$store.commit('setConnect', value)
|
|
|
|
|
|
echarts.connect('timeSeriesGroup')
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$store.commit('setConnect', value)
|
|
|
|
|
|
echarts.disconnect('timeSeriesGroup')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-03-28 09:16:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
chartRightBoxShow: {
|
|
|
|
|
|
immediate: false,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
if (n) {
|
|
|
|
|
|
this.disposeChart()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$refs.addChartModal.isStable = 'instability'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
delChartFlag: {
|
|
|
|
|
|
immediate: false,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
if (n) {
|
|
|
|
|
|
this.disposeChart()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-02-14 17:46:54 +08:00
|
|
|
|
}
|
2021-04-22 11:47:24 +08:00
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy () {
|
2023-04-12 10:36:22 +08:00
|
|
|
|
bus.$off('refreshPanel')
|
2021-08-05 22:25:55 +08:00
|
|
|
|
document.querySelector('#tableList') && document.querySelector('#tableList').removeEventListener('mouseenter', this.tableListEnter)
|
|
|
|
|
|
document.querySelector('#tableList') && document.querySelector('#tableList').removeEventListener('mouseleave', this.tableListLeave)
|
|
|
|
|
|
this.scrollbarWrap && this.scrollbarWrap.removeEventListener('scroll', bus.debounce)
|
2022-03-11 10:45:19 +08:00
|
|
|
|
this.$store.dispatch('dispatchPanelLock', { flag: true })
|
2022-11-22 19:16:59 +08:00
|
|
|
|
|
|
|
|
|
|
// 页面销毁 清除图表联动
|
|
|
|
|
|
this.$store.commit('setCurrentMousemove', 0)
|
|
|
|
|
|
this.$store.commit('setConnect', 'none')
|
|
|
|
|
|
echarts.disconnect('timeSeriesGroup')
|
2021-04-22 11:47:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|