2022-01-16 23:16:00 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="chart-header" :class="{'chart-header--title-chart': isTitle}">
|
2022-01-18 23:12:03 +08:00
|
|
|
|
<div class="chart-header__title" :class="{'chart-header__title--block': isBlock}">{{chartInfo.name}}</div>
|
2022-01-16 23:16:00 +08:00
|
|
|
|
<chart-error :isError="isError" :errorInfo="errorInfo"></chart-error>
|
2022-01-17 17:06:14 +08:00
|
|
|
|
<div class="chart-header__tools" v-if="!isTitle && !isTabs">
|
2022-01-18 23:12:03 +08:00
|
|
|
|
<div class="panel__time" v-if="chartInfo.params && chartInfo.params.showTimeTool">
|
|
|
|
|
|
<date-time-range class="date-time-range" :start-time="chartTimeFilter.startTime" :end-time="chartTimeFilter.endTime" ref="dateTimeRange" @change="reload"/>
|
|
|
|
|
|
<time-refresh class="date-time-range" @change="timeRefreshChange" :end-time="chartTimeFilter.endTime"/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<template v-else-if="!isBlock">
|
|
|
|
|
|
<el-popover trigger="click" placement="top" :content="chartInfo.remark" v-if="chartInfo.remark">
|
|
|
|
|
|
<template #reference>
|
|
|
|
|
|
<span class="header__operation-btn"><i class="cn-icon el-icon-info"></i></span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
<span class="header__operation-btn" @click="refresh"><i class="cn-icon cn-icon-refresh"></i></span>
|
|
|
|
|
|
</template>
|
2022-01-16 23:16:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-01-18 23:12:03 +08:00
|
|
|
|
import { isTitle, isTabs, isBlock } from './charts/tools'
|
2022-01-16 23:16:00 +08:00
|
|
|
|
import ChartError from '@/components/charts/ChartError'
|
2022-01-18 23:12:03 +08:00
|
|
|
|
import { getNowTime } from '@/utils/date-util'
|
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
2022-01-16 23:16:00 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'ChartHeader',
|
|
|
|
|
|
props: {
|
|
|
|
|
|
chartInfo: Object,
|
|
|
|
|
|
errorInfo: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
isError: {
|
|
|
|
|
|
type: Boolean,
|
|
|
|
|
|
default: false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
ChartError
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
dropdownMenuShow: false,
|
|
|
|
|
|
errorText: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
refresh () {
|
|
|
|
|
|
this.$emit('refresh')
|
2022-01-18 23:12:03 +08:00
|
|
|
|
},
|
|
|
|
|
|
timeRefreshChange () {
|
|
|
|
|
|
if (!this.$refs.dateTimeRange.isCustom) {
|
|
|
|
|
|
const value = this.chartTimeFilter.dateRangeValue
|
|
|
|
|
|
this.$refs.dateTimeRange.quickChange(value)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
reload (s, e, v) {
|
|
|
|
|
|
this.dateTimeRangeChange(s, e, v)
|
|
|
|
|
|
},
|
|
|
|
|
|
dateTimeRangeChange (s, e, v) {
|
|
|
|
|
|
this.chartTimeFilter = { startTime: s, endTime: e, dateRangeValue: v }
|
2022-01-16 23:16:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
setup (props) {
|
2022-01-18 23:12:03 +08:00
|
|
|
|
const dateRangeValue = 60
|
|
|
|
|
|
const { startTime, endTime } = getNowTime(dateRangeValue)
|
|
|
|
|
|
// entity详情内的chart时间工具不是公共的,需要单独定义
|
|
|
|
|
|
const chartTimeFilter = ref({ startTime, endTime, dateRangeValue })
|
2022-01-16 23:16:00 +08:00
|
|
|
|
return {
|
2022-01-18 23:12:03 +08:00
|
|
|
|
chartTimeFilter,
|
2022-01-17 17:06:14 +08:00
|
|
|
|
isTitle: isTitle(props.chartInfo.type),
|
2022-01-18 23:12:03 +08:00
|
|
|
|
isBlock: isBlock(props.chartInfo.type),
|
2022-01-17 17:06:14 +08:00
|
|
|
|
isTabs: isTabs(props.chartInfo.type)
|
2022-01-16 23:16:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|