diff --git a/nezha-fronted/src/components/common/mixin/mainMixinFun.js b/nezha-fronted/src/components/common/mixin/mainMixinFun.js
index 24356f389..fe995bb3e 100644
--- a/nezha-fronted/src/components/common/mixin/mainMixinFun.js
+++ b/nezha-fronted/src/components/common/mixin/mainMixinFun.js
@@ -223,6 +223,7 @@ export default {
this.nowTimeType = nowType || this.$refs.pickTime.$refs.timePicker.nowTimeType
const type = nowTimeType.type
const val = nowTimeType.value
+ console.log(val)
const oneDTimestamp = 24 * 60 * 60 * 1000
if (type === 'relative') {
const now = new Date(bus.computeTimezone(new Date().getTime()))
diff --git a/nezha-fronted/src/components/common/mixin/routerPathParams.js b/nezha-fronted/src/components/common/mixin/routerPathParams.js
index 4f6b76add..53fec37aa 100644
--- a/nezha-fronted/src/components/common/mixin/routerPathParams.js
+++ b/nezha-fronted/src/components/common/mixin/routerPathParams.js
@@ -246,66 +246,107 @@ export default {
switch (value) {
case '5m' :
this.defaultPick = 1
+ this.defaultPickType = 'minute'
+ this.defaultPickVal = 5
break
case '15m' :
this.defaultPick = 2
+ this.defaultPickType = 'minute'
+ this.defaultPickVal = 15
break
case '30m' :
this.defaultPick = 3
+ this.defaultPickType = 'minute'
+ this.defaultPickVal = 30
break
case '1h' :
this.defaultPick = 4
+ this.defaultPickType = 'hour'
+ this.defaultPickVal = 1
break
case '3h' :
this.defaultPick = 5
+ this.defaultPickType = 'hour'
+ this.defaultPickVal = 3
break
case '6h' :
this.defaultPick = 6
+ this.defaultPickType = 'hour'
+ this.defaultPickVal = 6
break
case '12h' :
this.defaultPick = 7
+ this.defaultPickType = 'hour'
+ this.defaultPickVal = 12
break
- case '1d' :
- this.defaultPick = 8
- break
+ // case '1d' :
+ // this.defaultPick = 8
+ // this.defaultPickType = 'hour'
+ // break
case '24h' :
this.defaultPick = 8
+ this.defaultPickType = 'hour'
+ this.defaultPickVal = 24
break
case '2d' :
this.defaultPick = 9
+ this.defaultPickType = 'date'
+ this.defaultPickVal = 2
break
case '7d' :
this.defaultPick = 10
+ this.defaultPickType = 'date'
+ this.defaultPickVal = 7
break
case '30d' :
this.defaultPick = 11
+ this.defaultPickType = 'date'
+ this.defaultPickVal = 30
break
case 'all' :
this.defaultPick = 12
+ this.defaultPickType = 'all'
+ this.defaultPickVal = 'all'
break
case '0t' :
this.defaultPick = 13
+ this.defaultPickType = 'relative'
+ this.defaultPickVal = '0'
break
case '1t' :
this.defaultPick = 14
+ this.defaultPickType = 'relative'
+ this.defaultPickVal = '1'
break
case '2t' :
this.defaultPick = 15
+ this.defaultPickType = 'relative'
+ this.defaultPickVal = '2'
break
case '7t' :
this.defaultPick = 16
+ this.defaultPickType = 'relative'
+ this.defaultPickVal = '7'
break
case '0w' :
this.defaultPick = 17
+ this.defaultPickType = 'relative'
+ this.defaultPickVal = '0'
break
case '1w' :
this.defaultPick = 18
+ this.defaultPickType = 'relative'
+ this.defaultPickVal = '1'
break
case '0m' :
this.defaultPick = 19
+ this.defaultPickType = 'relative'
+ this.defaultPickVal = '0'
break
case '1m' :
this.defaultPick = 20
+ this.defaultPickType = 'relative'
+ this.defaultPickVal = '1'
break
default:
this.defaultPick = 0
diff --git a/nezha-fronted/src/components/common/pickTime.vue b/nezha-fronted/src/components/common/pickTime.vue
index dad9eb56c..4da1b1b0e 100644
--- a/nezha-fronted/src/components/common/pickTime.vue
+++ b/nezha-fronted/src/components/common/pickTime.vue
@@ -76,7 +76,7 @@ export default {
},
data () {
return {
- searchTime: [],
+ searchTime: ['', ''],
visible: false,
intervalTimer: null,
interval: -1,
@@ -146,10 +146,10 @@ export default {
},
timeFormate (timeRange) {
if (timeRange && timeRange.length < 2) {
- return []
+ return ['', '']
}
if (!timeRange[0]) {
- return []
+ return ['', '']
}
const startTime = bus.timeFormate(timeRange[0], this.pickTimer)
const endTime = bus.timeFormate(timeRange[1], this.pickTimer)
diff --git a/nezha-fronted/src/components/common/searchSelectInfo.js b/nezha-fronted/src/components/common/searchSelectInfo.js
index a72d8cfb6..83bb37126 100644
--- a/nezha-fronted/src/components/common/searchSelectInfo.js
+++ b/nezha-fronted/src/components/common/searchSelectInfo.js
@@ -158,19 +158,19 @@ export default {
{
value: 'download',
label: i18n.t('overall.download')
- },
- {
- value: 'createTask',
- label: i18n.t('operationlog.createTask')
- },
- {
- value: 'sync',
- label: i18n.t('operationlog.sync')
- },
- {
- value: 'diagnosis',
- label: i18n.t('overall.diagnosis')
}
+ // {
+ // value: 'createTask',
+ // label: i18n.t('operationlog.createTask')
+ // },
+ // {
+ // value: 'sync',
+ // label: i18n.t('operationlog.sync')
+ // },
+ // {
+ // value: 'diagnosis',
+ // label: i18n.t('overall.diagnosis')
+ // }
],
alertMessageState: [
{
diff --git a/nezha-fronted/src/components/common/table/settings/dcTable.vue b/nezha-fronted/src/components/common/table/settings/dcTable.vue
index b44950708..6ed3e3591 100644
--- a/nezha-fronted/src/components/common/table/settings/dcTable.vue
+++ b/nezha-fronted/src/components/common/table/settings/dcTable.vue
@@ -154,7 +154,7 @@ export default {
data () {
return {
viewPermission: 'dc_view',
- regNum: /^[0-9]+.?[0-9]*/,
+ regNum: /^-[0-9]+(\\.[0-9]+)?|[0-9]+(\\.[0-9]+)?$/,
needAlertDaysData: true,
trendKey: 'dcId',
tableTitle: [
@@ -228,7 +228,7 @@ export default {
showTableTooltip,
hideTableTooltip,
regNumTest (val) { // 校验是否是数字
- return this.regNum.test(val)
+ return !isNaN(val)
},
messageStyle (title, row) {
if (title.prop === 'alertNum') {
diff --git a/nezha-fronted/src/components/common/table/settings/mibTable.vue b/nezha-fronted/src/components/common/table/settings/mibTable.vue
index faaeb1e09..c2a9ea7c7 100644
--- a/nezha-fronted/src/components/common/table/settings/mibTable.vue
+++ b/nezha-fronted/src/components/common/table/settings/mibTable.vue
@@ -65,7 +65,7 @@
{{$t('overall.type')}}:
- {{n.type}}
+ {{n.type ? n.type.name : ''}}
diff --git a/nezha-fronted/src/components/common/timePicker.vue b/nezha-fronted/src/components/common/timePicker.vue
index 2cd555279..041f5fb13 100644
--- a/nezha-fronted/src/components/common/timePicker.vue
+++ b/nezha-fronted/src/components/common/timePicker.vue
@@ -246,8 +246,9 @@ export default {
this.getUtcStr()
this.getRangeHistoryArr()
const timeTemp = this.$lodash.cloneDeep(this.searchTime)
- this.oldSearchTime[0] = timeTemp[0]
- this.oldSearchTime[1] = timeTemp[1]
+ console.log(this.searchTime)
+ this.oldSearchTime[0] = timeTemp[0] || ''
+ this.oldSearchTime[1] = timeTemp[1] || ''
// 监听dateFormat变化 改变日期格式
window.addEventListener('storage', this.watchDateFormat)
},
@@ -703,7 +704,7 @@ export default {
}
}
if (this.showEmpty && this.defaultPick === 12) {
- this.searchTime = []
+ this.searchTime = ['', '']
}
}
}
diff --git a/nezha-fronted/src/components/page/alert/alertMessage.vue b/nezha-fronted/src/components/page/alert/alertMessage.vue
index 6ac073953..bb8d50d83 100644
--- a/nezha-fronted/src/components/page/alert/alertMessage.vue
+++ b/nezha-fronted/src/components/page/alert/alertMessage.vue
@@ -402,7 +402,9 @@ export default {
],
errorContent: '',
isError: false,
- defaultPick: 10
+ defaultPick: 10,
+ defaultPickType: 'date',
+ defaultPickVal: 7
}
},
computed: {
@@ -446,15 +448,21 @@ export default {
},
methods: {
renderDefaultParams () {
+ sessionStorage.setItem('nz-reload', 0)
const q = JSON.parse(this.$route.query.body)
this.state = q.state
this.searchTime[0] = q.startAt ? this.momentTz(q.startAt) : ''
this.searchTime[1] = q.endAt ? this.momentTz(q.endAt) : ''
this.searchTime[2] = q.timeType
- if (!q.startAt) {
- this.searchTime[2] = 'all'
+ if (!q.startAt && !q.timeType) {
+ this.searchTime = ['', '', 'all']
+ } else if (q.timeType === 'all') {
+ this.searchTime = ['', '', 'all']
}
this.initTimeType(this.searchTime[2])
+ if (this.defaultPick && this.defaultPick !== 12) {
+ this.setDefaultSearchTime('')
+ }
// this.defaultPick = 11
},
batchAck () {
@@ -780,6 +788,116 @@ export default {
this.setSearchTime('searchTime')
this.getTableData()
},
+ setDefaultSearchTime () {
+ const type = this.defaultPickType
+ const val = this.defaultPickVal
+ const key = 'searchTime'
+ const oneDTimestamp = 24 * 60 * 60 * 1000
+ if (type === 'relative') {
+ const now = new Date(bus.computeTimezone(new Date().getTime()))
+ let start = bus.timeFormate(now, 'YYYY-MM-DD') // 使用固定时间格式 方便添加 00:00:00 23:59:59
+ let end = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss')
+ let unit = ''
+ if (this.defaultPick === 13) { // today
+ unit = 't'
+ end = start + ' 23:59:59'
+ start += ' 00:00:00'
+ start = this.momentTz(this.momentStrToTimestamp(start, 'YYYY-MM-DD HH:mm:ss'))
+ end = this.momentTz(this.momentStrToTimestamp(end, 'YYYY-MM-DD HH:mm:ss'))
+ }
+ if (this.defaultPick === 14) { // Yesterday
+ unit = 't'
+ end = start + ' 23:59:59'
+ start += ' 00:00:00'
+ start = this.momentTz(this.momentStrToTimestamp(start, 'YYYY-MM-DD HH:mm:ss') - oneDTimestamp)
+ end = this.momentTz(this.momentStrToTimestamp(end, 'YYYY-MM-DD HH:mm:ss') - oneDTimestamp)
+ }
+ if (this.defaultPick === 15) { // The day before yesterday
+ unit = 't'
+ end = start + ' 23:59:59'
+ start += ' 00:00:00'
+ start = this.momentTz(this.momentStrToTimestamp(start, 'YYYY-MM-DD HH:mm:ss') - 2 * oneDTimestamp)
+ end = this.momentTz(this.momentStrToTimestamp(end, 'YYYY-MM-DD HH:mm:ss') - 2 * oneDTimestamp)
+ }
+ if (this.defaultPick === 16) { // This day last week
+ unit = 't'
+ end = start + ' 23:59:59'
+ start += ' 00:00:00'
+ start = this.momentTz(this.momentStrToTimestamp(start, 'YYYY-MM-DD HH:mm:ss') - 7 * oneDTimestamp)
+ end = this.momentTz(this.momentStrToTimestamp(end, 'YYYY-MM-DD HH:mm:ss') - 7 * oneDTimestamp)
+ }
+ if (this.defaultPick === 17) { // This week
+ unit = 'w'
+ const noTime = this.momentStrToTimestamp(start + ' 00:00:00', 'YYYY-MM-DD HH:mm:ss')
+ const nowDay = this.momentDays(noTime)
+ end = start + ' 23:59:59'
+ if (nowDay == 0) {
+ start = this.momentSetDay(noTime, -6, 'YYYY-MM-DD')
+ end = this.momentSetDay(noTime, 0, 'YYYY-MM-DD')
+ } else {
+ start = this.momentSetDay(noTime, 1, 'YYYY-MM-DD')
+ end = this.momentSetDay(noTime, 7, 'YYYY-MM-DD')
+ }
+ start += ' 00:00:00'
+ end += ' 23:59:59'
+ start = this.momentTz(this.momentStrToTimestamp(start, 'YYYY-MM-DD HH:mm:ss'))
+ end = this.momentTz(this.momentStrToTimestamp(end, 'YYYY-MM-DD HH:mm:ss'))
+ }
+ if (this.defaultPick === 18) { // Previous week
+ unit = 'w'
+ let noTime = this.momentStrToTimestamp(start + ' 00:00:00', 'YYYY-MM-DD HH:mm:ss')
+ noTime = noTime - 7 * oneDTimestamp
+ const nowDay = this.momentDays(noTime)
+ if (nowDay == 0) { // 判断当前是否是周天 周天则为 -6 - 0 非周天 则是 1 - 7
+ start = this.momentSetDay(noTime, -6, 'YYYY-MM-DD')
+ end = this.momentSetDay(noTime, 0, 'YYYY-MM-DD')
+ } else {
+ start = this.momentSetDay(noTime, 1, 'YYYY-MM-DD')
+ end = this.momentSetDay(noTime, 7, 'YYYY-MM-DD')
+ }
+ start += ' 00:00:00'
+ end += ' 23:59:59'
+ start = this.momentTz(this.momentStrToTimestamp(start, 'YYYY-MM-DD HH:mm:ss'))
+ end = this.momentTz(this.momentStrToTimestamp(end, 'YYYY-MM-DD HH:mm:ss'))
+ }
+ if (this.defaultPick === 19) { // this month
+ unit = 'm'
+ const noTime = this.momentStrToTimestamp(start + ' 00:00:00', 'YYYY-MM-DD HH:mm:ss')
+ const endTime = this.momentStrToTimestamp(start + ' 23:59:59', 'YYYY-MM-DD HH:mm:ss')
+ start = this.momentSetMonthDate(noTime, 1)
+ end = this.momentSetMonthDate(endTime, 31)
+ }
+ if (this.defaultPick === 20) { // Previous month 需要判断当前是否是 1号
+ unit = 'm'
+ const noTime = this.momentStrToTimestamp(start + ' 00:00:00', 'YYYY-MM-DD HH:mm:ss')
+ end = this.momentStrToTimestamp(this.momentSetMonthDate(noTime, 1)) - 1000 // 当月1号 00:00:00 减1s 则是上月最后一天 23:59:59
+ start = this.momentSetMonthDate(end, 1, 'YYYY-MM-DD') + ' 00:00:00'
+ start = this.momentTz(this.momentStrToTimestamp(start, 'YYYY-MM-DD HH:mm:ss'))
+ end = this.momentTz(end)
+ }
+ this.$set(this[key], 0, start)
+ this.$set(this[key], 1, end)
+ this.$set(this[key], 2, val + unit)
+ } else 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[key], 0, startTime)
+ this.$set(this[key], 1, endTime)
+ this.$set(this[key], 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[key], 0, startTime)
+ this.$set(this[key], 1, endTime)
+ this.$set(this[key], 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[key], 0, startTime)
+ this.$set(this[key], 1, endTime)
+ this.$set(this[key], 2, val + 'd')
+ }
+ },
getTableData (state) {
if (state) {
this.state = state
@@ -817,10 +935,16 @@ export default {
...this.searchLabel
}
const path = this.fromRoute.alertMessage
- const routePathParams = this.$lodash.cloneDeep(param)
+ const routePathParams = JSON.parse(JSON.stringify(param))
delete routePathParams.statistics
- routePathParams.body.startAt = this.searchTime[0] ? this.momentStrToTimestamp(this.searchTime[0]) : ''
- routePathParams.body.endAt = this.searchTime[1] ? this.momentStrToTimestamp(this.searchTime[1]) : ''
+ console.log(this.searchTime[2])
+ if (!this.searchTime[2]) {
+ routePathParams.body.startAt = this.searchTime[0] ? this.momentStrToTimestamp(this.searchTime[0]) : ''
+ routePathParams.body.endAt = this.searchTime[1] ? this.momentStrToTimestamp(this.searchTime[1]) : ''
+ } else {
+ delete routePathParams.body.startAt
+ delete routePathParams.body.endAt
+ }
routePathParams.body.timeType = this.searchTime[2]
routePathParams.body = JSON.stringify(routePathParams.body)
this.updatePath(routePathParams, path)
@@ -828,6 +952,7 @@ export default {
...this.searchLabel,
body: encodeURIComponent(JSON.stringify(this.searchLabel.body))
}
+ console.log(this.searchLabel.body)
this.$get('/alert/message/query', { ...queryParams }).then(response => {
this.tools.loading = false
if (response.code == 200) {
diff --git a/nezha-fronted/src/components/page/config/operationLog.vue b/nezha-fronted/src/components/page/config/operationLog.vue
index 33f0c75df..21e7bec1e 100644
--- a/nezha-fronted/src/components/page/config/operationLog.vue
+++ b/nezha-fronted/src/components/page/config/operationLog.vue
@@ -66,9 +66,10 @@ export default {
}, {
id: 13,
name: this.$t('overall.option'),
- type: 'selectString',
+ type: 'select',
label: 'operation',
- disabled: false
+ disabled: false,
+ readonly: true,
}, {
id: 14,
name: this.$t('config.operationlog.operaId'),
@@ -78,7 +79,7 @@ export default {
}, {
id: 16,
name: this.$t('config.operationlog.state'),
- type: 'selectString',
+ type: 'select',
label: 'state',
readonly: true,
disabled: false
diff --git a/nezha-fronted/src/entrance/app/App.vue b/nezha-fronted/src/entrance/app/App.vue
index 483bfa8b7..54e35de22 100644
--- a/nezha-fronted/src/entrance/app/App.vue
+++ b/nezha-fronted/src/entrance/app/App.vue
@@ -39,6 +39,14 @@ export default {
if (window.outerWidth <= defaultWindowWidth) { // outerWidth 获取设备宽度
document.querySelector('meta[name=viewport]').setAttribute('content', `width=device-width, initial-scale=${window.outerWidth / (defaultWindowWidth * window.devicePixelRatio)}, maximum-scale=1.0, user-scalable=0`)
}
+ window.addEventListener('unload', this.clearUrl)
+ },
+ methods: {
+ clearUrl () {
+ sessionStorage.setItem('nz-reload', 1)
+ }
+ },
+ beforeDestroy () {
}
}