2020-04-14 21:46:38 +08:00
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.loading-font{
|
|
|
|
|
color:#232f3e !important;
|
|
|
|
|
}
|
|
|
|
|
.calendar{
|
|
|
|
|
}
|
|
|
|
|
.nz-dashboard-dropdown-bg {
|
|
|
|
|
background: $global-text-color-active;
|
|
|
|
|
color: #fff;
|
|
|
|
|
}
|
|
|
|
|
.calendar-dropdown-title {
|
|
|
|
|
line-height:24px;
|
|
|
|
|
padding-left:5px;
|
|
|
|
|
margin-left:0px;
|
|
|
|
|
margin-top: 3px;
|
|
|
|
|
text-align:left;
|
|
|
|
|
border-radius:4px;
|
2020-04-17 08:15:13 +08:00
|
|
|
width:160px;
|
2020-04-14 21:46:38 +08:00
|
|
|
height:24px;
|
|
|
|
|
border:solid 1px #d8dce1;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow-x: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
|
|
|
|
.el-dropdown-link {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
.calendar-popover{
|
|
|
|
|
line-height:22px;
|
|
|
|
|
text-align:center;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<template>
|
2020-04-17 08:15:13 +08:00
|
|
|
<div class="calendar top-tools" id="panel-calender">
|
|
|
|
|
<el-dropdown @command="timeChange" class="calendar-dropdown-title" trigger="click" v-scrollBar:el-dropdown @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"
|
|
|
|
|
id="panel-calender-popover">
|
2020-04-14 21:46:38 +08:00
|
|
|
<el-row :gutter="10" class="calendar-popover">
|
|
|
|
|
<el-col :span="24">{{searchTime[0]}}</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="10" class="calendar-popover">
|
|
|
|
|
<el-col :span="24">to</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="10" class="calendar-popover">
|
|
|
|
|
<el-col :span="24">{{searchTime[1]}}</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="10" class="el-dropdown-link" slot="reference">
|
|
|
|
|
<el-col :span="3" ><i class="el-icon-time"></i></el-col>
|
2020-04-17 08:15:13 +08:00
|
|
|
<el-col :span="17" class="panel-list-title" >{{showTime.text}}</el-col>
|
|
|
|
|
<el-col :span="4" style="padding-left:0px !important;"><i class="el-icon-arrow-down el-icon--right"></i></el-col>
|
2020-04-14 21:46:38 +08:00
|
|
|
</el-row>
|
|
|
|
|
</el-popover>
|
|
|
|
|
<el-dropdown-menu class="nz-dashboard-dropdown" slot="dropdown">
|
2020-04-17 08:15:13 +08:00
|
|
|
<!-- <el-dropdown-item >{{$t('dashboard.panel.customTimeRange')}}</el-dropdown-item> -->
|
2020-04-14 21:46:38 +08:00
|
|
|
<el-dropdown-item v-for="item in timeData" :key="item.id+1"
|
|
|
|
|
:class="showTime.id==item.id?'nz-dashboard-dropdown-bg':''" :command="item">
|
|
|
|
|
{{item.text}}
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
2020-04-17 08:15:13 +08:00
|
|
|
<el-date-picker prefix-icon=" " class="nz-dashboard-picker" size="mini" ref="calendar"
|
|
|
|
|
format="yyyy/MM/dd HH:mm" @change="dateChange" v-model="searchTime" type="datetimerange"
|
|
|
|
|
:picker-options="pickerOptions" :range-separator="$t('dashboard.panel.to')"
|
|
|
|
|
:start-placeholder="$t('dashboard.panel.startTime')"
|
|
|
|
|
:end-placeholder="$t('dashboard.panel.endTime')" align="right">
|
|
|
|
|
</el-date-picker>
|
2020-04-14 21:46:38 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import bus from '../../libs/bus';
|
|
|
|
|
|
|
|
|
|
export default {
|
2020-04-17 08:15:13 +08:00
|
|
|
name: "timePicker",
|
2020-04-14 21:46:38 +08:00
|
|
|
props: {
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-04-17 08:15:13 +08:00
|
|
|
isPopoverDisabled:false,
|
2020-04-14 21:46:38 +08:00
|
|
|
searchTime:[
|
2020-04-17 08:15:13 +08:00
|
|
|
bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - 5),'yyyy-MM-dd hh:mm:ss'),
|
2020-04-14 21:46:38 +08:00
|
|
|
bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())),'yyyy-MM-dd hh:mm:ss')
|
|
|
|
|
],
|
|
|
|
|
showTime: {
|
|
|
|
|
id: 1,
|
|
|
|
|
text: this.$t("dashboard.panel.lastFiveMin"),
|
|
|
|
|
},
|
2020-04-17 08:15:13 +08:00
|
|
|
oldTime:{
|
|
|
|
|
id: 1,
|
|
|
|
|
text: this.$t("dashboard.panel.lastFiveMin"),
|
|
|
|
|
},
|
2020-04-14 21:46:38 +08:00
|
|
|
timeData: [
|
2020-04-17 08:15:13 +08:00
|
|
|
{
|
|
|
|
|
id:0,
|
|
|
|
|
text:this.$t("dashboard.panel.customTimeRange"),
|
|
|
|
|
},
|
2020-04-14 21:46:38 +08:00
|
|
|
{
|
|
|
|
|
id:1,
|
|
|
|
|
text:this.$t("dashboard.panel.lastFiveMin"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'minute',
|
|
|
|
|
value:5,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:2,
|
|
|
|
|
text:this.$t("dashboard.panel.lastFifteenMin"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'minute',
|
|
|
|
|
value:15,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:3,
|
|
|
|
|
text:this.$t("dashboard.panel.lastThirtyMin"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'minute',
|
|
|
|
|
value:30,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:4,
|
|
|
|
|
text:this.$t("dashboard.panel.lastOneHour"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'hour',
|
|
|
|
|
value:1,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:5,
|
|
|
|
|
text:this.$t("dashboard.panel.lastThreeHour"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'hour',
|
|
|
|
|
value:3,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:6,
|
|
|
|
|
text:this.$t("dashboard.panel.lastSixHour"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'hour',
|
|
|
|
|
value:6,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:7,
|
|
|
|
|
text:this.$t("dashboard.panel.lastTwelveHour"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'hour',
|
|
|
|
|
value:12,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:8,
|
|
|
|
|
text:this.$t("dashboard.panel.lastTwentyFourHour"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'hour',
|
|
|
|
|
value:24,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:9,
|
|
|
|
|
text:this.$t("dashboard.panel.lastTwoDay"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'date',
|
|
|
|
|
value:2,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:10,
|
|
|
|
|
text:this.$t("dashboard.panel.lastSevenDay"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'date',
|
|
|
|
|
value:7,
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id:11,
|
|
|
|
|
text:this.$t("dashboard.panel.lastThirtyDay"),
|
2020-04-17 08:15:13 +08:00
|
|
|
type:'date',
|
|
|
|
|
value:30,
|
2020-04-14 21:46:38 +08:00
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
timeChange(val) {
|
2020-04-17 08:15:13 +08:00
|
|
|
this.showTime = val;
|
|
|
|
|
|
2020-04-14 21:46:38 +08:00
|
|
|
if (!val) {
|
|
|
|
|
return false;
|
2020-04-17 08:15:13 +08:00
|
|
|
}else {
|
|
|
|
|
let id = val.id;
|
|
|
|
|
if(id===0){
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
this.oldTime = val;
|
|
|
|
|
}
|
|
|
|
|
this.setSearchTime(val.type,val.value);
|
|
|
|
|
}
|
|
|
|
|
this.$emit('change', this.searchTime);
|
|
|
|
|
},
|
|
|
|
|
setSearchTime(type,val){
|
|
|
|
|
if(type==='minute'){
|
|
|
|
|
this.searchTime[0] = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val),'yyyy-MM-dd hh:mm:ss'),
|
|
|
|
|
this.searchTime[1] = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())),'yyyy-MM-dd hh:mm:ss');
|
|
|
|
|
}else if(type==='hour'){
|
|
|
|
|
this.searchTime[0] = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val),'yyyy-MM-dd hh:mm:ss'),
|
|
|
|
|
this.searchTime[1] = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())),'yyyy-MM-dd hh:mm:ss');
|
|
|
|
|
}else if(type==='date'){
|
|
|
|
|
this.searchTime[0] = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val),'yyyy-MM-dd hh:mm:ss'),
|
|
|
|
|
this.searchTime[1] = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())),'yyyy-MM-dd hh:mm:ss');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
popoverClick(val){
|
|
|
|
|
if(val){
|
|
|
|
|
this.isPopoverDisabled = true;
|
|
|
|
|
}else{
|
|
|
|
|
this.isPopoverDisabled = false;
|
2020-04-14 21:46:38 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|