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 15:57:03 +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-13 13:11:16 +08:00
|
|
|
<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">
|
|
|
|
|
Absolute time range
|
|
|
|
|
</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>
|
|
|
|
|
|
|
|
|
|
<div class="content-title">From</div>
|
|
|
|
|
<div @click="myDatePickerShow('start')" tabindex="1" class="content-input">
|
|
|
|
|
<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 13:11:16 +08:00
|
|
|
<div class="content-title">To</div>
|
|
|
|
|
<div @click="myDatePickerShow('end')" tabindex="2" class="content-input">
|
|
|
|
|
<el-input v-model="searchTime[1]" @change="dateChange('end',searchTime[1])"> </el-input>
|
|
|
|
|
|
|
|
|
|
|
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-12 15:54:29 +08:00
|
|
|
>Apply time range</el-button
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="date-range-title" style="padding-left: 0">
|
|
|
|
|
Recently used absolute ranges
|
|
|
|
|
</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-12 15:54:29 +08:00
|
|
|
—
|
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)"
|
|
|
|
|
>
|
|
|
|
|
<div class="date-range-title">Relatime time ranges</div>
|
|
|
|
|
<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-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-12 15:54:29 +08:00
|
|
|
import bus from "@/libs/bus";
|
2020-04-14 21:46:38 +08:00
|
|
|
|
|
|
|
|
export default {
|
2022-04-12 15:54:29 +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-12 15:54:29 +08:00
|
|
|
type: String,
|
|
|
|
|
},
|
2022-04-13 15:57:03 +08:00
|
|
|
sign:[Number,String]
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
2022-04-12 15:54:29 +08:00
|
|
|
data() {
|
2022-04-12 20:05:18 +08:00
|
|
|
return {
|
2022-04-13 13:11:16 +08:00
|
|
|
whoChoose:'',
|
|
|
|
|
searchTimeValue:'',
|
|
|
|
|
rangeHistory: [],
|
2022-04-12 20:05:18 +08:00
|
|
|
rangeHistoryArr: [],
|
2022-04-13 13:11:16 +08:00
|
|
|
address: "",
|
|
|
|
|
utc: localStorage.getItem("timezoneOffset"),
|
|
|
|
|
utcStr: "",
|
|
|
|
|
dropdownFlag: false,
|
|
|
|
|
isPopoverDisabled: false,
|
|
|
|
|
isCustom: false,
|
|
|
|
|
searchTime: [
|
|
|
|
|
bus.timeFormate(bus.getOffsetTimezoneData(-1)),
|
|
|
|
|
bus.timeFormate(bus.getOffsetTimezoneData()),
|
|
|
|
|
],
|
|
|
|
|
showTime: {
|
|
|
|
|
id: 4,
|
|
|
|
|
text: this.$t("dashboard.panel.lastOneHour"),
|
|
|
|
|
},
|
|
|
|
|
timeData: [
|
|
|
|
|
// {
|
|
|
|
|
// id: 0,
|
|
|
|
|
// text: this.$t("dashboard.panel.customTimeRange"),
|
|
|
|
|
// value: -1,
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
id: 12,
|
|
|
|
|
text: this.$t("dashboard.panel.noDate"),
|
|
|
|
|
value: 0,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 1,
|
|
|
|
|
text: this.$t("dashboard.panel.lastFiveMin"),
|
|
|
|
|
type: "minute",
|
|
|
|
|
value: 5,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 2,
|
|
|
|
|
text: this.$t("dashboard.panel.lastFifteenMin"),
|
|
|
|
|
type: "minute",
|
|
|
|
|
value: 15,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 3,
|
|
|
|
|
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,
|
|
|
|
|
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,
|
|
|
|
|
text: this.$t("dashboard.panel.lastThreeHour"),
|
|
|
|
|
type: "hour",
|
|
|
|
|
value: 3,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 6,
|
|
|
|
|
text: this.$t("dashboard.panel.lastSixHour"),
|
|
|
|
|
type: "hour",
|
|
|
|
|
value: 6,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 7,
|
|
|
|
|
text: this.$t("dashboard.panel.lastTwelveHour"),
|
|
|
|
|
type: "hour",
|
|
|
|
|
value: 12,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 8,
|
|
|
|
|
text: this.$t("dashboard.panel.lastTwentyFourHour"),
|
|
|
|
|
type: "hour",
|
|
|
|
|
value: 24,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 9,
|
|
|
|
|
text: this.$t("dashboard.panel.lastTwoDay"),
|
|
|
|
|
type: "date",
|
|
|
|
|
value: 2,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 10,
|
|
|
|
|
text: this.$t("dashboard.panel.lastSevenDay"),
|
|
|
|
|
type: "date",
|
|
|
|
|
value: 7,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 11,
|
|
|
|
|
text: this.$t("dashboard.panel.lastThirtyDay"),
|
|
|
|
|
type: "date",
|
|
|
|
|
value: 30,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
nowTimeType: {
|
|
|
|
|
id: 4,
|
|
|
|
|
text: this.$t("dashboard.panel.lastOneHour"),
|
|
|
|
|
type: "hour",
|
|
|
|
|
value: 1,
|
|
|
|
|
},
|
|
|
|
|
};
|
2022-04-12 20:05:18 +08:00
|
|
|
},
|
2022-04-13 13:11:16 +08:00
|
|
|
mounted() {
|
|
|
|
|
this.getItem();
|
|
|
|
|
this.getUtcStr();
|
|
|
|
|
this.getRangeHistoryArr();
|
2022-04-13 15:57:03 +08:00
|
|
|
console.log(this.sign);
|
2020-04-14 21:46:38 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2022-04-13 13:11:16 +08:00
|
|
|
getItem() {
|
2022-04-13 15:57:03 +08:00
|
|
|
this.rangeHistory = localStorage.getItem("date-range-history"+this.sign)
|
|
|
|
|
? JSON.parse(localStorage.getItem("date-range-history"+this.sign))
|
2022-04-13 13:11:16 +08:00
|
|
|
: [];
|
|
|
|
|
this.address = localStorage.getItem("nz-sys-timezone");
|
|
|
|
|
this.utc = localStorage.getItem("timezoneOffset");
|
2022-04-12 20:05:18 +08:00
|
|
|
},
|
2022-04-13 13:11:16 +08:00
|
|
|
myDatePickerShow(item) {
|
|
|
|
|
this.whoChoose = item
|
|
|
|
|
this.$refs.calendar.pickerVisible = true;
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-13 13:11:16 +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 13:11:16 +08:00
|
|
|
getRangeHistoryArr() {
|
|
|
|
|
const arr = this.rangeHistory.slice(0, 3)
|
|
|
|
|
this.rangeHistoryArr = arr
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
|
|
|
|
getUtcStr() {
|
|
|
|
|
let str = "UTC ";
|
2022-04-13 13:11:16 +08:00
|
|
|
this.utcStr = str + this.utc;
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2022-04-12 20:05:18 +08:00
|
|
|
timeRange(item) {
|
2022-04-13 13:11:16 +08:00
|
|
|
|
2022-04-12 15:54:29 +08:00
|
|
|
this.isCustom = true;
|
2022-04-12 20:05:18 +08:00
|
|
|
this.rangeHistory.unshift({
|
|
|
|
|
start: item[0],
|
2022-04-13 13:11:16 +08:00
|
|
|
end: item[1],
|
|
|
|
|
});
|
|
|
|
|
localStorage.setItem(
|
2022-04-13 15:57:03 +08:00
|
|
|
"date-range-history"+this.sign,
|
2022-04-13 13:11:16 +08:00
|
|
|
JSON.stringify(this.rangeHistory)
|
|
|
|
|
);
|
2022-04-13 15:57:03 +08:00
|
|
|
this.searchTime[2]=''
|
2022-04-13 13:11:16 +08:00
|
|
|
this.showDropdown();
|
|
|
|
|
this.getRangeHistoryArr()
|
|
|
|
|
console.log('timerange里searchTime',this.searchTime);
|
2022-04-12 20:05:18 +08:00
|
|
|
this.$emit("change", this.searchTime);
|
2022-04-13 13:11:16 +08:00
|
|
|
this.setSearchTime('','',this.searchTime)
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
|
|
|
|
showDropdown() {
|
|
|
|
|
this.dropdownFlag = !this.dropdownFlag;
|
|
|
|
|
},
|
2022-04-13 13:11:16 +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{
|
|
|
|
|
console.log(v);
|
|
|
|
|
let str = v.trim().split(' ')[1]
|
|
|
|
|
console.log(str);
|
|
|
|
|
let reg = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
|
|
|
|
|
if(reg.test(str)){
|
|
|
|
|
const startTime = bus.timeFormate(v)
|
|
|
|
|
this.$set(this.searchTime, 0, startTime);
|
|
|
|
|
}else{
|
|
|
|
|
this.$set(this.searchTime, 0, '');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if(type == 'end'){
|
|
|
|
|
if(!v){
|
|
|
|
|
const endTime = bus.timeFormate(this.searchTimeValue).trim().split(" ")[0] + ' ';
|
|
|
|
|
this.$set(this.searchTime, 1, endTime);
|
|
|
|
|
}else{
|
|
|
|
|
let str = v.trim().split(' ')[1]
|
|
|
|
|
console.log(str);
|
|
|
|
|
let reg = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
|
|
|
|
|
if(reg.test(str)){
|
|
|
|
|
const endTime = bus.timeFormate(v)
|
|
|
|
|
this.$set(this.searchTime, 1, endTime);
|
|
|
|
|
}else{
|
|
|
|
|
this.$set(this.searchTime, 1, '');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.searchTime[2] = ''
|
|
|
|
|
console.log('searchTime',this.searchTime);
|
2022-04-12 15:54:29 +08:00
|
|
|
this.$set(this.showTime, "id", 0);
|
|
|
|
|
this.$set(
|
|
|
|
|
this.showTime,
|
|
|
|
|
"text",
|
|
|
|
|
this.searchTime[0] +
|
|
|
|
|
" " +
|
|
|
|
|
this.$t("dashboard.panel.to") +
|
|
|
|
|
" " +
|
|
|
|
|
this.searchTime[1]
|
|
|
|
|
);
|
2022-04-13 13:11:16 +08:00
|
|
|
console.log('showTime',this.showTime);
|
2020-04-24 17:00:56 +08:00
|
|
|
},
|
2022-04-12 15:54:29 +08:00
|
|
|
setCustomTime(timeGroup, timeRange) {
|
2021-03-31 11:10:04 +08:00
|
|
|
if (timeGroup) {
|
2022-04-13 13:11:16 +08:00
|
|
|
console.log('timeGroup',timeGroup);
|
2022-04-12 15:54:29 +08:00
|
|
|
this.showTime = this.nowTimeType = this.timeData.find(
|
|
|
|
|
(item) => item.id == timeGroup.id
|
|
|
|
|
);
|
2022-04-13 13:11:16 +08:00
|
|
|
console.log(this.showTime);
|
2021-03-31 11:10:04 +08:00
|
|
|
if (this.showTime) {
|
2022-04-12 15:54:29 +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-13 15:57:03 +08:00
|
|
|
|
2022-04-13 13:11:16 +08:00
|
|
|
const time = this.searchTime.splice(' ')
|
|
|
|
|
this.showTime= this.nowTimeType ={
|
|
|
|
|
text:time[0] +' ' + this.$t('dashboard.panel.to') +' '+time[1]
|
2021-12-24 10:20:19 +08:00
|
|
|
}
|
2022-04-13 15:57:03 +08:00
|
|
|
console.log(this.showTime);
|
2022-04-13 13:11:16 +08:00
|
|
|
this.$set(this.searchTime, 0, bus.timeFormate(time[0]));
|
|
|
|
|
this.$set(this.searchTime, 1, bus.timeFormate(time[1]));
|
2022-04-13 15:57:03 +08:00
|
|
|
// this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time));
|
|
|
|
|
// this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time));
|
2022-04-13 13:11:16 +08:00
|
|
|
// 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 {
|
2022-04-13 13:11:16 +08:00
|
|
|
console.log('no timegroup');
|
2021-03-31 11:10:04 +08:00
|
|
|
this.showTime = this.nowTimeType = {
|
|
|
|
|
id: 4,
|
2022-04-12 15:54:29 +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-12 15:54:29 +08:00
|
|
|
timeChange(val, from) {
|
2022-04-13 13:11:16 +08:00
|
|
|
console.log(val, from);
|
2022-04-12 15:54:29 +08:00
|
|
|
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-12 15:54:29 +08:00
|
|
|
this.isCustom = false;
|
|
|
|
|
return false;
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
2022-04-12 15:54:29 +08:00
|
|
|
this.setSearchTime(val.type, val.value);
|
2020-04-17 08:15:13 +08:00
|
|
|
|
2022-04-12 15:54:29 +08:00
|
|
|
const id = val.id;
|
|
|
|
|
if (id === 0) {
|
|
|
|
|
// custom
|
|
|
|
|
if (from === "chart") {
|
|
|
|
|
this.isCustom = false;
|
|
|
|
|
this.$emit("change", this.searchTime);
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
2022-04-12 15:54:29 +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)
|
|
|
|
|
);
|
2021-10-29 14:53:38 +08:00
|
|
|
setTimeout(() => {
|
2022-04-12 15:54:29 +08:00
|
|
|
if (viewGraphDialogStyle["z-index"] !== "auto") {
|
|
|
|
|
const dom =
|
|
|
|
|
document.getElementsByClassName("el-picker-panel");
|
2021-10-29 14:53:38 +08:00
|
|
|
Array.prototype.forEach.call(dom, function (element) {
|
2022-04-12 15:54:29 +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-12 15:54:29 +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-13 13:11:16 +08:00
|
|
|
console.log('else',this.searchTime);
|
|
|
|
|
// this.isCustom = false;
|
|
|
|
|
this.showDropdown()
|
2021-03-19 18:52:19 +08:00
|
|
|
if (this.showEmpty && id === 12) {
|
2022-04-12 15:54:29 +08:00
|
|
|
this.searchTime = [];
|
2021-03-19 18:52:19 +08:00
|
|
|
}
|
2022-04-12 15:54:29 +08:00
|
|
|
this.$emit("change", this.searchTime);
|
2020-04-17 08:15:13 +08:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-13 13:11:16 +08:00
|
|
|
|
2020-04-17 08:15:13 +08:00
|
|
|
},
|
2022-04-12 15:54:29 +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 13:11:16 +08:00
|
|
|
setSearchTime(type, val,time) {
|
2022-04-12 15:54:29 +08:00
|
|
|
if (type === "minute") {
|
|
|
|
|
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()))
|
|
|
|
|
);
|
|
|
|
|
this.$set(this.searchTime, 0, startTime);
|
|
|
|
|
this.$set(this.searchTime, 1, endTime);
|
|
|
|
|
this.$set(this.searchTime, 2, val + "m");
|
|
|
|
|
} else if (type === "hour") {
|
|
|
|
|
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()))
|
|
|
|
|
);
|
|
|
|
|
this.$set(this.searchTime, 0, startTime);
|
|
|
|
|
this.$set(this.searchTime, 1, endTime);
|
|
|
|
|
this.$set(this.searchTime, 2, val + "h");
|
|
|
|
|
} else if (type === "date") {
|
|
|
|
|
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()))
|
|
|
|
|
);
|
|
|
|
|
this.$set(this.searchTime, 0, startTime);
|
|
|
|
|
this.$set(this.searchTime, 1, endTime);
|
|
|
|
|
this.$set(this.searchTime, 2, val + "d");
|
2022-04-13 13:11:16 +08:00
|
|
|
}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-12 15:54:29 +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-12 15:54:29 +08:00
|
|
|
popoverClick(val) {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (val) {
|
2022-04-12 15:54:29 +08:00
|
|
|
this.isPopoverDisabled = true;
|
2021-03-19 18:52:19 +08:00
|
|
|
} else {
|
2022-04-12 15:54:29 +08:00
|
|
|
this.isPopoverDisabled = false;
|
2020-04-14 21:46:38 +08:00
|
|
|
}
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
2020-10-12 18:15:24 +08:00
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
watch: {
|
|
|
|
|
defaultPick: {
|
|
|
|
|
immediate: true,
|
2022-04-12 15:54:29 +08:00
|
|
|
handler(n, o) {
|
2021-03-19 18:52:19 +08:00
|
|
|
if (n && Number.isInteger(n)) {
|
2022-04-12 15:54:29 +08:00
|
|
|
const showTime = this.timeData.find((item) => item.id == n);
|
2021-03-19 18:52:19 +08:00
|
|
|
if (showTime) {
|
2022-04-12 15:54:29 +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-12 15:54:29 +08:00
|
|
|
this.searchTime = [];
|
2020-10-12 18:15:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-12 15:54:29 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
2020-04-14 21:46:38 +08:00
|
|
|
</script>
|