2020-04-14 21:46:38 +08:00
|
|
|
<template>
|
2021-04-12 13:00:59 +08:00
|
|
|
<div id="panel-calender" :class="{'calendar--small': size === 'small'}" class="calendar">
|
2021-04-28 15:18:21 +08:00
|
|
|
<my-date-picker prefix-icon=" " class="panel-time-picker-hidden " size="mini" ref="calendar"
|
2022-01-04 15:00:36 +08:00
|
|
|
:value-format="timeFormatStrToDatePickFormat(timeFormatMain)"
|
|
|
|
|
:format="timeFormatStrToDatePickFormat(timeFormatMain)" @change="dateChange" v-model="searchTime" type="datetimerange"
|
2021-10-29 12:02:34 +08:00
|
|
|
popper-class="panel-time-picker-popper time-picker-popover__select-top"
|
2021-11-30 16:47:35 +08:00
|
|
|
:default-time="['00:00:00', '23:59:59']"
|
2020-04-24 17:00:56 +08:00
|
|
|
:range-separator="$t('dashboard.panel.to')"
|
|
|
|
|
:start-placeholder="$t('dashboard.panel.startTime')"
|
|
|
|
|
:end-placeholder="$t('dashboard.panel.endTime')" align="right">
|
2021-04-28 15:18:21 +08:00
|
|
|
</my-date-picker>
|
2021-04-12 13:00:59 +08:00
|
|
|
<el-dropdown ref="timePickerDropdown" class="calendar-dropdown-title" trigger="click" @command="timeChange" @visible-change="popoverClick">
|
2020-04-14 21:46:38 +08:00
|
|
|
<el-popover
|
|
|
|
|
placement="bottom-end"
|
2020-04-17 08:15:13 +08:00
|
|
|
min-width="120px"
|
|
|
|
|
:visible-arrow="false"
|
|
|
|
|
:disabled="isPopoverDisabled"
|
|
|
|
|
trigger="hover"
|
2021-10-29 12:02:34 +08:00
|
|
|
popper-class="popper-z-index right-box-select-top right-public-box-dropdown-top"
|
2020-04-17 08:15:13 +08:00
|
|
|
id="panel-calender-popover">
|
2020-10-12 18:15:24 +08:00
|
|
|
<template v-if="this.searchTime&&this.searchTime.length>1">
|
|
|
|
|
<el-row :gutter="10" class="calendar-popover">
|
|
|
|
|
<el-col :span="24" class="calendar-popover-text">{{searchTime[0]}}</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="10" class="calendar-popover">
|
|
|
|
|
<el-col :span="24" class="calendar-popover-text">{{$t('dashboard.panel.to')}}</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="10" class="calendar-popover">
|
|
|
|
|
<el-col :span="24" class="calendar-popover-text">{{searchTime[1]}}</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
2021-11-04 09:29:01 +08:00
|
|
|
<div class="time-no-data">{{$t("dashboard.panel.noDate")}}</div>
|
2020-10-12 18:15:24 +08:00
|
|
|
</template>
|
2020-04-24 17:00:56 +08:00
|
|
|
<div class="el-dropdown-link" slot="reference">
|
2020-09-10 17:00:32 +08:00
|
|
|
<i class="nz-icon nz-icon-time" style="width:20px;"></i>
|
2020-04-24 17:00:56 +08:00
|
|
|
<span class="panel-list-title" id="timePickerContent">{{showTime.text}}</span>
|
2021-03-05 20:34:58 +08:00
|
|
|
<span class="dropdown--suffix">
|
|
|
|
|
<i class="el-icon-arrow-down"></i>
|
|
|
|
|
</span>
|
2020-04-24 17:00:56 +08:00
|
|
|
</div>
|
2020-04-14 21:46:38 +08:00
|
|
|
</el-popover>
|
2021-09-26 11:56:36 +08:00
|
|
|
<el-dropdown-menu class="nz-dashboard-dropdown popper-z-index" style="margin-top: 5px" slot="dropdown">
|
2021-03-19 18:52:19 +08:00
|
|
|
<template v-for="(item, index) in timeData" >
|
|
|
|
|
<el-dropdown-item v-if="item.id !== 12 || showEmpty" :key="index" :class="showTime.id === item.id ? 'nz-dashboard-dropdown-bg' : ''" :command="item">
|
2020-10-12 18:15:24 +08:00
|
|
|
{{item.text}}
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
</template>
|
|
|
|
|
|
2020-04-14 21:46:38 +08:00
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-04-12 13:00:59 +08:00
|
|
|
import bus from '@/libs/bus'
|
2020-04-14 21:46:38 +08:00
|
|
|
|
|
|
|
|
export default {
|
2021-03-19 18:52:19 +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: {
|
|
|
|
|
type: String
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
data () {
|
2020-04-14 21:46:38 +08:00
|
|
|
return {
|
2021-03-19 18:52:19 +08:00
|
|
|
isPopoverDisabled: false,
|
|
|
|
|
isCustom: false,
|
2021-12-31 10:10:39 +08:00
|
|
|
searchTime: [
|
2022-01-04 16:26:15 +08:00
|
|
|
bus.timeFormate(bus.getOffsetTimezoneData(-1)),
|
|
|
|
|
bus.timeFormate(bus.getOffsetTimezoneData())
|
2021-12-31 10:10:39 +08:00
|
|
|
],
|
2020-04-14 21:46:38 +08:00
|
|
|
showTime: {
|
2020-04-27 22:17:31 +08:00
|
|
|
id: 4,
|
2021-03-19 18:52:19 +08:00
|
|
|
text: this.$t('dashboard.panel.lastOneHour')
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
timeData: [
|
2020-04-17 08:15:13 +08:00
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 0,
|
2021-03-31 10:02:12 +08:00
|
|
|
text: this.$t('dashboard.panel.customTimeRange'),
|
|
|
|
|
value: -1
|
2020-04-17 08:15:13 +08:00
|
|
|
},
|
2020-10-12 18:15:24 +08:00
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 12,
|
2021-03-31 10:02:12 +08:00
|
|
|
text: this.$t('dashboard.panel.noDate'),
|
|
|
|
|
value: 0
|
2020-10-12 18:15:24 +08:00
|
|
|
},
|
2020-04-14 21:46:38 +08:00
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 1,
|
|
|
|
|
text: this.$t('dashboard.panel.lastFiveMin'),
|
|
|
|
|
type: 'minute',
|
|
|
|
|
value: 5
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 2,
|
|
|
|
|
text: this.$t('dashboard.panel.lastFifteenMin'),
|
|
|
|
|
type: 'minute',
|
|
|
|
|
value: 15
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 3,
|
|
|
|
|
text: this.$t('dashboard.panel.lastThirtyMin'),
|
|
|
|
|
type: 'minute',
|
|
|
|
|
value: 30
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 4,
|
|
|
|
|
text: this.$t('dashboard.panel.lastOneHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 1
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 5,
|
|
|
|
|
text: this.$t('dashboard.panel.lastThreeHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 3
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 6,
|
|
|
|
|
text: this.$t('dashboard.panel.lastSixHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 6
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 7,
|
|
|
|
|
text: this.$t('dashboard.panel.lastTwelveHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 12
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 8,
|
|
|
|
|
text: this.$t('dashboard.panel.lastTwentyFourHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 24
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 9,
|
|
|
|
|
text: this.$t('dashboard.panel.lastTwoDay'),
|
|
|
|
|
type: 'date',
|
|
|
|
|
value: 2
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 10,
|
|
|
|
|
text: this.$t('dashboard.panel.lastSevenDay'),
|
|
|
|
|
type: 'date',
|
|
|
|
|
value: 7
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
2021-03-19 18:52:19 +08:00
|
|
|
id: 11,
|
|
|
|
|
text: this.$t('dashboard.panel.lastThirtyDay'),
|
|
|
|
|
type: 'date',
|
|
|
|
|
value: 30
|
2020-04-14 21:46:38 +08:00
|
|
|
}
|
|
|
|
|
],
|
2021-03-19 18:52:19 +08:00
|
|
|
nowTimeType: {
|
|
|
|
|
id: 4,
|
|
|
|
|
text: this.$t('dashboard.panel.lastOneHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 1
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2021-03-19 18:52:19 +08:00
|
|
|
dateChange (val) {
|
2022-01-04 16:26:15 +08:00
|
|
|
const startTime = bus.timeFormate(val[0])
|
|
|
|
|
const endTime = bus.timeFormate(val[1])
|
2021-03-19 18:52:19 +08:00
|
|
|
this.$set(this.searchTime, 0, startTime)
|
|
|
|
|
this.$set(this.searchTime, 1, endTime)
|
2020-04-24 17:00:56 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
this.$set(this.showTime, 'id', 0)
|
|
|
|
|
this.$set(this.showTime, 'text', this.searchTime[0] + ' ' + this.$t('dashboard.panel.to') + ' ' + this.searchTime[1])
|
|
|
|
|
this.$emit('change', this.searchTime)
|
2020-04-24 17:00:56 +08:00
|
|
|
},
|
2021-12-24 10:20:19 +08:00
|
|
|
setCustomTime (timeGroup, timeRange) {
|
2021-03-31 11:10:04 +08:00
|
|
|
if (timeGroup) {
|
|
|
|
|
this.showTime = this.nowTimeType = this.timeData.find(item => item.id == timeGroup.id)
|
|
|
|
|
if (this.showTime) {
|
2021-04-01 09:48:03 +08:00
|
|
|
this.showTime = Object.assign({}, this.showTime)
|
2021-03-31 11:10:04 +08:00
|
|
|
this.$set(this.searchTime, 0, timeGroup.start_time)
|
|
|
|
|
this.$set(this.searchTime, 1, timeGroup.end_time)
|
|
|
|
|
} else {
|
2021-03-31 10:02:12 +08:00
|
|
|
this.showTime = this.nowTimeType = {
|
2021-03-31 11:10:04 +08:00
|
|
|
id: 4,
|
|
|
|
|
text: this.$t('dashboard.panel.lastOneHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 1
|
2021-03-31 10:02:12 +08:00
|
|
|
}
|
2021-03-31 11:10:04 +08:00
|
|
|
const time = bus.getTimezontDateRange()
|
2021-12-24 10:20:19 +08:00
|
|
|
if (timeGroup.start_time) {
|
2022-01-04 16:26:15 +08:00
|
|
|
this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time))
|
|
|
|
|
this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time))
|
2021-12-24 10:20:19 +08:00
|
|
|
} else {
|
2022-01-04 16:26:15 +08:00
|
|
|
this.$set(this.searchTime, 0, bus.timeFormate(time[0]))
|
|
|
|
|
this.$set(this.searchTime, 1, bus.timeFormate(time[1]))
|
2021-12-24 10:20:19 +08:00
|
|
|
}
|
2021-03-31 11:10:04 +08:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.showTime = this.nowTimeType = {
|
|
|
|
|
id: 4,
|
|
|
|
|
text: this.$t('dashboard.panel.lastOneHour'),
|
|
|
|
|
type: 'hour',
|
|
|
|
|
value: 1
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
2021-03-31 11:10:04 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +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) {
|
2021-03-19 18:52:19 +08:00
|
|
|
this.isCustom = false
|
|
|
|
|
return false
|
|
|
|
|
} else {
|
|
|
|
|
this.setSearchTime(val.type, val.value)
|
2020-04-17 08:15:13 +08:00
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
const id = val.id
|
|
|
|
|
if (id === 0) { // custom
|
|
|
|
|
if (from === 'chart') {
|
|
|
|
|
this.isCustom = false
|
|
|
|
|
this.$emit('change', this.searchTime)
|
|
|
|
|
} else {
|
|
|
|
|
this.isCustom = true
|
|
|
|
|
this.$refs.calendar.focus()
|
2021-04-28 15:18:21 +08:00
|
|
|
this.$refs.calendar.pickerVisible = true
|
2021-10-29 14:53:38 +08:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-10-12 18:15:24 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
|
|
|
|
this.isCustom = false
|
|
|
|
|
if (this.showEmpty && id === 12) {
|
|
|
|
|
this.searchTime = []
|
|
|
|
|
}
|
|
|
|
|
this.$emit('change', this.searchTime)
|
2020-04-17 08:15:13 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
getCurrentTime () {
|
|
|
|
|
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
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
setSearchTime (type, val) {
|
|
|
|
|
if (type === 'minute') {
|
2022-01-04 16:26:15 +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-03-19 18:52:19 +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-01-04 16:26:15 +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-03-19 18:52:19 +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-01-04 16:26:15 +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-03-19 18:52:19 +08:00
|
|
|
this.$set(this.searchTime, 0, startTime)
|
|
|
|
|
this.$set(this.searchTime, 1, endTime)
|
|
|
|
|
this.$set(this.searchTime, 2, val + 'd')
|
2020-04-17 08:15:13 +08:00
|
|
|
}
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
setCostomTime: function (costomTime) {
|
|
|
|
|
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
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
popoverClick (val) {
|
|
|
|
|
if (val) {
|
|
|
|
|
this.isPopoverDisabled = true
|
|
|
|
|
} else {
|
|
|
|
|
this.isPopoverDisabled = false
|
2020-04-14 21:46:38 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
2020-04-24 17:00:56 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
created () {
|
2020-10-12 18:15:24 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
watch: {
|
|
|
|
|
defaultPick: {
|
|
|
|
|
immediate: true,
|
|
|
|
|
handler (n, o) {
|
|
|
|
|
if (n && Number.isInteger(n)) {
|
|
|
|
|
const showTime = this.timeData.find(item => item.id == n)
|
|
|
|
|
if (showTime) {
|
|
|
|
|
this.showTime = Object.assign({}, showTime)
|
2022-03-02 16:05:27 +08:00
|
|
|
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) {
|
|
|
|
|
this.searchTime = []
|
2020-10-12 18:15:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-31 10:10:39 +08:00
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
|
|
|
|
}
|
2020-04-14 21:46:38 +08:00
|
|
|
</script>
|