2020-04-14 21:46:38 +08:00
|
|
|
<template>
|
2022-04-12 15:54:29 +08:00
|
|
|
<div
|
|
|
|
|
id="panel-calender"
|
|
|
|
|
:class="{ 'calendar--small': size === 'small' }"
|
|
|
|
|
class="calendar"
|
2022-04-13 17:47:09 +08:00
|
|
|
v-clickoutside="changeDropdownFlag"
|
2022-04-12 15:54:29 +08:00
|
|
|
>
|
2022-04-13 16:22:54 +08:00
|
|
|
|
2022-04-12 15:54:29 +08:00
|
|
|
<div @click="showDropdown" class="date-range-text">
|
|
|
|
|
<div class="calendar-popover-text">
|
|
|
|
|
<i class="nz-icon nz-icon-time"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="calendar-popover-text" style="display: flex" v-if="isCustom">
|
|
|
|
|
<div class="calendar-popover-text">
|
2022-04-13 13:11:16 +08:00
|
|
|
{{ searchTime[0] }}
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
2022-04-13 13:11:16 +08:00
|
|
|
<div class="calendar-popover-text">{{ $t("dashboard.panel.to") }}</div>
|
2022-04-12 15:54:29 +08:00
|
|
|
<div class="calendar-popover-text">
|
2022-04-13 13:11:16 +08:00
|
|
|
{{ searchTime[1] }}
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="calendar-popover-text" v-else>
|
2022-04-14 11:51:57 +08:00
|
|
|
<el-tooltip class="item" effect="light" placement="bottom">
|
|
|
|
|
<div slot="content"> {{searchTime[0]}}<br/><p style="text-align:center">{{$t("dashboard.panel.to")}} </p>{{searchTime[1]}}</div>
|
|
|
|
|
<div class="time-no-data">{{ showTime.text }}</div>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
<!-- <div class="time-no-data">{{ showTime.text }}</div> -->
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="calendar-popover-text">
|
2022-04-13 13:11:16 +08:00
|
|
|
<i class="el-icon-arrow-down"></i>
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
<div v-if="dropdownFlag" class="date-range-panel popper-z-index">
|
|
|
|
|
<el-row class="date-range-panel-top" style="position: relative">
|
|
|
|
|
<el-col
|
|
|
|
|
:span="16"
|
|
|
|
|
class="date-range-panel-content date-range-panel-content-left"
|
|
|
|
|
>
|
|
|
|
|
<div class="date-range-title" style="padding-left: 0">
|
2022-04-13 19:06:47 +08:00
|
|
|
{{$t('timepicker.timerange')}}
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
|
|
|
|
<my-date-picker
|
2022-04-13 13:11:16 +08:00
|
|
|
prefix-icon=" "
|
|
|
|
|
class="panel-time-picker-hidden"
|
|
|
|
|
size="mini"
|
|
|
|
|
ref="calendar"
|
|
|
|
|
:format="timeFormatStrToDatePickFormat(timeFormatMain)"
|
|
|
|
|
@change="dateChange(whoChoose)"
|
|
|
|
|
v-model="searchTimeValue"
|
|
|
|
|
type="date"
|
|
|
|
|
popper-class="panel-time-picker-popper time-picker-popover__select-top"
|
|
|
|
|
align="right"
|
|
|
|
|
>
|
|
|
|
|
</my-date-picker>
|
|
|
|
|
|
2022-04-13 19:06:47 +08:00
|
|
|
<div class="content-title">{{$t('dashboard.panel.chartForm.valMapping.from')}}</div>
|
2022-04-13 13:11:16 +08:00
|
|
|
<div @click="myDatePickerShow('start')" tabindex="1" class="content-input">
|
2022-04-13 19:06:47 +08:00
|
|
|
<el-input v-model="searchTime[0]" @change="dateChange('start',searchTime[0])"> </el-input>
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
2022-04-13 19:06:47 +08:00
|
|
|
<div class="content-title">{{$t('dashboard.panel.chartForm.valMapping.to')}}</div>
|
2022-04-13 13:11:16 +08:00
|
|
|
<div @click="myDatePickerShow('end')" tabindex="2" class="content-input">
|
2022-04-13 19:06:47 +08:00
|
|
|
<el-input v-model="searchTime[1]" @change="dateChange('end',searchTime[1])"> </el-input>
|
2022-04-13 13:11:16 +08:00
|
|
|
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
|
|
|
|
<div>
|
2022-04-13 13:11:16 +08:00
|
|
|
<el-button
|
|
|
|
|
@click="timeRange(searchTime)"
|
|
|
|
|
type="primary"
|
|
|
|
|
size="mini"
|
2022-04-13 17:47:09 +08:00
|
|
|
class="time-range-button el-button--primary"
|
2022-04-13 19:06:47 +08:00
|
|
|
>{{$t('timepicker.applytimerange')}}</el-button
|
2022-04-12 15:54:29 +08:00
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="date-range-title" style="padding-left: 0">
|
2022-04-13 19:06:47 +08:00
|
|
|
{{$t('timepicker.recentlyUsed')}}
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="date-range-history">
|
|
|
|
|
<div
|
|
|
|
|
v-for="(item, index) in rangeHistoryArr"
|
|
|
|
|
:key="index"
|
|
|
|
|
class="date-range-history-item"
|
|
|
|
|
@click="historyChange(item)"
|
|
|
|
|
>
|
2022-04-13 13:11:16 +08:00
|
|
|
{{ timeFormate(item.start) }}
|
2022-04-13 19:06:47 +08:00
|
|
|
{{ $t("dashboard.panel.to") }}
|
2022-04-13 13:11:16 +08:00
|
|
|
{{ timeFormate(item.end) }}
|
2022-04-12 15:54:29 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col
|
|
|
|
|
:span="8"
|
|
|
|
|
class="date-range-panel-content date-range-panel-content-right"
|
|
|
|
|
style="border-left: 1px solid rgba(0, 0, 0, 0.09)"
|
|
|
|
|
>
|
2022-04-13 19:06:47 +08:00
|
|
|
<div class="date-range-title">{{$t('timepicker.relatime')}}</div>
|
2022-04-12 15:54:29 +08:00
|
|
|
<ul class="date-range-item">
|
|
|
|
|
<li
|
2022-04-13 13:11:16 +08:00
|
|
|
v-for="(item, key) in timeData"
|
2022-04-12 15:54:29 +08:00
|
|
|
@click="timeChange(item)"
|
2022-04-12 20:05:18 +08:00
|
|
|
:class="showTime.id === item.id ? 'active' : ''"
|
2022-04-12 15:54:29 +08:00
|
|
|
:key="key"
|
2022-04-14 11:51:57 +08:00
|
|
|
:v-if="item.id !== 12 || showEmpty"
|
|
|
|
|
|
2022-04-12 15:54:29 +08:00
|
|
|
>
|
2022-04-13 13:11:16 +08:00
|
|
|
<span
|
|
|
|
|
style="position: relative"
|
|
|
|
|
v-if="item.id !== 12 || showEmpty"
|
2022-04-12 20:05:18 +08:00
|
|
|
>
|
2022-04-12 15:54:29 +08:00
|
|
|
{{ item.text }}
|
|
|
|
|
<i
|
2022-04-13 13:11:16 +08:00
|
|
|
v-if="showTime.id === item.id"
|
2022-04-12 20:05:18 +08:00
|
|
|
class="nz-icon nz-icon-check"
|
2022-04-12 15:54:29 +08:00
|
|
|
></i>
|
|
|
|
|
</span>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row class="date-range-panel-bottom" style="">
|
|
|
|
|
<el-col :span="12">{{ address }}</el-col>
|
2022-04-13 15:57:03 +08:00
|
|
|
<el-col :span="12" class="utc-str">
|
|
|
|
|
<span>
|
|
|
|
|
{{ utcStr }}
|
|
|
|
|
</span>
|
|
|
|
|
</el-col>
|
2022-04-12 15:54:29 +08:00
|
|
|
</el-row>
|
|
|
|
|
</div>
|
|
|
|
|
</transition>
|
2020-04-14 21:46:38 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-04-13 16:22:54 +08:00
|
|
|
import bus from '@/libs/bus'
|
2020-04-14 21:46:38 +08:00
|
|
|
|
|
|
|
|
export default {
|
2022-04-13 16:22:54 +08:00
|
|
|
name: 'timePicker',
|
2020-04-14 21:46:38 +08:00
|
|
|
props: {
|
2021-03-19 18:52:19 +08:00
|
|
|
defaultPick: Number,
|
2021-04-12 13:00:59 +08:00
|
|
|
showEmpty: { default: false, type: Boolean },
|
|
|
|
|
size: {
|
2022-04-13 16:22:54 +08:00
|
|
|
type: String
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
sign: [Number, String]
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
data () {
|
2022-04-12 20:05:18 +08:00
|
|
|
return {
|
2022-04-13 16:22:54 +08:00
|
|
|
whoChoose: '',
|
|
|
|
|
searchTimeValue: '',
|
2022-04-13 13:11:16 +08:00
|
|
|
rangeHistory: [],
|
2022-04-12 20:05:18 +08:00
|
|
|
rangeHistoryArr: [],
|
2022-04-13 16:22:54 +08:00
|
|
|
address: '',
|
|
|
|
|
utc: localStorage.getItem('timezoneOffset'),
|
|
|
|
|
utcStr: '',
|
2022-04-13 13:11:16 +08:00
|
|
|
dropdownFlag: false,
|
|
|
|
|
isPopoverDisabled: false,
|
|
|
|
|
isCustom: false,
|
|
|
|
|
searchTime: [
|
|
|
|
|
bus.timeFormate(bus.getOffsetTimezoneData(-1)),
|
2022-04-13 16:22:54 +08:00
|
|
|
bus.timeFormate(bus.getOffsetTimezoneData())
|
2022-04-13 13:11:16 +08:00
|
|
|
],
|
|
|
|
|
showTime: {
|
|
|
|
|
id: 4,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastOneHour')
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
timeData: [
|
|
|
|
|
// {
|
|
|
|
|
// id: 0,
|
|
|
|
|
// text: this.$t("dashboard.panel.customTimeRange"),
|
|
|
|
|
// value: -1,
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
id: 12,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.noDate'),
|
|
|
|
|
value: 0
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastFiveMin'),
|
|
|
|
|
type: 'minute',
|
|
|
|
|
value: 5
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 2,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastFifteenMin'),
|
|
|
|
|
type: 'minute',
|
|
|
|
|
value: 15
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 3,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastThirtyMin'),
|
|
|
|
|
type: 'minute',
|
|
|
|
|
value: 30
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2022-04-13 13:11:16 +08:00
|
|
|
{
|
2022-04-12 15:54:29 +08:00
|
|
|
id: 4,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastOneHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 1
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2022-04-13 13:11:16 +08:00
|
|
|
{
|
|
|
|
|
id: 5,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastThreeHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 3
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 6,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastSixHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 6
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 7,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastTwelveHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 12
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 8,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastTwentyFourHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 24
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 9,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastTwoDay'),
|
|
|
|
|
type: 'date',
|
|
|
|
|
value: 2
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 10,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastSevenDay'),
|
|
|
|
|
type: 'date',
|
|
|
|
|
value: 7
|
2022-04-13 13:11:16 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 11,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastThirtyDay'),
|
|
|
|
|
type: 'date',
|
|
|
|
|
value: 30
|
|
|
|
|
}
|
2022-04-13 13:11:16 +08:00
|
|
|
],
|
|
|
|
|
nowTimeType: {
|
|
|
|
|
id: 4,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastOneHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 1
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-12 20:05:18 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
mounted () {
|
|
|
|
|
this.getItem()
|
|
|
|
|
this.getUtcStr()
|
|
|
|
|
this.getRangeHistoryArr()
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2022-04-13 17:47:09 +08:00
|
|
|
changeDropdownFlag(){
|
|
|
|
|
if (this.dropdownFlag) {
|
|
|
|
|
this.dropdownFlag = false
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
getItem () {
|
|
|
|
|
this.rangeHistory = localStorage.getItem('date-range-history' + this.sign)
|
|
|
|
|
? JSON.parse(localStorage.getItem('date-range-history' + this.sign))
|
|
|
|
|
: []
|
|
|
|
|
this.address = localStorage.getItem('nz-sys-timezone')
|
|
|
|
|
this.utc = localStorage.getItem('timezoneOffset')
|
2022-04-12 20:05:18 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
myDatePickerShow (item) {
|
2022-04-13 13:11:16 +08:00
|
|
|
this.whoChoose = item
|
2022-04-14 11:51:57 +08:00
|
|
|
this.isCustom = true
|
|
|
|
|
this.$refs.calendar.focus()
|
|
|
|
|
this.$refs.calendar.pickerVisible = true
|
|
|
|
|
if (document.getElementById('viewGraphDialog')) {
|
|
|
|
|
// 处理 多弹出的z-index的问题 当前为 alertMessage的处理
|
|
|
|
|
const viewGraphDialogStyle = window.getComputedStyle(
|
|
|
|
|
document.getElementById('viewGraphDialog', null)
|
|
|
|
|
)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (viewGraphDialogStyle['z-index'] !== 'auto') {
|
|
|
|
|
const dom =
|
|
|
|
|
document.getElementsByClassName('el-picker-panel')
|
|
|
|
|
Array.prototype.forEach.call(dom, function (element) {
|
|
|
|
|
element.style['z-index'] =
|
|
|
|
|
viewGraphDialogStyle['z-index'] + 1
|
|
|
|
|
})
|
|
|
|
|
this.$refs.calendar.$el.style['z-index'] =
|
|
|
|
|
viewGraphDialogStyle['z-index'] + 1
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
historyChange (item) {
|
|
|
|
|
this.searchTime[0] = item.start
|
|
|
|
|
this.searchTime[1] = item.end
|
|
|
|
|
this.isCustom = true
|
|
|
|
|
this.showDropdown()
|
|
|
|
|
this.$emit('change', this.searchTime)
|
|
|
|
|
this.setSearchTime('', '', this.searchTime)
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
getRangeHistoryArr () {
|
2022-04-13 13:11:16 +08:00
|
|
|
const arr = this.rangeHistory.slice(0, 3)
|
|
|
|
|
this.rangeHistoryArr = arr
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
getUtcStr () {
|
|
|
|
|
const str = 'UTC '
|
|
|
|
|
this.utcStr = str + this.utc
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
timeRange (item) {
|
|
|
|
|
this.showTime = this.nowTimeType = {
|
|
|
|
|
id: 0,
|
|
|
|
|
text: this.$t('dashboard.panel.customTimeRange'),
|
|
|
|
|
value: -1
|
|
|
|
|
}
|
|
|
|
|
this.isCustom = true
|
2022-04-12 20:05:18 +08:00
|
|
|
this.rangeHistory.unshift({
|
|
|
|
|
start: item[0],
|
2022-04-13 16:22:54 +08:00
|
|
|
end: item[1]
|
|
|
|
|
})
|
2022-04-13 13:11:16 +08:00
|
|
|
localStorage.setItem(
|
2022-04-13 16:22:54 +08:00
|
|
|
'date-range-history' + this.sign,
|
2022-04-13 13:11:16 +08:00
|
|
|
JSON.stringify(this.rangeHistory)
|
2022-04-13 16:22:54 +08:00
|
|
|
)
|
|
|
|
|
this.$set(this.searchTime, 2, '')
|
|
|
|
|
this.showDropdown()
|
2022-04-13 13:11:16 +08:00
|
|
|
this.getRangeHistoryArr()
|
2022-04-13 16:22:54 +08:00
|
|
|
this.setSearchTime('', '', this.searchTime)
|
|
|
|
|
this.$emit('change', this.searchTime)
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
showDropdown () {
|
|
|
|
|
this.dropdownFlag = !this.dropdownFlag
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
dateChange (type, v) {
|
|
|
|
|
if (type == 'start') {
|
|
|
|
|
if (!v) {
|
|
|
|
|
const startTime = bus.timeFormate(this.searchTimeValue).trim().split(' ')[0] + ' '
|
|
|
|
|
this.$set(this.searchTime, 0, startTime)
|
|
|
|
|
} else {
|
|
|
|
|
const str = v.trim().split(' ')[1]
|
|
|
|
|
const reg = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
|
|
|
|
|
if (reg.test(str)) {
|
2022-04-13 13:11:16 +08:00
|
|
|
const startTime = bus.timeFormate(v)
|
2022-04-13 16:22:54 +08:00
|
|
|
this.$set(this.searchTime, 0, startTime)
|
|
|
|
|
} else {
|
|
|
|
|
this.$set(this.searchTime, 0, '')
|
2022-04-13 13:11:16 +08:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-13 16:22:54 +08:00
|
|
|
} else if (type == 'end') {
|
|
|
|
|
if (!v) {
|
|
|
|
|
const endTime = bus.timeFormate(this.searchTimeValue).trim().split(' ')[0] + ' '
|
|
|
|
|
this.$set(this.searchTime, 1, endTime)
|
|
|
|
|
} else {
|
|
|
|
|
const str = v.trim().split(' ')[1]
|
|
|
|
|
const reg = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
|
|
|
|
|
if (reg.test(str)) {
|
2022-04-13 13:11:16 +08:00
|
|
|
const endTime = bus.timeFormate(v)
|
2022-04-13 16:22:54 +08:00
|
|
|
this.$set(this.searchTime, 1, endTime)
|
|
|
|
|
} else {
|
|
|
|
|
this.$set(this.searchTime, 1, '')
|
2022-04-13 13:11:16 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.searchTime[2] = ''
|
2022-04-13 16:22:54 +08:00
|
|
|
this.$set(this.showTime, 'id', 0)
|
2022-04-12 15:54:29 +08:00
|
|
|
this.$set(
|
|
|
|
|
this.showTime,
|
2022-04-13 16:22:54 +08:00
|
|
|
'text',
|
2022-04-12 15:54:29 +08:00
|
|
|
this.searchTime[0] +
|
2022-04-13 16:22:54 +08:00
|
|
|
' ' +
|
|
|
|
|
this.$t('dashboard.panel.to') +
|
|
|
|
|
' ' +
|
2022-04-12 15:54:29 +08:00
|
|
|
this.searchTime[1]
|
2022-04-13 16:22:54 +08:00
|
|
|
)
|
2020-04-24 17:00:56 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
setCustomTime (timeGroup, timeRange) {
|
2021-03-31 11:10:04 +08:00
|
|
|
if (timeGroup) {
|
2022-04-12 15:54:29 +08:00
|
|
|
this.showTime = this.nowTimeType = this.timeData.find(
|
|
|
|
|
(item) => item.id == timeGroup.id
|
2022-04-13 16:22:54 +08:00
|
|
|
)
|
2021-03-31 11:10:04 +08:00
|
|
|
if (this.showTime) {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.showTime = Object.assign({}, this.showTime)
|
|
|
|
|
this.$set(this.searchTime, 0, timeGroup.start_time)
|
|
|
|
|
this.$set(this.searchTime, 1, timeGroup.end_time)
|
2021-03-31 11:10:04 +08:00
|
|
|
} else {
|
2022-04-14 11:51:57 +08:00
|
|
|
// const time = this.searchTime.splice(' ')
|
2022-04-13 13:11:16 +08:00
|
|
|
// this.showTime = this.nowTimeType = {
|
2022-04-14 11:51:57 +08:00
|
|
|
// text: time[0] + ' ' + this.$t('dashboard.panel.to') + ' ' + time[1]
|
2022-04-13 13:11:16 +08:00
|
|
|
// }
|
2022-04-14 11:51:57 +08:00
|
|
|
// this.$set(this.searchTime, 0, bus.timeFormate(time[0]))
|
|
|
|
|
// this.$set(this.searchTime, 1, bus.timeFormate(time[1]))
|
|
|
|
|
this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time));
|
|
|
|
|
this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time));
|
|
|
|
|
this.showTime = this.nowTimeType = {
|
|
|
|
|
id: 4,
|
|
|
|
|
text: this.$t("dashboard.panel.lastOneHour"),
|
|
|
|
|
type: "hour",
|
|
|
|
|
value: 1,
|
|
|
|
|
};
|
|
|
|
|
const time = bus.getTimezontDateRange();
|
|
|
|
|
if (timeGroup.start_time) {
|
|
|
|
|
this.$set(
|
|
|
|
|
this.searchTime,
|
|
|
|
|
0,
|
|
|
|
|
bus.timeFormate(timeGroup.start_time)
|
|
|
|
|
);
|
|
|
|
|
this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time));
|
|
|
|
|
} else {
|
|
|
|
|
this.$set(this.searchTime, 0, bus.timeFormate(time[0]));
|
|
|
|
|
this.$set(this.searchTime, 1, bus.timeFormate(time[1]));
|
|
|
|
|
}
|
|
|
|
|
this.$set(this.searchTime, 0, bus.timeFormate(time[0]));
|
2021-03-31 11:10:04 +08:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.showTime = this.nowTimeType = {
|
|
|
|
|
id: 4,
|
2022-04-13 16:22:54 +08:00
|
|
|
text: this.$t('dashboard.panel.lastOneHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 1
|
|
|
|
|
}
|
|
|
|
|
const time = bus.getTimezontDateRange()
|
|
|
|
|
this.$set(this.searchTime, 0, time[0])
|
|
|
|
|
this.$set(this.searchTime, 1, time[1])
|
2020-04-24 17:00:56 +08:00
|
|
|
}
|
|
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
timeChange (val, from) {
|
|
|
|
|
this.nowTimeType = val
|
|
|
|
|
this.$set(this.showTime, 'id', val.id)
|
|
|
|
|
this.$set(this.showTime, 'text', val.text)
|
2020-04-14 21:46:38 +08:00
|
|
|
if (!val) {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.isCustom = false
|
|
|
|
|
return false
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.setSearchTime(val.type, val.value)
|
2020-04-17 08:15:13 +08:00
|
|
|
|
2022-04-13 16:22:54 +08:00
|
|
|
const id = val.id
|
2022-04-12 15:54:29 +08:00
|
|
|
if (id === 0) {
|
|
|
|
|
// custom
|
2022-04-13 16:22:54 +08:00
|
|
|
if (from === 'chart') {
|
|
|
|
|
this.isCustom = false
|
|
|
|
|
this.$emit('change', this.searchTime)
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.isCustom = true
|
|
|
|
|
this.$refs.calendar.focus()
|
|
|
|
|
this.$refs.calendar.pickerVisible = true
|
|
|
|
|
if (document.getElementById('viewGraphDialog')) {
|
2022-04-12 15:54:29 +08:00
|
|
|
// 处理 多弹出的z-index的问题 当前为 alertMessage的处理
|
|
|
|
|
const viewGraphDialogStyle = window.getComputedStyle(
|
2022-04-13 16:22:54 +08:00
|
|
|
document.getElementById('viewGraphDialog', null)
|
|
|
|
|
)
|
2021-10-29 14:53:38 +08:00
|
|
|
setTimeout(() => {
|
2022-04-13 16:22:54 +08:00
|
|
|
if (viewGraphDialogStyle['z-index'] !== 'auto') {
|
2022-04-12 15:54:29 +08:00
|
|
|
const dom =
|
2022-04-13 16:22:54 +08:00
|
|
|
document.getElementsByClassName('el-picker-panel')
|
2021-10-29 14:53:38 +08:00
|
|
|
Array.prototype.forEach.call(dom, function (element) {
|
2022-04-13 16:22:54 +08:00
|
|
|
element.style['z-index'] =
|
|
|
|
|
viewGraphDialogStyle['z-index'] + 1
|
|
|
|
|
})
|
|
|
|
|
this.$refs.calendar.$el.style['z-index'] =
|
|
|
|
|
viewGraphDialogStyle['z-index'] + 1
|
2021-10-29 14:53:38 +08:00
|
|
|
}
|
2022-04-13 16:22:54 +08:00
|
|
|
})
|
2021-10-29 14:53:38 +08:00
|
|
|
}
|
2020-10-12 18:15:24 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
2022-04-14 11:51:57 +08:00
|
|
|
this.isCustom = false;
|
2022-04-13 13:11:16 +08:00
|
|
|
this.showDropdown()
|
2021-03-19 18:52:19 +08:00
|
|
|
if (this.showEmpty && id === 12) {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.searchTime = []
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
2022-04-13 16:22:54 +08:00
|
|
|
this.$emit('change', this.searchTime)
|
2020-04-17 08:15:13 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
getCurrentTime () {
|
|
|
|
|
return this.searchTime
|
2022-04-13 13:11:16 +08:00
|
|
|
// let timeTypeId = this.showTime.id;
|
|
|
|
|
// if (timeTypeId === 0) {
|
|
|
|
|
// return this.searchTime;
|
|
|
|
|
// } else {
|
|
|
|
|
// if (!timeTypeId) {
|
|
|
|
|
// timeTypeId = 4;
|
|
|
|
|
// }
|
|
|
|
|
// const currentTime = this.timeData.find(
|
|
|
|
|
// (item) => item.id === timeTypeId
|
|
|
|
|
// );
|
|
|
|
|
// this.setSearchTime(currentTime.type, currentTime.value);
|
|
|
|
|
// return this.searchTime;
|
|
|
|
|
// }
|
2020-05-21 09:03:30 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
setSearchTime (type, val, time) {
|
|
|
|
|
if (type === 'minute') {
|
2022-04-12 15:54:29 +08:00
|
|
|
const startTime = bus.timeFormate(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime())).setMinutes(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime())).getMinutes() -
|
|
|
|
|
val
|
|
|
|
|
)
|
2022-04-13 16:22:54 +08:00
|
|
|
)
|
2022-04-12 15:54:29 +08:00
|
|
|
const endTime = bus.timeFormate(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime()))
|
2022-04-13 16:22:54 +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-12 15:54:29 +08:00
|
|
|
const startTime = bus.timeFormate(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime())).setHours(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime())).getHours() - val
|
|
|
|
|
)
|
2022-04-13 16:22:54 +08:00
|
|
|
)
|
2022-04-12 15:54:29 +08:00
|
|
|
const endTime = bus.timeFormate(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime()))
|
2022-04-13 16:22:54 +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-12 15:54:29 +08:00
|
|
|
const startTime = bus.timeFormate(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime())).setDate(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime())).getDate() - val
|
|
|
|
|
)
|
2022-04-13 16:22:54 +08:00
|
|
|
)
|
2022-04-12 15:54:29 +08:00
|
|
|
const endTime = bus.timeFormate(
|
|
|
|
|
new Date(bus.computeTimezone(new Date().getTime()))
|
2022-04-13 16:22:54 +08:00
|
|
|
)
|
|
|
|
|
this.$set(this.searchTime, 0, startTime)
|
|
|
|
|
this.$set(this.searchTime, 1, endTime)
|
|
|
|
|
this.$set(this.searchTime, 2, val + 'd')
|
|
|
|
|
} else {
|
|
|
|
|
this.$set(this.searchTime, 0, time[0])
|
|
|
|
|
this.$set(this.searchTime, 1, time[1])
|
2020-04-17 08:15:13 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
setCostomTime: function (costomTime) {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.searchTime = Object.assign(costomTime)
|
|
|
|
|
const val = Object.assign(this.timeData[0])
|
|
|
|
|
this.$set(this.showTime, 'id', val.id)
|
|
|
|
|
this.$set(this.showTime, 'text', val.text)
|
2020-04-24 19:57:04 +08:00
|
|
|
},
|
2022-04-13 16:22:54 +08:00
|
|
|
popoverClick (val) {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (val) {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.isPopoverDisabled = true
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.isPopoverDisabled = false
|
2020-04-14 21:46:38 +08:00
|
|
|
}
|
2022-04-13 16:22:54 +08:00
|
|
|
}
|
2020-10-12 18:15:24 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
watch: {
|
|
|
|
|
defaultPick: {
|
|
|
|
|
immediate: true,
|
2022-04-13 16:22:54 +08:00
|
|
|
handler (n, o) {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (n && Number.isInteger(n)) {
|
2022-04-13 16:22:54 +08:00
|
|
|
const showTime = this.timeData.find((item) => item.id == n)
|
2021-03-19 18:52:19 +08:00
|
|
|
if (showTime) {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.showTime = Object.assign({}, showTime)
|
|
|
|
|
this.searchTime = this.$parent.searchTime
|
2020-10-12 18:15:24 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
if (this.showEmpty && this.defaultPick === 12) {
|
2022-04-13 16:22:54 +08:00
|
|
|
this.searchTime = []
|
2020-10-12 18:15:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-13 16:22:54 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
</script>
|