2022-01-16 23:16:00 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="chart-header" :class="{'chart-header--title-chart': isTitle}">
|
2022-01-20 18:08:01 +08:00
|
|
|
|
<div class="chart-header__title" v-if="!isCurrentTable" :class="{'chart-header__title--block': isBlock}">{{chartInfo.name}}</div>
|
|
|
|
|
|
<template v-if="isCurrentTable">
|
2022-01-19 15:54:27 +08:00
|
|
|
|
<div class="chart-header__title">
|
|
|
|
|
|
<span :title="chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name">{{chartInfo.i18n ? $t(chartInfo.i18n) : chartInfo.name}}</span>
|
|
|
|
|
|
<span
|
|
|
|
|
|
v-if="chartInfo.params && chartInfo.params.as"
|
|
|
|
|
|
class="ip-detail-as"
|
|
|
|
|
|
>
|
|
|
|
|
|
as <span style="text-transform: capitalize">{{chartInfo.params.as}}</span>
|
|
|
|
|
|
</span>
|
2022-01-20 18:08:01 +08:00
|
|
|
|
</div >
|
2022-01-19 15:54:27 +08:00
|
|
|
|
<div class="header__operations">
|
|
|
|
|
|
<el-popover trigger="hover" placement="top" :content="chartInfo.remark" v-if="chartInfo.remark">
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<span class="header__operation-btn"><i class="cn-icon el-icon-info"></i></span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-popover>
|
|
|
|
|
|
<div class="header__operation header__operation--table">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
v-model="table.limit"
|
|
|
|
|
|
class="option__select select-topn"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
popper-class="option-popper"
|
|
|
|
|
|
@change="tableLimitChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option v-for="item in chartTableTopOptions" :key="item" :value="item">TOP {{item}}</el-option>
|
|
|
|
|
|
<template #prefix>TOP </template>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="header__operation header__operation--table">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
v-model="table.orderBy"
|
|
|
|
|
|
class="option__select select-column"
|
|
|
|
|
|
:placeholder="$t('overall.field')"
|
|
|
|
|
|
popper-class="option-popper"
|
|
|
|
|
|
@change="tableLimitChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template v-for="(item, index) in table.tableColumns" :key="item.prop">
|
|
|
|
|
|
<el-option v-if="index > 0" :value="item.prop">{{item.prop}}</el-option>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<span class="header__operation-btn" @click="refresh"><i class="cn-icon cn-icon-refresh"></i></span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2022-01-20 18:08:01 +08:00
|
|
|
|
<template v-else-if="isActiveIpTable">
|
|
|
|
|
|
<div class="header__operations">
|
|
|
|
|
|
<div class="header__operation header__operation--table" >
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
v-model="activeIpTable.orderBy"
|
|
|
|
|
|
class="option__select select-column"
|
|
|
|
|
|
:placeholder="$t('overall.field')"
|
|
|
|
|
|
popper-class="option-popper"
|
|
|
|
|
|
@change="activeIpTableLimitChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template v-for="item in chartActiveIpTableOrderOptions" :key="item">
|
|
|
|
|
|
<el-option :value="item">{{item}}</el-option>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2022-01-16 23:16:00 +08:00
|
|
|
|
<chart-error :isError="isError" :errorInfo="errorInfo"></chart-error>
|
2022-01-20 18:08:01 +08:00
|
|
|
|
<div class="chart-header__tools" v-if="!isTitle && !isTabs && !isCurrentTable && !isActiveIpTable">
|
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-20 18:08:01 +08:00
|
|
|
|
import {isTitle, isTabs, isBlock, isTable, isActiveIpTable, isCurrentTable} 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-20 18:08:01 +08:00
|
|
|
|
import {chartTableTopOptions, chartActiveIpTableOrderOptions} from "@/utils/constants";
|
2022-01-18 23:12:03 +08:00
|
|
|
|
|
2022-01-16 23:16:00 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'ChartHeader',
|
|
|
|
|
|
props: {
|
|
|
|
|
|
chartInfo: Object,
|
|
|
|
|
|
errorInfo: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
isError: {
|
|
|
|
|
|
type: Boolean,
|
|
|
|
|
|
default: false
|
2022-01-19 15:54:27 +08:00
|
|
|
|
},
|
|
|
|
|
|
table: Object
|
2022-01-16 23:16:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
ChartError
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
dropdownMenuShow: false,
|
2022-01-20 18:08:01 +08:00
|
|
|
|
errorText: '',
|
|
|
|
|
|
|
|
|
|
|
|
activeIpTable: { // ActiveIpTable select
|
|
|
|
|
|
orderBy: 'machine',
|
|
|
|
|
|
tableData: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '192.168.20.21',
|
|
|
|
|
|
num: 111
|
|
|
|
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
name: '192.168.20.22',
|
|
|
|
|
|
num: 345
|
|
|
|
|
|
}, {
|
|
|
|
|
|
name: '192.168.20.23',
|
|
|
|
|
|
num: 111
|
|
|
|
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
name: '192.168.20.24',
|
|
|
|
|
|
num: 345
|
|
|
|
|
|
}, {
|
|
|
|
|
|
name: '192.168.20.25',
|
|
|
|
|
|
num: 111
|
|
|
|
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
name: '192.168.20.26',
|
|
|
|
|
|
num: 345
|
|
|
|
|
|
}
|
|
|
|
|
|
] // table的所有数据
|
|
|
|
|
|
},
|
2022-01-16 23:16:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
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-19 15:54:27 +08:00
|
|
|
|
},
|
|
|
|
|
|
tableLimitChange () {
|
|
|
|
|
|
this.$emit('tableChange')
|
2022-01-20 18:08:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
activeIpTableLimitChange () {
|
|
|
|
|
|
this.$emit('tableChange')
|
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-19 15:54:27 +08:00
|
|
|
|
chartTableTopOptions,
|
2022-01-20 18:08:01 +08:00
|
|
|
|
chartActiveIpTableOrderOptions,
|
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-19 15:54:27 +08:00
|
|
|
|
isTabs: isTabs(props.chartInfo.type),
|
2022-01-20 18:08:01 +08:00
|
|
|
|
isTable: isTable(props.chartInfo.type),
|
|
|
|
|
|
isCurrentTable: isCurrentTable(props.chartInfo.type),
|
|
|
|
|
|
isActiveIpTable: isActiveIpTable(props.chartInfo.type),
|
2022-01-16 23:16:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|