fix:修改endpoint Query 传递时间参数 为NaN的问题

This commit is contained in:
zhangyu
2021-04-29 17:56:44 +08:00
parent f0a08d2a2b
commit df6915dfbb

View File

@@ -68,7 +68,7 @@
import subDataListMixin from '@/components/common/mixin/subDataList'
import nzBottomDataList from '@/components/common/bottomBox/nzBottomDataList'
import endpointQueryTab from '@/components/common/table/special/endpointQueryTab'
import bus from '@/libs/bus'
export default {
name: 'endpointTab',
mixins: [subDataListMixin],
@@ -83,6 +83,7 @@ export default {
obj: {
immediate: true,
handler (n) {
this.formatTime = new Date(bus.computeTimezoneTime(new Date()))
console.log(n)
}
}
@@ -144,6 +145,47 @@ export default {
changeTime (size, unit) {
this.formatTime = this.getTime(size, unit)
},
getTime (size, unit) { // 计算时间
const now = !this.formatTime ? new Date(bus.computeTimezone(new Date().getTime())) : new Date(this.formatTime)
if (unit) {
switch (unit) {
case 'y':
now.setFullYear(now.getFullYear() + size)
break
case 'M':
now.setMonth(now.getMonth() + size)
break
case 'd':
now.setDate(now.getDate() + size)
break
case 'h':
now.setHours(now.getHours() + size)
break
case 'm':
now.setMinutes(now.getMinutes() + size)
break
case 's':
now.setSeconds(now.getSeconds() + size)
break
default:
console.error('unit error')
}
} else {
now.setSeconds(now.getSeconds() + size)
}
const year = now.getFullYear()
let month = now.getMonth() + 1
month = month < 10 ? '0' + month : month
let day = now.getDate()
day = day < 10 ? '0' + day : day
let hour = now.getHours()
hour = hour < 10 ? '0' + hour : hour
let minute = now.getMinutes()
minute = minute < 10 ? '0' + minute : minute
let second = now.getSeconds()
second = second < 10 ? '0' + second : second
return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second
},
viewGraph () {
this.$refs.endpointQueryTab.viewGraph()
},