NEZ-1787 fix : 基本完成 下一步自测以及修改历史展示

This commit is contained in:
zhangxiaolong
2022-04-13 13:11:16 +08:00
parent 884cfac5da
commit a848db4267
2 changed files with 277 additions and 206 deletions

View File

@@ -157,7 +157,7 @@
} }
.date-range-panel { .date-range-panel {
height: 450px; height: 480px;
width: 500px; width: 500px;
background: #FFFFFF; background: #FFFFFF;
box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05); box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
@@ -179,6 +179,8 @@
} }
.content-input { .content-input {
.el-input{
.el-input__inner{
border: 1px solid #E7EAED; border: 1px solid #E7EAED;
border-radius: 2px; border-radius: 2px;
width: 230px; width: 230px;
@@ -189,6 +191,9 @@
outline: #169AFF; outline: #169AFF;
} }
}
}
.content-input:focus { .content-input:focus {
border: 1px solid #169AFF; border: 1px solid #169AFF;
} }

View File

@@ -28,20 +28,18 @@
</div> </div>
<div class="calendar-popover-text" style="display: flex" v-if="isCustom"> <div class="calendar-popover-text" style="display: flex" v-if="isCustom">
<div class="calendar-popover-text"> <div class="calendar-popover-text">
{{searchTime[0]}} {{ searchTime[0] }}
</div> </div>
<div class="calendar-popover-text">{{$t('dashboard.panel.to')}}</div> <div class="calendar-popover-text">{{ $t("dashboard.panel.to") }}</div>
<div class="calendar-popover-text"> <div class="calendar-popover-text">
{{searchTime[1]}} {{ searchTime[1] }}
</div> </div>
</div> </div>
<div class="calendar-popover-text" v-else> <div class="calendar-popover-text" v-else>
<div class="time-no-data">{{showTime.text}}</div> <div class="time-no-data">{{ showTime.text }}</div>
</div> </div>
<div class="calendar-popover-text"> <div class="calendar-popover-text">
<i <i class="el-icon-arrow-down"></i>
class="el-icon-arrow-down"
></i>
</div> </div>
</div> </div>
<!-- <el-dropdown ref="timePickerDropdown" class="calendar-dropdown-title" trigger="click" @command="timeChange" @visible-change="popoverClick"> <!-- <el-dropdown ref="timePickerDropdown" class="calendar-dropdown-title" trigger="click" @command="timeChange" @visible-change="popoverClick">
@@ -100,8 +98,8 @@
size="mini" size="mini"
ref="calendar" ref="calendar"
:format="timeFormatStrToDatePickFormat(timeFormatMain)" :format="timeFormatStrToDatePickFormat(timeFormatMain)"
@change="dateChange" @change="dateChange(whoChoose)"
v-model="searchTime" v-model="searchTimeValue"
type="date" type="date"
popper-class="panel-time-picker-popper time-picker-popover__select-top" popper-class="panel-time-picker-popper time-picker-popover__select-top"
align="right" align="right"
@@ -109,15 +107,22 @@
</my-date-picker> </my-date-picker>
<div class="content-title">From</div> <div class="content-title">From</div>
<div @click="myDatePickerShow" tabindex="1" class="content-input"> <div @click="myDatePickerShow('start')" tabindex="1" class="content-input">
{{ searchTime[0] }} <!-- {{ searchTime[0] }} -->
<el-input v-model="searchTime[0]" @change="dateChange('start',searchTime[0])"> </el-input>
</div> </div>
<div class="content-title">To</div> <div class="content-title">To</div>
<div @click="myDatePickerShow" tabindex="2" class="content-input"> <div @click="myDatePickerShow('end')" tabindex="2" class="content-input">
{{ searchTime[1] }} <el-input v-model="searchTime[1]" @change="dateChange('end',searchTime[1])"> </el-input>
<!-- {{ searchTime[1] }} -->
</div> </div>
<div> <div>
<el-button @click="timeRange(searchTime)" type="primary" size="mini" <el-button
@click="timeRange(searchTime)"
type="primary"
size="mini"
>Apply time range</el-button >Apply time range</el-button
> >
</div> </div>
@@ -131,11 +136,9 @@
class="date-range-history-item" class="date-range-history-item"
@click="historyChange(item)" @click="historyChange(item)"
> >
<!-- {{this.timeFormate(item.start)}} --> {{ timeFormate(item.start) }}
{{bus.timeFormate(item.start)}}
{{this.timeFormate(item.end)}} {{ timeFormate(item.end) }}
</div> </div>
</div> </div>
</el-col> </el-col>
@@ -147,19 +150,18 @@
<div class="date-range-title">Relatime time ranges</div> <div class="date-range-title">Relatime time ranges</div>
<ul class="date-range-item"> <ul class="date-range-item">
<li <li
v-for="(item,key) in timeData" v-for="(item, key) in timeData"
@click="timeChange(item)" @click="timeChange(item)"
:class="showTime.id === item.id ? 'active' : ''" :class="showTime.id === item.id ? 'active' : ''"
:key="key" :key="key"
> >
<span style="position: relative" <span
style="position: relative"
v-if="item.id !== 12 || showEmpty" v-if="item.id !== 12 || showEmpty"
> >
{{ item.text }} {{ item.text }}
<i <i
v-if="showTime.id === item.id " v-if="showTime.id === item.id"
class="nz-icon nz-icon-check" class="nz-icon nz-icon-check"
></i> ></i>
</span> </span>
@@ -190,11 +192,13 @@ export default {
}, },
data() { data() {
return { return {
rangeHistory : [], whoChoose:'',
searchTimeValue:'',
rangeHistory: [],
rangeHistoryArr: [], rangeHistoryArr: [],
address: '', address: "",
utc: localStorage.getItem("timezoneOffset"), utc: localStorage.getItem("timezoneOffset"),
utcStr: '', utcStr: "",
dropdownFlag: false, dropdownFlag: false,
isPopoverDisabled: false, isPopoverDisabled: false,
isCustom: false, isCustom: false,
@@ -290,57 +294,101 @@ export default {
type: "hour", type: "hour",
value: 1, value: 1,
}, },
} };
}, },
mounted(){ mounted() {
this.getItem() this.getItem();
this.getUtcStr() this.getUtcStr();
this.getRangeHistoryArr() this.getRangeHistoryArr();
}, },
methods: { methods: {
getItem(){ getItem() {
this.rangeHistory = localStorage.getItem("date-range-history")? JSON.parse(localStorage.getItem("date-range-history")): []; this.rangeHistory = localStorage.getItem("date-range-history")
this.address= localStorage.getItem("nz-sys-timezone"); ? JSON.parse(localStorage.getItem("date-range-history"))
this.utc= localStorage.getItem("timezoneOffset"); : [];
this.address = localStorage.getItem("nz-sys-timezone");
this.utc = localStorage.getItem("timezoneOffset");
}, },
myDatePickerShow(){ myDatePickerShow(item) {
this.whoChoose = item
this.$refs.calendar.pickerVisible = true; this.$refs.calendar.pickerVisible = true;
}, },
historyChange (item) { historyChange(item) {
console.log(item); this.searchTime[0] = item.start;
this.searchTime[0] = item.start this.searchTime[1] = item.end;
this.searchTime[1] = item.end this.isCustom = true;
this.isCustom = true this.showDropdown();
this.$emit("change", this.searchTime);
this.setSearchTime('','',this.searchTime)
}, },
getRangeHistoryArr(){ getRangeHistoryArr() {
// this.rangeHistoryArr = this.rangeHistory.slice(0, 4) const arr = this.rangeHistory.slice(0, 3)
// this.rangeHistoryArr = this.$loadsh.slice(this.rangeHistory,0, 4) this.rangeHistoryArr = arr
console.log('rangeHistoryArr',this.rangeHistoryArr);
}, },
getUtcStr() { getUtcStr() {
let str = "UTC "; let str = "UTC ";
this.utcStr = str + this.utc this.utcStr = str + this.utc;
}, },
timeRange(item) { timeRange(item) {
console.log(item);
this.isCustom = true; this.isCustom = true;
this.rangeHistory.unshift({ this.rangeHistory.unshift({
start: item[0], start: item[0],
end: item[1] end: item[1],
}) });
localStorage.setItem('date-range-history', JSON.stringify(this.rangeHistory)) localStorage.setItem(
this.showDropdown() "date-range-history",
JSON.stringify(this.rangeHistory)
);
this.showDropdown();
this.getRangeHistoryArr()
console.log('timerange里searchTime',this.searchTime);
this.searchTime[2]=''
this.$emit("change", this.searchTime); this.$emit("change", this.searchTime);
this.setSearchTime('','',this.searchTime)
}, },
showDropdown() { showDropdown() {
this.dropdownFlag = !this.dropdownFlag; this.dropdownFlag = !this.dropdownFlag;
}, },
dateChange(val) { dateChange(type,v) {
console.log('val',val); if(type == 'start'){
const startTime = bus.timeFormate(val[0]); if(!v){
const endTime = bus.timeFormate(val[1]); const startTime = bus.timeFormate(this.searchTimeValue).trim().split(" ")[0] + ' ';
this.$set(this.searchTime, 0, startTime); 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{
console.log('输入不规范');
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); 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{
console.log('输入不规范');
this.$set(this.searchTime, 1, '');
}
}
}
this.searchTime[2] = ''
console.log('searchTime',this.searchTime);
this.$set(this.showTime, "id", 0); this.$set(this.showTime, "id", 0);
this.$set( this.$set(
this.showTime, this.showTime,
@@ -351,39 +399,48 @@ export default {
" " + " " +
this.searchTime[1] this.searchTime[1]
); );
// localStorage.setItem('date-range-history', JSON.stringify(rangeHistory)) console.log('showTime',this.showTime);
// this.$emit("change", this.searchTime);
}, },
setCustomTime(timeGroup, timeRange) { setCustomTime(timeGroup, timeRange) {
if (timeGroup) { if (timeGroup) {
console.log('timeGroup',timeGroup);
this.showTime = this.nowTimeType = this.timeData.find( this.showTime = this.nowTimeType = this.timeData.find(
(item) => item.id == timeGroup.id (item) => item.id == timeGroup.id
); );
console.log(this.showTime);
if (this.showTime) { if (this.showTime) {
this.showTime = Object.assign({}, this.showTime); this.showTime = Object.assign({}, this.showTime);
this.$set(this.searchTime, 0, timeGroup.start_time); this.$set(this.searchTime, 0, timeGroup.start_time);
this.$set(this.searchTime, 1, timeGroup.end_time); this.$set(this.searchTime, 1, timeGroup.end_time);
} else { } else {
this.showTime = this.nowTimeType = { const time = this.searchTime.splice(' ')
id: 4, this.showTime= this.nowTimeType ={
text: this.$t("dashboard.panel.lastOneHour"), text:time[0] +' ' + this.$t('dashboard.panel.to') +' '+time[1]
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, 0, bus.timeFormate(time[0]));
this.$set(this.searchTime, 1, bus.timeFormate(time[1])); this.$set(this.searchTime, 1, bus.timeFormate(time[1]));
} // 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]));
} }
} else { } else {
console.log('no timegroup');
this.showTime = this.nowTimeType = { this.showTime = this.nowTimeType = {
id: 4, id: 4,
text: this.$t("dashboard.panel.lastOneHour"), text: this.$t("dashboard.panel.lastOneHour"),
@@ -396,7 +453,7 @@ export default {
} }
}, },
timeChange(val, from) { timeChange(val, from) {
console.log(val,from); console.log(val, from);
this.nowTimeType = val; this.nowTimeType = val;
this.$set(this.showTime, "id", val.id); this.$set(this.showTime, "id", val.id);
this.$set(this.showTime, "text", val.text); this.$set(this.showTime, "text", val.text);
@@ -436,30 +493,35 @@ export default {
} }
} }
} else { } else {
this.isCustom = false; console.log('else',this.searchTime);
// this.isCustom = false;
this.showDropdown()
if (this.showEmpty && id === 12) { if (this.showEmpty && id === 12) {
this.searchTime = []; this.searchTime = [];
} }
this.$emit("change", this.searchTime); this.$emit("change", this.searchTime);
} }
} }
}, },
getCurrentTime() { getCurrentTime() {
let timeTypeId = this.showTime.id;
if (timeTypeId === 0) {
return this.searchTime; return this.searchTime;
} else { console.log('getcurrenttime');
if (!timeTypeId) { // let timeTypeId = this.showTime.id;
timeTypeId = 4; // if (timeTypeId === 0) {
} // return this.searchTime;
const currentTime = this.timeData.find( // } else {
(item) => item.id === timeTypeId // if (!timeTypeId) {
); // timeTypeId = 4;
this.setSearchTime(currentTime.type, currentTime.value); // }
return this.searchTime; // const currentTime = this.timeData.find(
} // (item) => item.id === timeTypeId
// );
// this.setSearchTime(currentTime.type, currentTime.value);
// return this.searchTime;
// }
}, },
setSearchTime(type, val) { setSearchTime(type, val,time) {
if (type === "minute") { if (type === "minute") {
const startTime = bus.timeFormate( const startTime = bus.timeFormate(
new Date(bus.computeTimezone(new Date().getTime())).setMinutes( new Date(bus.computeTimezone(new Date().getTime())).setMinutes(
@@ -497,6 +559,10 @@ export default {
this.$set(this.searchTime, 0, startTime); this.$set(this.searchTime, 0, startTime);
this.$set(this.searchTime, 1, endTime); this.$set(this.searchTime, 1, endTime);
this.$set(this.searchTime, 2, val + "d"); this.$set(this.searchTime, 2, val + "d");
}else{
this.$set(this.searchTime, 0, time[0]);
this.$set(this.searchTime, 1, time[1]);
} }
}, },
setCostomTime: function (costomTime) { setCostomTime: function (costomTime) {